X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FContent%2FWidget%2FTagCloud.php;h=f214ba799951d882196ee57fb9d4ae00be729cb4;hb=3b80f335fad83fac4cdcf059f4129d5364eb6f90;hp=19ea3eea0485eed8e3f445bda7b3fe94bdc3f0a9;hpb=c845415a99ebc348103815a7b2c55b15c75cdd24;p=friendica.git diff --git a/src/Content/Widget/TagCloud.php b/src/Content/Widget/TagCloud.php index 19ea3eea04..f214ba7999 100644 --- a/src/Content/Widget/TagCloud.php +++ b/src/Content/Widget/TagCloud.php @@ -6,13 +6,12 @@ namespace Friendica\Content\Widget; -use dba; use Friendica\Core\L10n; +use Friendica\Core\Renderer; use Friendica\Core\System; -use Friendica\Database\DBM; - -require_once 'include/dba.php'; -require_once 'include/security.php'; +use Friendica\Database\DBA; +use Friendica\Model\Item; +use Friendica\Util\Security; /** * TagCloud widget @@ -38,7 +37,7 @@ class TagCloud $o = ''; $r = self::tagadelic($uid, $count, $owner_id, $flags, $type); if (count($r)) { - $contact = dba::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]); + $contact = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]); $url = System::removedBaseUrl($contact['url']); foreach ($r as $rr) { @@ -49,8 +48,8 @@ class TagCloud $tags[] = $tag; } - $tpl = get_markup_template('tagblock_widget.tpl'); - $o = replace_macros($tpl, [ + $tpl = Renderer::getMarkupTemplate('tagblock_widget.tpl'); + $o = Renderer::replaceMacros($tpl, [ '$title' => L10n::t('Tags'), '$tags' => $tags ]); @@ -74,8 +73,7 @@ class TagCloud */ private static function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HASHTAG) { - $item_condition = item_condition(); - $sql_options = item_permissions_sql($uid); + $sql_options = Item::getPermissionsSQLByUserId($uid); $limit = $count ? sprintf('LIMIT %d', intval($count)) : ''; if ($flags) { @@ -89,17 +87,18 @@ class TagCloud } // Fetch tags - $r = dba::p("SELECT `term`, COUNT(`term`) AS `total` FROM `term` + $r = DBA::p("SELECT `term`, COUNT(`term`) AS `total` FROM `term` LEFT JOIN `item` ON `term`.`oid` = `item`.`id` WHERE `term`.`uid` = ? AND `term`.`type` = ? AND `term`.`otype` = ? - AND $item_condition $sql_options + AND `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated` + $sql_options GROUP BY `term` ORDER BY `total` DESC $limit", $uid, $type, TERM_OBJ_POST ); - if (!DBM::is_result($r)) { + if (!DBA::isResult($r)) { return []; }