]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
AP: Debug option to deliver via AP first
[friendica.git] / src / Model / Item.php
index 192c9b141001147100c98c49dee58942546e20d4..b460d5f79fdf886364acfe50a0c7ddf99a4580e6 100644 (file)
@@ -559,10 +559,10 @@ class Item extends BaseObject
 
                $fields['permissionset'] = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
 
-               $fields['author'] = ['url' => 'author-link', 'name' => 'author-name',
+               $fields['author'] = ['url' => 'author-link', 'name' => 'author-name', 'addr' => 'author-addr',
                        'thumb' => 'author-avatar', 'nick' => 'author-nick', 'network' => 'author-network'];
 
-               $fields['owner'] = ['url' => 'owner-link', 'name' => 'owner-name',
+               $fields['owner'] = ['url' => 'owner-link', 'name' => 'owner-name', 'addr' => 'owner-addr',
                        'thumb' => 'owner-avatar', 'nick' => 'owner-nick', 'network' => 'owner-network'];
 
                $fields['contact'] = ['url' => 'contact-link', 'name' => 'contact-name', 'thumb' => 'contact-avatar',
@@ -2386,7 +2386,6 @@ class Item extends BaseObject
 
        public static function setHashtags(&$item)
        {
-
                $tags = BBCode::getTags($item["body"]);
 
                // No hashtags?
@@ -2394,23 +2393,23 @@ class Item extends BaseObject
                        return false;
                }
 
-               // This sorting is important when there are hashtags that are part of other hashtags
-               // Otherwise there could be problems with hashtags like #test and #test2
-               rsort($tags);
-
-               $URLSearchString = "^\[\]";
-
                // What happens in [code], stays in [code]!
                // escape the # and the [
                // hint: we will also get in trouble with #tags, when we want markdown in posts -> ### Headline 3
-               $item["body"] = preg_replace_callback("/\[code(.*)\](.*?)\[\/code\]/ism",
+               $item["body"] = preg_replace_callback("/\[code(.*?)\](.*?)\[\/code\]/ism",
                        function ($match) {
                                // we truly ESCape all # and [ to prevent gettin weird tags in [code] blocks
                                $find = ['#', '['];
                                $replace = [chr(27).'sharp', chr(27).'leftsquarebracket'];
-                               return ("[code" . str_replace($find, $replace, $match[1]) . "]" . $match[2] . "[/code]");
+                               return ("[code" . $match[1] . "]" . str_replace($find, $replace, $match[2]) . "[/code]");
                        }, $item["body"]);
-               
+
+               // This sorting is important when there are hashtags that are part of other hashtags
+               // Otherwise there could be problems with hashtags like #test and #test2
+               rsort($tags);
+
+               $URLSearchString = "^\[\]";
+
                // All hashtags should point to the home server if "local_tags" is activated
                if (Config::get('system', 'local_tags')) {
                        $item["body"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
@@ -2441,22 +2440,20 @@ class Item extends BaseObject
                                "#$2", $item["body"]);
 
                foreach ($tags as $tag) {
-                       if ((strpos($tag, '#') !== 0) || strpos($tag, '[url=')) {
+                       if ((strpos($tag, '#') !== 0) || strpos($tag, '[url=') || $tag[1] == '#') {
                                continue;
                        }
 
                        $basetag = str_replace('_',' ',substr($tag,1));
-                       if($basetag[0] != '#') { 
-                               $newtag = '#[url=' . System::baseUrl() . '/search?tag=' . $basetag . ']' . $basetag . '[/url]';
+                       $newtag = '#[url=' . System::baseUrl() . '/search?tag=' . $basetag . ']' . $basetag . '[/url]';
 
-                               $item["body"] = str_replace($tag, $newtag, $item["body"]);
+                       $item["body"] = str_replace($tag, $newtag, $item["body"]);
 
-                               if (!stristr($item["tag"], "/search?tag=" . $basetag . "]" . $basetag . "[/url]")) {
-                                       if (strlen($item["tag"])) {
-                                               $item["tag"] = ',' . $item["tag"];
-                                       }
-                                       $item["tag"] = $newtag . $item["tag"];
+                       if (!stristr($item["tag"], "/search?tag=" . $basetag . "]" . $basetag . "[/url]")) {
+                               if (strlen($item["tag"])) {
+                                       $item["tag"] = ',' . $item["tag"];
                                }
+                               $item["tag"] = $newtag . $item["tag"];
                        }
                }
 
@@ -2465,16 +2462,13 @@ class Item extends BaseObject
 
                // Remember! What happens in [code], stays in [code]
                // roleback the # and [
-               $item["body"] = preg_replace_callback("/\[code(.*)\](.*?)\[\/code\]/ism",
+               $item["body"] = preg_replace_callback("/\[code(.*?)\](.*?)\[\/code\]/ism",
                        function ($match) {
                                // we truly unESCape all sharp and leftsquarebracket
                                $find = [chr(27).'sharp', chr(27).'leftsquarebracket'];
                                $replace = ['#', '['];
-                               return ("[code" . str_replace($find, $replace, $match[1]) . "]" . $match[2] . "[/code]");
+                               return ("[code" . $match[1] . "]" . str_replace($find, $replace, $match[2]) . "[/code]");
                        }, $item["body"]);
-
-               // Convert back the masked hashtags
-               $item["body"] = str_replace("#", "#", $item["body"]);
        }
 
        public static function getGuidById($id)