mirror of
https://github.com/friendica/friendica
synced 2025-04-24 13:10:11 +00:00
Improved handling of native quotes
This commit is contained in:
parent
f418687a71
commit
3c169b534e
11 changed files with 204 additions and 217 deletions
|
@ -1070,46 +1070,6 @@ class BBCode
|
|||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks, if the provided body contains a native reshare
|
||||
*
|
||||
* @param string $body
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isNativeReshare(string $body): bool
|
||||
{
|
||||
$shared = BBCode::fetchShareAttributes($body);
|
||||
return !empty($shared['guid'] ?? '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the provided body contains a "share" element
|
||||
*
|
||||
* @param string $body
|
||||
* @return boolean
|
||||
*/
|
||||
public static function existsShare(string $body): bool
|
||||
{
|
||||
$shared = BBCode::fetchShareAttributes($body);
|
||||
return !empty($shared['link'] ?? '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the share block with a link
|
||||
*
|
||||
* @param string $body
|
||||
* @return string
|
||||
*/
|
||||
public static function replaceSharedData(string $body): string
|
||||
{
|
||||
return BBCode::convertShare(
|
||||
$body,
|
||||
function (array $attributes) {
|
||||
return '♲ ' . $attributes['link'];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the share block
|
||||
*
|
||||
|
@ -1118,7 +1078,7 @@ class BBCode
|
|||
*/
|
||||
public static function removeSharedData(string $body): string
|
||||
{
|
||||
return trim(preg_replace("/\s*\[share .*?\].*?\[\/share\]\s*/ism", '', $body));
|
||||
return trim(preg_replace("/\s*\[share.*?\].*?\[\/share\]\s*/ism", '', $body));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue