<?php
require($netsFileConfig['sysCoreRoot_Real'].'Cache/DbDescription/gsnavigationunit.php');
require($netsFileConfig['sysCoreRoot_Real'].'Cache/DbDescription/gsnavigationunitcont.php');
require($netsFileConfig['sysCoreRoot_Real'].'Cache/DbDescription/gsnavigationactive.php');
require($netsFileConfig['sysCoreRoot_Real'].'Cache/DbDescription/gsnavigationactivecont.php');
require($netsFileConfig['sysCoreRoot_Real'].'Inc/m_Gsnavigation/Gsnavigation/gsnavigationunit.php');
require($netsFileConfig['sysCoreRoot_Real'].'Inc/netsFunc/Func/netsSimpleXml.php');

class PaDefault extends CustomPage {
	public $ssetParid=2;
	
	public function PaDefault(){
		$this->ComPage();
	}
	public function OnPInitial(){
		$this->getUser('1,2,3,4,5,');
		$this->sTable=array(
			array('sttTableName'=>$this->sysTableHead.'gsnavigationunit','sttColumnHead'=>'gsnut'),
			array('sttTableName'=>$this->sysTableHead.'gsnavigationunitcont','sttColumnHead'=>'gsnuct'),);
		$this->sUiName='User/groupsalenavigation/groupsalenavigationunit_publish';
		//-- ------ #ActionType ------ --
		if ($this->sActionType=='DCollection') {
		}else {
			$this->sActionType='Normal';
		}
		
	}
	public function OnBInitial(){
		$this->sMetaTitle='发布团购网站信息';
		$this->sLimitCount=0;
		$this->sSortParameter='chooseFolder;cdtParid;External_Folder;'.$this->sysFileConfig['sysCoreRoot'].'Mana/m_cms/doc/docGroup.php;2|';
		$this->sApp=new gsnavigationunit($this->sConnString);
		$this->sSpicalValue=array();
		$this->sSpicalValue=array(0,$this->sTable[0]['sttColumnHead'].'CreateBy',$this->sUserInfo[0]['Columns']['uitID']['Value']);
		$this->sSpicalValue=array(0,$this->sTable[0]['sttColumnHead'].'IsUPublic',1);
		
		//-- #Share link --
		$this->sData_LinkShare=array();
		$tmpCacheFlag='nets/options_LinkShare_Groupsale';
		$tmpAR_Cache=$this->sDb->readCache($tmpCacheFlag);
		if(count($tmpAR_Cache)==0){
			$tmpParid=20;
			$tmpSQL=' SELECT A.cltID,A.cltName,A.cltURL,A.cltTarget,B.clctSourceR00
				FROM {Nets.TableHead}cmslink AS A
				INNER JOIN {Nets.TableHead}cmslinkcont AS B ON B.clctIndexID=A.cltID
				WHERE 1=1 AND A.cltRecycle=0 AND A.cltChecked>1 AND A.cltParid={Nets.Parid}
				ORDER BY A.cltOrderBy DESC,A.cltID DESC ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$tmpSTR=str_replace('{Nets.Parid}',$tmpParid,$tmpSTR);
			$this->sData_LinkShare=$this->sDb->Search($tmpSTR);
			
			if($this->sysFileConfig['CacheDbAble']==1){
				$this->sDb->writeCache($tmpCacheFlag,$this->sData_LinkShare);
			}
		}else {
			$this->sData_LinkShare=$tmpAR_Cache;
		}
		
		//-- ------ #Option ------ --
		//Parid
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.gsnugtID,A.gsnugtName,A.gsnugtParid FROM '.$this->sysTableHead.'gsnavigationunitgroup AS A
			WHERE 1=1 AND A.gsnugtRecycle=0 AND A.gsnugtChecked>1 AND A.gsnugtParid={Nets.Parid}
			ORDER BY A.gsnugtOrderBy DESC,A.gsnugtID DESC ';
		$tmpAR0['InitialString']=2;
		$tmpAR0['Parid']='gsnugtID';
		$tmpAR0['Text']='gsnugtName';
		$tmpAR0['Value']='gsnugtID';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_Groupsalenavigation_Unitgroup';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sParid1);
		$this->sParid2=$this->sParid1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='所有分类';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sParid2,$tmpAR0);
		//Zone
		$tmpAR0=explode($this->sysSPLIT1,$this->sysFileConfig['Zone_Opened']);
		$this->sZones_Can='';
		foreach ($tmpAR0 as $Row0) {
			$this->sZones_Can.=' OR A.sztName LIKE \''.$Row0.'\' ';
		}
		
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.sztID,A.sztName
			FROM '.$this->sysTableHead.'netssyszone AS A
			WHERE 1=1 AND A.sztRecycle=0 AND A.sztChecked>1 AND A.sztType=3 AND (1=2 '.$this->sZones_Can.')
			ORDER BY A.sztOrderBy DESC,A.sztID DESC ';
		
		$tmpAR0['InitialString']=0;
		$tmpAR0['Parid']='sztID';
		$tmpAR0['Text']='sztName';
		$tmpAR0['Value']='sztID';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_Zone_GroupsaleCity';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sZone1);
		$this->sZone2=$this->sZone1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='[所有地区]';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sZone2,$tmpAR0);
		
		//-- ------ #ActionType ------ --
		if ($this->sActionType=='DCollection') {
			$this->OnCollection();
		}else {
			$this->sActionType='Normal';
		}
		
		
	}
	public function OnCollection(){
		$tmpAR0=$this->AnalyerRequest('DCollection','',0);
		
		$this->sApp->sDbDescriptions_Other=array(
			$this->sysDbDescriptions[$this->sysTableHead.'groupsalenavigationactive'],
			$this->sysDbDescriptions[$this->sysTableHead.'groupsalenavigationactivecont'],
			);
		$tmpINT=$this->sApp->collectionByAPI($tmpAR0[0]);
		if($tmpINT!=0){
			$this->sJscript=$this->Message('ERROR','',$this->sApp->sysLastError,'');
			return 1;
		}
		
		//$this->sJscript=$this->Message('SUCCESS','','数据采集成功',$this->sysPage);
		$this->sJscript=$this->Message('SUCCESS','','数据采集成功','');
		return 0;
	}
	public function OnList(){
		
		return 0;
	}
	public function DefUiPanel(&$pColumn,$pFlag){
		parent::DefUiPanel($pColumn,$pFlag);

		if($pColumn['stcotName']=='gsnutParid' && $pFlag=='Search'){
			$pColumn['Option']=$this->sParid2;
		}else if($pColumn['stcotName']=='gsnutParid' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Option']=$this->sParid2;
		}else if($pColumn['stcotName']=='gsnuctInfo_Zones' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Option']=$this->sZone1;
			
		}else if($pColumn['stcotName']=='gsnuctPublisher_Name' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Value']=$this->sUserInfo[0]['Columns']['uitNickname']['Value'];
		}else if($pColumn['stcotName']=='gsnuctPublisher_Mobile' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Value']=$this->sUserInfo[1]['Columns']['uictCo_Mobile']['Value'];
		}else if($pColumn['stcotName']=='gsnuctPublisher_Software' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Value']=$this->sUserInfo[1]['Columns']['uictCo_Software']['Value'];
		}else if($pColumn['stcotName']=='gsnuctPublisher_Email' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Value']=$this->sUserInfo[0]['Columns']['uitEmail']['Value'];
		}else if($pColumn['stcotName']=='gsnutURL' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Value']=$this->sUserInfo[1]['Columns']['uictCo_Website']['Value'];

		}else if($pColumn['stcotName']=='gsnuctPublisher_Tele' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Value']=$this->sUserInfo[1]['Columns']['uictCo_Tele']['Value'];
		}else if($pColumn['stcotName']=='gsnuctPublisher_Address' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Value']=$this->sUserInfo[1]['Columns']['uictCo_Address']['Value'];
		}else if($pColumn['stcotName']=='gsnuctPublisher_Numcode' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Value']=$this->sUserInfo[1]['Columns']['uictCo_NumCode']['Value'];
		}else if($pColumn['stcotName']=='gsnuctPublisher_Fax' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Value']=$this->sUserInfo[1]['Columns']['uictCo_Fax']['Value'];
		}else if($pColumn['stcotName']=='gsnuctContent' && $pFlag=='Normal'){
			
		}
		
		return $pColumn;
	}
	
}


?>