mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
[ticket/13680] Updated quote notifications
Added get_quote_authors() to text_formatter.utils service to retrieve the names used in first-level quotes PHPBB3-13680
This commit is contained in:
@@ -34,6 +34,31 @@ class utils implements \phpbb\textformatter\utils_interface
|
||||
return \s9e\TextFormatter\Utils::removeFormatting($xml);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of quote authors, limited to the first level of quotes
|
||||
*
|
||||
* @param string $xml Parsed text
|
||||
* @return string[] List of authors
|
||||
*/
|
||||
public function get_quote_authors($xml)
|
||||
{
|
||||
$authors = array();
|
||||
if (strpos($xml, '<QUOTE ') === false)
|
||||
{
|
||||
return $authors;
|
||||
}
|
||||
|
||||
$dom = new \DOMDocument;
|
||||
$dom->loadXML($xml);
|
||||
$xpath = new \DOMXPath($dom);
|
||||
foreach ($xpath->query('//QUOTE[not(ancestor::QUOTE)]/@author') as $author)
|
||||
{
|
||||
$authors[] = $author->textContent;
|
||||
}
|
||||
|
||||
return $authors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove given BBCode and its content, at given nesting depth
|
||||
*
|
||||
|
@@ -28,6 +28,14 @@ interface utils_interface
|
||||
*/
|
||||
public function clean_formatting($text);
|
||||
|
||||
/**
|
||||
* Get a list of quote authors, limited to the first level of quotes
|
||||
*
|
||||
* @param string $text Parsed text
|
||||
* @return string[] List of authors
|
||||
*/
|
||||
public function get_quote_authors($text);
|
||||
|
||||
/**
|
||||
* Remove given BBCode and its content, at given nesting depth
|
||||
*
|
||||
|
Reference in New Issue
Block a user