1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/11768] Updated the text_formatter.s9e.utils service

Made it use s9e\TextFormatter\Utils. Refactored some tests to make
them more readable.

PHPBB3-11768
This commit is contained in:
JoshyPHP
2015-03-23 21:34:49 +01:00
parent 5b2d3fddfd
commit 37fedc656f
2 changed files with 16 additions and 38 deletions

View File

@@ -26,7 +26,7 @@ class utils implements \phpbb\textformatter\utils_interface
// Insert a space before <s> and <e> then remove formatting
$text = preg_replace('#<[es]>#', ' $0', $text);
return \s9e\TextFormatter\Unparser::removeFormatting($text);
return \s9e\TextFormatter\Utils::removeFormatting($text);
}
/**
@@ -34,18 +34,7 @@ class utils implements \phpbb\textformatter\utils_interface
*/
public function remove_bbcode($text, $bbcode_name, $depth = 0)
{
$dom = new \DOMDocument;
$dom->loadXML($text);
$xpath = new \DOMXPath($dom);
$nodes = $xpath->query(str_repeat('//' . strtoupper($bbcode_name), 1 + $depth));
foreach ($nodes as $node)
{
$node->parentNode->removeChild($node);
}
return $dom->saveXML($dom->documentElement);
return \s9e\TextFormatter\Utils::removeTag($text, strtoupper($bbcode_name), $depth);
}
/**
@@ -53,7 +42,7 @@ class utils implements \phpbb\textformatter\utils_interface
*/
public function remove_formatting($text)
{
return \s9e\TextFormatter\Unparser::removeFormatting($text);
return \s9e\TextFormatter\Utils::removeFormatting($text);
}
/**