From 0ea8f9877eb2b47abffe9a02fee7ea9fa066015d Mon Sep 17 00:00:00 2001 From: Rick Ellis Date: Tue, 12 Aug 2008 00:39:10 +0000 Subject: Added support for libraries in subdirectories --- system/libraries/Loader.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php index 9b21bc31a..ec09f00c6 100644 --- a/system/libraries/Loader.php +++ b/system/libraries/Loader.php @@ -757,8 +757,28 @@ class CI_Loader { */ function _ci_load_class($class, $params = NULL) { - // Get the class name - $class = str_replace(EXT, '', $class); + // Get the class name, and while we're at it trim any slashes. + // The directory path can be included as part of the class name, + // but we don't want a leading slash + $class = str_replace(EXT, '', trim($class, '/')); + + // Was the path included with the class name? + // We look for a slash to determine this + $subdir = ''; + if (strpos($class, '/') !== FALSE) + { + // explode the path so we can separate the filename from the path + $x = explode('/', $class); + + // Reset the $class variable now that we know the actual filename + $class = end($x); + + // Kill the filename from the array + unset($x[count($x)-1]); + + // Glue the path back together, sans filename + $subdir = implode($x, '/').'/'; + } // We'll test for both lowercase and capitalized versions of the file name foreach (array(ucfirst($class), strtolower($class)) as $class) -- cgit v1.2.3-24-g4f1b