]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Merge pull request #13331 from annando/paging-search
[friendica.git] / src / Model / Item.php
index de95d4e16c37dc671759927d5efe1524f4c32800..9028c9f853d13017b6854d0d9f2f5e99365313f4 100644 (file)
@@ -94,9 +94,9 @@ class Item
                'wall', 'private', 'starred', 'origin', 'parent-origin', 'title', 'body', 'language',
                'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object',
                'quote-uri', 'quote-uri-id', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'mention', 'global',
-               'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network', 'author-updated', 'author-gsid', 'author-addr', 'author-uri-id',
-               'owner-id', 'owner-link', 'owner-name', 'owner-avatar', 'owner-network', 'owner-contact-type', 'owner-updated',
-               'causer-id', 'causer-link', 'causer-name', 'causer-avatar', 'causer-contact-type', 'causer-network',
+               'author-id', 'author-link', 'author-alias', 'author-name', 'author-avatar', 'author-network', 'author-updated', 'author-gsid', 'author-addr', 'author-uri-id',
+               'owner-id', 'owner-link', 'owner-alias', 'owner-name', 'owner-avatar', 'owner-network', 'owner-contact-type', 'owner-updated',
+               'causer-id', 'causer-link', 'causer-alias', 'causer-name', 'causer-avatar', 'causer-contact-type', 'causer-network',
                'contact-id', 'contact-uid', 'contact-link', 'contact-name', 'contact-avatar',
                'writable', 'self', 'cid', 'alias',
                'event-created', 'event-edited', 'event-start', 'event-finish',
@@ -490,6 +490,23 @@ class Item
                        return $owner['id'];
                }
 
+               $contact_id      = 0;
+               $user_contact_id = 0;
+               foreach (['group-link', 'causer-link', 'owner-link', 'author-link'] as $field) {
+                       if (empty($item[$field])) {
+                               continue;
+                       }
+                       if (!$user_contact_id && Contact::isSharingByURL($item[$field], $item['uid'], true)) {
+                               $user_contact_id = Contact::getIdForURL($item[$field], $item['uid']);
+                       } elseif (!$contact_id) {
+                               $contact_id = Contact::getIdForURL($item[$field]);
+                       }
+               }
+
+               if ($user_contact_id) {
+                       return $user_contact_id;
+               }
+
                if (!empty($item['causer-id']) && Contact::isSharing($item['causer-id'], $item['uid'], true)) {
                        $cdata = Contact::getPublicAndUserContactID($item['causer-id'], $item['uid']);
                        if (!empty($cdata['user'])) {
@@ -497,18 +514,8 @@ class Item
                        }
                }
 
-               foreach (['owner-link', 'author-link', 'causer-link'] as $field) {
-                       if (empty($item[$field])) {
-                               continue;
-                       }
-                       if (Contact::isSharingByURL($item[$field], $item['uid'], true)) {
-                               $contact_id = Contact::getIdForURL($item[$field], $item['uid']);
-                       } else {
-                               $contact_id = Contact::getIdForURL($item[$field]);
-                       }
-                       if (!empty($contact_id)) {
-                               return $contact_id;
-                       }
+               if ($contact_id) {
+                       return $contact_id;
                }
 
                Logger::warning('contact-id could not be fetched, using self contact instead.', ['uid' => $item['uid'], 'item' => $item]);
@@ -3131,7 +3138,7 @@ class Item
 
                if (!empty($quote_uri_id)) {
                        if (isset($shared_item['plink'])) {
-                               $item['body'] .= "\n" . DI::contentItem()->createSharedBlockByArray($shared_item);
+                               $item['body'] .= "\n" . DI::contentItem()->createSharedBlockByArray($shared_item, false, true);
                        } else {
                                DI::logger()->warning('Missing plink in shared item', ['item' => $item, 'shared' => $shared, 'quote_uri_id' => $quote_uri_id, 'shared_item' => $shared_item]);
                        }
@@ -3210,6 +3217,12 @@ class Item
                        $body = BBCode::removeSharedData($body);
                }
 
+               $pos = strpos($s, BBCode::SHARED_ANCHOR);
+               if ($pos) {
+                       $shared_html = substr($s, $pos + strlen(BBCode::SHARED_ANCHOR));
+                       $s = substr($s, 0, $pos);
+               }
+       
                $s = self::addGallery($s, $attachments, $item['uri-id']);
                $s = self::addVisualAttachments($attachments, $item, $s, false);
                $s = self::addLinkAttachment($item['uri-id'], $attachments, $body, $s, false, $shared_links);
@@ -3230,6 +3243,10 @@ class Item
                        $s = preg_replace('|(<img[^>]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|', "$1-" . $ps, $s);
                }
 
+               if (!empty($shared_html)) {
+                       $s .= $shared_html;
+               }
+
                $s = HTML::applyContentFilter($s, $filter_reasons);
 
                $hook_data = ['item' => $item, 'html' => $s];
@@ -3733,7 +3750,7 @@ class Item
 
        /**
         * Does the given uri-id belongs to a post that is sent as starting post to a group?
-        * This does not apply to posts that are sent only in parallel to a group.
+        * This does apply to posts that are sent via ! and not in parallel to a group via @
         *
         * @param int $uri_id
         *