- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
class Super_Loader extends Zend_Loader {
public static function loadClass($class, $dirs = null)
{
parent::loadClass($class, $dirs);
}
private function moduleIsExist($name) {
if(is_dir(APPLICATION_PATH . "/modules/" . $name . "/")) {
return true;
}
return false;
}
public static function autoload($class)
{
$classArray = explode("_", $class);
$firstPart = array_shift($classArray);
if(self::moduleIsExist($firstPart)) {
$moduleDir = APPLICATION_PATH . "/modules/";
$typePart = array_shift($classArray);
switch($typePart) {
case "Lib":
$file_name = $moduleDir . $firstPart . "/lib/" . implode("/", $classArray) . ".php";
break;
case "Model":
$file_name = $moduleDir . $firstPart . "/models/" . implode("/", $classArray) . ".php";
break;
default:
break;
}
if($file_name) {
try {
self::loadFile($file_name);
return $class;
} catch (Exception $e) {
return false;
}
}
} else {
try {
self::loadClass($class);
return $class;
} catch (Exception $e) {
return false;
}
}
}
}