mlTabsPerLine=$tabsPerLine; $this->mlTabIndex=$lTabindexStart; $this->oSystem=&$oSystem; $this->msDBAccessKey=$dbAccessKey; $this->msViewSource=$viewSource; $this->asSearchInFields=$asSearchInFields; $this->gsEmpty(); } function gsEmpty() { $this->masEmpty["__all__"]=""; if(is_array($this->asSearchInFields)) foreach($this->asSearchInFields as $sKey) $this->masEmpty[$sKey]=""; } function gbContainsData($asData) { if(is_array($asData)) foreach($asData as $sKey=>$sValue) { if($sValue!="") return true; } return false; } function goLoadViewTPLParser($sView,$lError,$asAdditionalURLData=array(),$asAdditionalConditionData=array(),$oEnrichData=false,$sStandardOrderBy="",$bRefresh=false,$sStandardOrderDir="ASC") { if($bRefresh===true) { unset($_SESSION[$sView.".order"]); $asSearchData=false; $_SESSION[$sView.".search"]["searchData"]=false; unset($_SESSION[$sView.".order"]["dir"]); unset($_SESSION[$sView.".order"]["field"]); unset($_SESSION[$sView.".offset"]["offset"]); } if(sizeof($asAdditionalURLData)>0) { if($sAdditional=$this->oSystem->oControl->oURL->gsGetURLData($asAdditionalURLData)) { $sAdditional.="&"; } } $lOffset=false; $asSearchData=$this->oSystem->oClientData->gvGetVariable("__searchData",false); $bContains=$this->gbContainsData($asSearchData); if($bContains===true) { $lOffset=0; } else { if(isset($_SESSION[$sView.".search"]["searchData"])) { $asSearchData=$_SESSION[$sView.".search"]["searchData"]; } } $asSearchQuery=array(); $asAdditionalConditionData["SEARCHDATA"]=1; if($this->oSystem->oClientData->gvGetVariable("DROPLIST",false)=="TRUE") { $asSearchData=false; $_SESSION[$sView.".search"]["searchData"]=false; unset($_SESSION[$sView.".order"]["dir"]); unset($_SESSION[$sView.".order"]["field"]); unset($_SESSION[$sView.".offset"]["offset"]); } else { $asSearchQuery=array(); if($asSearchData!==false) { $_SESSION[$sView.".search"]["searchData"]=$asSearchData; if(isset($asSearchData["__all__"])&&$asSearchData["__all__"]!="") { if($this->asSearchInFields!==false) { $asSearchInData=explode(",",$asSearchData["__all__"]); foreach($asSearchInData as $sValue) { $asSingle=array(); foreach($this->asSearchInFields as $sFieldName) { $asSingle[]="(".$sFieldName." LIKE ('%".$sValue."%')".")"; } $asSearchQuery[]="(".join(" OR \n",$asSingle).")"; } } unset($asSearchData["__all__"]); } } $asAdditionalConditionData["SEARCHDATA"]=1; if(sizeof($asSearchQuery)>0) { $asAdditionalConditionData["SEARCHDATA"]="(".join(" AND \n",$asSearchQuery).")"; } } $lReadOffset=$this->oSystem->oClientData->gvGetVariable("offset",false); if($lReadOffset===false) { if($lOffset===false) { if(isset($_SESSION[$sView.".offset"]["offset"])) $lOffset=$_SESSION[$sView.".offset"]["offset"]; } } else $lOffset=$lReadOffset; $lOffset=$lOffset===false||empty($lOffset)?0:$lOffset; $sOrderBy=false; if($sOrderBy=$this->oSystem->oClientData->gvGetVariable("orderby",false)) { } else { if(isset($_SESSION[$sView.".order"]["field"])) { $sOrderNew=$sOrderBy!==false; $sOrderBy=$_SESSION[$sView.".order"]["field"]===""?false:$_SESSION[$sView.".order"]["field"];; } } $sOrderNew=$sOrderBy!==false; $sOrderBy=$sOrderBy===false?$sStandardOrderBy:$sOrderBy; $sOrderDir=false; if(isset($_SESSION[$sView.".order"]["dir"])&&$this->oSystem->oClientData->gvGetVariable("orderby",false)===false) $sOrderDir=$_SESSION[$sView.".order"]["dir"]; else { if($sOrderNew===true) { $sOrderDir=$sStandardOrderDir; if(isset($_SESSION[$sView.".order"]["dir"])) { $sOrderDir=$_SESSION[$sView.".order"]["dir"]; if($sOrderDir=="ASC") $sOrderDir="DESC"; else $sOrderDir="ASC"; } } } if($sOrderDir=="") $sOrderDir=$sStandardOrderDir; $_SESSION[$sView.".order"]["dir"]=$sOrderDir; $_SESSION[$sView.".order"]["field"]=$sOrderBy; $_SESSION[$sView.".offset"]["offset"]=$lOffset; $sOrderedBy=$sOrderBy." ".$sOrderDir; $lCount=18; $asCondition=$asAdditionalConditionData+array("Offset"=>$lOffset,"Count"=>$lCount,"Order"=>$sOrderedBy); $this->asCondition=$asCondition; $oDB=&$this->oSystem->oDB; if($this->msViewSource!==false) $oDB=new CDatabase($this->msViewSource); if($oView=$oDB->goGetView($sView,$asCondition,$this->msDBAccessKey)) { $lCount=$oView->mlShowPerPage; $oPageListGen=new CMGMListGenerator($lOffset,$lCount,$oView->mlGesamt); $sFile=PATHQS."views/view.".$sView.".tpl"; $this->mlTabsPerLine; $oTPL=$this->oSystem->goGetTPLParser($sFile,true,$this->mlTabIndex,$this->mlTabsPerLine); $oTPL->gbSetValArray($this->masEmpty); $oTPL->gbSetValArray($_SESSION[$sView.".search"]["searchData"]); $asData=$oView->moResult->gaaGetAllRecords(); if(sizeof($asData)==0) { $oTPL->gbSetBlock("liste",array()); $oTPL->gbSetBlock("error",array("0"=>"nichtunterwegs")); } else { if($oEnrichData!==false) { if(is_object($oEnrichData)&&method_exists($oEnrichData,"gasEnrich")) { foreach($asData as $sKey=>$asRecord) { $asData[$sKey]=$oEnrichData->gasEnrich($asRecord); } } } $oTPL->gbSetBlock("liste",$asData,"rowLow","rowHi"); $oTPL->gbSetBlock("error",array()); } $sHTML=$oTPL->gsParse(); $lMaxTabindex=$oTPL->getLastTabIndex(); unset($oTPL); $oTPL=new CTemplateParser($sHTML); $oTPL->gbSetValue("GESAMTDS",$oView->mlGesamt); $oTPL->gbSetValue("GESAMTSEITEN",$oPageListGen->mlGesamtSeiten); $oTPL->gbSetValue("FIRSTPAGE",$oPageListGen->mlFirstPage); $asButton["firstpage"]["FIRSTPAGE"]=$oPageListGen->mlFirstPage; $asButton["firstpage"]["FPTABINDEX"]=$lMaxTabindex; $asButton["prevpage"]["PREVPAGE"]=$oPageListGen->mlPrevPage; $asButton["prevpage"]["PPTABINDEX"]=$lMaxTabindex+1; $asButton["nextpage"]["NPTABINDEX"]=$lMaxTabindex+$oPageListGen->gesamtPageLinks+2; $asButton["nextpage"]["NEXTPAGE"]=$oPageListGen->mlNextPage; $asButton["lastpage"]["LPTABINDEX"]=$lMaxTabindex+$oPageListGen->gesamtPageLinks+3; $asButton["lastpage"]["LASTPAGE"]=$oPageListGen->mlMaxOffset; if($oView->mlGesamt==0 || $oPageListGen->mlGesamtSeiten==1) { $asButton["firstpage"]=false; $asButton["prevpage"]=false; $asButton["nextpage"]=false; $asButton["lastpage"]=false; } elseif($oPageListGen->mlOffset==$oPageListGen->mlFirstPage) { $asButton["firstpage"]=false; $asButton["prevpage"]=false; } elseif($oPageListGen->mlOffset==$oPageListGen->mlMaxOffset) { $asButton["lastpage"]=false; $asButton["nextpage"]=false; } $oTPL->gbSetButtons($asButton); $oTPL->gbSetValue("FPTABINDEX",$lMaxTabindex); $oTPL->gbSetValue("PPTABINDEX",$lMaxTabindex+1); $oTPL->gbSetValue("LASTPAGE",$oPageListGen->mlMaxOffset); $oTPL->gbSetValue("NEXTPAGE",$oPageListGen->mlNextPage); $oTPL->gbSetValue("PREVPAGE",$oPageListGen->mlPrevPage); $oTPL->gbSetValue("CURRENTPAGE",$oPageListGen->mlCurrentPage); $oTPL->gbSetValue("ADDITIONALURLDATA",$sAdditional); $oTPL->gbSetBlock("PAGESNAVI",$oPageListGen->gasGetOffsetList($sAdditional,$lMaxTabindex)); $oTPL->gbSetValue("NPTABINDEX",$lMaxTabindex+$oPageListGen->gesamtPageLinks+2); $oTPL->gbSetValue("LPTABINDEX",$lMaxTabindex+$oPageListGen->gesamtPageLinks+3); $oTPL->gbSetValue("CURRENTOFFSET",$lOffset); $sFile=PATHQS."views/navi.js"; $oJS=$this->oSystem->goGetTPLParser($sFile); $oJS->gbSetValue("CURRENTOFFSET",$lOffset); $oJS->gbSetValue("OrderedBy",$sOrderBy); $oJS->gbSetValue("OrderDir",$sOrderDir); $oJS->gbSetValue("OrderDirSmall",strtolower($sOrderDir)); $sHTML=$oTPL->gsParse().$oJS->gsParse(); $oNewTPL=$this->oSystem->goGetTPLParser($sHTML,false); return $oNewTPL; } else { @mail("thorsten.k@kk-gbr.de","View:".$sView,"VIEW".mysql_error()); return new CError(1000); } } function gasGetPageOffsets($lGesamt,$lPP) { } function getCondition() { return $this->asCondition; } } class CMGMListGenerator { function CMGMListGenerator($lOffset,$lCount,$lGesamt) { $this->gesamtPageLinks=0; $this->mlGesamt=$lGesamt; $this->mlOffset=$lOffset; $this->mlCount=$lCount; $this->mlPrevPage="false"; $this->mlNextPage="false"; $this->mlFirstPage="false";; if($this->mlGesamt>0) { $this->mlFirstPage=0; } if($this->mlOffset+$this->mlCount<$this->mlGesamt && $this->mlGesamt>0) { $this->mlNextPage=$this->mlOffset+$this->mlCount; } if($this->mlOffset-$this->mlCount>=0 && $this->mlGesamt>0) { $this->mlPrevPage=$this->mlOffset-$this->mlCount; } $this->mlGesamtSeiten=0; $this->mlGesamtSeiten=ceil($this->mlGesamt/$this->mlCount); if($this->mlGesamt>0 && $this->mlGesamtSeiten==0) { $this->mlGesamtSeiten=1; } $this->mlMaxOffset=($this->mlGesamtSeiten-1)*$this->mlCount; if($this->mlMaxOffset<0) $this->mlMaxOffset="false"; if($this->mlOffset==0) { if($this->mlGesamt==0) $this->mlCurrentPage=0; else $this->mlCurrentPage=1; } else $this->mlCurrentPage=floor($this->mlOffset/$this->mlCount)+1; } function gasGetOffsetList($sAdditional,$lTabIndex) { $asX=array(); $lLower=$this->mlCurrentPage-5; $lBuffer=0; if($lLower<0) { $lBuffer=$lLower; $lLower=0; } $lUpper=$this->mlCurrentPage+5+abs($lBuffer); $lBuffer=0; if($lUpper>$this->mlGesamtSeiten) { $lBuffer=$lUpper; $lUpper=$this->mlGesamtSeiten; $lLower=$lLower-($lBuffer-$this->mlGesamtSeiten); } if($lLower<0) { $lBuffer=$lLower; $lLower=0; } $i=0; for($i=$lLower;$i<$lUpper;$i++) { $asReturn["class"]="pageListNormal"; if($this->mlCurrentPage==$i+1) { $asReturn["class"]="pageListActive"; } $asReturn["offset"]=$i*$this->mlCount; $asReturn["page"]=$i+1; $asReturn["TABPAGE"]=$lTabIndex+2+$i; $asReturn["ADDITIONALURLDATA"]=$sAdditional; array_push($asX,$asReturn); } $this->gesamtPageLinks=$i; return $asX; } } ?>