<?php
class PaDefault extends CustomPage {
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnBInitial(){
		$this->sMetaTitle='首页';
		$this->getUser('1,2,3,4,5,');
		
		$this->sTemplatePath='Comm/postsList_Normal.php';
		
	}
	public function OnList(){
		$tmpAR0=$this->AnalyerRequest('ID',1,0);
		$this->sMainID=$tmpAR0[0];
		//-- ------ #Initial ------ --
		
		//-- ------ #This ------ --
		$tmpSQL=' SELECT A.copgtID,A.copgtName,
			B.copgctSourceR00,B.copgctTemplateid_List,B.copgctContent,B.copgctInfo_Moderator
			FROM {Nets.TableHead}commpostsgroup AS A 
			INNER JOIN {Nets.TableHead}commpostsgroupcont AS B ON B.copgctIndexID=A.copgtID
			WHERE 1=1 AND A.copgtRecycle=0 AND A.copgtChecked>1 AND A.copgtID={Nets.ID}
			ORDER BY A.copgtOrderBy DESC,A.copgtID 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
			$tmpSQL=' SELECT A.copgtID,A.copgtName
				FROM {Nets.TableHead}commpostsgroup AS A 
				WHERE 1=1 AND A.copgtRecycle=0 AND A.copgtChecked>1
				ORDER BY A.copgtOrderBy DESC,A.copgtID DESC LIMIT 0,8 ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$this->sOtherData=$this->sDb->Search($tmpSTR);
			return 1;
		}
		$this->sMainID=$this->sDetailData[0]['copgtID'];
		$this->sMetaTitle=$this->sDetailData[0]['copgtName'];
		//-- ------ #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]['copgctTemplateid_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.'commpostsgroup','copgt');
		$this->sNavigation=$this->sDb->getParent($this->sMainID,$this->sysTableHead.'commpostsgroup','copgt');
		//-- ------ #Child ------ --
		$tmpListSTR0='DList1';
		$tmpListAR0=$this->AnalyerRequest($tmpListSTR0,'1,0,3,0',0);
		$tmpSortSTR0='DSort1';
		$tmpSortAR0=$this->AnalyerRequest($tmpSortSTR0,'copgtID,2',0);
		//-- #Spell SQL --
		$tmpSQL=' SELECT A.copgtID,A.copgtName,
			B.copgctSourceR00,B.copgctContent,B.copgctInfo_Moderator,
			B.copgctCount_Views,B.copgctCount_Info,B.copgctCount_InfoAll,
			B.copgctCount_Discuss,B.copgctCount_DiscussAll
			FROM {Nets.TableHead}commpostsgroup AS A 
			INNER JOIN {Nets.TableHead}commpostsgroupcont AS B ON B.copgctIndexID=A.copgtID
			WHERE 1=1 AND A.copgtRecycle=0 AND A.copgtChecked>1 AND A.copgtParid={Nets.ID}
			ORDER BY A.copgtOrderBy DESC,A.copgtID DESC ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sMainID,$tmpSTR);
		$this->sChildData=$this->sDb->SearchP($tmpSTR,$tmpListAR0);
		//#Set page button
		$this->sPButton_Child=new netsPButton();
		$this->sPButton_Child->sPageName=$tmpListSTR0;
		$this->sPButton_Child->resetTemlate('../../../Config/m_default/File/PostsListPageButton.htm');
		$this->sPButton_Child->sPage=$this->sysPage;
		$this->sPButton_Child->sExtendParameter='&ID='.$this->sMainID;
		$this->sPButton_Child->setPage($this->sDb->sysPageInfo);

		//-- ------ #Posts ------ --
		$tmpListSTR0='DList0';
		$tmpListAR0=$this->AnalyerRequest($tmpListSTR0,'1,0,24,0',0);
		$tmpSortSTR0='DSort0';
		$this->sSortAR0=$this->AnalyerRequest($tmpSortSTR0,'coptID,2',0);
		$tmpSearchSTR0='DSearch';
		$this->sSearchAR=$this->AnalyerRequest($tmpSearchSTR0,'-1',0);
		//-- #Spell SQL --
		$tmpSQL=' SELECT A.coptID,A.coptName,A.coptCreateTime,
			B.copctEssence,B.copctTop,B.copctHot,B.copctIcon,B.copctPublisher_Name,B.copctCount_Views,B.copctCount_Discuss
			FROM {Nets.TableHead}commposts AS A 
			INNER JOIN {Nets.TableHead}commpostscont AS B ON B.copctIndexID=A.coptID
			WHERE 1=1 AND A.coptRecycle=0 AND A.coptChecked>1 AND (1=2 {Nets.Parids}) ';
		if ($this->sSearchAR[0]!=-1) {
			$tmpSQL.=' AND B.copctType='.$this->sSearchAR[0].' ';
		}
		if($this->sSortAR0[1]==1){
			$tmpSQL.=' ORDER BY A.coptOrderBy DESC,'.$this->sSortAR0[0].' ';
		}else if($this->sSortAR0[1]==2){
			$tmpSQL.=' ORDER BY A.coptOrderBy DESC,'.$this->sSortAR0[0].' DESC ';
		}
		$tmpSTR_0='';
		foreach ($tmpChildidAR0 as $Cell){
			$tmpSTR_0.=' OR A.coptParid='.$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/PostsListPageButton.htm');
		$this->sPButton->sPage=$this->sysPage;
		$this->sPButton->sExtendParameter='&ID='.$this->sMainID.'&DSearch='.$this->sSearchAR[0];
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		$this->sPButton->setSort($this->sSortAR0);
		$this->sSortButton[0]=array('stcotName'=>'coptID','stcoctUiName'=>'类型');
		$this->sSortButton[1]=array('stcotName'=>'coptName','stcoctUiName'=>'标题');
		
		$this->sSortButton[2]=array('stcotName'=>'copctEssence','stcoctUiName'=>'精华');
		$this->sSortButton[3]=array('stcotName'=>'copctTop','stcoctUiName'=>'置顶');
		$this->sSortButton[4]=array('stcotName'=>'copctHot','stcoctUiName'=>'热门');
		
		$this->sSortButton[5]=array('stcotName'=>'copctCount_Discuss','stcoctUiName'=>'发布');
		$this->sSortButton[6]=array('stcotName'=>'copctCount_Views','stcoctUiName'=>'查看');
		$this->sSortButton[7]=array('stcotName'=>'coptCreateTime','stcoctUiName'=>'发布时间');
		
	}
	public function getSearch($pValue,$pType){
		$tmpAR0=array(
			$this->sMainID,
			$this->sSearchAR[0],
			$this->sSortAR0[0],
			$this->sSortAR0[1],
			);
		if($pType==0) $tmpAR0[0]=$pValue;
		if($pType==1) $tmpAR0[1]=$pValue;
		if($pType==2) $tmpAR0[2]=$pValue;
		if($pType==3) $tmpAR0[3]=$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].
			'&DSearch='.$tmpAR0[1].
			'&DSort0='.$tmpAR0[2].$this->sysSPLIT1.$tmpAR0[3];
		return $tmpSTR;
	}
	
}
?>