<?php
class netsConPButton extends netsControl {
	public $sInstanctName='ConPButton0';
	public $sTemplatePath='../../../Config/m_default/File/ContentPageButton1.htm';
	public $sTemplate=array();
	public $sContentAR=array();
	public $sPageName='DCList0';
	public $sPageArray=array();
	public $sPageParameter='&DCList0=1,0';
	public $sPage='';
	public $sExtendParameter='&ID=0';
	
	public function netsConPButton(){
		$this->sTemplate=explode($this->sysSPLIT10,$this->readFile($this->sTemplatePath));
	}
	public function setPage($pInfo,$pContent){
		//-- ------ #Split content ------ --
		$this->sContentAR=explode($this->sysSPLIT12,$pContent);
		if(count($pInfo)!=2){
			$pInfo=array(1,0);
		}
		$pInfo[1]=count($this->sContentAR);
		//-- ------ #pInfo ------ --
		//[0].Page index
		//[1].Page count
		$this->sPageArray=$pInfo;
		$this->sPageParameter='&'.$this->sPageName.'='.$pInfo[0].','.$pInfo[1];
	}
	public function showPage(){
		if(count($this->sTemplate)<10){
			return 1;
		}
		//-- ------ #Spell template ------ --
		$tmpOut=$this->sTemplate[0];
		$tmpOut.=$this->sTemplate[1];
		//#First
		$tmpINT=1;
		$tmpSTR=$this->sTemplate[2];
		$tmpAR0=explode($this->sysSPLIT5,$tmpSTR);
		if($this->sPageArray[0]<2){
			$tmpSTR=$tmpAR0[0];
		}else {
			$tmpSTR=str_replace('{Nets.PageButtonLink}',
				$this->sPage.'?'.$this->sPageName.'='.
				$tmpINT.','.$this->sPageArray[1].$this->sExtendParameter,
				$tmpAR0[1]);
		}
		$tmpOut.=$tmpSTR;
		//#Prev
		$tmpINT=$this->sPageArray[0]-1;
		$tmpSTR=$this->sTemplate[3];
		$tmpAR0=explode($this->sysSPLIT5,$tmpSTR);
		if($this->sPageArray[0]<2){
			$tmpSTR=$tmpAR0[0];
		}else {
			$tmpSTR=str_replace('{Nets.PageButtonLink}',
				$this->sPage.'?'.$this->sPageName.'='.
				$tmpINT.','.$this->sPageArray[1].$this->sExtendParameter,
				$tmpAR0[1]);
		}
		$tmpOut.=$tmpSTR;
		//#Num
		$tmpSTR=$this->sTemplate[4];
		$tmpAR0=explode($this->sysSPLIT5,$tmpSTR);
		$Coun0=0;
		while ($this->sPageArray[1]>$Coun0) {
			$tmpINT=$Coun0+1;
			if($tmpINT==$this->sPageArray[0]){
				$tmpSTR=str_replace('{Nets.IndexButtonText}',$tmpINT,$tmpAR0[0]);
			}else {
				$tmpSTR=str_replace('{Nets.IndexButtonText}',$tmpINT,$tmpAR0[1]);
				$tmpSTR=str_replace('{Nets.PageButtonLink}',
					$this->sPage.'?'.$this->sPageName.'='.
					$tmpINT.','.$this->sPageArray[1].$this->sExtendParameter,
					$tmpSTR);
			}
			$tmpOut.=$tmpSTR;
			$Coun0++;
		}
		//#Next
		$tmpINT=$this->sPageArray[0]+1;
		$tmpSTR=$this->sTemplate[5];
		$tmpAR0=explode($this->sysSPLIT5,$tmpSTR);
		if($this->sPageArray[0]==$this->sPageArray[1]){
			$tmpSTR=$tmpAR0[0];
		}else {
			$tmpSTR=str_replace('{Nets.PageButtonLink}',
				$this->sPage.'?'.$this->sPageName.'='.
				$tmpINT.','.$this->sPageArray[1].$this->sExtendParameter,
				$tmpAR0[1]);
		}
		$tmpOut.=$tmpSTR;
		//#End
		$tmpINT=$this->sPageArray[1];
		$tmpSTR=$this->sTemplate[6];
		$tmpAR0=explode($this->sysSPLIT5,$tmpSTR);
		if($this->sPageArray[0]==$this->sPageArray[1]){
			$tmpSTR=$tmpAR0[0];
		}else {
			$tmpSTR=str_replace('{Nets.PageButtonLink}',
				$this->sPage.'?'.$this->sPageName.'='.
				$tmpINT.','.$this->sPageArray[1].$this->sExtendParameter,
				$tmpAR0[1]);
		}
		$tmpOut.=$tmpSTR;
		//#Info
		$tmpSTR=str_replace('{Nets.Index}',$this->sPageArray[0],$this->sTemplate[7]);
		$tmpSTR=str_replace('{Nets.PageCount}',$this->sPageArray[1],$tmpSTR);
		$tmpOut.=$tmpSTR;
		$tmpOut.=$this->sTemplate[8];
		
		echo ($tmpOut);
		return 0;
	}
	public function getContent(){
		return $this->sContentAR[$this->sPageArray[0]-1];
	}
	public function resetTemlate($pTemplatePath){
		$this->sTemplatePath=$pTemplatePath;
		$this->sTemplate=explode($this->sysSPLIT10,$this->readFile($this->sTemplatePath));
	}
}
?>