mirror of
https://github.com/friendica/friendica
synced 2025-04-24 08:30:11 +00:00
Issue 10966: Perform forum handling with the unified format
This commit is contained in:
parent
15bc1ac8a1
commit
b9ea7adbda
2 changed files with 54 additions and 26 deletions
|
@ -206,6 +206,27 @@ class Tag
|
|||
self::store($uriid, $type, $name, $url, $probing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags and mentions from the body
|
||||
*
|
||||
* @param string $body Body of the post
|
||||
* @param string $tags Accepted tags
|
||||
*
|
||||
* @return array Tag list
|
||||
*/
|
||||
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
|
||||
*
|
||||
|
@ -216,13 +237,10 @@ class Tag
|
|||
*/
|
||||
public static function storeFromBody(int $uriid, string $body, string $tags = null, $probing = true)
|
||||
{
|
||||
if (is_null($tags)) {
|
||||
$tags = self::TAG_CHARACTER[self::HASHTAG] . self::TAG_CHARACTER[self::MENTION] . self::TAG_CHARACTER[self::EXCLUSIVE_MENTION];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue