Exemple #1
0
 /**
  * 返回对象 ...
  * @return TagDbModel
  */
 public static function getInstance()
 {
     if (is_null(self::$dbModelObj) || !isset(self::$dbModelObj)) {
         self::$dbModelObj = new TagDbModel();
     }
     return self::$dbModelObj;
 }
Exemple #2
0
 /**
  * 分类页面
  */
 public function main()
 {
     //获取当前页码
     $page = 1;
     if (isset($this->param['page'])) {
         $page = $this->param['page'];
     }
     //获取分类Id
     $mid = $this->param['mid'];
     //获取该分类下的文章
     $articleList = ArticleBusiness::getArticleByMid($mid, $page);
     $pageNav = $articleList['page_nav'];
     $articleList = $articleList['data'];
     foreach ($articleList as $k => $article) {
         //整理数据
         $articleList[$k]['author'] = $article['author'];
         $articleList[$k]['title'] = $article['title'];
         $articleList[$k]['description'] = $article['description'];
         $articleList[$k]['ctime'] = date('Y-m-d H:i:s', $article['ctime']);
         $articleList[$k]['tag'] = explode('|', $article['tag']);
         if (empty($article['description'])) {
             $articleList[$k]['description'] = mb_substr($article['content'], 0, 300, 'UTF-8');
         } else {
             $articleList[$k]['description'] = mb_substr($article['description'], 0, 300, 'UTF-8');
         }
     }
     //获取该分类下热门文章
     $articleHotList = ArticleBusiness::getHotListByMid($mid);
     foreach ($articleHotList as $k => $article) {
         $articleHotList[$k]['title'] = mb_substr($article['title'], 0, 30, 'UTF-8') . '...';
     }
     //获取该分类下最新评论
     $commentNewList = CommentBusiness::getNewListByMid($mid);
     foreach ($commentNewList as $key => $comment) {
         $commentNewList[$key]['content'] = mb_substr($comment['content'], 0, 30, 'UTF-8') . '...';
     }
     //获取Tag
     $tags = TagBusiness::getRandList(ParamConstant::PARAM_TAG_LIST_NUM);
     //SEO的title,keywords,description
     $seo_title = $this->menuList[$mid]['seo_title'];
     $seo_description = $this->menuList[$mid]['seo_description'];
     $seo_keywords = $this->menuList[$mid]['seo_keywords'];
     View::assign('seo_title', $seo_title);
     View::assign('seo_description', $seo_description);
     View::assign('seo_keywords', $seo_keywords);
     View::assign('tags', $tags);
     View::assign('commentNewList', $commentNewList);
     View::assign('articleHotList', $articleHotList);
     View::assign('pageNav', $pageNav);
     View::assign('articleList', $articleList);
     View::showFrontTpl('menu');
 }
Exemple #3
0
 /**
  * @descrpition 首页
  */
 public function main()
 {
     //获取文章列表
     $articleList = ArticleBusiness::getNewList();
     foreach ($articleList as $k => $article) {
         //整理数据
         $articleList[$k]['author'] = $article['author'];
         $articleList[$k]['title'] = $article['title'];
         $articleList[$k]['description'] = $article['description'];
         $articleList[$k]['ctime'] = date('Y-m-d H:i:s', $article['ctime']);
         $articleList[$k]['tag'] = explode('|', $article['tag']);
         if (empty($article['description'])) {
             $articleList[$k]['description'] = mb_substr($article['content'], 0, 300, 'UTF-8');
         } else {
             $articleList[$k]['description'] = mb_substr($article['description'], 0, 300, 'UTF-8');
         }
     }
     //获取最热门文章
     $articleHotList = ArticleBusiness::getHotList();
     foreach ($articleHotList as $k => $article) {
         $articleHotList[$k]['title'] = mb_substr($article['title'], 0, 30, 'UTF-8') . '...';
     }
     //获取全站推荐文章
     $articleAllSiteRecommend = ArticleBusiness::getListByRecommendType(ParamConstant::PARAM_ARTICLE_RECOMMEND_TYPE_ALL_SITE, '0, 5');
     foreach ($articleAllSiteRecommend as &$article) {
         $article['title'] = mb_substr($article['title'], 0, 30, 'UTF-8') . '...';
     }
     //获取首页推荐
     $articleIndexRecommend = ArticleBusiness::getListByRecommendType(ParamConstant::PARAM_ARTICLE_RECOMMEND_TYPE_INDEX, '0, 5');
     foreach ($articleIndexRecommend as &$article) {
         $article['title'] = mb_substr($article['title'], 0, 30, 'UTF-8') . '...';
     }
     //获取最新评论
     $commentNewList = CommentBusiness::getNewList();
     foreach ($commentNewList as $key => $comment) {
         $commentNewList[$key]['content'] = mb_substr($comment['content'], 0, 30, 'UTF-8') . '...';
     }
     //获取Tag
     $tags = TagBusiness::getRandList(ParamConstant::PARAM_TAG_LIST_NUM);
     //获取友情链接
     $friendLinkList = FriendLinkBusiness::getFriendLinkList();
     View::assign('friendLinkList', $friendLinkList);
     View::assign('tags', $tags);
     View::assign('articleHotList', $articleHotList);
     View::assign('articleAllSiteRecommend', $articleAllSiteRecommend);
     View::assign('articleIndexRecommend', $articleIndexRecommend);
     View::assign('commentNewList', $commentNewList);
     View::assign('articleList', $articleList);
     View::showFrontTpl('index');
 }
Exemple #4
0
 /**
  * @descrpition 单篇文章展示
  * @return Ambigous
  */
 public function main()
 {
     $articleId = $this->param['aid'];
     if (empty($articleId)) {
         View::showErrorMessage(GAME_URL, '参数错误');
     }
     //获取文章信息
     $article = ArticleBusiness::getArticle($articleId);
     if (empty($article)) {
         View::showErrorMessage(GAME_URL, '内容丢掉了-.-');
     }
     $article['author'] = $article['author'];
     $article['title'] = $article['title'];
     $article['description'] = $article['description'];
     $article['ctime'] = date('Y-m-d H:i:s', $article['ctime']);
     $article['tag'] = explode('|', $article['tag']);
     //        $article['content'] = htmlspecialchars_decode($article['content']);
     //        preg_match_all("/\[code\](.*?)\[\/code\]/s",  $article['content'], $match);
     //
     //        $article['content'] =  preg_replace("/\[code\](.*?)\[\/code\]/s", htmlspecialchars('${1}'), $article['content']);
     //获取该文章的评论
     $commentList = CommentBusiness::getCommentByAid($this->param['aid']);
     $commentList = Func::arrayKey($commentList);
     //将评论二级分类
     foreach ($commentList as $key => $comment) {
         if ($comment['cid'] != 0) {
             $commentList[$comment['cid']]['son'][] = $comment;
             unset($commentList[$key]);
         }
     }
     //获取该分类下热门文章
     $articleHotList = ArticleBusiness::getHotListByMid($article['mid']);
     foreach ($articleHotList as $k => $a) {
         $articleHotList[$k]['title'] = mb_substr($a['title'], 0, 30, 'UTF-8') . '...';
     }
     //获取该分类下最新评论
     $commentNewList = CommentBusiness::getNewListByMid($article['mid']);
     foreach ($commentNewList as $key => $comment) {
         $commentNewList[$key]['content'] = mb_substr($commentNewList[$key]['content'], 0, 30, 'UTF-8') . '...';
     }
     //获取Tag
     $tags = TagBusiness::getRandList(ParamConstant::PARAM_TAG_LIST_NUM);
     //对文章进行处理,代码部分特殊显示.
     $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
     ArticleBusiness::clicks($articleId);
     View::assign('seo_title', $seo_title);
     View::assign('seo_description', $seo_description);
     View::assign('seo_keywords', $seo_keywords);
     View::assign('tags', $tags);
     View::assign('commentList', $commentList);
     View::assign('commentNewList', $commentNewList);
     View::assign('articleHotList', $articleHotList);
     View::assign('article', $article);
     View::showFrontTpl('article');
 }
Exemple #5
0
 /**
  * @descrpition 修改文章
  */
 public function edit()
 {
     if (Request::getRequest('dosubmit', 'str')) {
         $jumpUrl = '/admin.php/article/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['description'] = Request::getRequest('description', '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['recommend_type'] = Request::getRequest('recommend_type', 'int');
         $fields['content'] = Request::getRequest('content', 'str');
         //如果使用UEditor,则反转义一次
         $fields['content'] = htmlspecialchars_decode($fields['content']);
         //将TAG记录进TAG表
         $tags = explode('|', $fields['tag']);
         foreach ($tags as $tag) {
             $tagInfo = TagBusiness::getTagByTag($tag);
             if (!empty($tagInfo)) {
                 $tagInfo['num']++;
                 TagBusiness::editTag($tagInfo['id'], $tagInfo);
             } else {
                 $tagFields['tag'] = $tag;
                 $tagFields['num'] = 1;
                 TagBusiness::setTag($tagFields);
             }
         }
         $result = ArticleBusiness::editArticle($this->param['id'], $fields);
         if ($result) {
             View::showAdminMessage('/admin.php/article/lists', '修改成功');
         } else {
             View::showAdminErrorMessage($jumpUrl, '修改失败');
         }
     }
     $blogMenuList = MenuBusiness::getMenuList();
     $blogMenuList = Func::arrayKey($blogMenuList);
     $blogMenuList = Func::categoryTree($blogMenuList);
     $article = ArticleBusiness::getArticle($this->param['id']);
     View::assign('article', $article);
     View::assign('blogMenuList', $blogMenuList);
     View::showAdminTpl('article_edit');
 }