Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class MY_Loader extends CI_Loader {
- function library_exist($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)
- {
- // Lets search for the requested library file and load it.
- for ($i = 1; $i < 3; $i++)
- {
- $path = ($i % 2) ? APPPATH : BASEPATH;
- $filepath = $path.'libraries/'.$subdir.$class.EXT;
- // Does the file exist? No? Bummer...
- if ( ! file_exists($filepath))
- {
- continue;
- }
- else
- {
- return TRUE;
- }
- }
- }
- // One last attempt. Maybe the library is in a subdirectory, but it wasn't specified?
- if ($subdir == '')
- {
- $path = strtolower($class).'/'.$class;
- return $this->library_exist($path);
- }
- return FALSE;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement