diff options
author | JoshyPHP <s9e.dev@gmail.com> | 2019-12-16 01:34:26 +0100 |
---|---|---|
committer | JoshyPHP <s9e.dev@gmail.com> | 2019-12-16 01:34:26 +0100 |
commit | 2733ce07129dceb5b60acdceba1689fa5339a523 (patch) | |
tree | f3fc7dd98c7af58b0ff6e056189f4805a440b160 /phpBB/phpbb | |
parent | 2926ceba6a06a2f0f95452ae838a89247c493c93 (diff) | |
download | forums-2733ce07129dceb5b60acdceba1689fa5339a523.tar forums-2733ce07129dceb5b60acdceba1689fa5339a523.tar.gz forums-2733ce07129dceb5b60acdceba1689fa5339a523.tar.bz2 forums-2733ce07129dceb5b60acdceba1689fa5339a523.tar.xz forums-2733ce07129dceb5b60acdceba1689fa5339a523.zip |
[ticket/16250] Reworked status as constants
PHPBB3-16250
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r-- | phpBB/phpbb/textformatter/acp_utils_interface.php | 26 | ||||
-rw-r--r-- | phpBB/phpbb/textformatter/s9e/acp_utils.php | 6 |
2 files changed, 24 insertions, 8 deletions
diff --git a/phpBB/phpbb/textformatter/acp_utils_interface.php b/phpBB/phpbb/textformatter/acp_utils_interface.php index d1e3de9989..cdee56f19d 100644 --- a/phpBB/phpbb/textformatter/acp_utils_interface.php +++ b/phpBB/phpbb/textformatter/acp_utils_interface.php @@ -16,14 +16,30 @@ namespace phpbb\textformatter; interface acp_utils_interface { /** + * There is an issue with the definition + */ + const BBCODE_STATUS_INVALID_DEFINITION = 'invalid_definition'; + + /** + * There is an issue with the template + */ + const BBCODE_STATUS_INVALID_TEMPLATE = 'invalid_template'; + + /** + * The BBCode is valid and can be safely used by anyone + */ + const BBCODE_STATUS_SAFE = 'safe'; + + /** + * The BBCode is valid but may be unsafe to use + */ + const BBCODE_STATUS_UNSAFE = 'unsafe'; + + /** * Analyse given BBCode definition for issues and safeness * * Required elements in the return array: - * - status: - * - "safe" The BBCode is valid and can be safely used by anyone. - * - "unsafe" The BBCode is valid but may be unsafe to use. - * - "invalid_definition" There is an issue with the definition. - * - "invalid_template" There is an issue with the template. + * - status: see BBCODE_STATUS_* constants * * Optional elements in the return array: * - name: Name of the BBCode based on the definition. Required if status is "safe". diff --git a/phpBB/phpbb/textformatter/s9e/acp_utils.php b/phpBB/phpbb/textformatter/s9e/acp_utils.php index 981fa60813..c4a668020e 100644 --- a/phpBB/phpbb/textformatter/s9e/acp_utils.php +++ b/phpBB/phpbb/textformatter/s9e/acp_utils.php @@ -37,7 +37,7 @@ class acp_utils implements acp_utils_interface public function analyse_bbcode(string $definition, string $template): array { $configurator = $this->factory->get_configurator(); - $return = ['status' => 'safe']; + $return = ['status' => self::BBCODE_STATUS_SAFE]; // Capture and normalize the BBCode name manually because there's no easy way to retrieve // it in TextFormatter <= 2.x @@ -52,13 +52,13 @@ class acp_utils implements acp_utils_interface } catch (UnsafeTemplateException $e) { - $return['status'] = 'unsafe'; + $return['status'] = self::BBCODE_STATUS_UNSAFE; $return['error_text'] = $e->getMessage(); $return['error_html'] = $e->highlightNode('<span class="highlight">'); } catch (\Exception $e) { - $return['status'] = (preg_match('(xml|xpath|xsl)i', $e->getMessage())) ? 'invalid_template' : 'invalid_definition'; + $return['status'] = (preg_match('(xml|xpath|xsl)i', $e->getMessage())) ? self::BBCODE_STATUS_INVALID_TEMPLATE : self::BBCODE_STATUS_INVALID_DEFINITION; $return['error_text'] = $e->getMessage(); } |