<?php
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/commmicroblogging.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/commmicrobloggingcont.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Comm/Microblogging/commmicroblogging.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Comm/Microblogging/commmicrobloggingdiscuss.php');

require($netsFileConfig['sysCoreRoot'].'Inc/m_Oa/Oa/oacontact.php');

class PaDefault extends CustomPage {
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnBInitial(){
		$this->sMetaTitle='微博列表';
		$this->getUser('1,2,3,4,5,');
		$this->sApp=new commmicroblogging($this->sConnString);
		$this->sTable=array(
			array('sttTableName'=>$this->sysTableHead.'commmicroblogging','sttColumnHead'=>'combt'),
			array('sttTableName'=>$this->sysTableHead.'commmicrobloggingcont','sttColumnHead'=>'combct'),);
		$this->sTemplatePath='Comm/microbloggingList_Normal.php';
		

		//-- ------ #Contact ------ --
		$this->sContactApp=new oacontact($this->sConnString);
		$this->sContacts=array();
		$tmpINT=$this->sContactApp->GetContactToArray($this->sUserInfo[0]['Columns']['uitID']['Value'],$this->sContacts);
		
		//Parid
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.combgtID,A.combgtName,A.combgtParid,A.combgtNameStyle 
			FROM '.$this->sysTableHead.'commmicroblogginggroup AS A
			WHERE 1=1 AND A.combgtRecycle=0 AND A.combgtChecked>1 AND 
			A.combgtParid IN (SELECT combgtID FROM '.$this->sysTableHead.'commmicroblogginggroup WHERE 1=1 AND combgtRecycle=0 AND combgtChecked>1 AND combgtParid={Nets.Parid})
			ORDER BY A.combgtOrderBy DESC,A.combgtID DESC ';
		$tmpAR0['InitialString']=2;
		$tmpAR0['Parid']='combgtID';
		$tmpAR0['Text']='combgtName';
		$tmpAR0['Value']='combgtID';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='comm/comm_Microblogginggroup_list_ALL';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sParid1);
		$this->sParid2=$this->sParid1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='所有分类';
		$tmpAR0['Value']=2;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sParid2,$tmpAR0);
		//Type
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=67;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_Microblogging_Type';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sType1);
		$this->sType2=$this->sType1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='所有';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sType2,$tmpAR0);
		//Microblogging_UserType
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=78;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_Microblogging_UserType';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sUserType1);
		$this->sUserType2=$this->sUserType1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='所有';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sUserType2,$tmpAR0);

		//-- ------ #Control ------ --
		$this->sUiDescription_Custom0=array();
		$tmpSTR=$this->sUiDescriptionPath.'Plus/comm/microblogginglist_search.php';
		if(file_exists($tmpSTR)){
			require($tmpSTR);
			$this->sUiDescription_Custom0=$sysUiDescriptions['microblogginglist_search'];
		}
		
		
	}
	public function OnAdd(){

		$tmpDbDescriptions=array();
		foreach ($this->sTable as $tableCell){
			$tmpDbDescriptions[]=$this->sDbDescriptions[$tableCell['sttTableName']];
		}
		$tmpMainid=$this->AnalyerRequest('mainID',0,1);
		$this->sMainID=$tmpMainid[0];
		$tmpMainUserid=$this->AnalyerRequest('mainUserid',0,1);
		$this->sMainUserid=$tmpMainid[0];
		$tmpMainTableid=$this->AnalyerRequest('mainTableid',0,1);
		$this->sMainTableid=$tmpMainid[0];
		//-- ------ #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
		$tmpDbDescription0=$tmpDbDescriptions;
		$Coun0=0;
		foreach ($tmpDbDescription0 as $tableCell){
			foreach ($tableCell['Columns'] as $Column){
				if($Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'ID' &&
					$Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'NumCode' &&
					$Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'CreateBy' &&
					$Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'CreateTime' &&
					$Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'IndexID'){
					$tmpAR0=$this->AnalyerRequest($Column['stcotName'].'Txt',$Column['stcoctDefaultValue'],1);
					$tmpDbDescriptions[$Coun0]['Columns'][$Column['stcotName']]['Value']=$tmpAR0[0];
				}
			}
			$Coun0++;
		}
		//-- #Set conventional --
		if(isset($tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateBy']['Value'])){
			$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateBy']['Value']=$tmpMainUserid[0];
		}
		if(isset($tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateTime'])){
			$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateTime']['Value']=date($this->sysTimeFormat);
		}
		//DB name,Condition,User index,User column name
		$tmpFlag=0;
		foreach ($this->AnonymousUserData as $Row0){
			if (count($tmpDbDescriptions)>1) {
				if(isset($tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].$Row0[0]])){
					if ($tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].$Row0[0]]['Value']==$Row0[1]) {
						$tmpFlag=1;
					}
				}
			}
			if ($this->sUserInfo[0]['Columns']['uitID']['Value']==0 && $tmpFlag==1) {
				$tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].$Row0[0]]['Value']=$Row0[4];
			}else if ($tmpFlag==1 && isset($tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].$Row0[0]])) {
				$tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].$Row0[0]]['Value']=$this->sUserInfo[$Row0[2]]['Columns'][$Row0[3]]['Value'];
			}
		}
		//Spical value array
		foreach ($this->sSpicalValue as $Cell){
			if(isset($tmpDbDescriptions[$Cell[0]]['Columns'][$Cell[1]]['Value'])){
				$tmpDbDescriptions[$Cell[0]]['Columns'][$Cell[1]]['Value']=$Cell[2];
			}
		}
		//-- #Set spical --
		$tmpAR0=$this->AnalyerRequest('Microblogging_PublishTxt_Content','',1);
		$tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].'Content']['Value']=$tmpAR0[0];
		
		$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'Name']['Value']=$this->sCode->SubString($tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].'Content']['Value'],0,60);
		$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'Checked']['Value']=2;
		
		//Img
		$tmpAR0=$this->AnalyerRequest('Microblogging_PublishTxt_Content_0_BoxIndex',0,1);
		$tmpAR0=$this->AnalyerRequest('Microblogging_PublishTxt_Content_0_'.$tmpAR0[0].'_Value','',1);
		$tmpContent_Img=$tmpAR0[0];
		
		//Video
		$tmpAR0=$this->AnalyerRequest('Microblogging_PublishTxt_Content_1_BoxIndex',0,1);
		$tmpAR0=$this->AnalyerRequest('Microblogging_PublishTxt_Content_1_'.$tmpAR0[0].'_Value','',1);
		$tmpContent_Video=$tmpAR0[0];
		
		//Music
		$tmpAR0=$this->AnalyerRequest('Microblogging_PublishTxt_Content_2_BoxIndex',0,1);
		$tmpAR0=$this->AnalyerRequest('Microblogging_PublishTxt_Content_2_'.$tmpAR0[0].'_Value','',1);
		$tmpContent_Music=$tmpAR0[0];
		
		//Face
		$tmpAR0=$this->AnalyerRequest('Microblogging_PublishTxt_Content_3_BoxIndex',0,1);
		$tmpAR0=$this->AnalyerRequest('Microblogging_PublishTxt_Content_3_'.$tmpAR0[0].'_Value','',1);
		$tmpContent_Face=$tmpAR0[0];
		
		//Microspeak
		$tmpAR0=$this->AnalyerRequest('Microblogging_PublishTxt_Content_4_BoxIndex',0,1);
		$tmpAR0=$this->AnalyerRequest('Microblogging_PublishTxt_Content_4_'.$tmpAR0[0].'_Value','',1);
		$tmpContent_Microspeak=$tmpAR0[0];
		
		
		
		//#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.'?ActionType=Normal&Normal='.$tmpMainid[0].','.$tmpMainTableid[0].'');
		/*
		$this->sJscript=$this->Message_Frame('A,0',
			$this->sysFileConfig['sysCoreRoot'].$this->sysFileConfig['PathManaFrameMessage'],
			$this->sCode->URL_MakeParameter('添加成功',0),
			$this->sCode->URL_MakeParameter($this->sApp->sysLastError,0),
			$this->sCode->URL_MakeParameter($this->sysFileConfig['sysCoreRoot'].'Mana/m_cms/doc/doc.php',0));
		*/
		return 0;
	}
	public function OnList(){
		$tmpAR0=$this->AnalyerRequest('ID',2,0);
		$this->sMainID=$tmpAR0[0];
		//-- ------ #This group ------ --
		$tmpSQL=' SELECT A.combgtID,A.combgtName,B.combgctTemplateid_List 
			FROM {Nets.TableHead}commmicroblogginggroup AS A 
			INNER JOIN {Nets.TableHead}commmicroblogginggroupcont AS B ON B.combgctIndexID=A.combgtID
			WHERE 1=1 AND A.combgtRecycle=0 AND A.combgtChecked>1 AND A.combgtID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sMainID,$tmpSTR);
		$tmpData0=$this->sDb->Search($tmpSTR);
		if(count($tmpData0)==0){
			//Error
			return 1;
		}
		$this->sMetaTitle=$tmpData0[0]['combgtName'];
		//-- ------ #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}',$tmpData0[0]['combgctTemplateid_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.'commmicroblogginggroup','combgt');
		$this->sNavigation=$this->sDb->getParent($this->sMainID,$this->sysTableHead.'commmicroblogginggroup','combgt');
		//-- ------ #Datas ------ --

/*
内容或关链字,Content,
类型,Type,-1
话题,SpeakWord,
是否是联系人,Friend,-1
发布时间,CreateTime,-1
*/
		
		$tmpSearchSTR='DSearch';
		$this->sSearchAR=$this->AnalyerRequest($tmpSearchSTR,',-1,,-1,-1',0);
		$tmpListSTR0='DList0';
		$tmpListAR0=$this->AnalyerRequest($tmpListSTR0,'1,0,24,0',0);
		$tmpSortSTR0='DSort0';
		$tmpSortAR0=$this->AnalyerRequest($tmpSortSTR0,'combtID,2',0);
		//-- #Spell SQL --
		$tmpSQL=' SELECT A.combtID,A.combtName,A.combtParid,A.combtCreateBy,A.combtCreateTime,
			B.combctContent,B.combctSourceR00,
			B.combctCount_Views,B.combctCode_Positive,B.combctCode_Negative,B.combctCount_Discuss,
			B.combctPublisher_Name,B.combctPublisher_Email,B.combctPublisher_Source

			FROM {Nets.TableHead}commmicroblogging AS A
			INNER JOIN {Nets.TableHead}commmicrobloggingcont AS B ON B.combctIndexID=A.combtID
			WHERE 1=1 AND A.combtRecycle=0 AND A.combtChecked>1 AND (1=2 {Nets.Parids}) ';
		if ($this->sSearchAR[0]!='') {
			$tmpSQL.=' AND B.combctContent LIKE \'%'.$this->sSearchAR[0].'%\' ';
		}
		if ($this->sSearchAR[1]!=-1) {
			$tmpSQL.=' AND A.combtType='.$this->sSearchAR[1].' ';
		}
		
		$tmpSQL.=' ORDER BY A.combtOrderBy DESC,A.combtID DESC ';
		$tmpSTR_0='';
		foreach ($tmpChildidAR0 as $Cell){
			$tmpSTR_0.=' OR A.combtParid='.$Cell.' ';
		}
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Parids}',$tmpSTR_0,$tmpSTR);
		$this->sListData=$this->sDb->SearchP($tmpSTR,$tmpListAR0);
		$this->sRecordCount=$this->sDb->sysPageInfo[3];
		//#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->sysSPLIT1.$this->sSearchAR[4];
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		
		//-- ------ #Control value ------ --
		$Coun0=0;
		while (count($this->sUiDescription_Custom0)>$Coun0) {
			if ($this->sUiDescription_Custom0[$Coun0]['stcotName']=='Content') {
				$this->sUiDescription_Custom0[$Coun0]['Value']=$this->sSearchAR[0];
			}else if ($this->sUiDescription_Custom0[$Coun0]['stcotName']=='Friend') {
				$this->sUiDescription_Custom0[$Coun0]['Value']=$this->sSearchAR[3];
			
			}
			$Coun0++;
		}
		
		
		
	}
	public function DefUiPanel(&$pColumn,$pFlag){
		parent::DefUiPanel($pColumn,$pFlag);
		if($pColumn['stcotName']=='Friend' && $pFlag=='Normal'){
			$pColumn['Option']=$this->sUserType2;
			$pColumn['Parameter']=$this->sysPage.'?ID='.$this->sMainID.'&DSearch='.
				$this->sSearchAR[0].$this->sysSPLIT1.
				$this->sSearchAR[1].$this->sysSPLIT1.
				$this->sSearchAR[2].$this->sysSPLIT1.
				'{Nets.Value}'.$this->sysSPLIT1.
				$this->sSearchAR[4];
		}
		if ($pColumn['stcoctUiType']=='Text') {
			$pColumn['ControlStyle']='width:540px;';
		}
		return $pColumn;
	}
	public function DefUiJscript($pFlag){
?>
function JsDCheck(pPara){
	var tmpControl="";
	var tmpError="";
	var tmpChecker=new netsChecker();
	var tmpActionWithOut=document.getElementById("ActionWithOut");
	var Coun0=0;
	
	var tmpMBPublish=new MBPublish();
	//-- ------ #ActionWithOut ------ --
	if(tmpActionWithOut==undefined){
		return true;
	}
	if(tmpActionWithOut.value=="1"){
		return true;
	}else if(tmpActionWithOut.value=="2"){
		return false;
	}
	//-- ------ #Check ------ --
	//#Microblogging_PublishTxt_Content
	tmpCheckCont=document.getElementById("Microblogging_PublishTxt_Content");
	tmpCheckCont.value=tmpChecker.Filter(tmpCheckCont.value,0);
	if(!tmpChecker.CheckLen(tmpCheckCont.value,1,140) ||
		tmpCheckCont.value==tmpMBPublish.sDetailContent){
		Coun0++;
		tmpError+=Coun0+".发布的内容不能为空"+tmpCommon.sysSPLIT8;
	}

	//-- ------ #Result ------ --
	if(tmpError!=""){
		tmpSTR="<span class=\"FStrong\">对不起，您提交的内容存在以下错误:</span>"+tmpCommon.sysSPLIT8+tmpError;
		tmpFrames.showMessage("系统消息 - <?php echo ($this->sysFileConfig['bussinessMetaTitle']); ?>",tmpSTR,"","0");
		return false;
	}else{
		return true;
	}
}
<?php
	}
	
	public function getSearch($pValue,$pType){
/*

内容或关链字,Content,
类型,Type,-1
话题,SpeakWord,
是否是联系人,Friend,-1
发布时间,CreateTime,-1

*/
		//-- #VALUE --
		$tmpAR0=$this->sSearchAR;
		//Content
		if($pType==0) $tmpAR0[0]=$pValue;
		//Type
		if($pType==1) $tmpAR0[1]=$pValue;
		//SpeakWord
		if($pType==2) $tmpAR0[2]=$pValue;
		//Friend
		if($pType==3) $tmpAR0[3]=$pValue;
		//CreateTime
		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='.$this->sMainID.'&DSearch='.
			$tmpAR0[0].$this->sysSPLIT1.
			$tmpAR0[1].$this->sysSPLIT1.
			$tmpAR0[2].$this->sysSPLIT1.
			$tmpAR0[3].$this->sysSPLIT1.
			$tmpAR0[4];
		return $tmpSTR;
	}
	
	
}
?>