/** * 获得 view 的文件名 * 输入的参数是相对于 view 根目录的 PathFilename * 自动获得绝对ViewPathFilename * * 单独写一个方法是为了对付外部设置view路径的时的情况。 * 那时就在这里修改就好了。 * * @param string $relFilename * @return string */ protected function _getAbsViewPathFilename($relPathFilename) { //return Pft_Config::getAbsPathFilename( "PATH_VIEW", $relPathFilename ); /** * 改为在子系统下放置view的模式 * @author y31 * Mon Dec 10 23:32:01 CST 2007 */ return Pft_Config::getAbsPathFilename("PATH_APP", str_replace("/ctrl", "/view", str_replace("\\", "/", $relPathFilename))); }
/** * 根据controllerName 和 actionName 生产一个 controller * * @param String $controllerName * @param String $actionName * @return Pft_Controller_Action */ public static final function factory($controllerName, $actionName) { //$toFile = Pft_Config::getAppPath() . $controllerName . ".php"; $toFile = Pft_Config::getAbsPathFilename("PATH_APP", $controllerName . ".php"); //$arrTmp = array_map("ucfirst", explode( DIRECTORY_SEPARATOR, $controllerName) ); $arrTmp = array_map("ucfirstForControl", explode(DIRECTORY_SEPARATOR, $controllerName)); $className = ucfirst(implode("", $arrTmp)) . "Controller"; /** * 去掉了 Ctrl * @author y31 * Mon Dec 10 23:19:08 CST 2007 */ /* 这里要适应变化 通过上面的代码改成一个controller多个action的形式 //这种形式要求 conntroller $toFile = PATH_APP . $controllerName . DIRECTORY_SEPARATOR . $actionName . ".php"; $arrTmp = array_map("ucfirst", explode( DIRECTORY_SEPARATOR, $controllerName) ); $className = ucfirst(implode("",$arrTmp)).ucfirst($actionName)."Controller"; */ if (DEBUG) { include_once $toFile; } else { @(include_once $toFile); } //Pft::loadFile( $toFile ); if (class_exists($className)) { $class = new $className(); $class->setScriptFile($toFile); $class->setControllerName(str_replace(DIRECTORY_SEPARATOR, "_", str_replace("/ctrl/", "/", $controllerName))); $class->setControllerPrivilegeMaps(); return $class; } else { throw new Exception(Pft_I18n::trans("ERR_APP_LOST_CONTROLLER") . "[ " . $className . " ]"); return null; } }
/** * 预载入propel 及 相关的类 */ public static function preLoadPropelClasses() { //单系统路径模式 //self::loadFile( "PropelException.php", Pft_Config::getLibPath()."propel", true ); //多系统路径模式 $pathfilename = Pft_Config::getAbsPathFilename("PATH_LIB", "propel/PropelException.php"); self::loadFile($pathfilename, null, true); //单系统路径模式 //self::loadFile( "Propel.php", Pft_Config::getLibPath()."propel", true ); //多系统路径模式 $pathfilename = Pft_Config::getAbsPathFilename("PATH_LIB", "propel/Propel.php"); self::loadFile($pathfilename, null, true); Propel::init(Pft_Config::getPropelConfFilename()); //单系统路径模式 //self::loadFile( "Criteria.php", Pft_Config::getLibPath()."propel/util", true ); //多系统路径模式 $pathfilename = Pft_Config::getAbsPathFilename("PATH_LIB", "propel/util/Criteria.php"); self::loadFile($pathfilename, null, true); /** * 在 XxxxPeer 中自动 load Propel时, * 在此处 throw 的 exception 不能在 index 中捕获, * 怀疑在 Propel 的 某些Class 中 catch 了异常,然后没有再抛出 */ //throw new Exception("in preLoadPropelClasses"); }