diff options
Diffstat (limited to 'phpBB/phpbb/textformatter')
-rw-r--r-- | phpBB/phpbb/textformatter/s9e/utils.php | 25 | ||||
-rw-r--r-- | phpBB/phpbb/textformatter/utils_interface.php | 8 |
2 files changed, 33 insertions, 0 deletions
diff --git a/phpBB/phpbb/textformatter/s9e/utils.php b/phpBB/phpbb/textformatter/s9e/utils.php index 2018bbf519..576ab9481c 100644 --- a/phpBB/phpbb/textformatter/s9e/utils.php +++ b/phpBB/phpbb/textformatter/s9e/utils.php @@ -35,6 +35,31 @@ class utils implements \phpbb\textformatter\utils_interface } /** + * 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 * * @param string $xml Parsed text diff --git a/phpBB/phpbb/textformatter/utils_interface.php b/phpBB/phpbb/textformatter/utils_interface.php index 132dc8ece4..183c426161 100644 --- a/phpBB/phpbb/textformatter/utils_interface.php +++ b/phpBB/phpbb/textformatter/utils_interface.php @@ -29,6 +29,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 * * @param string $text Parsed text |