From 1bdc9c8903eb2db33fdb8174d61e15100dfbbca8 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 10 Apr 2011 10:39:31 +0200 Subject: update to CI 2.0.2 Signed-off-by: Florian Pritz --- system/core/Config.php | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index bfb60fa44..863c5ef4b 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -51,7 +51,7 @@ class CI_Config { // Set the base_url automatically if none was provided if ($this->config['base_url'] == '') { - if(isset($_SERVER['HTTP_HOST'])) + if (isset($_SERVER['HTTP_HOST'])) { $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; $base_url .= '://'. $_SERVER['HTTP_HOST']; @@ -74,24 +74,40 @@ class CI_Config { * * @access public * @param string the config file name + * @param boolean if configuration values should be loaded into their own section + * @param boolean true if errors should just return false, false if an error message should be displayed * @return boolean if the file was loaded correctly */ function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { $file = ($file == '') ? 'config' : str_replace(EXT, '', $file); + $found = FALSE; $loaded = FALSE; - foreach($this->_config_paths as $path) + foreach ($this->_config_paths as $path) { - $file_path = $path.'config/'.$file.EXT; + $check_locations = defined('ENVIRONMENT') + ? array(ENVIRONMENT.'/'.$file, $file) + : array($file); - if (in_array($file_path, $this->is_loaded, TRUE)) + foreach ($check_locations as $location) { - $loaded = TRUE; - continue; + $file_path = $path.'config/'.$location.EXT; + + if (in_array($file_path, $this->is_loaded, TRUE)) + { + $loaded = TRUE; + continue 2; + } + + if (file_exists($file_path)) + { + $found = TRUE; + break; + } } - if ( ! file_exists($path.'config/'.$file.EXT)) + if ($found === FALSE) { continue; } -- cgit v1.2.3-24-g4f1b