More functions moved to content class

This commit is contained in:
Michael 2022-10-27 05:44:44 +00:00
parent c65fff6f93
commit deccea0228
10 changed files with 113 additions and 59 deletions

View file

@ -3623,36 +3623,6 @@ class Item
return true;
}
/**
* Improve the data in shared posts
*
* @param array $item
* @param bool $add_media
* @return string body
*/
public static function improveSharedDataInBody(array $item, bool $add_media = false): string
{
$shared = BBCode::fetchShareAttributes($item['body']);
if (empty($shared['guid']) && empty($shared['message_id'])) {
return $item['body'];
}
$link = $shared['link'] ?: $shared['message_id'];
if (empty($shared_content)) {
$shared_content = DI::contentItem()->createSharedPostByUrl($link, $item['uid'] ?? 0, $add_media);
}
if (empty($shared_content)) {
return $item['body'];
}
$item['body'] = preg_replace("/\[share.*?\](.*)\[\/share\]/ism", $shared_content, $item['body']);
Logger::debug('New shared data', ['uri-id' => $item['uri-id'], 'link' => $link, 'guid' => $item['guid']]);
return $item['body'];
}
/**
* Fetch the uri-id of a quote
*