mirror of
https://github.com/friendica/friendica
synced 2025-04-25 10:30:12 +00:00
Centralize share tag attribute extraction code in Content\Text\BBCode
This commit is contained in:
parent
8446de2aa6
commit
a7d49877a8
2 changed files with 36 additions and 30 deletions
|
@ -3438,18 +3438,7 @@ class Item
|
|||
*/
|
||||
public static function getShareArray(array $item): array
|
||||
{
|
||||
if (!preg_match("/(.*?)\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", $item['body'], $matches)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$attribute_string = $matches[2];
|
||||
$attributes = ['comment' => trim($matches[1]), 'shared' => trim($matches[3])];
|
||||
foreach (['author', 'profile', 'avatar', 'guid', 'posted', 'link'] as $field) {
|
||||
if (preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches)) {
|
||||
$attributes[$field] = trim(html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
}
|
||||
return $attributes;
|
||||
return BBCode::fetchShareAttributes($item['body']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue