Exemple #1
0
 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();
 }
Exemple #2
0
 /**
  * 发表评论
  * curl -d "course_id=1&comment_id=1&video_id=0&content=helloaaaaaaaaaa" http://182.92.110.119/comment/publish
  */
 function publishAction()
 {
     $courseId = (int) $this->post("course_id", 0);
     $commentId = (int) $this->post("comment_id", 0);
     $videoId = (int) $this->post("video_id", 0);
     $content = $this->post("content", "");
     $time = time();
     $comment = array("uid" => $this->uid, "comment_id" => $commentId, "course_id" => $courseId, "video_id" => $videoId, "content" => $content, "create_time" => $time);
     $commentModel = new CommentModel();
     $id = $commentModel->insertComment($comment);
     if ($id) {
         $userModel = new UserModel();
         $videoModel = new VideoModel();
         $courseModel = new CourseModel();
         $author = $userModel->getUser($comment['uid']);
         $comment['create_time_fmt'] = Common_Time::flow($comment['create_time']);
         $comment['author_uid'] = $author['stuff_id'];
         $comment['author_name'] = $author['stuff_name'];
         $comment['author_avator'] = $author['avator'];
         if ($comment['comment_id']) {
             $parentComment = $commentModel->getComment($comment['comment_id']);
             $beReplyAuthor = $userModel->getUser($parentComment['uid']);
             $parentComment['author_uid'] = $beReplyAuthor['stuff_id'];
             $parentComment['author_name'] = $beReplyAuthor['stuff_name'];
             $parentComment['author_avator'] = $beReplyAuthor['avator'];
             $parentComment['create_time_fmt'] = Common_Time::flow($parentComment['create_time']);
             $comment['parent_comment'] = $parentComment;
         }
         if ($comment['video_id']) {
             $section = $videoModel->getVideoBelongSection($comment['video_id']);
             if (!$section) {
                 $practiseModel = new PractiseModel();
                 $practise = $practiseModel->getVideoBelongPractise($comment['video_id'], $courseId);
                 $comment['practise_seq'] = $practise['seq'];
                 $section = $courseModel->getSection($practise['section_id']);
             }
             $chapter = $courseModel->getSection($section["parent_id"]);
             $comment["chapter_id"] = $chapter["id"];
             $comment["chapter_name"] = $chapter["name"];
             $comment["chapter_seq"] = $chapter["seq"];
             $comment["section_id"] = $section["id"];
             $comment["section_name"] = $section["name"];
             $comment["section_seq"] = $section["seq"];
             $userVideo = $videoModel->getUserVideoVote($comment['uid'], $comment['video_id']);
             $comment["video_like"] = isset($userVideo['like_type']) ? $userVideo['like_type'] : 0;
         }
         $this->displayJson(Common_Error::ERROR_SUCCESS, array($comment));
     }
     $this->displayJson(Common_Error::ERROR_MYSQL_EXECUTE);
 }
Exemple #3
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);
     //某人所有文章分类
 }
Exemple #4
0
 public function articleInfo()
 {
     //实例化Model
     $articleModel = new ArticleModel();
     //文章
     $commentModel = new CommentModel();
     //评论
     $collectModel = new CollectModel();
     //文章收藏
     $articleId = Data::get($_GET['articleId'], Data::Int);
     if (!is_int($articleId) && $articleId <= 0) {
         R('Index', 'index');
     }
     $articleModel->setIncArticleByHitNum($articleId);
     //文章信息
     $content = $articleModel->getArticleById($articleId);
     //文章评论数
     $commentNum = $commentModel->getCommentCountByArticleId($articleId);
     $content['commentNum'] = $commentNum;
     //文章收藏数
     $collectNum = $collectModel->getCollectCountByarticleId($articleId);
     $content['collectNum'] = $collectNum;
     //是否已经收藏
     $if_collect = 0;
     if ($_SESSION['qq']) {
         if ($collectModel->getCollects($articleId, $_SESSION['qq']['userId'])) {
             $if_collect = 1;
         }
     }
     //评论查询
     $comments = $commentModel->getComment($articleId);
     //用户个人信息
     $allUserInfo = $this->getAllUserInfo();
     //博主个人信息
     $blogerInfo = $this->getBlogerInfo($content['adminId']);
     //获取所有文章分类
     $allTypes = $this->getAllTypes($content['adminId']);
     //获取所有文章标签
     $allTags = $this->getAllTags();
     //文章总数
     $count = $this->articleCount($content['adminId']);
     //最新三条评论
     $latestComments = $this->getLatestComments($content['adminId'], '0,3');
     $this->assign('count', $count);
     //某博主文章总数
     $this->assign("allTags", $allTags);
     //所有文章标签
     $this->assign("allTypes", $allTypes);
     //某人所有文章分类
     $this->assign('blogerInfo', $blogerInfo);
     //某博主信息
     $this->assign('allUserInfo', $allUserInfo);
     //某用户信息
     $this->assign('latestComments', $latestComments);
     //最新三条评论
     $this->assign('if_collect', $if_collect);
     //是否已经收藏
     $this->assign('article', $content);
     //文章详情
     $this->assign('comments', $comments);
     $this->display();
 }