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/html_helper.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'system/helpers/html_helper.php') diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 7a71eb82b..80a27876f 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -238,26 +238,30 @@ if ( ! function_exists('doctype')) */ function doctype($type = 'xhtml1-strict') { - global $_doctypes; + static $doctypes; - if ( ! is_array($_doctypes)) + if ( ! is_array($doctypes)) { - if (is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php')) + if (file_exists(APPPATH.'config/doctypes.php')) { - include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'); + include(APPPATH.'config/doctypes.php'); } - elseif (is_file(APPPATH.'config/doctypes.php')) + + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php')) { - include(APPPATH.'config/doctypes.php'); + include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'); } - if ( ! is_array($_doctypes)) + if (empty($_doctypes) OR ! is_array($_doctypes)) { + $doctypes = array(); return FALSE; } + + $doctypes = $_doctypes; } - return isset($_doctypes[$type]) ? $_doctypes[$type] : FALSE; + return isset($doctypes[$type]) ? $doctypes[$type] : FALSE; } } -- cgit v1.2.3-24-g4f1b