[eluser]Spockz[/eluser]
As I noticed loading libraries from subdirs isn't possible. So I altered some code to make it work. However I'm still with 1.6.3 and I didn't test this with 1.7.x. Here is the code I altered. I hope this adds something useful to CI:
/System/libraries/Loader.php
Code:
* Load class
*
* This function loads the requested class.
*
* @access private
* @param string the item that is being loaded
* @param mixed any additional parameters
* @return void
*/
function _ci_load_class($class, $params = NULL)
{
// Get the class name
$class = str_replace(EXT, '', $class);
// Split the classname in a path and file section
$classPathParts = explode('/', str_replace('\\', '/', $class));
$classFile = array_pop($classPathParts);
$classPath = implode('/', $classPathParts).(count($classPathParts) > 0 ? '/' : '');
// --
// We'll test for both lowercase and capitalized versions of the file name
foreach (array(ucfirst($classFile), strtolower($classFile)) as $classFile)
{
$subclass = APPPATH.'libraries/'.$classPath.config_item('subclass_prefix').$classFile.EXT;
// Is this a class extension request?
if (file_exists($subclass))
{
$baseclass = BASEPATH.'libraries/'.$classPath.ucfirst($classFile).EXT;
if ( ! file_exists($baseclass))
{
log_message('error', "Unable to load the requested class: ".$classPath.$classFile);
show_error("Unable to load the requested class: ".$classPath.$classFile);
}
// Safety: Was the class already loaded by a previous call?
if (in_array($subclass, $this->_ci_classes))
{
$is_duplicate = TRUE;
log_message('debug', $classPath.$classFile." class already loaded. Second attempt ignored.");
return;
}
include_once($baseclass);
include_once($subclass);
$this->_ci_classes[] = $subclass;
return $this->_ci_init_class($classPath.$classFile, config_item('subclass_prefix'), $params);
}
// Lets search for the requested library file and load it.
$is_duplicate = FALSE;
for ($i = 1; $i < 3; $i++)
{
$path = ($i % 2) ? APPPATH : BASEPATH;
$filepath = $path.'libraries/'.$classPath.$classFile.EXT;
// Does the file exist? No? Bummer...
if ( ! file_exists($filepath))
{
continue;
}
// Safety: Was the class already loaded by a previous call?
if (in_array($filepath, $this->_ci_classes))
{
$is_duplicate = TRUE;
log_message('debug', $classPath.$classFile." class already loaded. Second attempt ignored.");
return;
}
include_once($filepath);
$this->_ci_classes[] = $filepath;
return $this->_ci_init_class($classFile, '', $params);
}
} // END FOREACH
// If we got this far we were unable to find the requested class.
// We do not issue errors if the load call failed due to a duplicate request
if ($is_duplicate == FALSE)
{
log_message('error', "Unable to load the requested class: ".$classPath.$classFile);
show_error("Unable to load the requested class: ".$classPath.$classFile);
}
}