/**
  * 列表显示,包括page和single
  * @param string $post_type 文章类型
  * @param string $post_status 文章状态
  * @param string $order 顺序
  * @param string $keyword 搜索关键词
  */
 public function index($post_type = 'single', $post_status = 'publish', $order = 'post_id desc', $keyword = '')
 {
     //获取get参数
     $cat = I('get.cat');
     $tag = I('get.tag');
     $page = I('get.page', C('PAGER'));
     $where = array('post_status' => $post_status);
     $where['post_content|post_title'] = array('like', "%{$keyword}%");
     $post_ids = array();
     //投稿员只能看到自己的
     if (!$this->noVerify()) {
         $where['user_id'] = get_current_user_id();
     }
     //处理详细信息 搜索,指定TAG CAT文章
     if ($cat != '') {
         $post_ids = D('Cats', 'Logic')->getPostsId($cat);
         $post_ids = empty($post_ids) ? array('post_id' => 0) : $post_ids;
         $cat_detail = D('Cats', 'Logic')->detail($cat);
         $cat = '关于分类 ' . $cat_detail['cat_name'] . ' 的';
     } else {
         if ($tag != '') {
             $post_ids = D('Tags', 'Logic')->getPostsId($tag);
             $post_ids = empty($post_ids) ? array('post_id' => 0) : $post_ids;
             $tag_detail = D('Tags', 'Logic')->detail($tag);
             $tag = '关于标签' . $tag_detail['tag_name'] . ' 的';
         } else {
             if ($keyword != '') {
                 $key = '关于' . $keyword . ' 的';
             }
         }
     }
     $PostsLogic = new PostsLogic();
     $count = $PostsLogic->countAll($post_type, $where, $post_ids);
     // 查询满足要求的总记录数
     if ($count != 0) {
         $Page = new GreenPage($count, $page);
         // 实例化分页类 传入总记录数
         $pager_bar = $Page->show();
         $limit = $Page->firstRow . ',' . $Page->listRows;
         $posts_list = $PostsLogic->getList($limit, $post_type, $order, true, $where, $post_ids);
     }
     $this->assign('post_type', $post_type);
     $this->assign('action', $key . $cat . $tag . get_real_string($post_type) . '列表');
     $this->assign('posts', $posts_list);
     $this->assign('pager', $pager_bar);
     $this->display('index_no_js');
 }
 /**
  * 列表显示,包括page和single
  * @param string $post_type 文章类型
  * @param string $post_status 文章状态
  * @param string $order 顺序
  * @param string $keyword 搜索关键词
  * @param string $tpl 模板名称
  * @param string $name
  */
 public function index($post_type = 'single', $post_status = 'publish', $order = 'post_date desc', $keyword = '', $tpl = 'index_no_js', $name = '', $uid = 0)
 {
     $CatsLogic = new CatsLogic();
     $TagsLogic = new TagsLogic();
     $key = '';
     //获取get参数
     $cat = I('get.cat');
     $tag = I('get.tag');
     $page = I('get.page', get_opinion('PAGER'));
     $where = array('post_status' => $post_status);
     $where['post_content|post_title'] = array('like', "%{$keyword}%");
     $post_ids = array();
     if ($uid != 0 && $this->noVerify()) {
         $where['user_id'] = $uid;
         $UserLogic = new UserLogic();
         $user_info = $UserLogic->detail($uid);
         $key .= $user_info["user_nicename"] . ' 的';
     }
     //投稿员只能看到自己的
     if (!$this->noVerify()) {
         $where['user_id'] = get_current_user_id();
     }
     //处理详细信息 搜索,指定TAG CAT文章
     if ($cat != '') {
         $post_ids = $CatsLogic->getPostsIdWithChildren($cat);
         $post_ids = empty($post_ids) ? array('post_id' => 0) : $post_ids;
         $cat_detail = $CatsLogic->detail($cat);
         $cat = '关于分类 ' . $cat_detail['cat_name'] . ' 的';
     } else {
         if ($tag != '') {
             $post_ids = $TagsLogic->getPostsId($tag);
             $post_ids = empty($post_ids) ? array('post_id' => 0) : $post_ids;
             $tag_detail = $TagsLogic->detail($tag);
             $tag = '关于标签' . $tag_detail['tag_name'] . ' 的';
         } else {
             if ($keyword != '') {
                 $key .= '关于' . $keyword . ' 的';
             }
         }
     }
     $PostsLogic = new PostsLogic();
     $count = $PostsLogic->countAll($post_type, $where, $post_ids);
     // 查询满足要求的总记录数
     if ($count != 0) {
         $Page = new GreenPage($count, $page);
         // 实例化分页类 传入总记录数
         $pager_bar = $Page->show();
         $limit = $Page->firstRow . ',' . $Page->listRows;
         $posts_list = $PostsLogic->getList($limit, $post_type, $order, true, $where, $post_ids);
     }
     $cats = $CatsLogic->category();
     $tags = $TagsLogic->select();
     $this->assign("cats", $cats);
     $this->assign("tags", $tags);
     $this->assign('post_type', $post_type);
     $this->assign('action', $name . $key . $cat . $tag . get_real_string($post_type) . '列表');
     $this->assign('posts', $posts_list);
     $this->assign('pager', $pager_bar);
     $this->display($tpl);
 }