<?php
if (!defined('IN_59MIAO'))
{
	exit('Access Defined');
}
class BitemAction extends Action{
	private $cid;
	private $sid;	
	private $iid;
	private $item;  //保存商品信息
	private $_keywords=''; //关键字信息
	public function __construct(){
		parent::__construct();	
		$this->iid = isset($_GET['iid'])?$_GET['iid']:null;
		if(!$this->iid)
		{
			Header("Location: index.php");
			exit;
		}		
		$this->_nav = new NavModel();	
		$this->_keywords=new KeywordsModel();
	}
	public function index(){
		if (!$this->_tpl->is_cached(SMARTY_FRONT.'/bitem.tpl',$_SERVER["REQUEST_URI"])) {			
			$AllNav=$this->_nav->findAllFront();
			$this->_tpl->assign('AllNav',$AllNav['allnav']);
			$this->getItemsDetail();			
			$this->GetRightItem();	
			$AllKeywords=$this->_keywords->findAllFront();
			$this->_tpl->assign('KeyWords',$AllKeywords);	
			
			//seo
			$this->setSeo();			
		}
		$this->_tpl->display(SMARTY_FRONT.'/bitem.tpl',$_SERVER["REQUEST_URI"]);
	
	}
	private function getItemsDetail(){		
			$this->item=$this->_model->getItemsDetail();
			$this->_tpl->assign('item',$this->item);
			$this->_tpl->assign('cid',$this->item['cid']);	
	}		
	//获取相关内容
	private function GetRightItem(){			
			$right_items = $this->_model->GetRightItem();			
			$this->_tpl->assign('right_items',$right_items);
	}

	//seo 设置
	private function setSeo(){
		error_reporting(0);			
		$product_title=$this->item['title'];  //商品名称
		$product_price=$this->item['price'];  //商品价格
		$product_seller=$this->item['seller_name'];  //商品卖家
		$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',$product_content_title);
		$this->_tpl->assign('keywords',$product_content_keywords);
		$this->_tpl->assign('description',$product_content_info);
	}	
}
?>