diff options
| author | Tristan Darricau <github@nicofuma.fr> | 2017-01-06 19:52:17 +0100 |
|---|---|---|
| committer | Tristan Darricau <github@nicofuma.fr> | 2017-01-06 21:40:31 +0100 |
| commit | f82299b8e445cccfc8bad8cbe6505f3fb50d0f8f (patch) | |
| tree | e787c297018cc24f4e1fc160fecd4375fadbd9d8 /phpBB/phpbb | |
| parent | 2251816b10a300a873c1b5191d21445461e0d89d (diff) | |
| download | forums-f82299b8e445cccfc8bad8cbe6505f3fb50d0f8f.tar forums-f82299b8e445cccfc8bad8cbe6505f3fb50d0f8f.tar.gz forums-f82299b8e445cccfc8bad8cbe6505f3fb50d0f8f.tar.bz2 forums-f82299b8e445cccfc8bad8cbe6505f3fb50d0f8f.tar.xz forums-f82299b8e445cccfc8bad8cbe6505f3fb50d0f8f.zip | |
[ticket/14962] Introduces a new helper to check emptyness of bbcode texts
PHPBB3-14962
Diffstat (limited to 'phpBB/phpbb')
| -rw-r--r-- | phpBB/phpbb/textformatter/s9e/utils.php | 13 | ||||
| -rw-r--r-- | phpBB/phpbb/textformatter/utils_interface.php | 18 |
2 files changed, 26 insertions, 5 deletions
diff --git a/phpBB/phpbb/textformatter/s9e/utils.php b/phpBB/phpbb/textformatter/s9e/utils.php index b317fe4a8d..a9a6d4b892 100644 --- a/phpBB/phpbb/textformatter/s9e/utils.php +++ b/phpBB/phpbb/textformatter/s9e/utils.php @@ -136,4 +136,17 @@ class utils implements \phpbb\textformatter\utils_interface { return \s9e\TextFormatter\Unparser::unparse($xml); } + + /** + * {@inheritdoc} + */ + public function is_empty($text) + { + if ($text === null || $text === '') + { + return true; + } + + return trim($this->unparse($text)) === ''; + } } diff --git a/phpBB/phpbb/textformatter/utils_interface.php b/phpBB/phpbb/textformatter/utils_interface.php index 4810453cd1..4b7392976a 100644 --- a/phpBB/phpbb/textformatter/utils_interface.php +++ b/phpBB/phpbb/textformatter/utils_interface.php @@ -62,10 +62,18 @@ interface utils_interface public function remove_bbcode($text, $bbcode_name, $depth = 0); /** - * Return a parsed text to its original form - * - * @param string $text Parsed text - * @return string Original plain text - */ + * Return a parsed text to its original form + * + * @param string $text Parsed text + * @return string Original plain text + */ public function unparse($text); + + /** + * Return whether or not a parsed text represent an empty text. + * + * @param string $text Parsed text + * @return bool Tue if the original text is empty + */ + public function is_empty($text); } |
