<?php
class tagsControl extends skymvc{
	
	public function __construct(){
		parent::__construct();
		$this->loadModel(array("product","category","comment","product_data","user","feeds"));
		$this->loadConfig("c_category_children");
	}
	
	public function onDefault(){
		
		$this->smarty->display("tags/index.html");
	}
	
	public function onList(){
		
		$this->smarty->display("tags/list.html");
	}
	
	public function onShow(){
		$w=" status<99 AND isproduct=1 ";
		$url="/index.php?m=tags&a=show";
		 
		$tagname=get('tagname','h');
		if($tagname){
			$w.=" AND title like '%{$tagname}%' ";
			$url.="&tagname=".urlencode($tagname);
		}
		$this->smarty->assign("baseurl",$url);
		/*
		if(is_robot()){
			$w.=" AND status<10 ";
			$ord=" id DESC";	
		}else{*/
			$w.=" AND status<10  ";
			if(get('order')=='hot'){
				$ord=" grade DESC";
				$url.="&order=hot";
			}else{
				$ord=" id DESC";
				$url.="&order=new";
			}
		 
		
						 
		$pagesize=ISWAP?24:48;
		$start=get('per_page','i');
		
		$rscount=true;
		$list=$this->product->select(array(
			"where"=>$w,
			"start"=>$start,
			"limit"=>$pagesize,
			"order"=>$ord
			
		),$rscount);
		
		$pagelist=$this->pagelist($rscount,$pagesize,$url);
		 
		$c=$this->category->selectRow(array("where"=>array("id"=>$catid)));
		$seo=array(
			"title"=>strip_tags($c['title']),
			"keywords"=>$c['keywords'],
			"description"=>$c['description']
		);
		if(get('ajax')){
			exit(json_encode($list));
		}
		$this->smarty->assign(
			array(
			"baseurl"=>$url,
			"seo"=>$seo,
			"list"=>$list,
			"pagelist"=>$pagelist,
			"rscount"=>$rscount,
			"pagesize"=>$pagesize,
			)
		);
		$this->smarty->display("tags/show.html");
	}
	
}
?>