<?php
class channelAction extends security_normal {
	
	function action(){	
		$CategoryFN=$this->_getParamId(1);
		$htmlfn=MICE_DIR.'channel/'.$CategoryFN;
		if(MICE_HTML){
				if(file_exists($htmlfn)){
				include_once $htmlfn;
				exit;
			}
		}
		$CategoryFN=str_replace(MICE_HTML_EXT,'',$CategoryFN);
		
		if($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->getUrl()){
					//跳转
					echo '<html><body><form action="'.MiceRestoreQuote('micefun',$CategoryRS->getUrl()).'"  method="post" id="link" name="link"  target="_blank"  style="display:none;"></form><Script LANGUAGE="JavaScript">document.getElementById("link").submit();history.back(-1);</script></body></html>';
					exit;
				}
			}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);
			exit;
		}

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

		$filename = new getTPLFileName(__CLASS__);
		$tpl=$filename->TPLFileName;

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

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