<?php
if (!defined('IN_59MIAO'))
{
	exit('Access Defined');
}
class MallAction extends Action {
	private $_nav=null;	
	private $_apiaction=null;
	private $_keywords='';
	public function __construct() {
		parent::__construct();
		if (!$this->_tpl->is_cached(SMARTY_FRONT.'/mall.tpl',$_SERVER["REQUEST_URI"])) {
			$this->_nav = new NavModel();	
			$this->_keywords=new KeywordsModel();
		}
	}	
	//实现初始页面
	public function index() {
		if (!$this->_tpl->is_cached(SMARTY_FRONT.'/mall.tpl',$_SERVER["REQUEST_URI"])) {	
			$this->setSeo();
			$AllNav=$this->_nav->findAllFront();
			$this->_tpl->assign('AllNav',$AllNav['allnav']);
	
			$AllKeywords=$this->_keywords->findAllFront();			
			$this->_tpl->assign('KeyWords',$AllKeywords);	
			//获取分类信息
			$ShopCats=$this->_model->GetAllCat();	
			//print_r($ShopCats);	
			$allliste=$this->_model->GetAllSeller();
			$AllShopCats=$allchild=array();
			foreach ($ShopCats as $v){	
				$allchild=array();
				foreach ($allliste as $key=>$value){
					$site_logo = $value->site_logo;
					$net_logo=$value->net_logo;
					if(file_exists($site_logo)){
						$value->logo=$site_logo;
					}
					else{
						$value->logo=$net_logo;
					}					
					$arr=explode(",",$value->sitetype);
					if (in_array($v->cid, $arr)) {				
						$allchild[]=array(						
									'id'=>$value->id,
									'name'=>$value->name,
									'logo'=>$value->logo													
						);
					}
					else{
						continue;
					}
				}
				$AllShopCats[]=array(
						'cats'=>array(
								'cid'=>$v->cid,
								'name'=>$v->name
							),
						'shoplist'=>$allchild
					
				);	
			}				
			$this->_tpl->assign('shopcats',$ShopCats);	
			$this->_tpl->assign('allshopcats',$AllShopCats);
		}	
		$this->_tpl->display(SMARTY_FRONT.'/mall.tpl',$_SERVER["REQUEST_URI"]);
	}	
	//seo 设置
	private function setSeo(){
		error_reporting(0);		
		$site_title=$this->_site_title;
		$site_titleb=$this->_site_titleb;
		$site_keywords=$this->_site_keywords;
		$site_description=$this->_site_description;
		if(file_exists('./configs/seo_config.inc.php')){
			require_once './configs/seo_config.inc.php';	
		}				
		$this->_tpl->assign('title',$mall_title);
		$this->_tpl->assign('keywords',$mall_keywords);
		$this->_tpl->assign('description',$mall_info);
	}

}

?>