Commit ca4f88d2e70f0eb766372d2f4bfca9df51f23fac

  • avatar
  • p4bl0 <pablo.rauzy @gm…l.com>
  • Sun Mar 08 00:20:39 CET 2009
fixing a bug in the class autoloader method
  
6464
6565 public static function autoloader ($class_name)
6666 {
67 static $config = null;
68 if ($config == null)
69 $config = Belokan_Config::getInstance();
70
7167 if (substr($class_name, 0, 8) == 'Belokan_')
7268 $classPath = dirname(__FILE__).str_replace('_', '/', substr($class_name, 7)).'.php';
7369 else if (substr($class_name, -10) == 'Controller')
74 $classPath = $config->get('dir', 'controllers').substr($class_name, 0, -10).'.php';
70 $classPath = Belokan_Config::getInstance()->get('dir', 'controllers').substr($class_name, 0, -10).'.php';
7571 else {
76 $classPath = $config->get('dir', 'models').str_replace('_', '/', $class_name).'.php';
77 if (!file_exists($classPath) && $config->exists('dir', 'lib'))
78 $classPath = $config->get('dir', 'lib').str_replace('_', '/', $class_name).'.php';
72 $classPath = Belokan_Config::getInstance()->get('dir', 'models').str_replace('_', '/', $class_name).'.php';
73 if (!file_exists($classPath) && Belokan_Config::getInstance()->exists('dir', 'lib'))
74 $classPath = Belokan_Config::getInstance()->get('dir', 'lib').str_replace('_', '/', $class_name).'.php';
7975 }
8076
8177 if (file_exists($classPath)) {
8278 require_once $classPath;
8379 return true;
8480 } else {
85 if ($config->get('log', 'belokan'))
81 if (Belokan_Config::getInstance()->get('log', 'belokan'))
8682 Belokan_Log::getInstance()->add('Belokan', 'ERROR: Trying to load an inexistant class ('.$class_name.').');
8783 return false;
8884 }