示例#1
0
 public static final function factory($controllerAndActionName)
 {
     //$toFile = Watt_Config::getAppPath() . $controllerAndActionName . ".php";
     $toFile = Watt_Config::getAbsPathFilename("PATH_APP", $controllerAndActionName . ".php");
     $arrTmp = array_map("ucfirst", explode(DIRECTORY_SEPARATOR, $controllerAndActionName));
     $className = ucfirst(implode("", $arrTmp)) . "Controller";
     /*
     这里要适应变化
     通过上面的代码改成一个controller多个action的形式
     
     		//这种形式要求 conntroller
     		$toFile = PATH_APP . $controllerAndActionName . DIRECTORY_SEPARATOR . $actionName . ".php";
     		
     		$arrTmp = array_map("ucfirst", explode( DIRECTORY_SEPARATOR, $controllerAndActionName) );
     		$className = ucfirst(implode("",$arrTmp)).ucfirst($actionName)."Controller";
     */
     if (DEBUG) {
         include_once $toFile;
     } else {
         @(include_once $toFile);
     }
     //Watt::loadFile( $toFile );
     if (class_exists($className)) {
         $class = new $className();
         $class->setScriptFile($toFile);
         //$class->_autoGetControllerName();
         $class->setControllerName(str_replace(DIRECTORY_SEPARATOR, "_", $controllerAndActionName));
         //自动获取名称不够准确,只能继续使用第二种方法 by terry at Mon Jul 13 11:03:22 CST 2009
         $class->setControllerPrivilegeMaps();
         return $class;
     } else {
         throw new Exception(Watt_I18n::trans("ERR_APP_LOST_CONTROLLER") . "[ " . $className . " ]");
         //return null;
     }
 }
示例#2
0
文件: View.php 项目: uwitec/outbuying
 /**
  * 获得 view 的文件名
  * 输入的参数是相对于 view 根目录的 PathFilename
  * 自动获得绝对ViewPathFilename
  * 
  * 单独写一个方法是为了对付外部设置view路径的时的情况。
  * 那时就在这里修改就好了。
  *
  * @param string $relFilename
  * @return string
  */
 protected function _getAbsViewPathFilename($relPathFilename)
 {
     return Watt_Config::getAbsPathFilename("PATH_VIEW", $relPathFilename);
 }