diff options
author | Andrey Andreev <narf@bofh.bg> | 2013-01-29 14:05:02 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2013-01-29 14:05:02 +0100 |
commit | 0687911229be13e100724dbf8b15b95146b591a9 (patch) | |
tree | 0a843814096d353120efd4a2e648cc3cab05293e /system/helpers/text_helper.php | |
parent | c26d34ff12458760eb843454d3224e1dad1fb2e0 (diff) |
Replace is_file() with the faster file_exists()
(where it makes sense)
Also:
- Implemented caching of configuration arrays for smileys, foreign characters and doctypes.
- Implemented cascading-style loading of configuration files (except for library configs, DB and constants.php).
Diffstat (limited to 'system/helpers/text_helper.php')
-rw-r--r-- | system/helpers/text_helper.php | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index c255c15a8..54db14f94 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -358,31 +358,35 @@ if ( ! function_exists('convert_accented_characters')) /** * Convert Accented Foreign Characters to ASCII * - * @param string the text string + * @param string $str Input string * @return string */ function convert_accented_characters($str) { - global $foreign_characters; + static $_foreign_characters; - if ( ! isset($foreign_characters) OR ! is_array($foreign_characters)) + if ( ! is_array($_foreign_characters)) { - if (is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php')) + if (file_exists(APPPATH.'config/foreign_chars.php')) { - include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'); + include(APPPATH.'config/foreign_chars.php'); } - elseif (is_file(APPPATH.'config/foreign_chars.php')) + + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php')) { - include(APPPATH.'config/foreign_chars.php'); + include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'); } - if ( ! isset($foreign_characters) OR ! is_array($foreign_characters)) + if (empty($foreign_characters) OR ! is_array($foreign_characters)) { + $_foreign_characters = array(); return $str; } + + $_foreign_characters = $foreign_characters; } - return preg_replace(array_keys($foreign_characters), array_values($foreign_characters), $str); + return preg_replace(array_keys($_foreign_characters), array_values($_foreign_characters), $str); } } |