Permalink
Browse files

Cleanup

Signed-off-by: dchill42 <dchill42@gmail.com>
  • Loading branch information...
dchill42 committed Sep 14, 2012
1 parent 9576deb commit 9caf8781e22d0e2b48aae1b10770d08deab0a003
Showing with 28 additions and 16 deletions.
  1. +22 −10 system/core/Loader.php
  2. +6 −6 system/libraries/Driver.php
View
@@ -9,7 +9,7 @@
* Licensed under the Open Software License version 3.0
*
* This source file is subject to the Open Software License (OSL 3.0) that is
- * bundled with this package in the files license.txt / license.rst. It is
+ * bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
* http://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to obtain it
@@ -135,7 +135,7 @@ class CI_Loader {
*/
public function __construct()
{
- $this->_ci_ob_level = ob_get_level();
+ $this->_ci_ob_level = ob_get_level();
$this->_ci_library_paths = array(APPPATH, BASEPATH);
$this->_ci_helper_paths = array(APPPATH, BASEPATH);
$this->_ci_model_paths = array(APPPATH);
@@ -913,16 +913,29 @@ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
// Establish subdirectories to try - if one was specified, just use that
$trysubs = array($subdir);
- if ($subdir == '')
+ if ($subdir === '')
{
// Also check subdirectories matching class name
+ // This allows us to find libraries in self-named subdirectories
+ // (like Drivers) and extensions for those in the main libraries dir
$dir = strtolower($class).'/';
$trysubs[] = ucfirst($dir);
- $trysubs[] = $dir;
+
+ // If we aren't case-insensitive, check lowercase too
+ if (DIRECTORY_SEPARATOR !== '\\')
+ {
+ $trysubs[] = $dir;
+ }
}
// We'll test for both lowercase and capitalized versions of the file name
- foreach (array(ucfirst($class), strtolower($class)) as $class)
+ $cases = array(ucfirst($class));
+ if (DIRECTORY_SEPARATOR !== '\\')
+ {
+ // Case-sensitive - try lowercase too
+ $cases[] = strtolower($class);
+ }
+ foreach ($cases as $class)
{
// Is this a class extension request?
foreach($trysubs as $dir)
@@ -955,8 +968,8 @@ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
// Does this look like a driver?
$driversub = strtolower($class).'/';
- if ((strtolower($dir) == $driversub || strtolower($basesub) == $driversub)
- && ! class_exists('CI_Driver_Library'))
+ if ((strtolower($dir) === $driversub OR strtolower($basesub) === $driversub)
+ && ! class_exists('CI_Driver_Library'))
{
// We aren't instantiating an object here, just making the base class available
require BASEPATH.'libraries/Driver.php';
@@ -973,8 +986,7 @@ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
$CI =& get_instance();
if ( ! isset($CI->$object_name))
{
- return $this->_ci_init_class($class, config_item('subclass_prefix'), $params,
- $object_name);
+ return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
}
}
@@ -1006,7 +1018,7 @@ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
}
// Does this look like a driver?
- if (strtolower($dir) == strtolower($class).'/' && ! class_exists('CI_Driver_Library'))
+ if (strtolower($dir) === strtolower($class).'/' && ! class_exists('CI_Driver_Library'))
{
// We aren't instantiating an object here, just making the base class available
require BASEPATH.'libraries/Driver.php';
@@ -9,7 +9,7 @@
* Licensed under the Open Software License version 3.0
*
* This source file is subject to the Open Software License (OSL 3.0) that is
- * bundled with this package in the files license.txt / license.rst. It is
+ * bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
* http://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to obtain it
@@ -66,8 +66,8 @@ class CI_Driver_Library {
* The first time a child is used it won't exist, so we instantiate it
* subsequents calls will go straight to the proper child.
*
- * @param string Child class name
- * @return object Child class
+ * @param string Child class name
+ * @return object Child class
*/
public function __get($child)
{
@@ -80,8 +80,8 @@ public function __get($child)
*
* Separate load_driver call to support explicit driver load by library or user
*
- * @param string Driver name (w/o parent prefix)
- * @return object Child class
+ * @param string Driver name (w/o parent prefix)
+ * @return object Child class
*/
public function load_driver($child)
{
@@ -91,7 +91,7 @@ public function load_driver($child)
if ( ! isset($this->lib_name))
{
// Get library name without any prefix
- $this->subclass_prefix = (string)$CI->config->item('subclass_prefix');
+ $this->subclass_prefix = (string) $CI->config->item('subclass_prefix');
$this->lib_name = str_replace(array('CI_', $this->subclass_prefix), '', get_class($this));
}

0 comments on commit 9caf878

Please sign in to comment.