Esempio n. 1
0
 /**
  * 渲染模板
  * 
  * @param array  $assign   模板变量
  * @param string $tpl_path 模板路径(不填则是当前Controller)
  */
 public function viewDisplay(array $assign = array(), $tpl_path = null)
 {
     $view = new \Comm\View();
     $tpl_name = $this->getRequest()->getControllerName();
     if ($tpl_path) {
         $tpl_path .= '.phtml';
     } else {
         $tpl_path = strtolower(str_replace('_', '/', $tpl_name)) . '.phtml';
     }
     $view->display($tpl_path, $assign);
 }
Esempio n. 2
0
 public function indexAction()
 {
     $category_id = Comm\Arg::post('category_id');
     $title = Comm\Arg::post('title');
     $content = Comm\Arg::post('content');
     Model\Article::create($category_id, $title, $content);
     Comm\Response::json(100000, '发表成功', ['href' => Comm\View::path('manage/article/index')], false);
 }
Esempio n. 3
0
 /**
  * 以网页形式处理异常
  * 
  * @param Exception $exception
  */
 protected function _html(Exception $exception)
 {
     if ($exception instanceof ErrorException) {
         //系统错误
         if (!\Comm\Misc::isProEnv()) {
             $this->_debugHtml($exception);
         }
     } elseif ($exception instanceof \Exception\Nologin) {
         //用户未登录
         header('Location:' . Comm\View::path('user/github/login'));
     } elseif ($exception instanceof \Exception\Program) {
         //程序错误
         $this->viewDisplay(array('exception' => $exception), 'error/error');
     } else {
         //其它异常
         $this->viewDisplay(array('exception' => $exception), 'error/error');
     }
 }
Esempio n. 4
0
 public function indexAction()
 {
     $categorys = Model\Category::showUserAll();
     $this->viewDisplay(array('form_action' => Comm\View::path('aj/manage/article/create'), 'categorys' => $categorys), 'manage/article/update');
 }
Esempio n. 5
0
 public function indexAction()
 {
     session_destroy();
     return $this->redirect(Comm\View::path(''));
 }