]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Item.php
Merge pull request #10258 from nupplaphil/feat/drone_release
[friendica.git] / src / Content / Item.php
index f0d08d48e63bfdb568aeb24ac4044cea1c7733e4..e3a61bfec8a972e82b89b329cc1ea69310bc361b 100644 (file)
@@ -35,6 +35,7 @@ class Item
         * Return array with details for categories and folders for an item
         *
         * @param array $item
+        * @param int   $uid
         * @return [array, array]
         *
         * [
@@ -58,13 +59,15 @@ class Item
         *       ]
         *  ]
         */
-       public function determineCategoriesTerms(array $item)
+       public function determineCategoriesTerms(array $item, int $uid = 0)
        {
                $categories = [];
                $folders = [];
                $first = true;
 
-               foreach (Post\Category::getArrayByURIId($item['uri-id'], $item['uid'], Post\Category::CATEGORY) as $savedFolderName) {
+               $uid = $item['uid'] ?: $uid;
+
+               foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::CATEGORY) as $savedFolderName) {
                        if (!empty($item['author-link'])) {
                                $url = $item['author-link'] . "?category=" . rawurlencode($savedFolderName);
                        } else {
@@ -73,7 +76,7 @@ class Item
                        $categories[] = [
                                'name' => $savedFolderName,
                                'url' => $url,
-                               'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : ""),
+                               'removeurl' => local_user() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
                                'first' => $first,
                                'last' => false
                        ];
@@ -84,12 +87,12 @@ class Item
                        $categories[count($categories) - 1]['last'] = true;
                }
 
-               if (local_user() == $item['uid']) {
-                       foreach (Post\Category::getArrayByURIId($item['uri-id'], $item['uid'], Post\Category::FILE) as $savedFolderName) {
+               if (local_user() == $uid) {
+                       foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::FILE) as $savedFolderName) {
                                $folders[] = [
                                        'name' => $savedFolderName,
                                        'url' => "#",
-                                       'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : ""),
+                                       'removeurl' => local_user() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
                                        'first' => $first,
                                        'last' => false
                                ];
@@ -127,16 +130,6 @@ class Item
                        $tag_type = substr($tag, 0, 1);
                        //is it already replaced?
                        if (strpos($tag, '[url=')) {
-                               // Checking for the alias that is used for OStatus
-                               $pattern = '/[@!]\[url\=(.*?)\](.*?)\[\/url\]/ism';
-                               if (preg_match($pattern, $tag, $matches)) {
-                                       $data = Contact::getByURL($matches[1], false, ['alias', 'nick']);
-
-                                       if ($data['alias'] != '') {
-                                               $newtag = '@[url=' . $data['alias'] . ']' . $data['nick'] . '[/url]';
-                                       }
-                               }
-
                                return $replaced;
                        }