Пример #1
0
  public function lists(){
	//分类
	$model = M('ProductType');
	$data['pid'] = 0;
	$types = $model->where($data)->select();
	$this->assign('types',$types);
	//众筹
    $model = M('Projects');
	$data = $this->_search();
	$page = $_GET['p'] ? $_GET['p'] : 1;
	$order = 'id desc';
	$count = $model->where($data)->count();
	import("@.ORG.Util.Page");
	$page_size = 12;
	$p = new Page ( $count, $page_size );
	$page_count = ceil($count / $page_size);
	$pageno = $_GET['p'] ? $_GET['p'] : 1;
	$offset = ($pageno - 1) * $page_size;
	$list = $model->where($data)->order($order)->limit($offset.','.$page_size)->select();
	//echo $model->getlastsql();
	$page = $p->show ();
	$this->assign('list', $list);
	$this->assign('p',$pageno);
	$this->assign ("page",$page );
	$this->assign('count',$count);
	$this->assign('page_count', $page_count);
	//信息
	$title = '众筹页- '.C('site_name');
	$keywords = '众筹页';
	$description = '众筹页';
	$this->assign('title', $title);
	$this->assign('keywords', $keywords);
	$this->assign('description', $description);  
    $this->display();
  }
Пример #2
0
  /**
   * 交易记录
   */
  public function index(){
	$model = D('Record');
	$where = $this->_search();//获得查询条件
	if(isset($_GET['_order'])) {
		$order = $_GET['_order'];
	}else {
		$order = !empty($sortBy)? $sortBy: $model->getPk();
	}
	//排序方式默认按照倒序排列
	//接受 sost参数 0 表示倒序 非0都 表示正序
	if(isset($_GET['_sort'])) {
		$sort = $_GET['_sort']?'asc':'desc';
	}else {
		$sort = $asc?'asc':'desc';
	}
	if(!empty($_GET['listRows'])) {
		$listRows  =  $_GET['listRows'];
	}else{
		$page_size = C('page_size');
		$listRows = $page_size ? $page_size : 10;
	}
	$count = $model->where($where)->count();
	$page_count = ceil($count/$listRows);
	$this->assign('count',$count);
	$this->assign('page_count',$page_count);
	if($count>0){
	  import("@.ORG.Util.Page");
	  //创建分页对象
	  //$listRows = 1;
	  $p = new \Page($count,$listRows);
	  $list = $model->field('payment_mode,payment_company,pay_type,amount,balance,create_time,status')->where($where)->order('id desc')->limit($p->firstRow.','.$p->listRows)->select();
	  //分页显示
	  $page       = $p->Show();
	}
	//dump($list);exit;
	//列表排序显示
	$sortImg    = $sort ;                                   //排序图标
	$sortAlt    = $sort == 'desc'?'升序排列':'倒序排列';    //排序提示
	$sort       = $sort == 'desc'? 1:0;                     //排序方式
	//模板赋值显示
	$this->assign('list',$list);
	$this->assign('sort',$sort);
	$this->assign('order',$order);
	$this->assign("page",$page);
	$this->assign('headerTitle','交易明细');
	$this->assign('headerKeywords','交易明细');
	$this->assign('headerDescription','交易明细');
	$this->assign('wx_title','交易明细');
	$this->assign('wx_desc',C('wx_desc'));
    $this->display();
  }
Пример #3
0
  /**
   * 列表页
   */
  public function index(){
	$model = D('MemberCoupon');
	$where = $this->_search();//获得查询条件
	if(isset($_GET['_order'])) {
		$order = $_GET['_order'];
	}else {
		$order = !empty($sortBy)? $sortBy: $model->getPk();
	}
	//排序方式默认按照倒序排列
	//接受 sost参数 0 表示倒序 非0都 表示正序
	if(isset($_GET['_sort'])) {
		$sort = $_GET['_sort']?'asc':'desc';
	}else {
		$sort = $asc?'asc':'desc';
	}
	if(!empty($_GET['listRows'])) {
		$listRows  =  $_GET['listRows'];
	}else{
		$page_size = C('page_size');
		$listRows = $page_size ? $page_size : 10;
	}
	$count = $model->where($where)->count();
	$page_count = ceil($count/$listRows);
	$this->assign('count',$count);
	$this->assign('page_count',$page_count);
	if($count>0){
	  import("@.ORG.Util.Page");
	  //创建分页对象
	  //$listRows = 1;
	  $p = new Page($count,$listRows);
	  $list = $model->alias('a')->join('`'.C('DB_PREFIX').'coupon` as b on a.coupon_id=b.id')->field('a.*,b.title,b.info,b.value,b.btime,b.etime')->where($where)->order('a.status asc,id desc')->limit($p->firstRow.','.$p->listRows)->select();
	  //分页显示
	  $page       = $p->Show();
	}
	//dump($list);exit;
	//列表排序显示
	$sortImg    = $sort ;                                   //排序图标
	$sortAlt    = $sort == 'desc'?'升序排列':'倒序排列';    //排序提示
	$sort       = $sort == 'desc'? 1:0;                     //排序方式
	//模板赋值显示
	$this->assign('list',$list);
	$this->assign('sort',$sort);
	$this->assign('order',$order);
	$this->assign("page",$page);
	$this->assign('headerTitle','我的优惠券');
	$this->assign('headerKeywords','我的优惠券');
	$this->assign('headerDescription','我的优惠券');
	$this->assign('wx_title','我的优惠券');
	$this->assign('wx_desc',C('wx_desc'));
    $this->display();
  }
Пример #4
0
  /**
   * 首页
   */
  public function index(){
	$model = M('FlagList');
	$fl_data['fid'] = 14;
	$ads = $model->field('b.id,title,shorttitle,lit_pic2 as lit_pic,content,b.create_time')->alias('a')->join('`zy_article` as b on a.sourceid=b.id')->where($fl_data)->limit(4)->order('a.orderindex asc,b.id desc')->select();
	$this->assign('ads',$ads);
	foreach($ads as $ad){
	  $ids[] = $ad['id'];
	}
	//分类
	$type_model = M('classify');
	$type_data['id'] = array('gt',1);
	$type_data['pid'] = 0;
	$types = $type_model->where($type_data)->select();
	$this->assign('types',$types);
	//列表
    $model = M('article');
	$data = $this->_search();
	//dump($data);
	$data['id'] = array('not in',$ids);
	$page = $_GET['p'] ? $_GET['p'] : 1;
	$order = 'create_time desc,id desc';
	$count = $model->where($data)->count();
	//echo $model->getlastsql();
	import("@.ORG.Util.Page");
	$page_size = 12;
	$p = new Page ( $count, $page_size );
	$page_count = ceil($count / $page_size);
	$pageno = $_GET['p'] ? $_GET['p'] : 1;
	$offset = ($pageno - 1) * $page_size;
	$list = $model->field('id,lit_pic,title,content,create_time')->where($data)->order($order)->limit($offset.','.$page_size)->select();
	//echo $model->getlastsql();
	//dump($list);
	$page = $p->show ();
	$this->assign('list', $list);
	$this->assign('p',$pageno);
	$this->assign ("page",$page );

	//dump($page);exit;
	$this->assign('count',$count);
	$this->assign('page_count', $page_count);
	$title = '艺术品咨询- '.$this->configs['webname'];
	$keywords = $product['keywords'];
	$description = $product['description'];
	$this->assign('title', $title);
	$this->assign('keywords', $keywords);
	$this->assign('description', $description);
    $this->display();
  }
Пример #5
0
 public function category()
 {
     $id = Q('get.id', 0, 'intval');
     $article = Db::table('article')->where('cid', $id)->get();
     $page = Page::row(5)->make(count($article));
     $article = Db::table('article')->where('cid', $id)->limit(Page::limit())->get();
     $field = Db::table('category')->where('id', $id)->first();
     // p($field);exit;
     View::with('page', $page)->with('cms', $field)->with('article', $article);
     View::make($this->tpl . '/category.html');
 }
Пример #6
0
 public function index()
 {
     $User = D("Shop");
     // 实例化User对象
     import('@.Util.Page');
     // 导入分页类
     $where = array();
     $count = $User->where($where)->count();
     // 查询满足要求的总记录数
     $Page = new Page($count, 25);
     // 实例化分页类 传入总记录数和每页显示的记录数
     $Page->setConfig('theme', "%upPage% %linkPage% %downPage%");
     $show = $Page->show();
     // 分页显示输出
     // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
     $list = $User->where($where)->order($this->orderby)->limit($Page->firstRow . ',' . $Page->listRows)->select();
     // echo D()->getLastSql();
     $this->assign('list', $list);
     // 赋值数据集
     $this->assign('page', $show);
     // 赋值分页输出
     $this->display("index");
     // 输出模板
 }
Пример #7
0
 protected function getGoods()
 {
     //读取当前路径参数条件下的所有商品
     $args = explode('-', $_GET['s']);
     //拆解路径
     $args = array_filter($args);
     //过滤没有筛选条件属性
     $brand = Q('brand_id') ? ' and brand_id=' . Q('brand_id') : '';
     //添加品牌筛选条件
     //添加价格筛选条件
     if (!Q('price_level')) {
         //价格等级为0时,不添加筛选条件
         $price = '';
     } else {
         $price_level = explode('-', Q('price_level'));
         if (sizeof($price_level) == 1) {
             $price = ' and goods_price>' . $price_level[0];
         } else {
             $price = ' and goods_price between ' . $price_level[0] . ' and ' . $price_level[1];
         }
     }
     //A:如果规格中有相同的属性值,可能会出现问题
     //B:如果多个分组公用同一个类型时,可能会出现重复的情况
     if ($args) {
         $v = "('" . implode("','", $args) . "')";
         $sql = "select * from hd_goods_attr ga \n                    left join hd_goods g \n                    on ga.goods_id=g.goods_id \n                    where ga.goods_attr_value in " . $v . " \n                    and g.cate_id=" . Q('cate_id') . $brand . $price . " \n                    group by g.goods_id \n                    having count(*)=" . sizeof($args);
         $goods_count = sizeof(Db::select($sql));
         $page = Page::make($goods_count);
         //分页
         $sql = "select * from hd_goods_attr ga \n                    left join hd_goods g \n                    on ga.goods_id=g.goods_id \n                    where ga.goods_attr_value in " . $v . " \n                    and g.cate_id=" . Q('cate_id') . $brand . $price . " \n                    group by g.goods_id \n                    having count(*)=" . sizeof($args) . " \n                    limit " . Page::limit();
         // echo $sql;
         $data = Db::select($sql);
         // //查询商品属性表,找出当前分类、满足筛选条件的记录
         // $goods = Db::table('goods_attr')->whereIn('goods_attr_value',$args)->groupBy('goods_id')->having('count(*)','=',sizeof($args))->get();
         // $page = Page::make(sizeof($goods)); //分页
         // //根据分页限制获取商品
         // $goods_limit = Db::table('goods_attr')->whereIn('goods_attr_value',$args)->groupBy('goods_id')->having('count(*)','=',sizeof($args))->limit(Page::limit())->get();
         // foreach ($goods_limit as $k => $v) {
         //     //根据查出的ID反查出商品信息
         //     $data[$k]= Db::table('goods')->where('goods_id',$v['goods_id'])->where('cate_id',$_GET['cate_id'])->first();
         // }
     } else {
         $brand = Q('brand_id') ? ' and brand_id=' . Q('brand_id') : '';
         //添加品牌筛选条件
         $sql = "select * from hd_goods where cate_id=" . Q('cate_id') . $brand . $price;
         $goods_count = sizeof(Db::select($sql));
         $page = Page::make($goods_count);
         //分页
         $sql = "select * from hd_goods where cate_id=" . Q('cate_id') . $brand . $price . " limit " . Page::limit();
         $data = Db::select($sql);
         // $goods_count = sizeof(Db::select($sql));
         // $page = Page::row(2)->make($goods_count); //分页
         // $sql = "select * from hd_goods_attr ga
         //         left join hd_goods g
         //         on ga.goods_id=g.goods_id
         //         where ga.goods_attr_value in ".$v."
         //         and g.cate_id=".Q('cate_id').$brand."
         //         group by g.goods_id
         //         having count(*)=".sizeof($args)."
         //         limit ".Page::limit();
         // echo $sql;
         // $data = Db::select($sql);
         // //查询商品找出当前分类的记录
         // $goods = Db::table('goods')->where('cate_id',$_GET['cate_id'])->get();
         // $page = Page::make(sizeof($goods)); //分页
         // //根据分页限制获取商品
         // $goods_limit = Db::table('goods')->where('cate_id',$_GET['cate_id'])->limit(Page::limit())->get();
         // foreach ($goods_limit as $k => $v) {
         //     //根据查出的ID反查出商品信息
         //     $data[$k]= Db::table('goods')->where('goods_id',$v['goods_id'])->first();
         // }
     }
     $goodsData['page'] = $page;
     $goodsData['data'] = $data;
     return $goodsData;
 }
 /**
  * 排序
  */
 public function sort()
 {
     $b_data['pid'] = 0;
     $blist = $this->db->where($b_data)->order('sort asc,id asc')->select();
     $this->assign('blist', $blist);
     if ($_GET['pid']) {
         $data['pid'] = $_GET['pid'];
         $count = $this->db->where($data)->count();
         //创建分页对象
         $listRows = '20';
         $p = new \My\Page($count, $listRows);
         $pageno = $_GET['p'] ? $_GET['p'] : 1;
         $offset = ($pageno - 1) * $page_size;
         $p = new Page($count, $listRows);
         $list = $this->db->where($data)->order('sort asc,id asc')->limit($p->firstRow . ',' . $p->listRows)->select();
         //echo $model->getlastsql();
         $page = $p->Show();
         $this->assign('page', $page);
         $this->assign('list', $list);
     }
     $this->display();
 }
Пример #9
0
 /**
  * 排序页面
  */
 public function sort()
 {
     $count = $this->db->where($data)->count();
     //创建分页对象
     $listRows = '20';
     $p = new \My\Page($count, $listRows);
     $pageno = $_GET['p'] ? $_GET['p'] : 1;
     $offset = ($pageno - 1) * $page_size;
     $p = new Page($count, $listRows);
     $list = $this->db->field('*')->where($data)->order('sort asc,id desc')->limit($p->firstRow . ',' . $p->listRows)->select();
     $page = $p->Show();
     $this->assign('page', $page);
     $this->assign('list', $list);
     $this->display();
 }
Пример #10
0
 protected function getPageData($model, $listRows, $parameter, $order, $table)
 {
     $db_pre = C('db_prefix');
     if (!class_exists('Page')) {
         import('ORG.Util.Page');
     }
     $model = is_object($model) ? $model : M($model);
     $count = (int) $model->table($db_pre . $table)->where($parameter)->order($order)->count();
     $page = new Page($count, $listRows);
     $page->parameter = http_build_query($parameter);
     $return = array('page_list' => $page->show(), 'data_list' => (array) $model->table($db_pre . $table)->where($parameter)->order($order)->limit($page->firstRow . ',' . $page->listRows)->findAll());
     return $return;
 }
Пример #11
0
  /**
   * 列表页
   */
  public function index(){
	$model = D('Order');
	$od_model = D('OrderDetail');
	$where = $this->_search();//获得查询条件
	//dump($where);
	if(isset($_GET['_order'])) {
		$order = $_GET['_order'];
	}else {
		$order = !empty($sortBy)? $sortBy: $model->getPk();
	}
	//排序方式默认按照倒序排列
	//接受 sost参数 0 表示倒序 非0都 表示正序
	if(isset($_GET['_sort'])) {
		$sort = $_GET['_sort']?'asc':'desc';
	}else {
		$sort = $asc?'asc':'desc';
	}
	if(!empty($_GET['listRows'])) {
		$listRows  =  $_GET['listRows'];
	}else{
		$page_size = C('page_size');
		$listRows = $page_size ? $page_size : 10;
	}
	$count = $model->where($where)->count();
	$page_count = ceil($count/$listRows);
	$this->assign('count',$count);
	$this->assign('page_count',$page_count);
	if($count>0){
	  import("@.ORG.Util.Page");
	  //创建分页对象
	  //$listRows = 1;
	  $p = new Page($count,$listRows);
	  $list = $model->field('id,order_sn,payment_mode,actual_paid,create_time,is_rate,pay_status,delivery_status,status')->where($where)->order($order.' '.$sort)->limit($p->firstRow.','.$p->listRows)->select();
	  foreach($list as $val){
	    $order_ids[] = $val['id'];
		$id = $val['id'];
		if($val['status']==1){
		  if($val['pay_status']==0){
		    $val['status_name'] = '待支付';
			$val['state'] = 0;
		  }else{
		    if($val['delivery_status']==0){
			  $val['status_name'] = '待发货';
			  $val['state'] = 1;
			}else{
			  $val['status_name'] = '已发货';
			  $val['state'] = 2;
			}
		  }
		}else if($val['status']==2){
		  $val['status_name'] = '完成交易';
		  if($val['is_rate']==0){
		    $val['status_name'] = '待评价';
		  }
		  $val['state'] = 3;
		}else if($val['status']==-1){
		  $val['status_name'] = '订单已关闭';
		}else{
		  $val['status_name'] = '订单未确认';
		}
		$list2[$id] = $val;
	  }
	  //dump($list2);exit;
	  $od_data['order_id'] = array('in',$order_ids);
	  $items = $od_model->field('id,order_id,order_sn,product_name,spec,lit_pic,price,num,refund_status,status')->where($od_data)->order('id desc')->select();
	  foreach($items as $val){
		$id = $val['order_id'];
		//组装详细单号
	    $list2[$id]['items'][] = $val;
		$list2[$id]['item_count']++;
	  }
	  //分页显示
	  $page       = $p->Show();
	}
	//dump($list2);exit;
	//列表排序显示
	$sortImg    = $sort ;                                   //排序图标
	$sortAlt    = $sort == 'desc'?'升序排列':'倒序排列';    //排序提示
	$sort       = $sort == 'desc'? 1:0;                     //排序方式
	//模板赋值显示
	$this->assign('list',$list2);
	$this->assign('sort',$sort);
	$this->assign('order',$order);
	$this->assign("page",$page);
	$this->assign('headerTitle','订单列表页');
	$this->assign('headerKeywords','订单列表页');
	$this->assign('headerDescription','订单列表页');
	$this->assign('wx_title','订单列表页');
	$this->assign('wx_desc',C('wx_desc'));
    $this->display();
  }
Пример #12
0
 public function search()
 {
     $search_type = I('search_type');
     $keywords = I('keyword');
     $tid = I('tid');
     switch ($search_type) {
         case 'title':
             $map['title'] = array('like', '%' . $keywords . '%');
             $count = D('ArticleRelation')->relation(true)->where($map)->count();
             import('Common/Org/Util/Page');
             $page = new \Page($count, 2);
             $search = D('ArticleRelation')->relation(true)->where($map)->limit($page->limit())->select();
             foreach ($search as $k => $v) {
                 $search[$k]['keywords'] = explode(',', $v['keywords']);
                 $search[$k]['title'] = str_replace($keywords, '<b style="color:red">' . $keywords . '</b>', $v['title']);
             }
             break;
         case 'key_words':
             $search = M('article')->select();
             foreach ($search as $k => $v) {
                 $v['keywords'] = explode(',', $v['keywords']);
                 if (in_array($keywords, $v['keywords'])) {
                     foreach ($v['keywords'] as $key => $value) {
                         if ($value == $keywords) {
                             $values[] = str_replace($value, '<span style="color:red">' . $value . '</span>', $value);
                         } else {
                             $values[] = $value;
                         }
                     }
                     $v['keywords'] = $values;
                     $search_keywords[] = $v;
                 }
             }
             $search = $search_keywords;
             break;
         case 'tag':
             $sql = "SELECT aid FROM think_tag WHERE tagname='{$keywords}'";
             $aid = M()->query($sql);
             foreach ($aid as $k => $v) {
                 $aids[] = $v['aid'];
             }
             $map['id'] = array('in', $aids);
             $count = D('ArticleRelation')->relation(true)->where($map)->count();
             import('Common/Org/Util/Page');
             $page = new \Page($count, 2);
             $search = D('ArticleRelation')->relation(true)->where($map)->limit($page->limit())->select();
             foreach ($search as $k => $v) {
                 $values = array();
                 foreach ($v['tag'] as $key => $value) {
                     if ($keywords) {
                         $values[$key]['tagname'] = str_replace($keywords, '<b style="color:red">' . $value['tagname'] . '</b>', $value['tagname']);
                     } else {
                         $values[$key]['tagname'] = $value;
                     }
                 }
                 $search[$k]['tag'] = $values;
             }
             break;
     }
     $this->pageshow = $page->show();
     $this->keyword = $keywords;
     $this->assign('search', $search);
     $this->display('search');
 }
Пример #13
0
  public function lists(){
	//分类
	$model = M('product_type');
	$data['pid'] = 0;
	$types = $model->where($data)->select();
	$this->assign('types',$types);
	//数据
    $model = M('Auction');
	$data = $this->_search();
	$page = $_GET['p'] ? $_GET['p'] : 1;
	if($_GET['order']==1){
	  $order = 'create_time desc,id desc';
	}else if($_GET['order']==2){
	  $order = 'price desc';
	}else if($_GET['order']==2){
	  $order = 'look_num desc';
	}else{
	  $order = 'create_time desc,id desc';
	}
	
	$count = $model->where($data)->count();
	import("@.ORG.Util.Page");
	$page_size = 12;
	$p = new Page ( $count, $page_size );
	$page_count = ceil($count / $page_size);
	$pageno = $_GET['p'] ? $_GET['p'] : 1;
	$offset = ($pageno - 1) * $page_size;
	$list = $model->field('*')->where($data)->order($order)->limit($offset.','.$page_size)->select();
	$page = $p->show ();
	unset($data);
	//价高数量
	$data['type'] = 1;
	$data['status'] = 1;
	$data['endtime'] = array('gt',time());
	$jg_count = $model->where($data)->count();
	//价低
	$data['type'] = 2;
	$jd_count = $model->where($data)->count();
	//组装URL
	$url  =  preg_replace("/\/_order.+/", "",__SELF__);
	if(ACTION_NAME=='index'){
	  $pos = strpos($url,'index/');
	  if($pos===false){
	    $url = $url.'/index';
	  }
	}
	$this->assign('url',$url);
	$this->assign('jg_count',$jg_count);
	$this->assign('jd_count',$jd_count);
	$this->assign('list', $list);
	$this->assign('p',$pageno);
	$this->assign ("page",$page );
	$this->assign('count',$count);
	$this->assign('page_count', $page_count);
	$title = '艺术品拍卖-'.$this->configs['webname'];
	$keywords = $product['keywords'];
	$description = $product['description'];
	$this->assign('title', $title);
	$this->assign('keywords', $keywords);
	$this->assign('description', $description);
    $this->display();
  }
Пример #14
0
 /**
  * 专题页面栏目
  */
 public function group()
 {
     //**字符截取函数
     import('Class.String', APP_PATH);
     //文件在当前项目目录下的class目录
     $id = I('get.id');
     //类别ID
     //dump($id);
     //exit;
     //**获取栏目的下级所有子栏目
     import('Class.Category', APP_PATH);
     //文件在当前项目目录下的class目录
     $m = D('Column')->order('column_sort ASC')->relation(true)->select();
     $m = Category::getChilds($m, $id);
     //获取id所有的下级栏目的信息
     //二级导航栏目的url,可根据手机站或pc站自动适配url
     $modlu = __ACTION__;
     strpos($modlu, "wap");
     if (strpos($modlu, "wap") == '') {
         //如果url中不存在wap(不区分大小写)
         //栏目url
         foreach ($m as $k3 => $v3) {
             $m[$k3]['url'] = __APP__ . '/' . $v3['url'] . '/' . group . '/' . 'id' . '/' . $v3['id'];
         }
     } else {
         //栏目url
         foreach ($m as $k3 => $v3) {
             $m[$k3]['url'] = __APP__ . '/' . 'wap' . '/' . $v3['url'] . '/' . group . '/' . 'id' . '/' . $v3['id'];
         }
     }
     $this->assign('navlist', $m);
     // 		var_dump($m);
     // 		exit;
     //**获取子栏目的上级栏目
     import('Class.Category', APP_PATH);
     //文件在当前项目目录下的class目录
     $m = D('Column')->order('column_sort ASC')->relation(true)->select();
     $m = Category::getParents($m, $id);
     //获取nv_id所有的上级栏目的信息
     //全局导航栏目的url,可根据手机站或者pc站石洞适配url
     $modlu = __ACTION__;
     strpos($modlu, "wap");
     if (strpos($modlu, "wap") == '') {
         //如果url中不存在wap(不区分大小写)
         //栏目url
         foreach ($m as $k3 => $v3) {
             $m[$k3]['url'] = __APP__ . '/' . $v3['url'] . '/' . group . '/' . 'id' . '/' . $v3['id'];
         }
     } else {
         //栏目url
         foreach ($m as $k3 => $v3) {
             $m[$k3]['url'] = __APP__ . '/' . 'wap' . '/' . $v3['url'] . '/' . group . '/' . 'id' . '/' . $v3['id'];
         }
     }
     //var_dump($m);
     //exit;
     $this->assign('topnavlist', $m);
     //**全局导航 判断设置最后一个没有尖括号
     $last = count($m) - 1;
     $this->assign('last', $last);
     //echo $last;
     //exit;
     //**获取当前栏目的信息
     $topcate = D('Column')->where("id={$id}")->order('column_sort')->relation(true)->select();
     $this->assign('nav_list', $topcate);
     //dump($topcate);
     //exit;
     if ($topcate == null) {
         $this->error('参数错误');
     }
     $this->assign('blist', $topcate);
     //****SEO信息
     $title = $topcate[0]['column_name'];
     $m = M('Config');
     $data = $m->field('config_webname')->find();
     //dump($data);
     //exit;
     $title = $title . ' - ' . $data['config_webname'];
     //dump($title);
     //exit;
     $keywords = $topcate[0]['column_keyw'];
     $description = $topcate[0]['column_descr'];
     $this->assign('title', $title);
     $this->assign('keywords', $keywords);
     $this->assign('description', $description);
     //dump($title);
     //exit;
     //**获取所有栏目的信息
     import('Class.Category', APP_PATH);
     $m = D('Column')->order('column_sort')->relation(true)->select();
     //查询所有栏目的信息
     //dump($m);
     //exit;
     //****查询指定id的栏目下的所有子栏目文章
     foreach ($topcate as $k => $v) {
         $cids = Category::getChildsId($m, $v['id']);
         //传递一个父级分类ID返回所有子分类ID
         $cids[] = $v['id'];
         //将父级id也压进来赋值给$cids
         //dump($cids);
         //exit;
         $where = array('nv_id' => array('IN', $cids));
         //查询新闻表nv_id字段和$cids相等时的数据
         $topcate[$k]['news'] = D('News')->where($where)->where("news_dell=0")->relation(true)->select();
         $result = $topcate[$k]['news'];
         //查询新闻表下的所有文章   查询新闻数据赋值给字段news
         //**分页实现代码
         import('ORG.Util.Page');
         // 导入分页类
         $count = count($result);
         // 查询满足要求的总记录数
         $Page = new Page($count, 5);
         // 实例化分页类 传入总记录数和每页显示的记录数
         $show = $Page->show();
         // 分页显示输出
         //**分页实现代码
         //查询数据,实现分页
         $where = array('nv_id' => array('IN', $cids));
         //查询新闻表nv_id字段和$cids相等时的数据
         $m = D('News');
         $field = 'g.id,g.news_content,g.news_title,g.news_pic,g.news_sort';
         $topcate[$k]['news'] = $m->alias('g')->join('LEFT JOIN tuzi_attr i ON i.id = g.news_type')->join('LEFT JOIN tuzi_column c ON c.id = g.nv_id')->field($field)->where($where)->where("news_dell=0")->order('news_sort,id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
         $result = $topcate[$k]['news'];
         //查询新闻表下的所有文章   查询新闻数据赋值给字段news
         //     		dump($result);
         //     		exit;
     }
     //循环过滤html src标签和截取中文函数  用于摘要简介  substr_ext函数写在commonaction.class.php中
     foreach ($result as $k2 => $v2) {
         $result[$k2]['news_content'] = $this->substr_ext($v2['news_content'], 0, 160, 'utf-8', "");
     }
     foreach ($result as $k2 => $v2) {
         $result[$k2]['news_title'] = $this->substr_ext($v2['news_title'], 0, 20, 'utf-8', "");
     }
     //全局导航栏目的url,可根据手机站或者pc站石洞适配url
     $modlu = __ACTION__;
     strpos($modlu, "wap");
     if (strpos($modlu, "wap") == '') {
         //如果url中不存在wap(不区分大小写)
         //文章url
         foreach ($result as $k3 => $v3) {
             $result[$k3]['url'] = __APP__ . '/' . MODULE_NAME . '/' . detail . '/' . 'id' . '/' . $v3['id'];
         }
     } else {
         //文章url
         foreach ($result as $k3 => $v3) {
             $result[$k3]['url'] = __APP__ . '/' . 'wap' . '/' . MODULE_NAME . '/' . detail . '/' . 'id' . '/' . $v3['id'];
         }
     }
     // 		dump($result);
     // 		exit;
     //**分页实现代码
     $this->assign('page', $show);
     // 赋值分页输出
     //**分页实现代码
     $this->assign('vlist', $result);
     //dump($topcate);
     //dump($result);
     //exit;
     $this->display();
 }
 protected function _list($model, $map, $sort = '')
 {
     //排序字段 默认为主键名
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'];
     } else {
         if (in_array('sort', get_model_fields($model))) {
             $sort = "sort asc";
         } else {
             if (empty($sort)) {
                 $sort = "id desc";
             }
         }
     }
     //取得满足条件的记录数
     $count_model = clone $model;
     //取得满足条件的记录数
     $count = $count_model->where($map)->count();
     if ($count > 0) {
         //创建分页对象
         if (!empty($_REQUEST['list_rows'])) {
             $list_rows = $_REQUEST['list_rows'];
         } else {
             $list_rows = get_user_config('list_rows');
         }
         import("@.ORG.Util.Page");
         $p = new \Page($count, $list_rows);
         //分页查询数据
         $vo_list = $model->where($map)->order($sort)->limit($p->firstRow . ',' . $p->listRows)->select();
         //echo $model->getlastSql();
         $p->parameter = $this->_search($model);
         //分页显示
         $page = $p->show();
         if ($vo_list) {
             $this->assign('list', $vo_list);
             $this->assign('sort', $sort);
             $this->assign("page", $page);
             return $vo_list;
         }
     }
     return FALSE;
 }
Пример #16
0
  /**
    +----------------------------------------------------------
	* 根据表单生成查询条件
	* 进行列表过滤
    +----------------------------------------------------------
	* @access protected
    +----------------------------------------------------------
	* @param Model $model 数据对象
	* @param HashMap $map 过滤条件
	* @param string $sortBy 排序
	* @param boolean $asc 是否正序
    +----------------------------------------------------------
	* @return void
    +----------------------------------------------------------
	* @throws ThinkExecption
    +----------------------------------------------------------
	*/
  protected function _list($model, $map, $sortBy = '', $asc = false) {
	//排序字段 默认为主键名
	if (isset ( $_REQUEST ['_order'] )) {
		$order = $_REQUEST ['_order'];
	} else {
		$order = ! empty ( $sortBy ) ? $sortBy : $model->getPk ();
	}
	//排序方式默认按照倒序排列
	//接受 sost参数 0 表示倒序 非0都 表示正序
	if (isset ( $_REQUEST ['_sort'] )) {
		$sort = $_REQUEST ['_sort'] ? 'asc' : 'desc';
	} else {
		$sort = $asc ? 'asc' : 'desc';
	}
	//取得满足条件的记录数
	$count = $model->where ( $map )->count ();
	if (! empty ( $_REQUEST ['listRows'] )) {
		$listRows = $_REQUEST ['listRows'];
	} else {
		$page_size = C('page_size');
		$listRows = $page_size ? $page_size : 20;
	}
	$page_count = ceil($count/$listRows);
	$this->assign('count',$count);
	$this->assign('page_count',$page_count);
	if ($count > 0) {
		//import ( "@.ORG.Page1" );.
		//import("@.ORG.Util.Page");
		//创建分页对象
		$p = new \Page ( $count, $listRows );
		//分页查询数据

		$voList = $model->where($map)->order( "`" . $order . "` " . $sort)->limit($p->firstRow . ',' . $p->listRows)->select ( );
		//分页跳转的时候保证查询条件
		foreach ( $map as $key => $val ) {
			if (! is_array ( $val )) {
				$p->parameter .= "$key=" . urlencode ( $val ) . "&";
			}
		}
		//分页显示
		$page = $p->show ();
		//列表排序显示
		$sortImg = $sort; //排序图标
		$sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列'; //排序提示
		$sort = $sort == 'desc' ? 1 : 0; //排序方式
		//模板赋值显示
		$this->assign ( 'list', $voList );
		$this->assign ( 'sort', $sort );
		$this->assign ( 'order', $order );
		$this->assign ( 'sortImg', $sortImg );
		$this->assign ( 'sortType', $sortAlt );
		$this->assign ( "page", $page );
	}
	Cookie( '_currentUrl_', __SELF__ );
	return;
  }