From 0625e19f3318874d6f95b546312601538edb0f14 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 20 Oct 2006 22:16:54 +0000 Subject: --- system/libraries/Loader.php | 50 ++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) (limited to 'system/libraries/Loader.php') diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php index 3b1a7f2cd..b313c6d5a 100644 --- a/system/libraries/Loader.php +++ b/system/libraries/Loader.php @@ -655,51 +655,37 @@ class CI_Loader { function _ci_load_class($class, $params = NULL) { // Prep the class name - $class = strtolower(str_replace(EXT, '', $class)); - - // Is this a class extension request? - if (substr($class, 0, 3) == 'my_') - { - $class = preg_replace("/my_(.+)/", "\\1", $class); + $class = ucfirst(strtolower(str_replace(EXT, '', $class))); - // Load the requested library from the main system/libraries folder - if (file_exists(BASEPATH.'libraries/'.ucfirst($class).EXT)) - { - include_once(BASEPATH.'libraries/'.ucfirst($class).EXT); - } - - // Now look for a matching library - foreach (array(ucfirst($class), $class) as $filename) + // Is this a class extension request? + if (file_exists(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT)) + { + if ( ! file_exists(BASEPATH.'libraries/'.$class.EXT)) { - if (file_exists(APPPATH.'libraries/'.$filename.EXT)) - { - include_once(APPPATH.'libraries/'.$filename.EXT); - } + log_message('error', "Unable to load the requested class: ".$class); + show_error("Unable to load the requested class: ".$class); } - - return $this->_ci_init_class($filename, 'MY_', $params); + + include_once(BASEPATH.'libraries/'.ucfirst($class).EXT); + include_once(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT); + + return $this->_ci_init_class($filename, config_item('subclass_prefix'), $params); } // Lets search for the requested library file and load it. - // For backward compatibility we'll test for filenames that are - // both uppercase and lower. - foreach (array(ucfirst($class), $class) as $filename) + for ($i = 1; $i < 3; $i++) { - for ($i = 1; $i < 3; $i++) + $path = ($i % 2) ? APPPATH : BASEPATH; + if (file_exists($path.'libraries/'.$filename.EXT)) { - $path = ($i % 2) ? APPPATH : BASEPATH; - - if (file_exists($path.'libraries/'.$filename.EXT)) - { - include_once($path.'libraries/'.$filename.EXT); - return $this->_ci_init_class($filename, '', $params); - } + include_once($path.'libraries/'.$filename.EXT); + return $this->_ci_init_class($filename, '', $params); } } // If we got this far we were unable to find the requested class log_message('error', "Unable to load the requested class: ".$class); - show_error("Unable to load the class: ".$class); + show_error("Unable to load the requested class: ".$class); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b