示例#1
0
 public function getArticleById()
 {
     $errors = $this->errors;
     $articleId = $_GET['articleId'];
     //实例化Model
     $adminModel = new AdminModel();
     //博主
     $articleModel = new ArticleModel();
     //文章
     $articleTypeModel = new ArticleTypeModel();
     //文章分类
     $articleTagModel = new ArticleTagModel();
     //文章标签
     $commentModel = new CommentModel();
     //评论
     $collectModel = new CollectModel();
     //文章收藏
     //获取所有文章分类
     $allTypes = $articleTypeModel->getCatrgoryByAdminId($_SESSION['admin']['adminId']);
     $allTypes = formatkey($allTypes, 'typeId');
     //设置typeId主键
     //获取所有文章标签
     $allTags = $articleTagModel->getArticleTag();
     $allTags = formatkey($allTags, 'tagId');
     //设置typeId主键
     $articleInfo = $articleModel->getArticleById($articleId);
     if ($articleInfo['tagId']) {
         $articleInfo['tagId'] = explode(',', trim($value['tagId'], ','));
     }
     //查询评论数
     $articleInfo['commentCount'] = $commentModel->getCommentCountByArticleId($articleId);
     //查询收藏数
     $articleInfo['collectCount'] = $collectModel->getCollectCountByArticleId($articleId);
     //获取最新的评论
     $comment = $commentModel->getComment($articleId, '0,2');
     //博主信息
     $adminInfo = $adminModel->getAdminById($_SESSION['admin']['adminId']);
     $this->assign("admin", $adminInfo);
     //文章
     $this->assign("article", $articleInfo);
     //文章
     $this->assign("allTags", $allTags);
     //所有文章标签
     $this->assign("allTypes", $allTypes);
     //某人所有文章分类
     $this->assign("comment", $comment);
     //某人所有文章分类
 }
示例#2
0
 public function articleTagList()
 {
     $blogerId = Data::get($_GET['blogerId'], Data::Int);
     //$blogerId =1;//测试
     if (!is_int($blogerId) && $blogerId <= 0) {
         R('Index', 'index');
     }
     //实例化Model
     $articleModel = new ArticleModel();
     //文章
     $commentModel = new CommentModel();
     //评论
     $collectModel = new CollectModel();
     //文章收藏
     //获取所有文章标签
     $allTags = $this->getAllTags();
     $str = "";
     $p = isset($_GET['p']) ? $_GET['p'] : 1;
     $pagesize = 10;
     $curpage = ($p - 1) * $pagesize;
     $limit = $curpage . "," . $pagesize;
     //排序
     if (isset($_GET['order']) && $_GET['order'] == "addTime.desc" || $_GET['order'] == "hitNum.desc") {
         $order = str_replace('.', ' ', $_GET['order']);
     } else {
         $order = 'addTime desc';
     }
     $tagId = Data::get($_GET['tagId'], Data::Int);
     $articleModel = new ArticleModel();
     $articles = $articleModel->getArticlesByTagId($limit, $order, $tagId);
     $articlesArr = array();
     foreach ($articles as $key => $value) {
         //对tagId 进行处理
         if ($value['tagId']) {
             $value['tagId'] = explode(',', trim($value['tagId'], ','));
         }
         //查询评论数
         $value['commentCount'] = $commentModel->getCommentCountByArticleId($value['articleId']);
         //查询收藏数
         $value['collectCount'] = $collectModel->getCollectCountByArticleId($value['articleId']);
         //是否已收藏
         if ($_SESSION['qq']['userId']) {
             if ($collectModel->getCollects($value['articleId'], $_SESSION['qq']['userId'])) {
                 $value['if_collect'] = 1;
             }
         } else {
             $value['if_collect'] = 0;
         }
         $articlesArr[$value['articleId']] = $value;
     }
     $this->assign('page', $str);
     //分页
     $this->assign("articles", $articlesArr);
     //文章
     $this->assign("allTags", $allTags);
     //所有文章标签
     $this->assign("pageTitle", "个人主页");
     $this->display();
 }