private function autoload($class) { $eject_array = array('gadgetIndexAbstract', 'gadgetIndexController', 'gadgetApplicationController', 'gadgetApplicationAbstract'); if (!is_array(self::$_maps)) { self::$_maps = (include ROOT_DIR . DS . 'conf' . DS . 'maps.php'); } $pattern = '/[A-Z][a-z0-9]+/'; preg_match_all($pattern, $class, $matches); $prefix = null; $path = null; if (isset($matches[0]) && !empty($matches[0])) { $prefix = substr($class, 0, stripos($class, $matches[0][0])); if ($prefix == 'read' || $prefix == 'write') { return; } $path = ''; foreach ($matches[0] as $m) { $path .= strtolower($m) . DS; } $path = rtrim($path, DS) . '.php'; } else { $path = strtolower($class) . '.php'; } if (in_array($class, $eject_array)) { $path = str_replace('/', '', $path); } if ($prefix && isset(self::$_maps[$prefix])) { $classPath = self::$_maps[$prefix]; } else { $classPath = ROOT_DIR . DS . 'common' . DS; } if (is_array($classPath)) { $required = false; foreach ($classPath as $cp) { if (file_exists($cp . $path)) { require $cp . $path; $required = true; break; } } if (!$required) { log::errorLog($class . ': FileNotFound'); return false; } } else { if (file_exists($classPath . $path)) { require $classPath . $path; } else { log::errorLog($class . ': FileNotFound'); return false; } } }