$profile_name = $item['author-link'];
}
- $tags = [];
- $hashtags = [];
- $mentions = [];
-
- $searchpath = System::baseUrl()."/search?tag=";
-
- $taglist = dba::select('term', ['type', 'term', 'url'],
- ["`otype` = ? AND `oid` = ? AND `type` IN (?, ?)", TERM_OBJ_POST, $item['id'], TERM_HASHTAG, TERM_MENTION],
- ['order' => ['tid']]);
-
- while ($tag = dba::fetch($taglist)) {
- if ($tag["url"] == "") {
- $tag["url"] = $searchpath . strtolower($tag["term"]);
- }
-
- $tag["url"] = best_link_url($item, $sp, $tag["url"]);
-
- if ($tag["type"] == TERM_HASHTAG) {
- $hashtags[] = "#<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
- $prefix = "#";
- } elseif ($tag["type"] == TERM_MENTION) {
- $mentions[] = "@<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
- $prefix = "@";
- }
- $tags[] = $prefix."<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
- }
- dba::close($taglist);
+ $tags = \Friendica\Model\Term::populateTagsFromItem($item);
$sp = false;
$profile_link = best_link_url($item, $sp);
}
$body_e = $body;
- $tags_e = $tags;
- $hashtags_e = $hashtags;
- $mentions_e = $mentions;
+ $tags_e = $tags['tags'];
+ $hashtags_e = $tags['hashtags'];
+ $mentions_e = $tags['mentions'];
$location_e = $location;
$owner_name_e = $owner_name;
$a = get_app();
Addon::callHooks('prepare_body_init', $item);
- $searchpath = System::baseUrl() . "/search?tag=";
-
- $tags = [];
- $hashtags = [];
- $mentions = [];
-
// In order to provide theme developers more possibilities, event items
// are treated differently.
if ($item['object-type'] === ACTIVITY_OBJ_EVENT && isset($item['event-id'])) {
return $ev;
}
- $taglist = dba::p("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = ? AND `oid` = ? AND `type` IN (?, ?) ORDER BY `tid`",
- intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION));
-
- while ($tag = dba::fetch($taglist)) {
- if ($tag["url"] == "") {
- $tag["url"] = $searchpath . strtolower($tag["term"]);
- }
-
- $orig_tag = $tag["url"];
-
- $tag["url"] = best_link_url($item, $sp, $tag["url"]);
-
- if ($tag["type"] == TERM_HASHTAG) {
- if ($orig_tag != $tag["url"]) {
- $item['body'] = str_replace($orig_tag, $tag["url"], $item['body']);
- }
-
- $hashtags[] = "#<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
- $prefix = "#";
- } elseif ($tag["type"] == TERM_MENTION) {
- $mentions[] = "@<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
- $prefix = "@";
- }
-
- $tags[] = $prefix . "<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
- }
- dba::close($taglist);
+ $tags = \Friendica\Model\Term::populateTagsFromItem($item);
- $item['tags'] = $tags;
- $item['hashtags'] = $hashtags;
- $item['mentions'] = $mentions;
+ $item['tags'] = $tags['tags'];
+ $item['hashtags'] = $tags['hashtags'];
+ $item['mentions'] = $tags['mentions'];
// Compile eventual content filter reasons
$filter_reasons = [];