diff options
author | Rick Ellis <rick.ellis@ellislab.com> | 2008-08-12 02:39:10 +0200 |
---|---|---|
committer | Rick Ellis <rick.ellis@ellislab.com> | 2008-08-12 02:39:10 +0200 |
commit | 0ea8f9877eb2b47abffe9a02fee7ea9fa066015d (patch) | |
tree | 772a796d5e3420e75dd6a31cd33c12e2a861fb6f | |
parent | bb01b06ba1ff051c7492def2df6eceb634ec017c (diff) |
Added support for libraries in subdirectories
-rw-r--r-- | system/libraries/Loader.php | 24 |
1 files changed, 22 insertions, 2 deletions
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)
|