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