<?php
if (!defined('IN_59MIAO'))
{
	exit('Access Defined');
}
//Seo控制器
class SeoAction extends Action {
	public function __construct() {
		parent::__construct();
	}	
	public function index() {		
		$this->_tpl->assign('title','网站首页');
		$this->_tpl->assign('index_seo',true);
		$this->_tpl->assign('AllInfo',$this->_model->findOne('index'));
		$this->update('index', '网站首页修改失败,您可能没有做任何修改');
		$this->display();		
	}	
	public function mall(){
		$this->_tpl->assign('title','商家列表页');
		$this->_tpl->assign('mall_seo',true);
		$this->_tpl->assign('AllInfo',$this->_model->findOne('mall'));
		$this->update('mall', '商家列表页修改失败,您可能没有做任何修改');
		$this->display();		
	}
	//商家详情页面
	public function sellerlist(){
		$this->_tpl->assign('title','商家详情页');
		$this->_tpl->assign('sellerlist_seo',true);
		$this->_tpl->assign('AllInfo',$this->_model->findOne('seller_list'));
		$this->update('seller_list', '商家详情页修改失败,您可能没有做任何修改');
		$this->display();	
	}
	public function all(){
		$this->_tpl->assign('title','商品分类页');
		$this->_tpl->assign('all_seo',true);
		$this->_tpl->assign('AllInfo',$this->_model->findOne('all'));
		$this->update('all', '商品分类页修改失败,您可能没有做任何修改');
		$this->display();
	}
	public function promo(){
		$this->_tpl->assign('title','促销活动页');
		$this->_tpl->assign('promo_seo',true);
		$this->_tpl->assign('AllInfo',$this->_model->findOne('promo'));
		$this->update('promo', '促销活动页修改失败,您可能没有做任何修改');
		$this->display();
	}
	public function product_list(){
		$this->_tpl->assign('title','商品列表页');
		$this->_tpl->assign('product_list_seo',true);
		$this->_tpl->assign('AllInfo',$this->_model->findOne('product_list'));
		$this->update('product_list', '商品列表页修改失败,您可能没有做任何修改');
		$this->display();
	}	
	public function product_content(){
		$this->_tpl->assign('title','商品详细页');
		$this->_tpl->assign('product_content_seo',true);
		$this->_tpl->assign('AllInfo',$this->_model->findOne('product_content'));
		$this->update('product_content', '商品详细页修改失败,您可能没有做任何修改');
		$this->display();
	}	
	public function taoshop(){
		$this->_tpl->assign('title','淘宝店铺页');
		$this->_tpl->assign('taoshop_seo',true);
		$this->_tpl->assign('AllInfo',$this->_model->findOne('taoshop'));
		$this->update('taoshop', '淘宝店铺页修改失败,您可能没有做任何修改');
		$this->display();
	}	
	//购物资讯页面
	public function artile(){
		$this->_tpl->assign('title','购物资讯页');
		$this->_tpl->assign('artile_artile_seo',true);
		$this->_tpl->assign('AllInfo',$this->_model->findOne('artile'));
		$this->update('artile', '购物资讯列表页修改失败,您可能没有做任何修改');
		$this->display();
	}	
	public function artile_list(){
		$this->_tpl->assign('title','购物资讯列表页');
		$this->_tpl->assign('artile_list_seo',true);
		$this->_tpl->assign('AllInfo',$this->_model->findOne('artile_list'));
		$this->update('artile_list', '购物资讯列表页修改失败,您可能没有做任何修改');
		$this->display();
	}
	public function artile_content(){
		$this->_tpl->assign('title','购物资讯详细页');
		$this->_tpl->assign('artile_content_seo',true);
		$this->_tpl->assign('AllInfo',$this->_model->findOne('artile_content'));
		$this->update('artile_content', '购物资讯详细页修改失败,您可能没有做任何修改');
		$this->display();
	}		
	
	public function display(){		
		$this->_tpl->display(SMARTY_ADMIN.'seo/seo.tpl');
	}
	//显示rewrite规则
	public function showrewrite(){
		$this->seo_rewrite();	
		$this->_tpl->display(SMARTY_ADMIN.'seo/showrewrite.tpl');
	}
	//伪静态规则
	public function rule(){
		if(isset($_POST['send'])){
			$this->_model->set_rule()?$this->_redirect->succ(Tool::getPrevPage(), '恭喜您,SEO规则设置成功') : $this->_redirect->error('对不起,SEO规则设置失败');
		}
		$this->seo_rewrite();			
		$this->_tpl->display(SMARTY_ADMIN.'seo/rule.tpl');
	}
	private function seo_rewrite(){
		$this->_tpl->assign('rewrite',REWRITE);
		$this->_tpl->assign('rewrite_suffix',REWRITE_SUFFIX);	
		$this->_tpl->assign('index',INDEX);
		$this->_tpl->assign('mall',MALL);
		$this->_tpl->assign('sellerinfo',SELLERINFO);
		$this->_tpl->assign('all',ALL);
		$this->_tpl->assign('b2c_category',B2C_CATEGORY);
		$this->_tpl->assign('tao_category',TAO_CATEGORY);
		$this->_tpl->assign('bitem',BITEM);
		$this->_tpl->assign('item',ITEM);
		$this->_tpl->assign('promo',PROMO);
		$this->_tpl->assign('artile',ARTILE);
		$this->_tpl->assign('artilelist',ARTILELIST);
		$this->_tpl->assign('artile_content',ARTILE_CONTENT);
		$this->_tpl->assign('shop',SHOP);
		$this->_tpl->assign('search',SEARCH);		
	}	
	//修改系统设置
	public function update($mark,$info) {	
		if (isset($_POST['send'])) $this->_model->update($mark)?$this->_redirect->succ(Tool::getPrevPage()) : $this->_redirect->error($info);		
	}
	//设置seo写入文件
	public function set_seo(){
		$this->_model->set_seo()?$this->_redirect->succ(Tool::getPrevPage(), '恭喜您,Seo缓存清理成功') : $this->_redirect->error('对不起,Seo缓存清理失败！');
	}
}
?>