<?php

class PaDefault extends CustomPage {
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnBInitial(){
		$this->sMetaTitle='团购首页';
		$this->getUser('1,2,3,4,5,');
		$this->sTemplatePath='Gsnavigation/gsnavigationunitList_Normal.php';
		//-- #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='Gsnavigation/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);
		
	}
	
	public function OnList(){
		$tmpAR0=$this->AnalyerRequest('ID',-1,0);
		$this->sMainID=$tmpAR0[0];
		$tmpAR0=$this->AnalyerRequest('DKeyword','',0);
		$this->sKeyword=$tmpAR0[0];
		$this->sSearchAR=$this->AnalyerRequest('DSearch','-1',0);
		//-- ------ #This group ------ --
		$tmpSQL=' SELECT A.gsnugtID,A.gsnugtName,B.gsnugctTemplateid_List 
			FROM {Nets.TableHead}gsnavigationunitgroup AS A 
			INNER JOIN {Nets.TableHead}gsnavigationunitgroupcont AS B ON B.gsnugctIndexID=A.gsnugtID
			WHERE 1=1 AND A.gsnugtRecycle=0 AND A.gsnugtChecked>1 AND A.gsnugtID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sMainID,$tmpSTR);
		$tmpData_Group=$this->sDb->Search($tmpSTR);
		if(count($tmpData_Group)==0){
			//Error
			$tmpData_Group=array(array(
				'gsnugtID'=>0,
				'gsnugtName'=>'所有团购网站',
				'gsnugctTemplateid_List'=>0,
				),);
			//return 1;
		}
		$this->sMetaTitle=$tmpData_Group[0]['gsnugtName'];
		//-- ------ #Template ------ --
		$tmpSQL=' SELECT A.stemtID,A.stemtName,B.stemctPath 
			FROM {Nets.TableHead}netssystemplate AS A
			INNER JOIN {Nets.TableHead}netssystemplatecont AS B ON B.stemctIndexID=A.stemtID
			WHERE 1=1 AND A.stemtRecycle=0 AND A.stemtChecked>1 AND A.stemtID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$tmpData_Group[0]['gsnugctTemplateid_List'],$tmpSTR);
		$tmpData0=$this->sDb->Search($tmpSTR);
		if(count($tmpData0)!=0){
			$this->sTemplatePath=$tmpData0[0]['stemctPath'];
		}
		//-- ------ #Navigation ------ --
		$tmpChildidAR0=$this->sDb->getChild($this->sMainID,$this->sysTableHead.'gsnavigationunitgroup','gsnugt');
		$this->sNavigation=$this->sDb->getParent($this->sMainID,$this->sysTableHead.'gsnavigationunitgroup','gsnugt');
		//-- ------ #Datas ------ --
		$tmpListSTR0='DList0';
		$tmpListAR0=$this->AnalyerRequest($tmpListSTR0,'1,0,192,0',0);
		$tmpSortSTR0='DSort0';
		$tmpSortAR0=$this->AnalyerRequest($tmpSortSTR0,'cdtID,2',0);
		//-- #Spell SQL --
		$tmpSQL=' SELECT A.gsnutID,A.gsnutName,A.gsnutParid,A.gsnutNameStyle
			
			FROM {Nets.TableHead}gsnavigationunit AS A
			INNER JOIN {Nets.TableHead}gsnavigationunitcont AS B ON B.gsnuctIndexID=A.gsnutID
			WHERE 1=1 AND A.gsnutRecycle=0 AND A.gsnutChecked>1 ';

		if ($this->sKeyword!='') {
			$tmpSQL.=' AND A.gsnutName LIKE \'%'.$this->sKeyword.'%\' ';
		}
		if ($this->sMainID!=-1) {
			$tmpSTR_0='';
			foreach ($tmpChildidAR0 as $Cell){
				$tmpSTR_0.=' OR A.gsnutParid='.$Cell.' ';
			}
			$tmpSQL.=' AND (1=2 '.$tmpSTR_0.') ';
		}
		if ($this->sSearchAR[0]!=-1) {
			$tmpSQL.=' AND A.gsnutState='.$this->sSearchAR[0].' ';
		}
		if ($this->sZoneid!=-1) {
			$tmpSQL.=' AND (B.gsnuctInfo_Zones LIKE \''.$this->sZoneid.',%\' OR B.gsnuctInfo_Zones LIKE \'%,'.$this->sZoneid.',%\')';
		}
		
		$tmpSQL.=' ORDER BY A.gsnutOrderBy DESC,A.gsnutID DESC ';
		
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$this->sListData=$this->sDb->SearchP($tmpSTR,$tmpListAR0);
		$this->sRecordCount=$this->sDb->sysPageInfo[3];
		//#Set page button
		$this->sPButton->resetTemlate('../../../Config/m_default/File/pageButton3.htm');
		$this->sPButton->sPage=$this->sysPage;
		$this->sPButton->sExtendParameter='&ID='.$this->sMainID.'&DKeyword='.$this->sKeyword.'&DSearch='.$this->sSearchAR[0];
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		
	}
	public function getSearch($pValue,$pType){
/*
Parid
Keyword
State

*/
		$tmpAR0=array(
			$this->sMainID,
			$this->sKeyword,
			$this->sSearchAR[0],

			);
		if($pType==0) $tmpAR0[0]=$pValue;
		if($pType==1) $tmpAR0[1]=$pValue;
		if($pType==2) $tmpAR0[2]=$pValue;


		//#SPICAL
		if ($pType==100) {
			/*
			$tmpAR0[8]=0;
			$tmpAR0[9]=0;
			$tmpAR0[10]=0;
			*/
		}else if ($pType==101) {
		}
		//#SPELL
		$tmpSTR=$this->sysPage.'?ID='.$tmpAR0[0].
			'&DKeyword='.$tmpAR0[1].
			'&DSearch='.$tmpAR0[2];
		return $tmpSTR;
	}
	
	
	
	
	
}

?>