mirror of
https://github.com/friendica/friendica
synced 2025-04-24 11:50:10 +00:00
More functions moved to content class
This commit is contained in:
parent
c65fff6f93
commit
deccea0228
10 changed files with 113 additions and 59 deletions
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue