Пример #1
0
 /**
  * 节的详细页(视频学习页)
  *
  */
 function infoAction()
 {
     $videoId = (int) $this->get("video_id", 0);
     $videoId = $videoId ? $videoId : $this->section['video_id'];
     $videoModel = new VideoModel();
     $video = $videoModel->getVideo($videoId);
     $video['is_user_like'] = $videoModel->isUserLikeOrDislike($this->uid, $videoId);
     $data = array('course_id' => $this->course['id'], 'course_name' => $this->course['name'], 'chapter_id' => $this->chapter['id'], 'chapter_name' => $this->chapter['name'], 'chatper_seq' => $this->chapter['seq'], 'section_id' => $this->section['id'], 'section_name' => $this->section['name'], 'section_seq' => $this->section['seq'], 'video_id' => $video['id'], 'video_url' => $video['url'], 'video_duration' => $video['duration'], 'duration' => $video['duration'], 'video_image' => $video['image'], 'video_like_num' => $video['like_num'], 'video_dislike_num' => $video['dislike_num'], 'video_view_num' => $video['view_num'], 'is_user_like' => $video['is_user_like']);
     if (!$this->teacher || $this->teacher['id'] != $video['user_id']) {
         $userModel = new UserModel();
         $this->teacher = $userModel->getTeacher($video['user_id']);
     }
     $data['teacher'] = array('id' => $this->teacher['id'], 'name' => $this->teacher['name'], 'job_title' => $this->teacher['job_title'], 'avator' => $this->teacher['avator']);
     if ($this->isMobile) {
         $this->displayJson(Common_Error::ERROR_SUCCESS, $data);
     }
     if ($this->course['type'] == 1) {
         $practiseModel = new PractiseModel();
         $practise = $practiseModel->getVideoBelongPractise($videoId, $this->course['id']);
         $this->assign("practise", $practise);
     }
     $this->assign("course", $this->course);
     $this->assign("chapter", $this->chapter);
     $this->assign("section", $this->section);
     $this->assign("teacher", $this->teacher);
     $this->assign("video", $video);
 }
Пример #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);
 }