]> git.mxchange.org Git - friendica.git/commitdiff
Removed legacy usage of the "tag" field
authorMichael <heluecht@pirati.ca>
Tue, 5 May 2020 19:54:25 +0000 (19:54 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 5 May 2020 19:54:25 +0000 (19:54 +0000)
mod/photos.php
mod/tagrm.php
src/Model/Tag.php

index 8f968d0c08d74f6f19eb142223cfb66d8137b3b0..f4983a8380449b5681431958f0642e1e5dba02da 100644 (file)
@@ -1307,9 +1307,10 @@ function photos_content(App $a)
                }
 
                $tags = null;
+               $tag_text = Tag::tagTextFromItemId($link_item['uri-id']);
 
-               if (!empty($link_item['id']) && !empty($link_item['tag'])) {
-                       $arr = explode(',', $link_item['tag']);
+               if (!empty($link_item['id']) && !empty($tag_text)) {
+                       $arr = explode(',', $tag_text);
                        // parse tags and add links
                        $tag_arr = [];
                        foreach ($arr as $tag) {
index 7e8ae8524b92a78a8be0a4cddfcc3549e62766a6..3aefe0680f7fe583e1ad2e470532efda12f914db 100644 (file)
@@ -97,15 +97,16 @@ function tagrm_content(App $a)
                // NOTREACHED
        }
 
-       $item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]);
+       $item = Item::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => local_user()]);
        if (!DBA::isResult($item)) {
                DI::baseUrl()->redirect($_SESSION['photo_return']);
        }
 
-       $arr = explode(',', $item['tag']);
+       $tag_text = Tag::tagTextFromItemId($item['uri-id']);
 
+       $arr = explode(',', $tag_text);
 
-       if (empty($item['tag'])) {
+       if (empty($arr)) {
                DI::baseUrl()->redirect($_SESSION['photo_return']);
        }
 
index 9b4b1eb41b806d127eb0b85c9653c56e2ba88cc0..f21d2ffec686f8308a42528e2f16494b97ee03c4 100644 (file)
@@ -339,6 +339,23 @@ class Tag
                return DBA::selectToArray('tag-view', ['type', 'name', 'url'], $condition);
        }
 
+       /**
+        * Return a string with all tags and mentions
+        *
+        * @param integer $uri_id
+        * @return string tags and mentions
+        */
+       public static function tagTextFromItemId(int $uri_id)
+       {
+               $tag_list = [];
+               $tags = self::getByURIId($uri_id);
+               foreach ($tags as $tag) {
+                       $tag_list[] = self::TAG_CHARACTER[$tag['type']] . '[url=' . $tag['url'] . ']' . $tag['name'] . '[/url]';
+               }
+
+               return implode(',', $tag_list);
+       }
+
        /**
         * Sorts an item's tags into mentions, hashtags and other tags. Generate personalized URLs by user and modify the
         * provided item's body with them.