From 723b5ae803c7db2782b5f4884da071fda1ddd51b Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 2 Jun 2018 08:28:01 +0000 Subject: [PATCH] Use MagicLinkbyId when possible --- include/conversation.php | 15 ++++++++------- include/text.php | 2 +- src/Model/Event.php | 2 +- src/Model/Term.php | 2 +- src/Object/Post.php | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index c7b581757a..b8cdd7a061 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -14,6 +14,7 @@ use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\Contact; +use Friendica\Model\Profile; use Friendica\Object\Post; use Friendica\Object\Thread; use Friendica\Util\DateTimeFormat; @@ -268,8 +269,8 @@ function localize_item(&$item) { $obj = $r[0]; - $author = '[url=' . Contact::magicLink($item['author-link']) . ']' . $item['author-name'] . '[/url]'; - $objauthor = '[url=' . Contact::magicLink($obj['author-link']) . ']' . $obj['author-name'] . '[/url]'; + $author = '[url=' . Contact::magicLinkById($item['author-id']) . ']' . $item['author-name'] . '[/url]'; + $objauthor = '[url=' . Contact::magicLinkById($obj['author-id']) . ']' . $obj['author-name'] . '[/url]'; switch ($obj['verb']) { case ACTIVITY_POST: @@ -341,12 +342,12 @@ function localize_item(&$item) { // add zrl's to public images $photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is"; if (preg_match($photo_pattern, $item['body'])) { - $photo_replace = '[url=' . Contact::magicLink('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]'; + $photo_replace = '[url=' . Profile::zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]'; $item['body'] = BBCode::pregReplaceInTag($photo_pattern, $photo_replace, 'url', $item['body']); } // add sparkle links to appropriate permalinks - $item['plink'] = Contact::magicLink($item['author-link'], $item['plink']); + $item['plink'] = Contact::magicLinkById($item['author-id'], $item['plink']); } /** @@ -664,7 +665,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order = $tags = \Friendica\Model\Term::populateTagsFromItem($item); - $profile_link = Contact::magicLink($item['author-link']); + $profile_link = Contact::magicLinkbyId($item['author-id']); if (strpos($profile_link, 'redir/') === 0) { $sparkle = ' sparkle'; @@ -920,7 +921,7 @@ function item_photo_menu($item) { $sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;'; } - $profile_link = Contact::magicLink($item['author-link']); + $profile_link = Contact::magicLinkById($item['author-id']); $sparkle = (strpos($profile_link, 'redir/') === 0); $cid = 0; @@ -1027,7 +1028,7 @@ function builtin_activity_puller($item, &$conv_responses) { } if (activity_match($item['verb'], $verb) && ($item['id'] != $item['parent'])) { - $url = Contact::MagicLink($item['author-link']); + $url = Contact::MagicLinkbyId($item['author-id']); if (strpos($url, 'redir/') === 0) { $sparkle = ' class="sparkle" '; } diff --git a/include/text.php b/include/text.php index b982881287..f145c03e53 100644 --- a/include/text.php +++ b/include/text.php @@ -1296,7 +1296,7 @@ function prepare_body(array &$item, $attach = false, $is_preview = false) foreach ($matches as $mtch) { $mime = $mtch[3]; - $the_url = Contact::magicLink($item['author-link'], $mtch[1]); + $the_url = Contact::magicLinkById($item['author-id'], $mtch[1]); if (strpos($mime, 'video') !== false) { if (!$vhead) { diff --git a/src/Model/Event.php b/src/Model/Event.php index 1f3259f228..1c848dcad7 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -868,7 +868,7 @@ class Event extends BaseObject $location = self::locationToArray($item['event-location']); // Construct the profile link (magic-auth). - $profile_link = Contact::magicLink($item['author-link']); + $profile_link = Contact::magicLinkById($item['author-id']); $tpl = get_markup_template('event_stream_item.tpl'); $return = replace_macros($tpl, [ diff --git a/src/Model/Term.php b/src/Model/Term.php index 1a4294c68a..fd44603f97 100644 --- a/src/Model/Term.php +++ b/src/Model/Term.php @@ -196,7 +196,7 @@ class Term $orig_tag = $tag["url"]; - $tag["url"] = Contact::magicLink($item['author-link'], $tag['url']); + $tag["url"] = Contact::magicLinkById($item['author-id'], $tag['url']); if ($tag["type"] == TERM_HASHTAG) { if ($orig_tag != $tag["url"]) { diff --git a/src/Object/Post.php b/src/Object/Post.php index 3895afa326..74dc24b2f3 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -204,7 +204,7 @@ class Post extends BaseObject $profile_name = $item['author-link']; } - $profile_link = Contact::magicLink($item['author-link']); + $profile_link = Contact::magicLinkById($item['author-id']); if (strpos($profile_link, 'redir/') === 0) { $sparkle = ' sparkle'; } @@ -861,7 +861,7 @@ class Post extends BaseObject $this->owner_photo = $this->getDataValue('owner-avatar'); $this->owner_name = $this->getDataValue('owner-name'); $this->wall_to_wall = true; - $this->owner_url = Contact::magicLink($this->getDataValue('owner-link')); + $this->owner_url = Contact::magicLinkById($this->getDataValue('owner-id')); } } } -- 2.39.5