/**
  * 删除分类操作
  * @return void [description]
  */
 public function deleteCate()
 {
     $id = (int) I('get.id');
     //判断如果有下级分类,则连同下级分类一起删除
     if (M('cate')->where('pid=' . $id . '')->select()) {
         $cate = M('cate')->order('sort DESC')->select();
         // 从数据库取得所有分类
         $condition = \Admin\Common\Category::getChildsId($cate, $id);
         // 取得传入父分类的所有子分类
         $where['id'] = array('in', $condition);
         // 删除分类及其所有子分类
         if (M('cate')->where($where)->delete()) {
             $this->success('删除成功', U('Category/index'));
         } else {
             $this->error('删除失败');
         }
     } else {
         // 删除分类
         if (M('cate')->where('id=' . $id . '')->delete()) {
             $this->success('删除成功', U('Category/index'));
         } else {
             $this->error('删除失败');
         }
     }
 }
 /**
  * 列表页
  */
 public function index()
 {
     $id = (int) I('get.id');
     $cate = M('cate')->order('sort')->select();
     $cids = \Admin\Common\Category::getChildsId($cate, $id);
     $cids[] = $id;
     $where = array('cid' => array('IN', $cids), 'del' => 0);
     // 获取总文章数
     $count = M('blog')->where($where)->count();
     // 实例化分页类
     $page = new \Think\Page($count, 5);
     // 设置分页链接样式
     $page->setConfig('prev', '<');
     $page->setConfig('next', '>');
     $limit = $page->firstRow . ',' . $page->listRows;
     $cate = D('BlogView')->getAll($where, $limit);
     // 显示分页
     $page = $page->show();
     // 解析并重新整理分页URL
     $page = trimPageUrl($page);
     // 转换每一篇文章video字段的HTML实体用于输出
     foreach ($cate as $key => $value) {
         $cate[$key]['video'] = htmlspecialchars_decode($cate[$key]['video']);
         $cate[$key]['image'] = __APP__ . '/' . trim($cate[$key]['image'], '@');
     }
     $this->assign('cate', $cate);
     $this->assign('page', $page);
     $this->display();
 }