aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/utf/utf_tools.php
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2011-05-08 03:21:19 -0400
committerOleg Pudeyev <oleg@bsdpower.com>2011-05-08 03:21:19 -0400
commitab44fe5e394fe7b69c57266e2934200a3ee9bbc5 (patch)
treee6021c19fa15800787b1a7459fb8ad40cf2d8391 /phpBB/includes/utf/utf_tools.php
parent9c6660a2253149baff0094b943823de6758b35a6 (diff)
parentc0336988155736583c6fc4398980bd2a4e4036b6 (diff)
downloadforums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.tar
forums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.tar.gz
forums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.tar.bz2
forums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.tar.xz
forums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.zip
Merge branch 'develop' into feature/prune-users
* develop: (170 commits) [ticket/10145] Always recompile all templates when DEBUG_EXTRA is defined. [feature/attachment-management-no-reassignment] Handle privacy and some more. [ticket/10148] Turn TEMPLATE_BITFIELD into an instance variable. [ticket/10147] Corrected a typo in includes/functions_template.php. [ticket/10141] Save a hash lookup when value is not in cache. [ticket/10143] Added tests for storing a previously deleted value in db cache. [ticket/10105] Update AIM express link. [ticket/10105] Update AIM application download link. [ticket/10137] Remove unintended space at end of PHP_URL_FOPEN_SUPPORT_EXPLAIN. [ticket/10141] Split double-assignment into conditional and unconditional part. [ticket/10141] Use a cache in $auth->_fill_acl() for better performance. [ticket/9961] Create log entries when users are activated. [ticket/10139] Make signatures of set_atomic() consistent by using $new_value. [ticket/10139] Rename $cache to $use_cache to avoid confusion with cache object [ticket/10006] Remove unneeded if statements [ticket/10006] Remove return values [ticket/10006] More testing [ticket/10006] Tweak the tests a bit [ticket/10006] Add phpbb_config::delete [ticket/7941] Added @return to generate_board_url docstring. ...
Diffstat (limited to 'phpBB/includes/utf/utf_tools.php')
-rw-r--r--phpBB/includes/utf/utf_tools.php117
1 files changed, 87 insertions, 30 deletions
diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php
index cac5b4e744..65d40c0fd3 100644
--- a/phpBB/includes/utf/utf_tools.php
+++ b/phpBB/includes/utf/utf_tools.php
@@ -1712,49 +1712,106 @@ function utf8_case_fold_nfc($text, $option = 'full')
return $text;
}
-/**
-* 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.
-*/
-function utf8_normalize_nfc($strings)
+if (extension_loaded('intl'))
{
- if (empty($strings))
+ /**
+ * 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.
+ */
+ function utf8_normalize_nfc($strings)
{
- return $strings;
- }
+ if (empty($strings))
+ {
+ 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);
+ }
+ else
+ {
+ foreach ($strings as $key => $string)
+ {
+ if (is_array($string))
+ {
+ foreach ($string as $_key => $_string)
+ {
+ if (Normalizer::isNormalized($strings[$key][$_key]))
+ {
+ continue;
+ }
+ $strings[$key][$_key] = (string) Normalizer::normalize($strings[$key][$_key]);
+ }
+ }
+ else
+ {
+ if (Normalizer::isNormalized($strings[$key]))
+ {
+ continue;
+ }
+ $strings[$key] = (string) Normalizer::normalize($strings[$key]);
+ }
+ }
+ }
- if (!is_array($strings))
- {
- utf_normalizer::nfc($strings);
+ return $strings;
}
- else if (is_array($strings))
+}
+else
+{
+ /**
+ * 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.
+ */
+ function utf8_normalize_nfc($strings)
{
- foreach ($strings as $key => $string)
+ if (empty($strings))
{
- if (is_array($string))
+ 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);
+ }
+ else if (is_array($strings))
+ {
+ foreach ($strings as $key => $string)
{
- foreach ($string as $_key => $_string)
+ if (is_array($string))
{
- utf_normalizer::nfc($strings[$key][$_key]);
+ foreach ($string as $_key => $_string)
+ {
+ utf_normalizer::nfc($strings[$key][$_key]);
+ }
+ }
+ else
+ {
+ utf_normalizer::nfc($strings[$key]);
}
- }
- else
- {
- utf_normalizer::nfc($strings[$key]);
}
}
- }
- return $strings;
+ return $strings;
+ }
}
/**