mirror of
https://github.com/friendica/friendica
synced 2025-04-30 00:24:24 +02:00
Merge pull request #12061 from annando/share-rework
The "share" handling is improved
This commit is contained in:
commit
a7e9457ef2
14 changed files with 75 additions and 112 deletions
|
@ -680,10 +680,10 @@ class Item
|
|||
$shared_content .= '[h3]' . $item['title'] . "[/h3]\n";
|
||||
}
|
||||
|
||||
$shared = BBCode::fetchShareAttributes($item['body']);
|
||||
$shared = ItemModel::getShareArray($item);
|
||||
|
||||
// If it is a reshared post then reformat it to avoid display problems with two share elements
|
||||
if (Diaspora::isReshare($item['body'], false)) {
|
||||
if (!empty($shared)) {
|
||||
if (!empty($shared['guid']) && ($encaspulated_share = self::createSharedPostByGuid($shared['guid'], 0, '', $add_media))) {
|
||||
$item['body'] = preg_replace("/\[share.*?\](.*)\[\/share\]/ism", $encaspulated_share, $item['body']);
|
||||
}
|
||||
|
|
|
@ -1023,6 +1023,7 @@ class BBCode
|
|||
{
|
||||
DI::profiler()->startRecording('rendering');
|
||||
if (preg_match('~(.*?)\[share](.*)\[/share]~ism', $text, $matches)) {
|
||||
DI::profiler()->stopRecording();
|
||||
return [
|
||||
'author' => '',
|
||||
'profile' => '',
|
||||
|
@ -1093,12 +1094,7 @@ class BBCode
|
|||
*/
|
||||
public static function removeSharedData(string $body): string
|
||||
{
|
||||
return BBCode::convertShare(
|
||||
$body,
|
||||
function (array $attributes) {
|
||||
return '';
|
||||
}
|
||||
);
|
||||
return preg_replace("/\s*\[share .*?\].*?\[\/share\]\s*/ism", '', $body);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue