/** * @todo: 删除评论 * @author Saki <*****@*****.**> * @date 2014-12-30 上午9:59:25 * @version V1.0 */ public function delete() { $aid = $_GET['aid']; $id = $_GET['id']; $model = new \Admin\Model\ArticleCommentModel(); $data = $model->deleteComment($id, $aid); //删除成功进行页面跳转 if ($data['errcode'] == 0) { $this->redirect('ArticleList/view', array('id' => $aid, 'p' => 1)); } }
/** * @todo: 发送评论 * @author Saki <*****@*****.**> * @date 2014-12-22 上午9:34:18 * @version V1.0 */ public function PostComment() { $model = new \Admin\Model\ArticleCommentModel(); $post = $_POST['ArticleComment']; $id = $post['aid']; $comment_id = $model->createComment($post); //发送邮件,这里为游客发送评论,则为管理员邮箱收到邮件 if ($comment_id) { \Think\Hook::listen('postComment', $comment_id); \Think\Hook::add('postComment', 'Home\\Behaviors\\emailBehavior'); } $this->redirect('Article/view', array('id' => $id, 'p' => 1)); }
/** * @todo: 预览文章 * @author Saki <*****@*****.**> * @date 2014-12-16 上午9:21:57 * @version V1.0 */ public function view() { $p = isset($_GET['p']) ? $_GET['p'] : 0; //评论分页标志 //文章详细信息 $model = new \Admin\Model\ArticleListModel(); $info = $model->getArticleInfo($_GET['id']); $tags = explode(",", $info['tags']); //查询评论列表 $comments_model = new \Admin\Model\ArticleCommentModel(); //统计总条数 $condition['aid'] = $_GET['id']; $condition['pid'] = 0; $count = $comments_model->where($condition)->count(); //分页显示设置 $Page = new \Think\Page($count, 3); $Page->setConfig('prev', '上一页'); $Page->setConfig('next', '下一页'); $Page->setConfig('theme', '%FIRST% %LINK_PAGE% %END%'); $show = $Page->show(); $comments_list = $comments_model->getComments_First($Page, $condition); //输出 $this->assign('info', $info); $this->assign('tags', $tags); $this->assign('comments_list', $comments_list); $this->assign('page', $show); $this->assign('p', $p); $this->display(); }