/** * * 删除分类 */ public function delCate() { if (is_numeric($id = I('id', '', 'intval')) || is_array($id = I('id'))) { $PS = new PaperService(); $res = $PS->deleteCates($id); } if ($res === true) { redirect(U('Cates/index')); die; } else { $this->error($res, U('Cates/index'), 2); } }
/** * * 添加评论 */ public function addComment() { if (IS_POST) { $PS = new PaperService(); if (($res = $PS->doAddComment(I('post.'))) == true) { redirect(U('Forum/index', array('id' => I('post.post_id')))); } else { $this->error($res, U('Forum/index', array('id' => I('post.post_id')), 2)); } } else { redirect(U('Forum/index', array('id' => I('id')))); } }
/** * * 分类下文章列表 */ public function index() { $PS = new PaperService(); is_numeric($cateId = I('get.cate', '', 'intval')) ? $cateId : ''; //如果拿到了具体分类的信息,则显示该分类下的文章 $posts = $PS->getPost(I('get.p'), 15, '', 0, $cateId); $post = $PS->packPostInfo($posts[0]); //如果传递了cateId,则把分类名称传递过去 if (!empty($cateId)) { $this->assign('mark', $post[0]['cate']); } $this->assign('posts', $post); $this->assign('pager', $posts[1]); $this->display(); }
/** * * 博客文章显示 * @param int id 可以根据接受的id显示博客文章 */ public function index() { $PS = new PaperService(); if (I('get.id')) { $postId = I('get.id', '', 'intval'); $post = $PS->getFetchForum($postId); } else { $post = $PS->getFetchForum(); } #获得文章下的评论 $comments = $PS->getFetchComment($post['id']); $this->assign('comments', $comments); $this->assign('post', $post); $this->display('article'); }