From 0687911229be13e100724dbf8b15b95146b591a9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 29 Jan 2013 15:05:02 +0200 Subject: 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). --- system/helpers/smiley_helper.php | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'system/helpers/smiley_helper.php') diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index c2f50ec73..d9a693493 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -213,16 +213,30 @@ if ( ! function_exists('_get_smiley_array')) */ function _get_smiley_array() { - if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php')) - { - include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'); - } - elseif (file_exists(APPPATH.'config/smileys.php')) + static $_smileys; + + if ( ! is_array($smileys)) { - include(APPPATH.'config/smileys.php'); + if (file_exists(APPPATH.'config/smileys.php')) + { + include(APPPATH.'config/smileys.php'); + } + + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'); + } + + if (empty($smileys) OR ! is_array($smileys)) + { + $_smileys = array(); + return FALSE; + } + + $_smileys = $smileys; } - return (isset($smileys) && is_array($smileys)) ? $smileys : FALSE; + return $_smileys; } } -- cgit v1.2.3-24-g4f1b