<?php
require('../../../QPlatform/Common/Component/ComInitialHead.php');
require($netsFileConfig['sysCoreRoot'].'Inc/netsFunc/Func/netsSimpleXml.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Cms/Doc/cmsdoc.php');

class PaDefault extends CustomPage {
	public $ssetParid=1;
	
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnPInitial(){
		$this->checkUser('1,2,3,');
		$this->sTable=array(
			array('sttTableName'=>$this->sysTableHead.'cmsdoc','sttColumnHead'=>'cdt'),
			array('sttTableName'=>$this->sysTableHead.'cmsdoccont','sttColumnHead'=>'cdct'),);
		$this->sUiName='Platform/cms/doc_doc';
	}
	public function OnBInitial(){
		$this->sMetaTitle='文档';
		$this->sLimitCount=0;
		$this->sApp=new cmsdoc($this->sConnString);
		//Parid
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.cdgtID,A.cdgtName,A.cdgtParid,A.cdgtNameStyle 
			FROM '.$this->sysTableHead.'cmsdocgroup AS A
			WHERE 1=1 AND A.cdgtRecycle=0 AND A.cdgtChecked>1 AND A.cdgtParid={Nets.Parid}
			ORDER BY A.cdgtOrderBy DESC,A.cdgtID DESC ';
		$tmpAR0['SQL0']=' SELECT A.cdgtID,A.cdgtName,A.cdgtParid 
			FROM '.$this->sysTableHead.'cmsdocgroup AS A
			WHERE 1=1 AND A.cdgtRecycle=0 AND A.cdgtChecked>1 AND A.cdgtID={Nets.Parid}
			ORDER BY A.cdgtOrderBy DESC,A.cdgtID DESC ';
		$tmpAR0['InitialString']=$this->ssetParid;
		$tmpAR0['Parid']='cdgtID';
		$tmpAR0['Text']='cdgtName';
		$tmpAR0['Value']='cdgtID';
		$tmpAR0['Type']=0;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='cms/doc_Group';
		$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);
		//Channel
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT 
			A.cctID,A.cctName,A.cctParid
			FROM '.$this->sysTableHead.'cmschannel AS A 
			WHERE 1=1 AND A.cctRecycle=0 AND A.cctChecked>1 AND A.cctParid={Nets.Parid}
			ORDER BY A.cctOrderBy DESC,A.cctID DESC ';
		$tmpAR0['InitialString']=$this->ssetParid;
		$tmpAR0['Parid']='cctID';
		$tmpAR0['Text']='cctName';
		$tmpAR0['Value']='cctID';
		$tmpAR0['Type']=0;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$this->sChannelid1=$this->sChannelid2=$this->sControl->bindDropdown($tmpAR0);
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='[所有的频道]';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sChannelid2,$tmpAR0);
		//Templateid_Detail
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.stemtID,A.stemtName FROM '.$this->sysTableHead.'netssystemplate AS A 
			WHERE 1=1 AND A.stemtRecycle=0 AND A.stemtChecked>1 AND A.stemtFunctionid={Nets.Parid}
			ORDER BY A.stemtOrderBy DESC,A.stemtID DESC ';
		$tmpAR0['InitialString']=2;
		$tmpAR0['Parid']='stemtID';
		$tmpAR0['Text']='stemtName';
		$tmpAR0['Value']='stemtID';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$this->sTemplateid_Detail1=$this->sTemplateid_Detail2=$this->sControl->bindDropdown($tmpAR0);
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='[所有的模板]';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sTemplateid_Detail2,$tmpAR0);
		
	}
	public function OnList(){
		//-- ------ #Search data ------ --
		$tmpSTR0='DList0';
		$tmpAR0=$this->getQueryString($tmpSTR0);
		$tmpSTR1='DSort0';
		$tmpAR1=$this->AnalyerRequest($tmpSTR1,'cdtID,2',0);
		$tmpSTR2='Search0';
		$this->sSearchData=$this->AnalyerRequest($tmpSTR2,'-1,,-1',0);
		//#Spell sql
		$tmpSQL=' SELECT 
			A.cdtID,A.cdtName,A.cdtParid,A.cdtOrderBy,C.cdgtName
			FROM (('.$this->sysTableHead.'cmsdoc AS A 
			INNER JOIN '.$this->sysTableHead.'cmsdoccont AS B ON B.cdctIndexID=A.cdtID)
			LEFT OUTER JOIN '.$this->sysTableHead.'cmsdocgroup AS C ON C.cdgtID=A.cdtParid)
			WHERE 1=1 
			AND A.cdtID>'.$this->sLimitCount;
		if($this->sSearchData[0]!='-1'){
			$tmpSQL.=' AND A.cdtChecked='.$this->sSearchData[0].' ';
		}
		if($this->sSearchData[1]!=''){
			$tmpSQL.=' AND A.cdtName LIKE \'%'.$this->sSearchData[1].'%\' ';
		}
		if($this->sSearchData[2]!='-1'){
			$tmpSQL.=' AND A.cdtParid='.$this->sSearchData[2].' ';
		}
		
		if($tmpAR1[1]==1){
			$tmpSQL.=' ORDER BY '.$tmpAR1[0].' ';
		}else if($tmpAR1[1]==2){
			$tmpSQL.=' ORDER BY '.$tmpAR1[0].' DESC ';
		}
		$this->sListData=$this->sDb->SearchP($tmpSQL,$tmpAR0);
		//#Set page button
		$this->sPButton->sPage=$this->sysPage;
		$this->sPButton->sExtendParameter='&'.$tmpSTR2.'='.$this->sSearchData[0].$this->sysSPLIT1.$this->sSearchData[1].$this->sysSPLIT1.$this->sSearchData[2];
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		$this->sPButton->setSort($tmpAR1);
		$this->sSortButton[0]=array('stcotName'=>'cdtID','stcoctUiName'=>'编号');
		$this->sSortButton[1]=array('stcotName'=>'cdtName','stcoctUiName'=>'文档名称');
		
		return 0;
	}
	public function OnExternal_Search(){
		//-- ------ #Search data ------ --
		$tmpSTR0='DList0';
		$tmpAR0=$this->getQueryString($tmpSTR0);
		$tmpSTR1='DSort0';
		$tmpAR1=$this->AnalyerRequest($tmpSTR1,'cdtID,2',0);
		$tmpSTR2='Search0';
		$this->sSearchData=$this->AnalyerRequest($tmpSTR2,',-1',0);
		$this->sExternal_SearchData=$this->AnalyerRequest($this->sActionType,',-1',0);
		//#Spell sql
		$tmpSQL=' SELECT A.cdtID,A.cdtName
			FROM '.$this->sysTableHead.'cmsdoc AS A 
			WHERE 1=1 
			AND A.cdtID>'.$this->sLimitCount;
		if($this->sSearchData[0]!=''){
			$tmpSQL.=' AND A.cdtName LIKE \'%'.$this->sSearchData[0].'%\' ';
		}
		if($this->sSearchData[1]!='-1'){
			$tmpSQL.=' AND A.cdtParid='.$this->sSearchData[1].' ';
		}
		if($tmpAR1[1]==1){
			$tmpSQL.=' ORDER BY '.$tmpAR1[0].' ';
		}else if($tmpAR1[1]==2){
			$tmpSQL.=' ORDER BY '.$tmpAR1[0].' DESC ';
		}
		$this->sListData=$this->sDb->SearchP($tmpSQL,$tmpAR0);
		//#Set page button
		$this->sExtendParameter='&ActionType='.$this->sActionType.'&'.$this->sActionType.'='.$this->sExternal_SearchData[0].','.$this->sExternal_SearchData[1];
		$this->sysPages[0]=$this->sysPage.'?'.$this->sExtendParameter;
		
		$this->sPButton->sPage=$this->sysPage;
		$this->sPButton->sExtendParameter='&'.$tmpSTR2.'='.$this->sSearchData[0].','.$this->sSearchData[1].$this->sExtendParameter;
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		$this->sPButton->setSort($tmpAR1);
		$this->sSortButton[0]=array('stcotName'=>'cdtID','stcoctUiName'=>'编号');
		$this->sSortButton[1]=array('stcotName'=>'cdtName','stcoctUiName'=>'文档标题');
		
		return 0;
	}
	public function OnNormal(){
		$tmpAR0=$this->AnalyerRequest('Normal','0,0',0);
		
		$tmpSQL=' SELECT * 
			FROM '.$this->sysTableHead.'cmsdoc AS A 
			INNER JOIN '.$this->sysTableHead.'cmsdoccont AS B ON B.cdctIndexID=A.cdtID ';
		$Coun0=2;
		foreach ($this->sTable as $Row0){
			if (count($this->sTable)>2) {
				$tmpSQL.=' INNER JOIN '.$Row0['sttTableName'].' AS '.$this->sysTableMark[$Coun0].' ON '.$this->sysTableMark[$Coun0].'.'.$Row0['sttColumnHead'].'IndexID=A.cdtID ';
				$Coun0++;
			}
		}
		$tmpSQL.=' WHERE 1=1 AND A.cdtID='.$tmpAR0[0].' ';
		$tmpDataCollection0=$this->sDb->Search($tmpSQL);
		if(count($tmpDataCollection0)>0){
			$tmpRow=$tmpDataCollection0[0];
			$this->sMainID=$tmpRow[$this->sTable[0]['sttColumnHead'].'ID'];
			//-- #Get value --
			$Coun0=0;
			while (count($this->sUiDescription_Normal)>$Coun0) {
				if(isset($tmpRow[$this->sUiDescription_Normal[$Coun0]['stcotName']])){
					$this->sUiDescription_Normal[$Coun0]['Value']=$tmpRow[$this->sUiDescription_Normal[$Coun0]['stcotName']];
					//-- ------ #Spical set ------ --
					if($this->sUiDescription_Normal[$Coun0]['stcotName']=='cdtParid'){
					}else if($this->sUiDescription_Normal[$Coun0]['stcotName']=='cdctModelid_Detail'){
						$this->sUiDescription_Normal[$Coun0]['Value']=$this->sMainTableid;
					}else if($this->sUiDescription_Normal[$Coun0]['stcotName']=='cdtCreateBy'){
						$tmpSQL=' SELECT A.uitID,A.uitName FROM '.$this->sysTableHead.'netsuserinfo AS A
							WHERE 1=1 AND A.uitRecycle=0 AND A.uitChecked>1 AND A.uitID={Nets.ID} ';
						$tmpSTR=str_replace('{Nets.ID}',$tmpRow[$this->sUiDescription_Normal[$Coun0]['stcotName']],$tmpSQL);
						$tmpData0=$this->sDb->Search($tmpSTR);
						if(count($tmpData0)>0){
							$this->sUiDescription_Normal[$Coun0]['ShowValue']=$tmpData0[0]['uitName'];
						}
					}else if($this->sUiDescription_Normal[$Coun0]['stcotName']=='cdctChannelid'){
						$tmpSQL=' SELECT A.cctID,A.cctName FROM '.$this->sysTableHead.'cmschannel AS A
							WHERE 1=1 AND A.cctRecycle=0 AND A.cctChecked>1 AND (1=2 {Nets.IDS}) ';
						$tmpAR0=explode($this->sysSPLIT1,$tmpRow[$this->sUiDescription_Normal[$Coun0]['stcotName']]);
						$tmpSTR='';
						foreach ($tmpAR0 as $Cell0){
							$tmpSTR.=' OR A.cctID='.$this->sCode->Int32($Cell0,0);
						}
						$tmpSTR=str_replace('{Nets.IDS}',$tmpSTR,$tmpSQL);
						$tmpData0=$this->sDb->Search($tmpSTR);
						$tmpAR0=array();
						foreach ($tmpData0 as $Row0){
							$tmpAR1=$this->sControl->sDpReturnTemplate;
							$tmpAR1['Text']=$Row0['cctName'];
							$tmpAR1['Value']=$Row0['cctID'];
							$tmpAR0[]=$tmpAR1;
						}
						$this->sUiDescription_Normal[$Coun0]['Option']=$tmpAR0;
					}
				}
				$Coun0++;
			}
		}else {}
	}
	
	public function DefUiPanel(&$pColumn,$pFlag){
		parent::DefUiPanel($pColumn,$pFlag);
		$tmpSimpleXml=new netsSimpleXml();
		
		if($pColumn['stcotName']=='cdtParid' && $pFlag=='Search'){
			$pColumn['Option']=$this->sParid2;
		}else if($pColumn['stcotName']=='cdtParid' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Option']=$this->sParid1;

		}
		return $pColumn;
	}
}
//-- ------ #Instanct ------ --
$tmpDefault=new PaDefault();
$tmpDefault->OnPage();
$tmpControls=new CustomControls();
$tmpControlPage=new CustomControlPage();
$tmpComHead->sMenuid=$tmpDefault->sMenuid;
$tmpComHead->sOpenSort=1;
$tmpDefault->sysMetaTitle=$tmpDefault->sMetaTitle.' - '.$tmpDefault->sysFileConfig['sysTitle'];
//-- ------ #Template ------ --
require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/Head_Frame.php');
?>
<!-- ------ #Content ------ -->
<br />
<div class="Error_4"><a href="http://www.unionnets.com"><img src="../../../Ui/m_nets/Img/Logo.jpg" /></a></div><br />
<div class="Error_4 FSize0 FFamily2">您访问的是网集在线平台</div><br />

<!-- ------ #End ------ -->
<!-- #End_Version -->
<div class="Error_4">
<span class="Logo_B">POWER BY <a href="http://www.unionnets.com" class="Link2 Logo_B_0" target="_blank">UNION<span class="Logo_B_1">NETS</span><span class="Logo_B_2">.COM</span></a></span>
<span class="FHead0">鄂ICP备10024117号</span><br />
</div>

<!-- ------ #SCRIPT ------ -->
<script type="text/javascript">
tmpFrames.loadedContent("",0);

</script>
<?php require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/Head_Frame.php'); ?>