예제 #1
0
 /**
  * 兼容旧式CMS深目录结构的二级cat结构
  * @param $info
  */
 public function channel($info)
 {
     //TODO 兼容旧式CMS深目录结构的二级cat结构
     $Cat = new CatsLogic();
     $cat = $Cat->detail($info);
     $children = $Cat->getChildren($cat['cat_id']);
     $Cat = new CatsLogic();
     $Posts = new PostsLogic();
     $cat = $Cat->detail($info);
     $this->if404($cat, "非常抱歉,没有这个分类,可能它已经躲起来了");
     //优雅的404
     $posts_id = $Cat->getPostsId($cat['cat_id']);
     $count = sizeof($posts_id);
     $count == 0 ? $res404 = 0 : ($res404 = 1);
     if (!empty($posts_id)) {
         $Page = new GreenPage($count, get_opinion('PAGER'));
         $pager_bar = $Page->show();
         $limit = $Page->firstRow . ',' . $Page->listRows;
         $posts_list = $Posts->getList($limit, 'single', 'post_id desc', true, array(), $posts_id);
     }
     $this->assign('children', $children);
     $this->assign('title', $cat['cat_name']);
     // 赋值数据集
     $this->assign('res404', $res404);
     $this->assign('postslist', $posts_list);
     // 赋值数据集
     $this->assign('pager', $pager_bar);
     // 赋值分页输出
     $this->assign('breadcrumbs', get_breadcrumbs('cats', $cat['cat_id']));
     $this->display('Archive/channel-list');
 }
예제 #2
0
 /**
  * 兼容旧式CMS深目录结构的二级cat结构
  * @param $info
  */
 public function channel($info)
 {
     //TODO 兼容旧式CMS深目录结构的二级cat结构
     $CatsLogic = new CatsLogic();
     $cat = $CatsLogic->detail($info);
     $children = $CatsLogic->getChildren($cat['cat_id']);
     if (empty($children['cat_children'])) {
         $children = $CatsLogic->getChildren($children['cat_father']);
     }
     $CatsLogic = new CatsLogic();
     $Posts = new PostsLogic();
     $cat = $CatsLogic->detail($info);
     $this->if404($cat, "非常抱歉,没有这个分类,可能它已经躲起来了");
     //优雅的404
     $posts_id = $CatsLogic->getPostsIdWithChildren($cat['cat_id']);
     $count = sizeof($posts_id);
     $count == 0 ? $res404 = 0 : ($res404 = 1);
     if (!empty($posts_id)) {
         $Page = new GreenPage($count, get_opinion('PAGER'));
         $pager_bar = $Page->show();
         $limit = $Page->firstRow . ',' . $Page->listRows;
         $posts_list = $Posts->getList($limit, 'single', 'post_date desc', true, array(), $posts_id);
     }
     $this->assign('children', $children);
     $this->assign('title', $cat['cat_name']);
     // 赋值数据集
     $this->assign('res404', $res404);
     $this->assign('postslist', $posts_list);
     // 赋值数据集
     $this->assign('pager', $pager_bar);
     // 赋值分页输出
     $this->assign('breadcrumbs', get_breadcrumbs('cats', $cat['cat_id']));
     if (File::file_exists(T('Home@Archive/channel-list'))) {
         $this->display('Archive/channel-list');
     } else {
         //TODO   这里怎么处理却决于你自己了。
         //            $this->error404('缺少对应的模版而不能显示');
         $this->display('Archive/single-list');
     }
 }
예제 #3
0
 /**
  * 编辑分类
  * @param $id
  */
 public function editCategory($id)
 {
     $CatsLogic = new CatsLogic();
     $action = '编辑';
     $cat = $CatsLogic->detail($id);
     $cats = $CatsLogic->category();
     $this->assign('action', $action);
     $this->assign('cat', $cat);
     $this->assign('cats', $cats);
     $this->display('editcategory');
 }
예제 #4
0
 /**
  * 分类文章
  * @param int $id 分类id
  */
 public function cat($id)
 {
     $Cat = new CatsLogic();
     $Posts = new PostsLogic();
     $cat = $Cat->detail($id);
     $posts_id = $Cat->getPostsId($cat['cat_id']);
     $count = sizeof($posts_id);
     if (!empty($posts_id)) {
         $Page = new GreenPage($count, get_opinion('PAGER'));
         $limit = $Page->firstRow . ',' . $Page->listRows;
         $res = $Posts->getList($limit, 'single', 'post_date desc', true, array(), $posts_id);
         foreach ($res as $key => $value) {
             $res[$key]['post_content'] = strip_tags($res[$key]['post_content']);
             $res[$key]['post_url'] = U('Api/Index/post', array('id' => $res[$key]['post_id']), false, true);
             $res[$key]["post_img"] = get_post_img($value);
         }
         $res_array["posts"] = $res;
         $this->jsonReturn(1, $res_array);
     } else {
         $res_array["detail"] = "没有文章";
         $this->jsonReturn(0, $res_array);
     }
 }