<?php
require($netsFileConfig['sysCoreRoot'].'Inc/m_Nets/System/netssysconfiginfo.php');

class PaDefault extends CustomPage {
	public $sConfigParid=1;
	public $sConfigColumns=array();
	
	public function PaDefault($pConfigParid,$pTitle){
		$this->sConfigParid=$pConfigParid;
		$this->sMetaTitle=$pTitle;
		$this->CustomPage();
	}
	public function OnPInitial(){
		$this->checkUser('1,2,3,');
		$this->sApp=new netssysconfiginfo($this->sConnString);
	}
	public function OnBInitial(){
		$this->sLimitCount=0;
		//HtmlEditType
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=38;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$this->sHtmlEditType1=$this->sControl->bindDropdown($tmpAR0);
		//UserEditType
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=60;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$this->sUserEditType1=$this->sControl->bindDropdown($tmpAR0);
		//WaterPosition
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=39;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$this->sWaterPosition1=$this->sControl->bindDropdown($tmpAR0);
		//MapType
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=58;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$this->sMapType1=$this->sControl->bindDropdown($tmpAR0);
		//MapControlShowType
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=59;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$this->sMapControlShowType1=$this->sControl->bindDropdown($tmpAR0);
		//EmailConfirmType
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=66;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$this->sEmailConfirmType1=$this->sControl->bindDropdown($tmpAR0);
		
		//-- ------ #ActionType ------ --
		if($this->sActionTypeF=='DCacheClear'){
			$this->OnCacheClear();
		}else if($this->sActionTypeF=='DModify_Regular'){
			$this->OnModify_Regular();
		}
		
		
	}
	public function OnModify(){
		//Get config
		$this->sDbDescription=$this->sApp->getFileConfigControl($this->sConfigParid);
		//Save to db
		$Coun0=0;
		$tmpDbDescription=$this->sDbDescription;
		foreach ($tmpDbDescription['Columns'] as $Column){
			$tmpAR0=$this->AnalyerRequest($Column['stcotName'].'Txt',$Column['stcoctDefaultValue'],1);
			$this->sDbDescription['Columns'][$Column['stcotName']]['Value']=$tmpAR0[0];
			
			$tmpSQL=' UPDATE '.$this->sysTableHead.'netssysconfiginfo AS A 
				SET A.scitUserValue=\''.$tmpAR0[0].'\' 
				WHERE A.scitSign LIKE \''.$Column['stcotName'].'\'; ';
			$this->sDb->Execute($tmpSQL);
			$Coun0++;
		}
		//Save to file
		$this->sApp->saveToFile($this->sFileConfigPath,$this->sFileConfigPathCore);
		$this->sApp->saveToFile_Regular($this->sFileConfigPathRegular);
		$this->sJscript=$this->Message('SUCCESS','','保存成功',$this->sysPage);
		return 0;
	}
	public function OnModify_Regular(){
		//Get config
		$this->sDbDescription=$this->sApp->getFileConfigControl($this->sConfigParid);
		//Save to db
		$Coun0=0;
		$tmpDbDescription=$this->sDbDescription;
		foreach ($tmpDbDescription['Columns'] as $Column){
			$tmpAR0=$this->AnalyerRequest($Column['stcotName'].'Txt',$Column['stcoctDefaultValue'],1);
			$this->sDbDescription['Columns'][$Column['stcotName']]['Value']=$tmpAR0[0];
			
			$tmpSQL=' UPDATE '.$this->sysTableHead.'netssysconfiginfo AS A 
				SET A.scitUserValue=\''.$tmpAR0[0].'\' 
				WHERE A.scitSign LIKE \''.$Column['stcotName'].'\'; ';
			$this->sDb->Execute($tmpSQL);
			$Coun0++;
		}
		//Save to file
		$this->sApp->saveToFile_Regular($this->sFileConfigPathRegular);
		$this->sJscript=$this->Message('SUCCESS','','保存成功',$this->sysPage);
		return 0;
	}
	public function OnCacheClear(){
		$this->clearAllCache('cms/');
		$this->clearAllCache('Menu/');
		$this->clearAllCache('nets/');
		$this->clearAllCache('shop/');
		$this->clearAllCache('user/');
		
		$this->sJscript=$this->Message('SUCCESS','','成功清理所有缓存',$this->sysPage);
	}
	public function OnLoad(){
		$this->sUiDescription_Normal=array();
		$this->sDbDescription=array();
		$this->sApp->getFileConfig($this->sConfigParid,$this->sUiDescription_Normal,$this->sDbDescription);
	}
	
	public function DefUiPanel(&$pColumn,$pFlag){
		if($pColumn['stcotName']=='Quick'){
			$pColumn['Style']='width:50px;';
		}else if($pColumn['stcotName']=='HtmlEditorType'){
			$pColumn['Option']=$this->sHtmlEditType1;
		}else if($pColumn['stcotName']=='UserEditorType'){
			$pColumn['Option']=$this->sUserEditType1;
		}else if($pColumn['stcotName']=='ThumbWaterPosition'){
			$pColumn['Option']=$this->sWaterPosition1;
		}else if($pColumn['stcotName']=='userUserMailCheckAble' || $pColumn['stcotName']=='userUserMobileCheckAble'){
			$pColumn['Option']=$this->sEmailConfirmType1;
		}else if($pColumn['stcotName']=='UploadFileRename' || $pColumn['stcotName']=='userWordFilterAble' || 
			$pColumn['stcotName']=='userWordLimitAble' || $pColumn['stcotName']=='EmailAble' || 
			$pColumn['stcotName']=='userUserRegSendEmail' || $pColumn['stcotName']=='userUserCheckAble'  ||
			$pColumn['stcotName']=='userUserRegAble' || $pColumn['stcotName']=='CacheDbAble' || 
			$pColumn['stcotName']=='CachePageAble' || $pColumn['stcotName']=='MapStaticShow' || 
			$pColumn['stcotName']=='MapPositionFromZone' || $pColumn['stcotName']=='LoginRepeateAble' ||
			$pColumn['stcotName']=='MessageFrameAble' || $pColumn['stcotName']=='Zone_AutoIdentification' || 
			$pColumn['stcotName']=='sysZoneMustbe' || $pColumn['stcotName']=='sysShowAdvancedOptions' ||
			$pColumn['stcotName']=='DbMenu_User' || $pColumn['stcotName']=='DbMenu_Platform' ||
			$pColumn['stcotName']=='DbMenu_QPlatform' || $pColumn['stcotName']=='DbMenu_Mana' ||
			$pColumn['stcotName']=='DbMenu_Q_User' || $pColumn['stcotName']=='DbMenu_Q_Platform' ||
			$pColumn['stcotName']=='DbMenu_Q_QPlatform' || $pColumn['stcotName']=='DbMenu_Q_Mana'){
			$pColumn['Option']=$this->sBoolean1;
		}else if($pColumn['stcotName']=='ThumbWater' || $pColumn['stcotName']=='ThumbEnable'){
			$pColumn['Option']=$this->sEnable1;
		}else if($pColumn['stcotName']=='CheckCmsDoc' || $pColumn['stcotName']=='CheckCmsDocDiscuss' || $pColumn['stcotName']=='CheckCmsAsk' || 
			$pColumn['stcotName']=='CheckCmsAskReply' || $pColumn['stcotName']=='CheckShopSale' || 
			$pColumn['stcotName']=='CheckShopSaleDiscuss' || $pColumn['stcotName']=='CheckShopPresent' || 
			$pColumn['stcotName']=='CheckShopFavourable' || $pColumn['stcotName']=='CheckRequireSupply' || 
			$pColumn['stcotName']=='CheckRequireSupplyDiscuss' || $pColumn['stcotName']=='CheckRequireRequire' || 
			$pColumn['stcotName']=='CheckRequireRequireDiscuss' || $pColumn['stcotName']=='CheckSortUnit' || 
			$pColumn['stcotName']=='CheckSortUnitDiscuss' || $pColumn['stcotName']=='CheckSortUnitProduct' || 
			$pColumn['stcotName']=='CheckSortUnitProductDiscuss' || $pColumn['stcotName']=='CheckCommCircle' || 
			$pColumn['stcotName']=='CheckCommCircleDiscuss' || $pColumn['stcotName']=='CheckCommPosts' || 
			$pColumn['stcotName']=='CheckCommPostsReply' || $pColumn['stcotName']=='CheckStoryVolume' || 
			$pColumn['stcotName']=='CheckStoryVolumeDiscuss' || $pColumn['stcotName']=='CheckStoryNode' || 
			$pColumn['stcotName']=='CheckStoryNodeDiscuss' || $pColumn['stcotName']=='CheckStoryArticle' || 
			$pColumn['stcotName']=='CheckStoryArticleDiscuss' || $pColumn['stcotName']=='sysDefaultChecked'){
			$pColumn['Option']=$this->sChecked1;
		}else if($pColumn['stcotName']=='MapType'){
			$pColumn['Option']=$this->sMapType1;
		}else if($pColumn['stcotName']=='MapControlShowType'){
			$pColumn['Option']=$this->sMapControlShowType1;
			
			
		}else if($pColumn['stcotName']=='sysCorePowerNumcode'){
			$pColumn['stcoctUiIntroduct']='
				<script src="'.$this->sysFileConfig['sysUiCoreRoot'].'Ui/m_nets/Jscript/QPlatform/Main.js" type="text/javascript"></script>
				<div id="mainPower_Box"></div>
				<script type="text/javascript">var tmpMain=new Main();tmpMain.OnLoad_Power();</script>';
			
		}
		return $pColumn;
	}
	public function DefUiButton($pFlag,$Exception){
		parent::DefUiButton($pFlag,array('List','Normal','ListChildLink','NormalChildLink','Normal_Head',));
		if ($pFlag=='Normal') { ?>
<li class="ButBut Button_Normal"><a href="#Here" class="Link1 FBlack2" onclick="tmpCommon.setActionType('Normal','DCacheClear','',''); tmpCommon.netsSubmit();">清理所有缓存</a></li>
<?php if ($this->sConfigParid==2) { ?>
<li class="ButBut Button_Normal"><a href="#Here" class="Link1 FBlack2" onclick="tmpCommon.setActionType('Normal','DModify','',''); tmpCommon.netsSubmit();">保存所有设置</a></li>
<?php } ?>
<li class="ButBut Button_Normal"><a href="#Here" class="Link1 FBlack2" onclick="tmpCommon.setActionType('Normal','DModify_Regular','',''); tmpCommon.netsSubmit();">保存设置</a></li>

<?php }else if ($pFlag=='Normal_Head' && !in_array($pFlag,$Exception)) { ?>
<li class="Tab_Option_Button">
	<div class="Tab_Option_ButtonCell"><img src="<?php echo($this->sysFileConfig['sysUiCoreRoot']); ?>Ui/Common/Img/Common/icon_head_6.jpg" /></div>
	<div class="Tab_Option_ButtonCell"><a href="#Here" class="Link1 FBlue2" onclick="tmpCommon.setActionType('Normal','DCacheClear',''); tmpCommon.netsSubmit();">清理所有缓存</a></div></li>
<?php if ($this->sConfigParid==2) { ?>
<li class="Tab_Option_Button">
	<div class="Tab_Option_ButtonCell"><img src="<?php echo($this->sysFileConfig['sysUiCoreRoot']); ?>Ui/Common/Img/Common/icon_head_6.jpg" /></div>
	<div class="Tab_Option_ButtonCell"><a href="#Here" class="Link1 FBlue2" onclick="tmpCommon.setActionType('Normal','DModify',''); tmpCommon.netsSubmit();">保存所有设置</a></div></li>
<?php } ?>
<li class="Tab_Option_Button">
	<div class="Tab_Option_ButtonCell"><img src="<?php echo($this->sysFileConfig['sysUiCoreRoot']); ?>Ui/Common/Img/Common/icon_head_6.jpg" /></div>
	<div class="Tab_Option_ButtonCell"><a href="#Here" class="Link1 FBlue2" onclick="tmpCommon.setActionType('Normal','DModify_Regular',''); tmpCommon.netsSubmit();">保存设置</a></div></li>


<?php }
	}
	
	
	
}
?>