<?php
/*
　* @$Id
　* @
　* @Ver: 2.0
　* @Create: 2009-11-18 8:10
　* @Modify: 
　* @Author: CPWEB http://www.cpweb.net.cn
　* @Copyright (C) 2008 www.cpweb.net.cn. All Rights Reserved.
　* @License CPWEB is free software and use is subject to license terms
　*/
class EmptyAction extends Action{
	public $powered;
	function _initialize(){
		$this->powered='<div align="center">Powered By <a href="http://www.cpweb.net.cn/" target="_blank">cpweb</a>'.C('CPWEB_VERSION').'   ©2007-2009 <a href="http://www.cpweb.net.cn" target="_blank">cpweb企业网站管理系统</a> (www.cpweb.net.cn) 版权所有</div>';
	}
	public function index(){
		if(MODULE_NAME=='Cpweb'){
			$Modules=CPWEBA('Index');
			$channel['id']=0;
			$channel['name']='首页';
		}else{
			$ChannelView=D('ChannelView');
			$map_c['Channel.opens']=1;
			$map_c['Channel.folder']=MODULE_NAME;
			$channel=$ChannelView->where($map_c)->find();
			if(!$channel){
				$Model=D('ModelView');
				$map_m['Model.address']=MODULE_NAME;
				$map_m['Type.type_values']='module';
				$channel=$Model->where($map_m)->find();
				if(!$channel) $this->error('你所访问的页面不存在');
			}
			$Modules=CPWEBA($channel['address']);
			if(!$Modules) $this->error('你所访问的页面不存在');
			$Modules->model=$channel['address'];
		}
		$Modules->channel=$channel;
		$Modules->powered=$this->powered;
		$Modules->cpweb_head();
		$Modules->index();
	}
	public function _empty(){
		if(MODULE_NAME=='Index'){
			$Modules=CPWEBA('Index');
			$channel['id']=0;
			$channel['name']=ACTION_NAME.' - 首页';
			$Modules->channel=$channel;
			$Modules->cpweb_head();
			$Modules->index();
		}elseif(MODULE_NAME=='Cpweb'){
			$Modules=CPWEBA('Index');
			$channel['id']=0;
			$channel['name']=ACTION_NAME.' - 首页';
			$Modules->channel=$channel;
			$Modules->cpweb_head();
			$Modules->index();
		}else{
			$ChannelView=D('ChannelView');
			$map_c['Channel.opens']=1;
			$map_c['Channel.folder']=MODULE_NAME;
			$channel=$ChannelView->where($map_c)->find();
			if(!$channel){
				$Model=D('ModelView');
				$map_m['Model.address']=MODULE_NAME;
				$map_m['Type.type_values']='module';
				$channel=$Model->where($map_m)->find();
				if(!$channel) $this->error('你所访问的页面不存在');
			}
			$Modules=CPWEBA($channel['address']);
			if(!$Modules) $this->error('你所访问的页面不存在');
			$Modules->model=$channel['address'];
			$Modules->channel=$channel;
			$Modules->powered=$this->powered;
			$Modules->cpweb_head();
			
			//获取当前操作名
			$action = ACTION_NAME;
			if(strpos($action,':')) {
				// 执行操作链 最多只能有一个输出
				$actionList	=	explode(':',$action);
				foreach ($actionList as $action){
					$Modules->$action();
				}
			}else{
				if (method_exists($Modules,'_before_'.$action)) {
					// 执行前置操作
					call_user_func(array(&$Modules,'_before_'.$action));
				}
				//执行当前操作
				call_user_func(array(&$Modules,$action));
				if (method_exists($Modules,'_after_'.$action)) {
					//  执行后缀操作
					call_user_func(array(&$Modules,'_after_'.$action));
				}
			}
		}
	}
}
?>