2019-08-06 03:00:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Content\Widget;
|
|
|
|
|
|
|
|
use Friendica\Core\Renderer;
|
2020-01-18 22:07:07 +01:00
|
|
|
use Friendica\DI;
|
2019-08-06 03:00:27 +02:00
|
|
|
use Friendica\Model\Term;
|
|
|
|
|
2019-08-06 13:37:48 +02:00
|
|
|
/**
|
|
|
|
* Trending tags aside widget for the community pages, handles both local and global scopes
|
|
|
|
*
|
|
|
|
* @package Friendica\Content\Widget
|
|
|
|
*/
|
2019-08-06 03:00:27 +02:00
|
|
|
class TrendingTags
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param string $content 'global' (all posts) or 'local' (this node's posts only)
|
|
|
|
* @param int $period Period in hours to consider posts
|
|
|
|
* @return string
|
|
|
|
* @throws \Exception
|
|
|
|
*/
|
|
|
|
public static function getHTML($content = 'global', int $period = 24)
|
|
|
|
{
|
|
|
|
if ($content == 'local') {
|
2019-08-06 13:36:51 +02:00
|
|
|
$tags = Term::getLocalTrendingHashtags($period, 20);
|
2019-08-06 03:00:27 +02:00
|
|
|
} else {
|
2019-08-06 13:36:51 +02:00
|
|
|
$tags = Term::getGlobalTrendingHashtags($period, 20);
|
2019-08-06 03:00:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$tpl = Renderer::getMarkupTemplate('widget/trending_tags.tpl');
|
|
|
|
$o = Renderer::replaceMacros($tpl, [
|
2020-01-18 20:53:01 +01:00
|
|
|
'$title' => DI::l10n()->tt('Trending Tags (last %d hour)', 'Trending Tags (last %d hours)', $period),
|
2020-01-18 20:52:34 +01:00
|
|
|
'$more' => DI::l10n()->t('More Trending Tags'),
|
2019-08-06 03:00:27 +02:00
|
|
|
'$tags' => $tags,
|
|
|
|
]);
|
|
|
|
|
|
|
|
return $o;
|
|
|
|
}
|
|
|
|
}
|