コード例 #1
0
ファイル: ArticleCtrl.class.php プロジェクト: Jnnock/myyyk
 public function index()
 {
     //var_dump($_SESSION['qq']);
     $articleId = $_GET['articleId'];
     $article = new ArticleModel();
     $content = $article->getArticleById($articleId);
     $collect = new CollectModel();
     $comment = new CommentModel();
     $commentNum = $comment->getCommentCountByArticleId($articleId);
     $content['commentNum'] = $commentNum;
     if ($this->isLogin()) {
         if ($collect->getCollects($article, $_SESSION['qq']['userId'])) {
             $this->assign('collects', '已收藏');
         } else {
             $collectNum = $collect->getCollectCountByuserId($article);
             $this->assign('collectNum', $collectNum);
             $this->assign('collects', '收藏');
         }
     }
     $this->assign('article', $content);
     //评论查询
     $comments = $comment->getComment($articleId);
     $user = new UserModel();
     $arr = array();
     foreach ($comments as $key => $val) {
         $val[$key]['user'] = $user->getUserById($val['userId']);
     }
     $this->assign('comments', $comments);
     $this->display();
 }
コード例 #2
0
ファイル: UserCtrl.class.php プロジェクト: Jnnock/myyyk
 public function index()
 {
     //header('content-type:text/html;charset=utf-8');
     $userId = $_SESSION['qq']['userId'];
     $collect = new CollectModel();
     //查询收藏
     $user_collect = $collect->getCollectByuserId($userId);
     $article = new ArticleModel();
     $arr = array();
     foreach ($user_collect as $v) {
         //根据收藏的文章id查询文章
         $a = $article->getArticleById($v['articleId']);
         //取出admin的昵称
         $a['adminName'] = $this->getAdmin($a['adminId']);
         $arr[] = $a;
     }
     $comment = new CommentModel();
     $commentAlbum = $comment->getCommentByAlbum($userId);
     $album = new AlbumModel();
     $articles = array();
     $albums = array();
     foreach ($commentAlbum as $v) {
         if ($v['albumId'] != null) {
             $c = $album->getAlbumById($v['albumId']);
             $c['adminName'] = $this->getAdmin($v['adminId']);
             $albums[] = $c;
         }
     }
     $commentArticle = $comment->getCommentByArticle($userId);
     foreach ($commentArticle as $v) {
         if ($v['articleId'] != null) {
             $a = $article->getArticleById($v['articleId']);
             $a['adminName'] = $this->getAdmin($v['adminId']);
             $articles[] = $a;
         }
     }
     var_dump($albums);
     $this->assign('user', $_SESSION['qq']['userName']);
     //评论过的相册
     $this->assign('albums', $albums);
     //评论过的文章
     $this->assign('articles', $articles);
     //收藏
     $this->assign('user_collect', $arr);
     $this->display();
 }
コード例 #3
0
ファイル: AdminCtrl.class.php プロジェクト: Jnnock/myyyk
 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);
     //某人所有文章分类
 }