<?php
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/cmsfriend.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/cmsfriendcont.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Cms/Other/cmsfriend.php');

class PaDefault extends CustomPage {
	public $sCmsdoc=array();
	
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnPInitial(){
		$this->sTable=array(
			array('sttTableName'=>$this->sysTableHead.'cmsfriend','sttColumnHead'=>'cft'),
			array('sttTableName'=>$this->sysTableHead.'cmsfriendcont','sttColumnHead'=>'cfct'),);

	}
	public function OnBInitial(){
		$this->sMetaTitle='友情链接';
		$this->getUser('1,2,3,4,5,');
		$this->sApp=new cmsfriend($this->sConnString);
		$this->sTemplatePath='Cms/friendshipHome.php';
		
	}
	public function OnAdd(){
		$tmpDbDescriptions=array();
		foreach ($this->sTable as $tableCell){
			$tmpDbDescriptions[]=$this->sDbDescriptions[$tableCell['sttTableName']];
		}
		$tmpMainid=$this->AnalyerRequest('mainID','0',1);
		$tmpMainUserid=$this->AnalyerRequest('mainUserid',0,1);
		$tmpMainTableid=$this->AnalyerRequest('mainTableid',0,1);
		//-- ------ #Submit limit check ------ --
		$tmpINT=$this->submitLimitWrite($this->sysPage,-1,-1,-1);
		if($tmpINT!=0){
			$this->sJscript=$this->Message('SUCCESS','','对不起，您提交得太快了，请'.$this->sysFileConfig['SubmitLimitFreeze'].'秒后再提交。','');
			return 1;
		}
		//-- ------ #Add ------ --
		$this->sApp->TransStart();
		//#Get numCode
		$tmpSTR=$this->sTable[0]['sttColumnHead'].'NumCode';
		$tmpDbDescriptions[0]['TableDescription']['SearchColumn']=$tmpSTR;
		$tmpDbDescriptions[0]['Columns'][$tmpSTR]['Value']='N_'.date('YmdHis');
		$this->sApp->numCode($tmpDbDescriptions[0]);
		//#Set value
		$tmpSTR='cftName';
		$tmpAR0=$this->AnalyerRequest($tmpSTR.'Txt','',1);
		$tmpDbDescriptions[0]['Columns'][$tmpSTR]['Value']=$tmpAR0[0];
		$tmpSTR='cftLink';
		$tmpAR0=$this->AnalyerRequest($tmpSTR.'Txt','',1);
		$tmpDbDescriptions[0]['Columns'][$tmpSTR]['Value']=$tmpAR0[0];
		$tmpSTR='cfctPublisher_Email';
		$tmpAR0=$this->AnalyerRequest($tmpSTR.'Txt','',1);
		$tmpDbDescriptions[1]['Columns'][$tmpSTR]['Value']=$tmpAR0[0];
		$tmpSTR='cfctContent';
		$tmpAR0=$this->AnalyerRequest($tmpSTR.'Txt','',1);
		$tmpDbDescriptions[1]['Columns'][$tmpSTR]['Value']=$tmpAR0[0];
		$tmpSTR='cftChecked';
		$tmpAR0=$this->AnalyerRequest($tmpSTR.'Txt','',1);
		$tmpDbDescriptions[0]['Columns'][$tmpSTR]['Value']=$tmpAR0[0];
		//-- #Set spical --
		$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateBy']['Value']=$this->sUserInfo[0]['Columns']['uitID']['Value'];
		$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateTime']['Value']=date($this->sysTimeFormat);
		if ($tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateBy']['Value']==0) {
			$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateBy']['Value']=2;
		}
		//#Add
		$tmpINT=$this->sApp->Check($tmpDbDescriptions,array(),array());
		if($tmpINT!=0){
			$this->sApp->TransRollback();
			$this->sJscript=$this->Message('ERROR','',$this->sApp->sysLastError,'');
			return 1;
		}
		$Coun0=0;
		while (count($tmpDbDescriptions)>$Coun0){
			if($Coun0==0){
				$tmpDbDescriptions[$Coun0]['TableDescription']['SearchColumn']=$this->sTable[$Coun0]['sttColumnHead'].'NumCode,'.$this->sTable[$Coun0]['sttColumnHead'].'ID';
			}else {
				$tmpDbDescriptions[$Coun0]['TableDescription']['SearchColumn']=$this->sTable[$Coun0]['sttColumnHead'].'IndexID';
			}
			$Coun0++;
		}
		$tmpINT=$this->sApp->add($tmpDbDescriptions);
		if($tmpINT!=0){
			$this->sApp->TransRollback();
			$this->sJscript=$this->Message('ERROR','',$this->sApp->sysLastError,'');
			return 1;
		}
		foreach ($this->sDb->sysDbCacheClear as $Cell){
			$this->clearCache($Cell);
		}
		foreach ($this->sysPageCacheClear as $Cell){
			$this->clearCache($Cell);
		}
		$this->sApp->TransCommit();
		$this->sJscript=$this->Message('SUCCESS','','添加成功',$this->sysPage.'?DType='.$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'Type']['Value'].$this->sysSPLIT1);
		return 0;
	}
	public function OnList(){
		$tmpAR0=$this->AnalyerRequest('DType','0,',0);
		
		//-- ------ #Form ------ --
		$this->sUiDescription_0=array();
		$tmpName='cmsfriend';
		$tmpSTR=$this->sUiDescriptionPath.'Plus/cms/'.$tmpName.'.php';
		if(file_exists($tmpSTR)){
			require($tmpSTR);
			$this->sUiDescription_0=$sysUiDescriptions[$tmpName];
			$sysUiDescriptions=array();
		}

		return 0;
	}
	public function DefUiPanel(&$pColumn,$pFlag){
		if($pColumn['stcotName']=='cfctContent' && $pFlag=='Normal'){
			$pColumn['ControlStyle']='width:320px;height:40px;';
			$pColumn['Parameter_JS_Onfocus']="tmpMCommon.OnDiscussInput(this.name,0);CCodeTxt_ShowCACode(0);";
		}else if($pColumn['stcotName']=='cfctPublisher_Email' && $pFlag=='Normal'){
			$pColumn['Value']=$this->sUserInfo[0]['Columns']['uitEmail']['Value'];

		}
		if($pColumn['stcoctUiType']=='Text' && $pFlag=='Normal'){
			$pColumn['ControlStyle']='width:320px;';

		}
	}



}
?>