Use MagicLinkbyId when possible

This commit is contained in:
Michael 2018-06-02 08:28:01 +00:00
parent 8a34895a23
commit 723b5ae803
5 changed files with 13 additions and 12 deletions

View file

@ -14,6 +14,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Object\Post; use Friendica\Object\Post;
use Friendica\Object\Thread; use Friendica\Object\Thread;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
@ -268,8 +269,8 @@ function localize_item(&$item) {
$obj = $r[0]; $obj = $r[0];
$author = '[url=' . Contact::magicLink($item['author-link']) . ']' . $item['author-name'] . '[/url]'; $author = '[url=' . Contact::magicLinkById($item['author-id']) . ']' . $item['author-name'] . '[/url]';
$objauthor = '[url=' . Contact::magicLink($obj['author-link']) . ']' . $obj['author-name'] . '[/url]'; $objauthor = '[url=' . Contact::magicLinkById($obj['author-id']) . ']' . $obj['author-name'] . '[/url]';
switch ($obj['verb']) { switch ($obj['verb']) {
case ACTIVITY_POST: case ACTIVITY_POST:
@ -341,12 +342,12 @@ function localize_item(&$item) {
// add zrl's to public images // add zrl's to public images
$photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is"; $photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is";
if (preg_match($photo_pattern, $item['body'])) { 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']); $item['body'] = BBCode::pregReplaceInTag($photo_pattern, $photo_replace, 'url', $item['body']);
} }
// add sparkle links to appropriate permalinks // 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); $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) { if (strpos($profile_link, 'redir/') === 0) {
$sparkle = ' sparkle'; $sparkle = ' sparkle';
@ -920,7 +921,7 @@ function item_photo_menu($item) {
$sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;'; $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); $sparkle = (strpos($profile_link, 'redir/') === 0);
$cid = 0; $cid = 0;
@ -1027,7 +1028,7 @@ function builtin_activity_puller($item, &$conv_responses) {
} }
if (activity_match($item['verb'], $verb) && ($item['id'] != $item['parent'])) { 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) { if (strpos($url, 'redir/') === 0) {
$sparkle = ' class="sparkle" '; $sparkle = ' class="sparkle" ';
} }

View file

@ -1296,7 +1296,7 @@ function prepare_body(array &$item, $attach = false, $is_preview = false)
foreach ($matches as $mtch) { foreach ($matches as $mtch) {
$mime = $mtch[3]; $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 (strpos($mime, 'video') !== false) {
if (!$vhead) { if (!$vhead) {

View file

@ -868,7 +868,7 @@ class Event extends BaseObject
$location = self::locationToArray($item['event-location']); $location = self::locationToArray($item['event-location']);
// Construct the profile link (magic-auth). // 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'); $tpl = get_markup_template('event_stream_item.tpl');
$return = replace_macros($tpl, [ $return = replace_macros($tpl, [

View file

@ -196,7 +196,7 @@ class Term
$orig_tag = $tag["url"]; $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 ($tag["type"] == TERM_HASHTAG) {
if ($orig_tag != $tag["url"]) { if ($orig_tag != $tag["url"]) {

View file

@ -204,7 +204,7 @@ class Post extends BaseObject
$profile_name = $item['author-link']; $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) { if (strpos($profile_link, 'redir/') === 0) {
$sparkle = ' sparkle'; $sparkle = ' sparkle';
} }
@ -861,7 +861,7 @@ class Post extends BaseObject
$this->owner_photo = $this->getDataValue('owner-avatar'); $this->owner_photo = $this->getDataValue('owner-avatar');
$this->owner_name = $this->getDataValue('owner-name'); $this->owner_name = $this->getDataValue('owner-name');
$this->wall_to_wall = true; $this->wall_to_wall = true;
$this->owner_url = Contact::magicLink($this->getDataValue('owner-link')); $this->owner_url = Contact::magicLinkById($this->getDataValue('owner-id'));
} }
} }
} }