use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\System;
use Friendica\Database\DBA;
+use Friendica\DI;
use Friendica\Model\Item;
/**
/**
* Construct a tag/term cloud block for an user.
*
- * @brief Construct a tag/term cloud block for an user.
* @param int $uid The user ID.
* @param int $count Max number of displayed tags/terms.
* @param int $owner_id The contact ID of the owner of the tagged items.
$r = self::tagadelic($uid, $count, $owner_id, $flags, $type);
if (count($r)) {
$contact = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]);
- $url = System::removedBaseUrl($contact['url']);
+ $url = DI::baseUrl()->remove($contact['url']);
+ $tags = [];
foreach ($r as $rr) {
$tag['level'] = $rr[2];
$tag['url'] = $url . '?tag=' . urlencode($rr[0]);
$tags[] = $tag;
}
- $tpl = Renderer::getMarkupTemplate('tagblock_widget.tpl');
+ $tpl = Renderer::getMarkupTemplate('widget/tagcloud.tpl');
$o = Renderer::replaceMacros($tpl, [
- '$title' => L10n::t('Tags'),
+ '$title' => DI::l10n()->t('Tags'),
'$tags' => $tags
]);
}
* Get alphabetical sorted array of used tags/terms of an user including
* a weighting by frequency of use.
*
- * @brief Get alphabetical sorted array of used tags/terms of an user including
- * a weighting by frequency of use.
* @param int $uid The user ID.
* @param int $count Max number of displayed tags/terms.
* @param int $owner_id The contact id of the owner of the tagged items.
}
// Fetch tags
- $r = DBA::p("SELECT `term`, COUNT(`term`) AS `total` FROM `term`
+ $tag_stmt = 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` = ?
$type,
TERM_OBJ_POST
);
- if (!DBA::isResult($r)) {
+ if (!DBA::isResult($tag_stmt)) {
return [];
}
+ $r = DBA::toArray($tag_stmt);
+
return self::tagCalc($r);
}
/**
* Calculate weighting of tags according to the frequency of use.
*
- * @brief Calculate weighting of tags according to the frequency of use.
* @param array $arr Array of tags/terms with tag/term name and total count of use.
* @return array Alphabetical sorted array of used tags/terms of an user.
*/
- private static function tagCalc($arr)
+ private static function tagCalc(array $arr)
{
$tags = [];
$min = 1e9;
/**
* Compare function to sort tags/terms alphabetically.
*
- * @brief Compare function to sort tags/terms alphabetically.
* @param string $a
* @param string $b
*