diff options
author | Silvio <silvio@devlet.com.br> | 2010-10-18 10:28:56 -0200 |
---|---|---|
committer | Silvio <silvio@devlet.com.br> | 2010-10-18 10:28:56 -0200 |
commit | 8b55b69339146f0b03b01dd1c12501754cbd9de0 (patch) | |
tree | 05849a7485ddc7209293d0961b708207701ba9df | |
parent | 568718854e0d53c0d07ce4097dc8af4ea280eaa6 (diff) | |
download | cinisis-8b55b69339146f0b03b01dd1c12501754cbd9de0.tar.gz cinisis-8b55b69339146f0b03b01dd1c12501754cbd9de0.tar.bz2 |
Enhancing autoloader
-rw-r--r-- | index.php | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -5,17 +5,23 @@ // Autoloader. function cinisis_autoload($class) { + $base = dirname(__FILE__) .'/'; + if (strstr($class, 'Db')) { - require_once 'classes/backends/'. $class .'.php'; + $file = 'classes/backends/'. $class .'.php'; } elseif (strstr($class, 'Iterator')) { - require_once 'classes/iterators/'. $class .'.php'; + $file = 'classes/iterators/'. $class .'.php'; } elseif (strstr($class, 'Helper')) { - require_once 'classes/helpers/'. $class .'.php'; + $file = 'classes/helpers/'. $class .'.php'; } else { - require_once 'classes/'. $class .'.php'; + $file = 'classes/'. $class .'.php'; + } + + if (file_exists($base . $file)) { + require_once $base . $file; } } |