*/
namespace Friendica\Model;
-use Friendica\Core\Cache;
+use Friendica\Core\Cache\Duration;
use Friendica\Core\Logger;
-use Friendica\Core\System;
use Friendica\Database\DBA;
+use Friendica\DI;
use Friendica\Util\Strings;
/**
*/
public static function getGlobalTrendingHashtags(int $period, $limit = 10)
{
- $tags = Cache::get('global_trending_tags');
+ $tags = DI::cache()->get('global_trending_tags');
if (!$tags) {
$tagsStmt = DBA::p("SELECT t.`term`, COUNT(*) AS `score`
if (DBA::isResult($tagsStmt)) {
$tags = DBA::toArray($tagsStmt);
- Cache::set('global_trending_tags', $tags, Cache::HOUR);
+ DI::cache()->set('global_trending_tags', $tags, Duration::HOUR);
}
}
*/
public static function getLocalTrendingHashtags(int $period, $limit = 10)
{
- $tags = Cache::get('local_trending_tags');
+ $tags = DI::cache()->get('local_trending_tags');
if (!$tags) {
$tagsStmt = DBA::p("SELECT t.`term`, COUNT(*) AS `score`
if (DBA::isResult($tagsStmt)) {
$tags = DBA::toArray($tagsStmt);
- Cache::set('local_trending_tags', $tags, Cache::HOUR);
+ DI::cache()->set('local_trending_tags', $tags, Duration::HOUR);
}
}
*/
public static function insertFromTagFieldByItemId($item_id, $tag_str)
{
- $profile_base = System::baseUrl();
+ $profile_base = DI::baseUrl();
$profile_data = parse_url($profile_base);
- $profile_path = defaults($profile_data, 'path', '');
+ $profile_path = $profile_data['path'] ?? '';
$profile_base_friendica = $profile_data['host'] . $profile_path . '/profile/';
$profile_base_diaspora = $profile_data['host'] . $profile_path . '/u/';
'implicit_mentions' => [],
];
- $searchpath = System::baseUrl() . "/search?tag=";
+ $searchpath = DI::baseUrl() . "/search?tag=";
$taglist = DBA::select(
'term',
$item['body'] = str_replace($orig_tag, $tag['url'], $item['body']);
}
- $return['hashtags'][] = $prefix . '<a href="' . $tag['url'] . '" target="_blank">' . $tag['term'] . '</a>';
- $return['tags'][] = $prefix . '<a href="' . $tag['url'] . '" target="_blank">' . $tag['term'] . '</a>';
+ $return['hashtags'][] = $prefix . '<a href="' . $tag['url'] . '" target="_blank">' . htmlspecialchars($tag['term']) . '</a>';
+ $return['tags'][] = $prefix . '<a href="' . $tag['url'] . '" target="_blank">' . htmlspecialchars($tag['term']) . '</a>';
break;
case self::MENTION:
$tag['url'] = Contact::magicLink($tag['url']);
- $return['mentions'][] = $prefix . '<a href="' . $tag['url'] . '" target="_blank">' . $tag['term'] . '</a>';
- $return['tags'][] = $prefix . '<a href="' . $tag['url'] . '" target="_blank">' . $tag['term'] . '</a>';
+ $return['mentions'][] = $prefix . '<a href="' . $tag['url'] . '" target="_blank">' . htmlspecialchars($tag['term']) . '</a>';
+ $return['tags'][] = $prefix . '<a href="' . $tag['url'] . '" target="_blank">' . htmlspecialchars($tag['term']) . '</a>';
break;
case self::IMPLICIT_MENTION:
$return['implicit_mentions'][] = $prefix . $tag['term'];