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).
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 7a71eb8..80a2787 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -238,26 +238,30 @@
*/
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'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php');
- }
- elseif (is_file(APPPATH.'config/doctypes.php'))
+ if (file_exists(APPPATH.'config/doctypes.php'))
{
include(APPPATH.'config/doctypes.php');
}
- if ( ! is_array($_doctypes))
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
{
+ include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php');
+ }
+
+ 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;
}
}