Commit ca4f88d2e70f0eb766372d2f4bfca9df51f23fac
- Diff rendering mode:
- inline
- side by side
Belokan.php
(5 / 9)
|   | |||
| 64 | 64 | ||
| 65 | 65 | public static function autoloader ($class_name) | |
| 66 | 66 | { | |
| 67 | static $config = null; | ||
| 68 | if ($config == null) | ||
| 69 | $config = Belokan_Config::getInstance(); | ||
| 70 | |||
| 71 | 67 | if (substr($class_name, 0, 8) == 'Belokan_') | |
| 72 | 68 | $classPath = dirname(__FILE__).str_replace('_', '/', substr($class_name, 7)).'.php'; | |
| 73 | 69 | 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'; | ||
| 75 | 71 | 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'; | ||
| 79 | 75 | } | |
| 80 | 76 | ||
| 81 | 77 | if (file_exists($classPath)) { | |
| 82 | 78 | require_once $classPath; | |
| 83 | 79 | return true; | |
| 84 | 80 | } else { | |
| 85 | if ($config->get('log', 'belokan')) | ||
| 81 | if (Belokan_Config::getInstance()->get('log', 'belokan')) | ||
| 86 | 82 | Belokan_Log::getInstance()->add('Belokan', 'ERROR: Trying to load an inexistant class ('.$class_name.').'); | |
| 87 | 83 | return false; | |
| 88 | 84 | } |

