/** * 自动加载 */ public function load($className) { //优先使用映射集合 if (isset(self::$_loadMapp[$className])) { return CLoader::import($className, self::$_loadMapp[$className]); } else { if (file_exists($path = APP_PATH . '/modules/' . CRoute::getInstance()->getModule() . '/controllers/' . $className . '.php')) { return CLoader::importFile($path); } else { if (file_exists($path = APP_PATH . '/modules/' . CRoute::getInstance()->getModule() . '/classes/' . $className . '.php')) { return CLoader::importFile($path); } else { if (file_exists($path = CODE_PATH . '/controllers/' . $className . '.php')) { return CLoader::importFile($path); } else { if (file_exists($path = FRAME_PATH . '/components/' . $className . '.php')) { return CLoader::importFile($path); } else { $list = array(); $importList = CConfig::getInstance()->load('IMPORT'); if (!empty($importList)) { foreach ((array) $importList as $thisPath) { $list[] = APP_PATH . '/' . str_replace(array('.', '*'), array('/', ''), $thisPath); } } //查询指定的加载目录 foreach ($list as $val) { if (file_exists($path = $val . $className . '.php')) { return CLoader::importFile($path); } else { if (false !== strpos($className, '_')) { //处理类名中的路径 $path = str_replace('_', '/', $className); if (file_exists($path = trim($val, '/\\') . '/' . $path . '.php')) { return CLoader::importFile($path); } } } } } } } } } }
/** * 检查方法名前缀 */ private function _checkActionPreFix($routeData) { $prefix = CConfig::getInstance()->load('ACTION_PREFIX'); if (!empty($prefix) && isset($routeData[1])) { $routeData[1] = $prefix . $routeData[1]; } //设置路由对象 $routeObject = CRoute::getInstance(); $routeObject->setController($routeData[0]); $routeObject->setAction($routeData[1]); $routeObject->setModule($routeData['m']); //返回对象 return $routeObject; }