]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Tag.php
Don't cache local avatars
[friendica.git] / src / Model / Tag.php
index 3020a2f2934839e0108779bda564314752e09bcb..17a68f120f4b5ab643277ac387571410b6d93944 100644 (file)
@@ -207,22 +207,40 @@ class Tag
        }
 
        /**
-        * Store tags and mentions from the body
+        * Get tags and mentions from the body
         * 
-        * @param integer $uriid   URI-Id
         * @param string  $body    Body of the post
         * @param string  $tags    Accepted tags
-        * @param boolean $probing Perform a probing for contacts, adding them if needed
+        *
+        * @return array Tag list
         */
-       public static function storeFromBody(int $uriid, string $body, string $tags = null, $probing = true)
+       public static function getFromBody(string $body, string $tags = null)
        {
                if (is_null($tags)) {
                        $tags =  self::TAG_CHARACTER[self::HASHTAG] . self::TAG_CHARACTER[self::MENTION] . self::TAG_CHARACTER[self::EXCLUSIVE_MENTION];
                }
 
+               if (!preg_match_all("/([" . $tags . "])\[url\=([^\[\]]*)\]([^\[\]]*)\[\/url\]/ism", $body, $result, PREG_SET_ORDER)) {
+                       return [];
+               }
+
+               return $result;
+       }
+
+       /**
+        * Store tags and mentions from the body
+        * 
+        * @param integer $uriid   URI-Id
+        * @param string  $body    Body of the post
+        * @param string  $tags    Accepted tags
+        * @param boolean $probing Perform a probing for contacts, adding them if needed
+        */
+       public static function storeFromBody(int $uriid, string $body, string $tags = null, $probing = true)
+       {
                Logger::info('Check for tags', ['uri-id' => $uriid, 'hash' => $tags, 'callstack' => System::callstack()]);
 
-               if (!preg_match_all("/([" . $tags . "])\[url\=([^\[\]]*)\]([^\[\]]*)\[\/url\]/ism", $body, $result, PREG_SET_ORDER)) {
+               $result = self::getFromBody($body, $tags);
+               if (empty($result)) {
                        return;
                }