Example #1
0
 /**
  * @brief 执行视图渲染
  * @return 视图
  */
 public function run()
 {
     $controller = $this->getController();
     IInterceptor::run("onCreateView", $controller);
     $this->resolveView($this->getView());
     $data = null;
     if (file_exists($this->view . $controller->extend)) {
         $controller->render($this->view, $data);
     } else {
         $path = $this->view . $controller->extend;
         $path = IException::pathFilter($path);
         IError::show("not found this view page({$path})", 404);
     }
     IInterceptor::run("onFinishView");
 }
Example #2
0
 /**
  * @brief 解析视图路径
  * @param string $viewPath 视图名称
  * @return bool
  */
 public function resolveView($viewPath)
 {
     if (preg_match('/^\\w[\\w\\-]*$/', $viewPath)) {
         //分割模板目录的层次
         $view = strtr($viewPath, '-', '/');
         $this->basePath = $this->getController()->getViewFile($view);
         if ($this->basePath) {
             $this->view = $this->basePath;
             return;
         }
     } else {
         $viewPath = IException::pathFilter($viewPath);
         throw new IHttpException("the view filename({$viewPath}) is wrong", 403);
     }
 }
Example #3
0
 /**
  * @brief 执行视图渲染
  * @return 视图
  */
 public function run()
 {
     $controller = $this->getController();
     IInterceptor::run("onCreateView", $controller);
     $this->resolveView($this->getView());
     $data = null;
     if (file_exists($this->view . $controller->extend)) {
         $controller->render($this->view, $data);
     } else {
         $path = $this->view . $controller->extend;
         $path = IException::pathFilter($path);
         $data = array('title' => 'HTTP 404', 'heading' => 'not found', 'message' => "not found this view page({$path})");
         throw new IHttpException($data, 404);
     }
     IInterceptor::run("onFinishView");
 }