diff options
author | Igor Wiedler <igor@wiedler.ch> | 2011-03-06 21:39:42 +0100 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2011-03-06 21:39:42 +0100 |
commit | 6681b2417a3f87a666c816658a2daab8a464e233 (patch) | |
tree | d16fc4e92428c3044649855fbd4ccf01c0fd42d9 /phpBB/includes/utf/utf_tools.php | |
parent | 6df35c2cb6895fedee6a85645b369bff52c25670 (diff) | |
download | forums-6681b2417a3f87a666c816658a2daab8a464e233.tar forums-6681b2417a3f87a666c816658a2daab8a464e233.tar.gz forums-6681b2417a3f87a666c816658a2daab8a464e233.tar.bz2 forums-6681b2417a3f87a666c816658a2daab8a464e233.tar.xz forums-6681b2417a3f87a666c816658a2daab8a464e233.zip |
[ticket/9669] Switch if/else to make the if positive
PHPBB3-9669
Diffstat (limited to 'phpBB/includes/utf/utf_tools.php')
-rw-r--r-- | phpBB/includes/utf/utf_tools.php | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index 34f9633677..3ee121a179 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -1712,11 +1712,12 @@ function utf8_case_fold_nfc($text, $option = 'full') return $text; } -if (!extension_loaded('intl')) +if (extension_loaded('intl')) { /** - * A wrapper function for the normalizer which takes care of including the class if required and modifies the passed strings - * to be in NFC (Normalization Form Composition). + * wrapper around PHP's native normalizer from intl + * previously a PECL extension, included in the core since PHP 5.3.0 + * http://php.net/manual/en/normalizer.normalize.php * * @param mixed $strings a string or an array of strings to normalize * @return mixed the normalized content, preserving array keys if array given. @@ -1728,17 +1729,15 @@ if (!extension_loaded('intl')) return $strings; } - if (!class_exists('utf_normalizer')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx); - } - if (!is_array($strings)) { - utf_normalizer::nfc($strings); + if (Normalizer::isNormalized($strings)) + { + return $strings; + } + return (string) Normalizer::normalize($strings); } - else if (is_array($strings)) + else { foreach ($strings as $key => $string) { @@ -1746,12 +1745,20 @@ if (!extension_loaded('intl')) { foreach ($string as $_key => $_string) { - utf_normalizer::nfc($strings[$key][$_key]); + if (Normalizer::isNormalized($strings[$key][$_key])) + { + continue; + } + $strings[$key][$_key] = (string) Normalizer::normalize($strings[$key][$_key]); } } else { - utf_normalizer::nfc($strings[$key]); + if (Normalizer::isNormalized($strings[$key])) + { + continue; + } + $strings[$key] = (string) Normalizer::normalize($strings[$key]); } } } @@ -1761,10 +1768,9 @@ if (!extension_loaded('intl')) } else { - /** - * wrapper around PHP's native normalizer from intl - * previously a PECL extension, included in the core since PHP 5.3.0 - * http://php.net/manual/en/normalizer.normalize.php + /** + * A wrapper function for the normalizer which takes care of including the class if + * required and modifies the passed strings to be in NFC (Normalization Form Composition). * * @param mixed $strings a string or an array of strings to normalize * @return mixed the normalized content, preserving array keys if array given. @@ -1776,15 +1782,17 @@ else return $strings; } + if (!class_exists('utf_normalizer')) + { + global $phpbb_root_path, $phpEx; + include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx); + } + if (!is_array($strings)) { - if (Normalizer::isNormalized($strings)) - { - return $strings; - } - return (string) Normalizer::normalize($strings); + utf_normalizer::nfc($strings); } - else + else if (is_array($strings)) { foreach ($strings as $key => $string) { @@ -1792,20 +1800,12 @@ else { foreach ($string as $_key => $_string) { - if (Normalizer::isNormalized($strings[$key][$_key])) - { - continue; - } - $strings[$key][$_key] = (string) Normalizer::normalize($strings[$key][$_key]); + utf_normalizer::nfc($strings[$key][$_key]); } } else { - if (Normalizer::isNormalized($strings[$key])) - { - continue; - } - $strings[$key] = (string) Normalizer::normalize($strings[$key]); + utf_normalizer::nfc($strings[$key]); } } } |