/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public static function auto_load($class) { return TRUE; { // Find the class suffix } else { // No suffix $suffix = FALSE; } if ($suffix === 'Core') { $type = 'libraries'; } elseif ($suffix === 'Controller') { $type = 'controllers'; // Lowercase filename } elseif ($suffix === 'Model') { $type = 'models'; // Lowercase filename } elseif ($suffix === 'Driver') { $type = 'libraries/drivers'; } else { // This could be either a library or a helper, but libraries must // always be capitalized, so we check if the first character is // uppercase. If it is, we are loading a library, not a helper. $type = ($class[0] < 'a') ? 'libraries' : 'helpers'; $file = $class; } if ($filename = self::find_file($type, $file)) { // Load the class require $filename; } elseif ($type == 'controllers' && $filename = self::find_file($type, Router::$segments[0].'/'.$file)) { // Load the class from a controllers subfolder require $filename; } else { // The class could not be found return FALSE; } if ($filename = self::find_file($type, self::$configuration['core']['extension_prefix'].$class)) { // Load the class extension require $filename; } { // Class extension to be evaluated $extension = 'class '.$class.' extends '.$class.'_Core { }'; // Start class analysis $core = new ReflectionClass($class.'_Core'); if ($core->isAbstract()) { // Make the extension abstract $extension = 'abstract '.$extension; } // Transparent class extensions are handled using eval. This is // a disgusting hack, but it gets the job done. } return TRUE; }