Exemplo n.º 1
0
Arquivo: doc.php Projeto: web5/LX_Blog
 /**
  * 手册首页
  */
 public function main()
 {
     $articleId = isset($this->param['aid']) ? $this->param['aid'] : 0;
     if (!$articleId) {
         $article = ItemDocArticleBusiness::getOneMostOld();
     } else {
         //获取文章信息
         $article = ItemDocArticleBusiness::getArticle($articleId);
     }
     if (empty($article)) {
         View::showErrorMessage(ITEM_DOMAIN, '内容丢掉了-.-');
     }
     $articleId = $article['id'];
     $article['ctime'] = date('Y-m-d H:i:s', $article['ctime']);
     $article['tag'] = empty($article['tag']) ? '' : explode('|', $article['tag']);
     //获取该文章的评论
     $commentList = ItemDocCommentBusiness::getCommentByAid($articleId);
     $commentList = Func::arrayKey($commentList);
     //将评论二级分类
     foreach ($commentList as $key => $comment) {
         if ($comment['cid'] != 0) {
             $commentList[$comment['cid']]['son'][] = $comment;
             unset($commentList[$key]);
         }
     }
     //对文章进行处理,代码部分特殊显示.
     $article['content'] = preg_replace('/\\[code\\]/s', '<pre class="prettyprint linenums">', $article['content']);
     $article['content'] = preg_replace('/\\[\\/code\\]/s', '</pre>', $article['content']);
     //SEO的title,keywords,description
     $seo_title = $article['seo_title'];
     $seo_description = $article['seo_description'];
     $seo_keywords = $article['seo_keywords'];
     //文章的点击数+1
     ItemDocArticleBusiness::clicks($articleId);
     //获取项目下的菜单列表
     $itemMenuList = ItemDocMenuBusiness::getMenuListByItem();
     $itemMenuList = Func::arrayKey($itemMenuList);
     //获取项目下的文章列表
     $itemArticleList = ItemDocArticleBusiness::getListByItem();
     foreach ($itemArticleList as $itemArticle) {
         if (isset($itemMenuList[$itemArticle['mid']])) {
             $itemMenuList[$itemArticle['mid']]['article_list'][] = $itemArticle;
         }
     }
     View::assign('itemMenuList', $itemMenuList);
     View::assign('seo_title', $seo_title);
     View::assign('seo_description', $seo_description);
     View::assign('seo_keywords', $seo_keywords);
     View::assign('commentList', $commentList);
     View::assign('article', $article);
     View::showFrontTpl('doc');
 }
Exemplo n.º 2
0
 /**
  * @descrpition 修改文章
  */
 public function edit()
 {
     if (Request::getRequest('dosubmit', 'str')) {
         $jumpUrl = '/admin.php/itemdocarticle/edit/id-' . $this->param['id'];
         $fields = array();
         $fields['title'] = Request::getRequest('title', 'str');
         $fields['seo_title'] = Request::getRequest('seo_title', 'str');
         $fields['seo_description'] = Request::getRequest('seo_description', 'str');
         $fields['seo_keywords'] = Request::getRequest('seo_keywords', 'str');
         $fields['author'] = Request::getRequest('author', 'str');
         $fields['clicks'] = Request::getRequest('clicks', 'str');
         $fields['tag'] = Request::getRequest('tag', 'str');
         $fields['good_num'] = Request::getRequest('good_num', 'str');
         $fields['bad_num'] = Request::getRequest('bad_num', 'str');
         $fields['ctime'] = Request::getRequest('ctime', 'str');
         $fields['ctime'] = strtotime($fields['ctime']);
         $fields['mid'] = Request::getRequest('mid', 'int');
         $fields['item'] = Request::getRequest('item', 'str');
         $fields['content'] = Request::getRequest('content', 'str');
         //如果使用UEditor,则反转义一次
         $fields['content'] = htmlspecialchars_decode($fields['content']);
         //将TAG记录进TAG表
         $tags = explode('|', $fields['tag']);
         foreach ($tags as $tag) {
             if (empty($tag)) {
                 continue;
             }
             $tagInfo = ItemDocTagBusiness::getTagByTag($tag);
             if (!empty($tagInfo)) {
                 $tagInfo['num']++;
                 ItemDocTagBusiness::editTag($tagInfo['id'], $tagInfo);
             } else {
                 $tagFields['tag'] = $tag;
                 $tagFields['num'] = 1;
                 ItemDocTagBusiness::setTag($tagFields);
             }
         }
         $result = ItemDocArticleBusiness::editArticle($this->param['id'], $fields);
         if ($result) {
             View::showAdminMessage('/admin.php/itemdocarticle/lists', '修改成功');
         } else {
             View::showAdminErrorMessage($jumpUrl, '修改失败');
         }
     }
     $blogMenuList = ItemDocMenuBusiness::getMenuList();
     $blogMenuList = Func::arrayKey($blogMenuList);
     $blogMenuList = Func::categoryTree($blogMenuList);
     $article = ItemDocArticleBusiness::getArticle($this->param['id']);
     View::assign('article', $article);
     View::assign('blogMenuList', $blogMenuList);
     View::showAdminTpl('item_doc_article_edit');
 }