From 9a311fd3c45faadb7081a48b068f07c0f44b9e5e Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 15 Dec 2010 10:50:15 +0000 Subject: Package paths can now be auto-loaded in autoload.php. --- system/core/Loader.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'system/core') diff --git a/system/core/Loader.php b/system/core/Loader.php index 4b6b19eea..afbae6175 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -942,6 +942,15 @@ class CI_Loader { return FALSE; } + // Autoload packages + if (isset($autoload['packages'])) + { + foreach ($autoload['packages'] as $package_path) + { + $this->add_package_path($package_path); + } + } + // Load any custom config file if (count($autoload['config']) > 0) { -- cgit v1.2.3-24-g4f1b From fd6948997faf5f064f76353da65bd1d0ec65ec51 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 15 Dec 2010 10:52:37 +0000 Subject: Potential PHP 5.4 issue, get_magic_quotes_gpc() is being removed. This change will check the function exists before calling it in Input. --- system/core/Input.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core') diff --git a/system/core/Input.php b/system/core/Input.php index 9d8811cdd..5a227332c 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -492,7 +492,7 @@ class CI_Input { } // We strip slashes if magic quotes is on to keep things consistent - if (get_magic_quotes_gpc()) + if (function_exists('get_magic_quotes_gpc') AND get_magic_quotes_gpc()) { $str = stripslashes($str); } -- cgit v1.2.3-24-g4f1b From 4df8b2276bbcc7f025a41b0d09f2f8cd7927b51a Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 15 Dec 2010 14:23:14 +0000 Subject: ['base_url'] is now empty by default and will guess what it should be. --- system/core/Config.php | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'system/core') diff --git a/system/core/Config.php b/system/core/Config.php index bdd1b8333..506af0d99 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -47,6 +47,25 @@ class CI_Config { { $this->config =& get_config(); log_message('debug', "Config Class Initialized"); + + // Set the base_url automatically if none was provided + if ($this->config['base_url'] == '') + { + // Base URL (keeps this crazy sh*t out of the config.php + if(isset($_SERVER['HTTP_HOST'])) + { + $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http'; + $base_url .= '://'. $_SERVER['HTTP_HOST']; + $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); + } + + else + { + $base_url = 'http://localhost/'; + } + + $this->set_item('base_url', $base_url); + } } // -------------------------------------------------------------------- @@ -185,14 +204,7 @@ class CI_Config { return FALSE; } - $pref = $this->config[$item]; - - if ($pref != '' && substr($pref, -1) != '/') - { - $pref .= '/'; - } - - return $pref; + return rtrim($this->config[$item], '/').'/'; } // -------------------------------------------------------------------- @@ -208,14 +220,7 @@ class CI_Config { { if ($uri == '') { - if ($this->item('base_url') == '') - { - return $this->item('index_page'); - } - else - { - return $this->slash_item('base_url').$this->item('index_page'); - } + return $this->slash_item('base_url').$this->item('index_page'); } if ($this->item('enable_query_strings') == FALSE) @@ -244,14 +249,7 @@ class CI_Config { $uri = $str; } - if ($this->item('base_url') == '') - { - return $this->item('index_page').'?'.$uri; - } - else - { - return $this->slash_item('base_url').$this->item('index_page').'?'.$uri; - } + return $this->slash_item('base_url').$this->item('index_page').'?'.$uri; } } -- cgit v1.2.3-24-g4f1b From fb5523855cb0592abe8e8720d7019fa82acfb054 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 15 Dec 2010 14:29:21 +0000 Subject: Revised the base_url auto-generation detection of protocol as some servers will not send off. --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core') diff --git a/system/core/Config.php b/system/core/Config.php index 506af0d99..081f1d899 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -54,7 +54,7 @@ class CI_Config { // Base URL (keeps this crazy sh*t out of the config.php if(isset($_SERVER['HTTP_HOST'])) { - $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http'; + $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; $base_url .= '://'. $_SERVER['HTTP_HOST']; $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); } -- cgit v1.2.3-24-g4f1b From 23174a64277cad04c89d943fa65694299f7424d6 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 15 Dec 2010 15:18:16 +0000 Subject: ['404_override'] can now take methods and URI segments, not just a controller name. This is useful for 404 pages on errors/page_missing or /pages/view/404. --- system/core/Router.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'system/core') diff --git a/system/core/Router.php b/system/core/Router.php index 9276800c3..79a8b4fcc 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -270,19 +270,17 @@ class CI_Router { // If we've gotten this far it means that the URI does not correlate to a valid // controller class. We will now see if there is an override - if (isset($this->routes['404_override']) AND $this->routes['404_override'] != '') + if (!empty($this->routes['404_override'])) { - if (strpos($this->routes['404_override'], '/') !== FALSE) - { - $x = explode('/', $this->routes['404_override']); + $x = explode('/', $this->routes['404_override']); - $this->set_class($x[0]); - $this->set_method($x[1]); + $this->set_class($x[0]); + $this->set_method(isset($x[1]) ? $x[1] : 'index'); - return $x; - } + return $x; } + // Nothing else to do at this point but show a 404 show_404($segments[0]); } -- cgit v1.2.3-24-g4f1b From de3dbc36dab42d86c66d76efd6fdb1d1dce71ce8 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Mon, 27 Dec 2010 17:41:02 +0000 Subject: Languages can now be placed in packages folders, and added ->load->get_package_paths(). --- system/core/Config.php | 1 - system/core/Lang.php | 18 +++++++++++------- system/core/Loader.php | 35 +++++++++++++++++++++-------------- 3 files changed, 32 insertions(+), 22 deletions(-) (limited to 'system/core') diff --git a/system/core/Config.php b/system/core/Config.php index 081f1d899..8ecfba73a 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -51,7 +51,6 @@ class CI_Config { // Set the base_url automatically if none was provided if ($this->config['base_url'] == '') { - // Base URL (keeps this crazy sh*t out of the config.php if(isset($_SERVER['HTTP_HOST'])) { $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; diff --git a/system/core/Lang.php b/system/core/Lang.php index e7867b354..8ec179771 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -78,17 +78,21 @@ class CI_Lang { { include($alt_path.'language/'.$idiom.'/'.$langfile); } - elseif (file_exists(APPPATH.'language/'.$idiom.'/'.$langfile)) - { - include(APPPATH.'language/'.$idiom.'/'.$langfile); - } else { - if (file_exists(BASEPATH.'language/'.$idiom.'/'.$langfile)) + $found = FALSE; + + foreach (get_instance()->load->get_package_paths(TRUE) as $package_path) { - include(BASEPATH.'language/'.$idiom.'/'.$langfile); + if (file_exists($package_path.'language/'.$idiom.'/'.$langfile)) + { + include($package_path.'language/'.$idiom.'/'.$langfile); + $found = TRUE; + break; + } } - else + + if ($found !== TRUE) { show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile); } diff --git a/system/core/Loader.php b/system/core/Loader.php index afbae6175..136cae9bf 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -81,12 +81,12 @@ class CI_Loader { { foreach($library as $read) { - $this->library($read); + $this->library($read); } - + return; } - + if ($library == '' OR isset($this->_base_classes[$library])) { return FALSE; @@ -527,7 +527,7 @@ class CI_Loader { function add_package_path($path) { $path = rtrim($path, '/').'/'; - + array_unshift($this->_ci_library_paths, $path); array_unshift($this->_ci_model_paths, $path); array_unshift($this->_ci_helper_paths, $path); @@ -539,6 +539,22 @@ class CI_Loader { // -------------------------------------------------------------------- + /** + * Get Package Paths + * + * Return a list of all package paths, by default it will ignore BASEPATH. + * + * @access public + * @param string + * @return void + */ + function get_package_paths($include_base = FALSE) + { + return $include_base === TRUE ? $this->_ci_library_paths : $this->_ci_model_paths; + } + + // -------------------------------------------------------------------- + /** * Remove Package Path * @@ -563,7 +579,7 @@ class CI_Loader { else { $path = rtrim($path, '/').'/'; - + foreach (array('_ci_library_paths', '_ci_model_paths', '_ci_helper_paths') as $var) { if (($key = array_search($path, $this->{$var})) !== FALSE) @@ -942,15 +958,6 @@ class CI_Loader { return FALSE; } - // Autoload packages - if (isset($autoload['packages'])) - { - foreach ($autoload['packages'] as $package_path) - { - $this->add_package_path($package_path); - } - } - // Load any custom config file if (count($autoload['config']) > 0) { -- cgit v1.2.3-24-g4f1b