Exemplo n.º 1
0
 /**
  * 显示博文
  */
 public function showAction()
 {
     $id = get("id", "int");
     $where['status'] = \Admin\Article\Type\Status::STATUS_ENABLE;
     $where['member_id'] = 1;
     $where['id'] = $id;
     $row = db()->Table('article')->getRow($where)->limit(0, 1)->done();
     if (!empty($row['password'])) {
         $cookiePassword = addslashes(trim(cookie('xtt_logpwd_' . $row['id'])));
         if ($cookiePassword != $row['password']) {
             $this->getView()->assign(array('id' => $id, 'msg' => ""));
             return $this->getView()->display("checkpwd");
         }
     }
     $config = new \Admin\Model\webConfigModel();
     $webConfig = $config->getConfig();
     if ($webConfig['ischkcomment']) {
         new \Common\Security\CommentVerSession();
     }
     $model = new \Home\Model\homeModel();
     $row['category'] = $model->getArticleCategory($row['category']);
     $tag = new \Admin\Model\articleModel();
     //获取该文章标签
     $tags = $tag->getTags($row['id'], true);
     if ($tags) {
         $row['tags'] = explode(",", $tags);
     }
     $row['author'] = member($row['member_id']);
     $row['content'] = stripslashes($row['content']);
     //加载评论
     $commentWhere['status'] = \Admin\Comment\Type\Status::STATUS_ENABLE;
     $commentWhere['type'] = \Admin\Comment\Type\Type::TYPE_ARTICLE;
     $commentWhere['data'] = $id;
     $comments = db()->Table('comment')->getAll($commentWhere)->order("id " . $webConfig['comment_order'])->done();
     //生成序列树
     $comments = $this->sortOut($comments);
     $this->getView()->assign(array('blog' => $row, "comments" => $comments));
     return $this->getView()->display();
 }
Exemplo n.º 2
0
 /**
  * 日志编辑
  */
 public function editAction()
 {
     $id = get('id', 'int');
     $row = db()->Table('article')->getRow(array('id' => $id))->done();
     //getRow
     if (!$row) {
         return $this->link()->error("参数错误");
     }
     $row['title'] = htmlspecialchars($row['title']);
     $row['content'] = htmlspecialchars($row['content']);
     $row['excerpt'] = htmlspecialchars($row['excerpt']);
     $form = new \Admin\Article\Form\editForm();
     //获取表单
     $form->bind($row);
     //绑定Row
     $form->start('articleEdit');
     //开始渲染
     $this->getView()->assign(array('form' => $form));
     $tag = new \Admin\Model\articleModel();
     //获取该文章标签
     $tTags = $tag->getTags($id, true);
     //获取已有全部标签
     $tags = $tag->getTags("", true);
     $this->getView()->assign(array('tags' => $tags, 'tTags' => $tTags, 'data' => $row));
     $this->getView()->display();
 }