<?php

class PaDefault extends CustomPage {
	public $ssetParid=2;
	
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnBInitial(){
		$this->sMetaTitle='专题列表';
		$this->getUser('1,2,3,4,5,');
		$this->sTemplatePath='Cms/topicsList_Normal.php';
		
		//Parid
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.ctogtID,A.ctogtName,A.ctogtParid FROM '.$this->sysTableHead.'cmstopicsgroup AS A
			WHERE 1=1 AND A.ctogtRecycle=0 AND A.ctogtChecked>1 AND A.ctogtParid={Nets.Parid}
			ORDER BY A.ctogtOrderBy DESC,A.ctogtID DESC ';
		$tmpAR0['SQL0']=' SELECT A.ctogtID,A.ctogtName,A.ctogtParid FROM '.$this->sysTableHead.'cmstopicsgroup AS A
			WHERE 1=1 AND A.ctogtRecycle=0 AND A.ctogtChecked>1 AND A.ctogtParid={Nets.Parid}
			ORDER BY A.ctogtOrderBy DESC,A.ctogtID DESC ';
		$tmpAR0['InitialString']=$this->ssetParid;
		$tmpAR0['Parid']='ctogtID';
		$tmpAR0['Text']='ctogtName';
		$tmpAR0['Value']='ctogtID';
		$tmpAR0['Type']=0;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpSTR=$this->sControl->sHeadString;
		$this->sControl->sHeadString='';
		$this->sParid1=$this->sParid2=$this->sControl->bindDropdown($tmpAR0);
		$this->sControl->sHeadString=$tmpSTR;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='[所有分类]';
		$tmpAR0['Value']=2;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sParid2,$tmpAR0);
		
		
	
	}
	public function OnList(){
		$tmpAR0=$this->AnalyerRequest('ID',0,0);
		$this->sMainID=$tmpAR0[0];
		//-- ------ #Initial ------ --
		
		//-- ------ #This ------ --
		$tmpSQL=' SELECT A.ctogtID,A.ctogtName,
			B.ctogctSourceR00,B.ctogctTemplateid_List,B.ctogctContent
			FROM {Nets.TableHead}cmstopicsgroup AS A 
			INNER JOIN {Nets.TableHead}cmstopicsgroupcont AS B ON B.ctogctIndexID=A.ctogtID
			WHERE 1=1 AND A.ctogtRecycle=0 AND A.ctogtChecked>1 AND A.ctogtID={Nets.ID}
			ORDER BY A.ctogtOrderBy DESC,A.ctogtID DESC ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sMainID,$tmpSTR);
		$this->sDetailData=$this->sDb->Search($tmpSTR);
		if(count($this->sDetailData)!=1){
			//Error
			//#Other
			$this->sDetailData=array(array(
				'ctogtID'=>'0',
				'ctogtName'=>'',
				'ctogctSourceR00'=>'',
				'ctogctTemplateid_List'=>'0',
				'ctogctContent'=>'',
				));
		}
		$this->sMainID=$this->sDetailData[0]['ctogtID'];
		$this->sMetaTitle=$this->sDetailData[0]['ctogtName'];
		//-- ------ #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}',$this->sDetailData[0]['ctogctTemplateid_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.'cmstopicsgroup','ctogt');
		$this->sNavigation=$this->sDb->getParent($this->sMainID,$this->sysTableHead.'cmstopicsgroup','ctogt');
		//-- ------ ### ------ --
		$tmpListSTR0='DList0';
		$tmpListAR0=$this->AnalyerRequest($tmpListSTR0,'1,0,24,0',0);
		$tmpSortSTR0='DSort0';
		$this->sSortAR0=$this->AnalyerRequest($tmpSortSTR0,'ctotID,2',0);
		$tmpSearchSTR0='DSearch';
		$this->sSearchAR=$this->AnalyerRequest($tmpSearchSTR0,',-1,-1,-1',0);
		//-- #Spell SQL --
		$tmpSQL=' SELECT A.ctotID,A.ctotName,A.ctotParid,
			B.ctoctPublisher_Name,B.ctoctCount_Views,B.ctoctCount_Discuss,B.ctoctSourceR00
			FROM {Nets.TableHead}cmstopics AS A 
			INNER JOIN {Nets.TableHead}cmstopicscont AS B ON B.ctoctIndexID=A.ctotID
			WHERE 1=1 AND A.ctotRecycle=0 AND A.ctotChecked>1 AND (1=2 {Nets.Parids}) ';
		if ($this->sSearchAR[0]!='') {
			$tmpSQL.=' AND B.ctotName LIKE \'%'.$this->sSearchAR[0].'%\' ';
		}
		if ($this->sSearchAR[1]==1) {
			$tmpSQL.=' AND B.ctotState='.$this->sSearchAR[1].' ';
		}else if ($this->sSearchAR[1]==2) {
			$tmpSQL.=' AND B.ctotState='.$this->sSearchAR[1].' ';
		}
		if($this->sSortAR0[1]==1){
			$tmpSQL.=' ORDER BY A.ctotOrderBy DESC,'.$this->sSortAR0[0].' ';
		}else if($this->sSortAR0[1]==2){
			$tmpSQL.=' ORDER BY A.ctotOrderBy DESC,'.$this->sSortAR0[0].' DESC ';
		}
		$tmpSTR_0='';
		foreach ($tmpChildidAR0 as $Cell){
			$tmpSTR_0.=' OR A.ctotParid='.$Cell.' ';
		}
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Parids}',$tmpSTR_0,$tmpSTR);
		$this->sListData=$this->sDb->SearchP($tmpSTR,$tmpListAR0);
		//#Set page button
		$this->sPButton->resetTemlate('../../../Config/m_default/File/pageButton3.htm');
		$this->sPButton->sPage=$this->sysPage;
		$this->sPButton->sExtendParameter='&ID='.$this->sMainID.'&DSearch='.$this->sSearchAR[0].$this->sysSPLIT1.
			$this->sSearchAR[1].$this->sysSPLIT1.
			$this->sSearchAR[2].$this->sysSPLIT1.
			$this->sSearchAR[3];
		$this->sPButton->setPage($this->sDb->sysPageInfo);

	}
	public function getSearch($pValue,$pType){
/*
MainID

Keyword
State
Code
ExtendIndex

*/
		$tmpAR0=array(
			$this->sMainID,
			$this->sSearchAR[0],
			$this->sSearchAR[1],
			$this->sSearchAR[2],
			$this->sSearchAR[3],);
		if($pType==0) $tmpAR0[0]=$pValue;
		if($pType==1) $tmpAR0[1]=$pValue;
		if($pType==2) $tmpAR0[2]=$pValue;
		if($pType==3) $tmpAR0[3]=$pValue;
		if($pType==4) $tmpAR0[4]=$pValue;
		
		//#SPICAL
		if ($pType==100) {
			/*
			$tmpAR0[8]=0;
			$tmpAR0[9]=0;
			$tmpAR0[10]=0;
			$tmpAR0[11]=0;
			$tmpAR0[12]=0;
			*/
		}else if ($pType==101) {
		}
		//#SPELL
		$tmpSTR=$this->sysPage.'?ID='.$tmpAR0[0].
			'&DSearch='.$tmpAR0[1].$this->sysSPLIT1.$tmpAR0[2].$this->sysSPLIT1.$tmpAR0[3].$this->sysSPLIT1.$tmpAR0[4];
		return $tmpSTR;
	}
	
}

?>