<?php
/**
 *  控制器
 */
class <$controller> extends MY_Controller{
	public function __construct(){
		parent::__construct();
		$this->m=$this->load->model("<$controller>m");//加载新闻模型
		$this->m=$this-><$controller>m;//重命名新闻模型
		$this->model=$this->router->class;//当前模块名称
		
	}
	
	public function index(){
	   $this->lists();
	}
	public function lists($catid=''){
		 
		$tp="<$controller>_list";	  
		/*手机端响应式处理*/
		$w_style=$_GET['b'];
		$tp=auto_tp($tp,'wap/wap_'.$tp,$w_style);
		/*手机端响应式结束*/
		
		  $pagecatid=$catid;
		
		 if($catid){
		    $catid=$this->p->ar_catid($catid);//获取栏目下所有子类ID
			$where="catid in({$catid})";
		 }else{
		    $where='';
		 }
		 
		 //读取当前栏目和顶级栏目信息
      $this->category=$data['category']=$this->p->get_category_info2($this->model,'lists',$pagecatid);//读取当前栏目和顶级栏目信息
		 if($data['category']!=false){
			$this->load->vars('category',$data['category']);//当前栏目
			$this->load->vars('top_category',$data['category']['top']);//顶级栏目
			$this->load->vars('parent_category',$data['category']['parent']);//父级栏目
		 }
	
	  //读取伪静态路由规则
	  $this->config->load('my_routes',true);
	  $data_routes= $this->config->item('my_routes');
	  $this->load->vars('my_routes',$data_routes['my_routes']);

	     //统计数量
		$count = $this->m->lists('','',$where,'count');
		//配置分页
		$GLOBALS['wl_page']['test']=isset($GLOBALS['wl_page']['test'])?$GLOBALS['wl_page']['<$controller>']:10;
		$page_list = config_page($count,$data_routes['my_routes'][$pagecatid],$GLOBALS['wl_page']['<$controller>']);
		$this->my_page->initialize($page_list);
		$data['list'] = $this->m->lists($page_list['perpage'],$page_list['nowindex'],$where);
		$pages=trim($this->my_page->show()) ? $this->my_page->show() : " ";
		
		$this->load->vars('data',$data);
		$this->load->vars('pages',$pages);
		$this->load->view($tp);

	}
	
	public function show($id=''){
		 $tp="<$controller>_show";	  
		/*手机端响应式处理*/
		$w_style=$_GET['b'];
		$tp=auto_tp($tp,'wap/wap_'.$tp,$w_style);
		/*手机端响应式结束*/
		
	  $id=$this->uri->segment(2);
	   $id=intval($id);
	//读取当前栏目和顶级栏目信息
      $this->category=$data['category']=$this->p->get_category_info2($this->model,'show',$id);//读取当前栏目和顶级栏目信息
		 if($data['category']!=false){
			$this->load->vars('category',$data['category']);//当前栏目
			$this->load->vars('top_category',$data['category']['top']);//顶级栏目
			$this->load->vars('parent_category',$data['category']['parent']);//父级栏目
		 }
		  //读取伪静态路由规则
		  $this->config->load('my_routes',true);
		  $data_routes= $this->config->item('my_routes');
		  $this->load->vars('my_routes',$data_routes['my_routes']);

	        if($this->category==false){$this->load->view('error_404'); return false;}
		    $data=$this->p->routes_show($id,$this->model);
			$data_page=$this->p->get_next_page2($id,$this->model,$this->category['id'],$this->category['catdir']);          
		   $this->load->vars('data_page',$data_page);
	        $this->load->vars('data',$data);	
		    $this->load->view($tp);
	}

	
	

}
	