X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fdisplay.php;h=0d082f5982c11a42518dd92341adbf7f2cb8a021;hb=e93fba51362a8cc212cb42542fd013ffd28b1164;hp=175616f98d9c4ef77a292773d67b95dbc0d25c80;hpb=ae3d4f63a31c5a9f35c55e6507263a600867b55a;p=friendica.git diff --git a/mod/display.php b/mod/display.php index 175616f98d..0d082f5982 100644 --- a/mod/display.php +++ b/mod/display.php @@ -16,6 +16,7 @@ use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Core\Session; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Item; @@ -93,7 +94,8 @@ function display_init(App $a) } if ($item["id"] != $item["parent"]) { - $item = Item::selectFirstForUser($item_user, $fields, ['id' => $item["parent"]]); + $parent = Item::selectFirstForUser($item_user, $fields, ['id' => $item["parent"]]); + $item = $parent ?: $item; } $profiledata = display_fetchauthor($a, $item); @@ -133,51 +135,20 @@ function display_fetchauthor($a, $item) $profiledata['network'] = $author['network']; // Check for a repeated message - $skip = false; - $body = trim($item["body"]); - - // Skip if it isn't a pure repeated messages - // Does it start with a share? - if (!$skip && strpos($body, "[share") > 0) { - $skip = true; - } - // Does it end with a share? - if (!$skip && (strlen($body) > (strrpos($body, "[/share]") + 8))) { - $skip = true; - } - if (!$skip) { - $attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","$1",$body); - // Skip if there is no shared message in there - if ($body == $attributes) { - $skip = true; + $shared = Item::getShareArray($item); + if (!empty($shared) && empty($shared['comment'])) { + if (!empty($shared['author'])) { + $profiledata['name'] = $shared['author']; } - } - if (!$skip) { - preg_match("/author='(.*?)'/ism", $attributes, $matches); - if (!empty($matches[1])) { - $profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); - } - preg_match('/author="(.*?)"/ism', $attributes, $matches); - if (!empty($matches[1])) { - $profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); - } - preg_match("/profile='(.*?)'/ism", $attributes, $matches); - if (!empty($matches[1])) { - $profiledata["url"] = $matches[1]; - } - preg_match('/profile="(.*?)"/ism', $attributes, $matches); - if (!empty($matches[1])) { - $profiledata["url"] = $matches[1]; - } - preg_match("/avatar='(.*?)'/ism", $attributes, $matches); - if (!empty($matches[1])) { - $profiledata["photo"] = $matches[1]; + if (!empty($shared['profile'])) { + $profiledata['url'] = $shared['profile']; } - preg_match('/avatar="(.*?)"/ism', $attributes, $matches); - if (!empty($matches[1])) { - $profiledata["photo"] = $matches[1]; + + if (!empty($shared['avatar'])) { + $profiledata['photo'] = $shared['avatar']; } + $profiledata["nickname"] = $profiledata["name"]; $profiledata["network"] = Protocol::matchByProfileUrl($profiledata["url"]); @@ -202,6 +173,8 @@ function display_content(App $a, $update = false, $update_uid = 0) $o = ''; + $item = null; + if ($update) { $item_id = $_REQUEST['item_id']; $item = Item::selectFirst(['uid', 'parent', 'parent-uri'], ['id' => $item_id]); @@ -251,7 +224,7 @@ function display_content(App $a, $update = false, $update_uid = 0) } } - if (!$item_id) { + if (empty($item)) { throw new HTTPException\NotFoundException(L10n::t('The requested item doesn\'t exist or has been deleted.')); } @@ -273,16 +246,20 @@ function display_content(App $a, $update = false, $update_uid = 0) $is_remote_contact = false; $item_uid = local_user(); - if (isset($item_parent_uri)) { + $parent = null; + if (!empty($item_parent_uri)) { $parent = Item::selectFirst(['uid'], ['uri' => $item_parent_uri, 'wall' => true]); - if (DBA::isResult($parent)) { - $a->profile['uid'] = ($a->profile['uid'] ?? 0) ?: $parent['uid']; - $a->profile['profile_uid'] = ($a->profile['profile_uid'] ?? 0) ?: $parent['uid']; - $is_remote_contact = Session::getRemoteContactID($a->profile['profile_uid']); - if ($is_remote_contact) { - $item_uid = $parent['uid']; - } + } + + if (DBA::isResult($parent)) { + $a->profile['uid'] = ($a->profile['uid'] ?? 0) ?: $parent['uid']; + $a->profile['profile_uid'] = ($a->profile['profile_uid'] ?? 0) ?: $parent['uid']; + $is_remote_contact = Session::getRemoteContactID($a->profile['profile_uid']); + if ($is_remote_contact) { + $item_uid = $parent['uid']; } + } else { + $a->profile = ['uid' => intval($item['uid']), 'profile_uid' => intval($item['uid'])]; } $page_contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $a->profile['uid']]); @@ -350,7 +327,7 @@ function display_content(App $a, $update = false, $update_uid = 0) $title = trim(HTML::toPlaintext(BBCode::convert($item["title"], false), 0, true)); $author_name = $item["author-name"]; - $image = $a->removeBaseURL($item["author-avatar"]); + $image = DI::baseUrl()->remove($item["author-avatar"]); if ($title == "") { $title = $author_name;