<?php
class listAction extends security_normal {
	
	function action(){
		$CategoryFN=$this->_getParamId(1);
		$PageFN=$this->_getParamId(2);
		$htmlfn=MICE_DIR.'list/'.$CategoryFN.'/'.$PageFN;
		if(MICE_HTML){
				if(file_exists($htmlfn)){
				include_once $htmlfn;
				exit;
			}
		}
		$PageId=preg_replace("/(\w+)_(\d+)".MICE_HTML_EXT."/i","\${2}",$PageFN);
		if($PageId<1)	$PageId=1;
		
		if(is_numeric($PageId) AND $CategoryFN!=''){
			global $conn;
			$category=new model_Category();
			if(is_numeric($CategoryFN)){
				$category->setSubsection('WHERE type LIKE \'article%\' AND isvisible=0 AND (filename=\''.$CategoryFN.'\' OR category_id='.$CategoryFN.') ORDER BY path');
			}else{
				$category->setSubsection('WHERE type LIKE \'article%\' AND isvisible=0 AND filename=\''.$CategoryFN.'\' ORDER BY path');
			}
			$CategoryRS=$category->doSelectOne();
			$CategoryId=$CategoryRS->getCategoryId();

			if($CategoryRS){
				if($CategoryRS->getTpl()){								//模板
					$tpl=$CategoryRS->getTpl();
				}else{
					$filename = new getTPLFileName(__CLASS__);
					$tpl=$filename->TPLFileName;
				}
			}else{
				$jsstring='Dialog.alert(\'对不起,您查看的分类不存在或已经被删除\',function(){window.location.href="'.MICE_URL.'";window.event.returnValue = false;},300,100,"提示信息");';
				MessageBox($jsstring);
				exit;
			}
		}else{
			$jsstring='Dialog.alert(\'参数错误\',function(){window.location.href="'.MICE_URL.'";window.event.returnValue = false;},300,100,"提示信息");';
			MessageBox($jsstring);
			exit;
		}
		$miceSession = new session();
		if($miceSession->get('mu__grouplevel')<$CategoryRS->getUsergroupId() and $CategoryRS->getUsergroupId()>0){
			$jsstring='Dialog.alert(\'只有会员才能查看,您尚未登录或注册\',function(){window.location.href="'.MICE_URL.'";window.event.returnValue = false;},300,100,"提示信息");';
			MessageBox($jsstring);
		}

		$smarty = new Smarty();
		$smarty->load_filter('pre','micePreCompileIndex');
		$smarty->assign('CategoryRS',$CategoryRS);
		$smarty->assign('CategoryId',$CategoryId);
		$smarty->assign('PageId',$PageId);

		if(MICE_HTML){
			//将内容写入至静态文件
			$content = $smarty->fetch($tpl);
			$fp = fopen($htmlfn, 'w'); 
			fwrite($fp, $content); 
			fclose($fp);
		}

		$smarty->display($tpl);
	}	
}
?>