1
0
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:
JoshyPHP
2015-05-03 16:06:42 +02:00
parent 98db63e8cc
commit f5ce9f2738
9 changed files with 126 additions and 31 deletions

View File

@@ -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
*