]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Item.php
Fix magic links in contact photo menu
[friendica.git] / src / Content / Item.php
index 45890f4047aff5f854b605025495578bcc95fbf0..172729f2689faca7ad91fe8fc89b26e2962277e8 100644 (file)
@@ -96,32 +96,33 @@ class Item
        }
 
        /**
-        * Return array with details for categories and folders for an item
+        * Lists categories and folders for an item
         *
         * @param array $item
         * @param int   $uid
-        * @return [array, array]
-        *
+        * @return array
         * [
-        *      [ // categories array
-        *          {
-        *               'name': 'category name',
-        *               'removeurl': 'url to remove this category',
-        *               'first': 'is the first in this array? true/false',
-        *               'last': 'is the last in this array? true/false',
-        *           } ,
-        *           ....
-        *       ],
-        *       [ //folders array
-        *                      {
-        *               'name': 'folder name',
-        *               'removeurl': 'url to remove this folder',
-        *               'first': 'is the first in this array? true/false',
-        *               'last': 'is the last in this array? true/false',
-        *           } ,
-        *           ....
-        *       ]
-        *  ]
+        *     [ // categories array
+        *         {
+        *             'name': 'category name',
+        *             'removeurl': 'url to remove this category',
+        *             'first': 'is the first in this array? true/false',
+        *             'last': 'is the last in this array? true/false',
+        *         },
+        *         ...
+        *     ],
+        *     [ //folders array
+        *         {
+        *             'name': 'folder name',
+        *             'removeurl': 'url to remove this folder',
+        *             'first': 'is the first in this array? true/false',
+        *             'last': 'is the last in this array? true/false',
+        *         } ,
+        *         ...
+        *     ]
+        * ]
+        *
+        * @throws \Exception
         */
        public function determineCategoriesTerms(array $item, int $uid = 0): array
        {
@@ -135,9 +136,9 @@ class Item
                        return [$categories, $folders];
                }
 
-               foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::CATEGORY) as $savedFolderName) {
+               foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid) as $savedFolderName) {
                        if (!empty($item['author-link'])) {
-                               $url = $item['author-link'] . "?category=" . rawurlencode($savedFolderName);
+                               $url = $item['author-link'] . '/conversations?category=' . rawurlencode($savedFolderName);
                        } else {
                                $url = '#';
                        }
@@ -338,7 +339,7 @@ class Item
                                                } else {
                                                        $post_type = $this->l10n->t('status');
                                                }
-                                               // Let's break everthing ... ;-)
+                                               // Let's break everything ... ;-)
                                                break;
                                }
                                $plink = '[url=' . $obj['plink'] . ']' . $post_type . '[/url]';
@@ -377,7 +378,11 @@ class Item
                        'url' => $item['author-link'],
                ];
                $profile_link = Contact::magicLinkByContact($author, $item['author-link']);
-               $sparkle = (strpos($profile_link, 'contact/redir/') === 0);
+               if (strpos($profile_link, 'contact/redir/') === 0) {
+                       $status_link  = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/status']);
+                       $photos_link  = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/photos']);
+                       $profile_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/profile']);
+               }
 
                $cid = 0;
                $pcid = $item['author-id'];
@@ -391,12 +396,6 @@ class Item
                        $rel = $contact['rel'];
                }
 
-               if ($sparkle) {
-                       $status_link = $profile_link . '/status';
-                       $photos_link = $profile_link . '/photos';
-                       $profile_link = $profile_link . '/profile';
-               }
-
                if (!empty($pcid)) {
                        $contact_url   = 'contact/' . $pcid;
                        $posts_link    = $contact_url . '/posts';
@@ -685,11 +684,11 @@ class Item
 
                // If it is a reshared post then reformat it to avoid display problems with two share elements
                if (!empty($shared)) {
-                       if (!empty($shared['guid']) && ($encaspulated_share = $this->createSharedPostByGuid($shared['guid'], true))) {
+                       if (!empty($shared['guid']) && ($encapsulated_share = $this->createSharedPostByGuid($shared['guid'], true))) {
                                if (!empty(BBCode::fetchShareAttributes($item['body']))) {
-                                       $item['body'] = preg_replace("/\[share.*?\](.*)\[\/share\]/ism", $encaspulated_share, $item['body']);
+                                       $item['body'] = preg_replace("/\[share.*?\](.*)\[\/share\]/ism", $encapsulated_share, $item['body']);
                                } else {
-                                       $item['body'] .= $encaspulated_share;
+                                       $item['body'] .= $encapsulated_share;
                                }
                        }
                        $item['body'] = HTML::toBBCode(BBCode::convertForUriId($item['uri-id'], $item['body'], BBCode::ACTIVITYPUB));