X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FTag.php;h=17a68f120f4b5ab643277ac387571410b6d93944;hb=48087136680d345e9222c974ae983262b319d308;hp=3020a2f2934839e0108779bda564314752e09bcb;hpb=322b7c856ca9ba53bd9c7da50dd5c1e3c9197d56;p=friendica.git diff --git a/src/Model/Tag.php b/src/Model/Tag.php index 3020a2f293..17a68f120f 100644 --- a/src/Model/Tag.php +++ b/src/Model/Tag.php @@ -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; }