]> git.mxchange.org Git - friendica.git/blob - src/Content/Widget/TrendingTags.php
Merge pull request #8095 from annando/local-delivery
[friendica.git] / src / Content / Widget / TrendingTags.php
1 <?php
2
3 namespace Friendica\Content\Widget;
4
5 use Friendica\Core\L10n;
6 use Friendica\Core\Renderer;
7 use Friendica\Model\Term;
8
9 /**
10  * Trending tags aside widget for the community pages, handles both local and global scopes
11  *
12  * @package Friendica\Content\Widget
13  */
14 class TrendingTags
15 {
16         /**
17          * @param string $content 'global' (all posts) or 'local' (this node's posts only)
18          * @param int    $period  Period in hours to consider posts
19          * @return string
20          * @throws \Exception
21          */
22         public static function getHTML($content = 'global', int $period = 24)
23         {
24                 if ($content == 'local') {
25                         $tags = Term::getLocalTrendingHashtags($period, 20);
26                 } else {
27                         $tags = Term::getGlobalTrendingHashtags($period, 20);
28                 }
29
30                 $tpl = Renderer::getMarkupTemplate('widget/trending_tags.tpl');
31                 $o = Renderer::replaceMacros($tpl, [
32                         '$title' => L10n::tt('Trending Tags (last %d hour)', 'Trending Tags (last %d hours)', $period),
33                         '$more' => L10n::t('More Trending Tags'),
34                         '$tags' => $tags,
35                 ]);
36
37                 return $o;
38         }
39 }