Improved handling of native quotes

This commit is contained in:
Michael 2022-10-29 22:11:39 +00:00
parent f418687a71
commit 3c169b534e
11 changed files with 204 additions and 217 deletions

View file

@ -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));
}
/**