コード例 #1
0
ファイル: Abs.php プロジェクト: chaoyanjie/HiBlog
 /**
  * 渲染模板
  * 
  * @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);
 }
コード例 #2
0
ファイル: Create.php プロジェクト: chaoyanjie/HiBlog
 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);
 }
コード例 #3
0
ファイル: Error.php プロジェクト: chaoyanjie/HiBlog
 /**
  * 以网页形式处理异常
  * 
  * @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');
     }
 }
コード例 #4
0
ファイル: Create.php プロジェクト: chaoyanjie/HiBlog
 public function indexAction()
 {
     $categorys = Model\Category::showUserAll();
     $this->viewDisplay(array('form_action' => Comm\View::path('aj/manage/article/create'), 'categorys' => $categorys), 'manage/article/update');
 }
コード例 #5
0
ファイル: Logout.php プロジェクト: chaoyanjie/HiBlog
 public function indexAction()
 {
     session_destroy();
     return $this->redirect(Comm\View::path(''));
 }