diff options
| author | Marc Alexander <admin@m-a-styles.de> | 2017-01-07 00:16:45 +0100 |
|---|---|---|
| committer | Marc Alexander <admin@m-a-styles.de> | 2017-01-07 00:16:45 +0100 |
| commit | 7074876f3298df301bad89c1a55c4265aad4c710 (patch) | |
| tree | c0791ce965d13da2916116f55f55f27540ebea8d /phpBB/phpbb | |
| parent | 166320ef9edd0f8c5e6ddaee35f05741c274eb4e (diff) | |
| parent | 538f03efb058c84daf3e677a3137be8900678f2b (diff) | |
| download | forums-7074876f3298df301bad89c1a55c4265aad4c710.tar forums-7074876f3298df301bad89c1a55c4265aad4c710.tar.gz forums-7074876f3298df301bad89c1a55c4265aad4c710.tar.bz2 forums-7074876f3298df301bad89c1a55c4265aad4c710.tar.xz forums-7074876f3298df301bad89c1a55c4265aad4c710.zip | |
Merge pull request #4619 from Nicofuma/ticket/14962
[ticket/14962] Introduces a new helper to check emptyness of bbcode texts
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); } |
