<?php
$ajaxbool	= $rock->get('ajaxbool','false');
if($ajaxbool == 'false'){	
	include_once(''.ROOT_PATH.'/include/Smarty.php');
}
include_once(''.ROOT_PATH.'/include/smartyFun.php');

$m			= $rock->get('m', $m);			//mode模块名次
$a			= $rock->get('a', $a);			//act操作动作
$d			= $rock->get('d', $d);			//dir项目目录下路径

define('M', $m);
define('A', $a);
define('D', $d);
define('P', $p);

include_once($rock->strformat('?0/?1/?1Action.php',ROOT_PATH, $p));
$rand		= date('YmdHis').rand(1000,9999);
if(substr($d,-1)!='/' && $d!='')$d.='/';
$errormsg	= '';
$methodbool	= true;
$actfile	= $rock->strformat('?0/?1/?2?3/?3Action.php',ROOT_PATH, $p, $d, $m);
if(file_exists($actfile)){
	include_once($actfile);
	$clsname	= ''.$m.'ClassAction';
	$xhrock		= new $clsname();
	$actname	= ''.$a.'Action';
	if($ajaxbool == 'true')$actname	= ''.$a.'Ajax';
	if(method_exists($xhrock, $actname)){
		$xhrock->$actname();
	}else{
		$methodbool = false;
		if($ajaxbool == 'false')echo ''.$actname.' not found';
	}
	$xhrock->afterAction();
}else{
	echo ''.$actfile.' not found;';
	$xhrock		= new Action();
}


if($xhrock->display && $ajaxbool == 'false'){
	$xhrock->smartydata['p']	= $p;
	$xhrock->smartydata['a']	= $a;
	$xhrock->smartydata['m']	= $m;
	$xhrock->smartydata['d']	= $d;
	$xhrock->smartydata['rand']	= $rand;
	$xhrock->smartydata['qom']	= QOM;
	$xhrock->setSmartyData();
	$temppath					= ''.ROOT_PATH.'/'.$p.'/';
	$tplpaths					= ''.$temppath.''.$d.''.$m.'/';
	$smarty->template_dir		= $tplpaths;
	$tplname					= 'tpl_'.$m.'';
	if($a!='default')$tplname.='_'.$a.'';
	$tplname					.= '.html';
	$mpathname	= $tplpaths.$tplname;
	
	if(!file_exists($mpathname) || !$methodbool){
		if(!$methodbool){
			$errormsg	= 'in ('.$m.') not found ('.$a.');';
		}else{
			$errormsg	= ''.$mpathname.' not exists;';
		}
		echo $errormsg;
	}else{
		$smarty->display($tplname);	//输出模版
	}
}