<?php
require('../../../QPlatform/Common/Component/ComInitialHead.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Nets/System/netssyssheme.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/netssyssheme.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/netssysshemecont.php');

class PaDefault extends CustomPage {
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnPInitial(){
		$this->checkUser('1,2,3,');
		$this->sTable=array(
			array('sttTableName'=>$this->sysTableHead.'netssyssheme','sttColumnHead'=>'sst'),
			array('sttTableName'=>$this->sysTableHead.'netssysshemecont','sttColumnHead'=>'ssct'),);
		$this->sUiName='Platform/nets/system_makehtml';
		
		if($this->sActionType!='Makehtml'){
			$this->sActionType='Normal';
		}
		
	}
	public function OnBInitial(){
		$this->sMetaTitle='生成静态文件';
		$this->sLimitCount=0;
		$this->sApp=new netssyssheme($this->sConnString);

		if($this->sActionType=='Makehtml'){
			$this->OnMakehtml();
		}else {
			$this->OnNormal();
		}
	}
	public function OnMakehtml(){
		$tmpDescriptions=array(
			$this->sysDbDescriptions[$this->sysTableHead.'netssyssheme'],
			$this->sysDbDescriptions[$this->sysTableHead.'netssysshemecont'],
			);
		$tmpAR0=$this->AnalyerRequest('Makehtml','0,0',0);
		$tmpDescriptions[0]['Columns']['uitID']['Value']=1;
		$tmpIndexSection=$tmpAR0[0];
		$tmpIndexCell=$tmpAR0[1];
		$tmpINT=$this->sApp->makeHtml_BYID($tmpDescriptions,$tmpIndexSection,$tmpIndexCell);
		//-- ------ #ssctHtmlDescription ------ --
		$tmpAR1=$this->sApp->getNotes($tmpDescriptions[1]['Columns']['ssctHtmlDescription']['Value']);
		$this->sSectionAR=array();
		$Coun0=0;
		foreach($tmpAR1 as $Cell){
			$this->sSectionAR[$Coun0]=$this->sControl->sDpReturnTemplate;
			$this->sSectionAR[$Coun0]['Text']=$Cell;
			$this->sSectionAR[$Coun0]['Value']=$Coun0;
			$Coun0++;
		}
		
		$tmpSTR=' - '.$this->sSectionAR[$tmpAR0[0]]['Text'].'<br />'.$this->sysSPLIT5.$tmpIndexCell;
		if($tmpINT!=0){
			$this->sTopMessage='<span class="FBlue1">'.$this->sApp->sysLastError.'</span>'.$tmpSTR;
			return 1;
		}
		
		$this->sTopMessage='<span class="FBlue1">'.$this->sApp->sysLastMessage.'</span>'.$tmpSTR;
	}
	public function OnNormal(){
		$tmpINT=0;
		$tmpAR0=$this->AnalyerRequest('Normal','0,0',0);
		$tmpAR0[0]=1;
		
		$tmpSQL=' SELECT * 
			FROM '.$this->sysTableHead.'netssyssheme AS A 
			INNER JOIN '.$this->sysTableHead.'netssysshemecont AS B ON B.ssctIndexID=A.sstID ';
		$Coun0=2;
		foreach ($this->sTable as $Row0){
			if (count($this->sTable)>2) {
				$tmpSQL.=' INNER JOIN '.$Row0['sttTableName'].' AS '.$this->sysTableMark[$Coun0].' ON '.$this->sysTableMark[$Coun0].'.'.$Row0['sttColumnHead'].'IndexID=A.sstID ';
				$Coun0++;
			}
		}
		$tmpSQL.=' WHERE 1=1 AND A.sstID='.$tmpAR0[0].' ';
		$tmpDataCollection0=$this->sDb->Search($tmpSQL);
		if(count($tmpDataCollection0)>0){
			$tmpRow=$tmpDataCollection0[0];
			$this->sMainID=$tmpRow[$this->sTable[0]['sttColumnHead'].'ID'];
			//-- #Get value --
			$Coun0=0;
			while (count($this->sUiDescription_Normal)>$Coun0) {
				if(isset($tmpRow[$this->sUiDescription_Normal[$Coun0]['stcotName']])){
					$this->sUiDescription_Normal[$Coun0]['Value']=$tmpRow[$this->sUiDescription_Normal[$Coun0]['stcotName']];
					//-- ------ #Spical set ------ --
					if($this->sUiDescription_Normal[$Coun0]['stcotName']=='ssctHtmlDescription'){
					}else if($this->sUiDescription_Normal[$Coun0]['stcotName']=='sstTableid'){
						$this->sUiDescription_Normal[$Coun0]['Value']=$this->sMainTableid;
					}
				}
				$Coun0++;
			}
			//-- ------ #ssctHtmlDescription ------ --
			$tmpAR0=$this->sApp->getNotes($tmpDataCollection0[0]['ssctHtmlDescription']);
			$this->sSectionAR=array();
			$Coun0=0;
			foreach($tmpAR0 as $Cell){
				$this->sSectionAR[$Coun0]=$this->sControl->sDpReturnTemplate;
				$this->sSectionAR[$Coun0]['Text']=$Cell;
				$this->sSectionAR[$Coun0]['Value']=$Coun0;
				$Coun0++;
			}
		}else {
			$Coun0=0;
			foreach($this->sUiDescription_Normal as $Row0){
				if($Row0['stcotName']=='sstTableid'){
					$this->sUiDescription_Normal[$Coun0]['Value']=$this->sMainTableid;
				}
				$Coun0++;
			}
		}
	}
	
	public function DefUiPanel(&$pColumn,$pFlag){
		parent::DefUiPanel($pColumn,$pFlag);
		if($pColumn['stcotName']=='sstSection_0' && $pFlag=='Normal'){
			$pColumn['Option']=$this->sSectionAR;
		}else if($pColumn['stcotName']=='sstReport_0' && $pFlag=='Normal'){
			$pColumn['Value']='<span class=\'FRed1 FStrong\'>注意：静态生成将生产较大的服务器负载，请在访问量较小的时候执行本操作。</span><br />';
			$pColumn['ControlStyle']='width:640px; height:200px; overflow:scroll; background-color:#F2F8FB; padding:4px 4px 4px 4px;';
		}
		return $pColumn;
	}
	public function DefUiButton($pFlag,$Exception){
		parent::DefUiButton($pFlag,array('List','Normal','ListChildLink','NormalChildLink',));
		if ($pFlag=='Normal') { ?>
<li class="ButBut"><input type="button" value="生成静态文件" class="Control2" onclick="tmpMakeHtml.OnRequest();" /></li>
<?php }
	}
}
//-- ------ #Instanct ------ --
$tmpDefault=new PaDefault();
$tmpDefault->OnPage();
$tmpControls=new ComControls();
$tmpControlPage=new ComControlPage();
$tmpComHead->sMenuid=$tmpDefault->sMenuid;
$tmpDefault->sysMetaTitle=$tmpDefault->sMetaTitle.' - '.$tmpDefault->sysFileConfig['sysTitle'];
//-- ------ #Template ------ --
require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/Head_0.php'); ?>
<script type="text/javascript" src="sysmarkhtml_callback.js"></script>
<?php if($tmpDefault->sActionType=='Makehtml'){ ?>
<!-- ------ #nets_Makehtml ------ -->
<!--S.nets_Makehtml--><?php echo($tmpDefault->sTopMessage) ?><!--sendRequest--><!--E.nets_Makehtml-->
<?php
}else{
	require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Common/normal.php');
}
require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/End_0.php'); ?>