msTPL=$sTPL; $this->mbShow=$TEST; $this->mlTABSPerLine=$TAB_PER_LINE; $this->mlTabindex=$lTabIndexStart; $this->masValues=array(); $this->gbSetValue("__SYSTEM_URL__",URLQS); $this->gbSetValue("__IMAGES_URL__",URLIMAGEROOT); if ($sType===true) { $this->masValues["confirmtextyes"]="Ja"; $this->masValues["confirmtextno"]="Nein"; } $this->masBlocks=array(); $this->asButtons=false; } function gbSetContent($sVal) { $this->masValues["content"]=$sVal; } function gbSetValue($sName,$sValue){ $this->masValues[$sName]=$sValue; } function gbSetValArray($asData){ $this->masValues=array_merge($this->masValues,$asData); } function gbSetButtons($asButtons) { if(is_array($asButtons)&&sizeof($asButtons)>0) $this->asButtons=array_merge($this->asButtons,$asButtons); } function gbSetBlock($sBlockName,$asData,$bgColor0=false,$bgColor1=false){ $errCode=$this->mbSetBlockData($sBlockName,$asData,$bgColor0,$bgColor1); return $errCode==0; } function mbSetBlockData($sBlockName,$asData,$bgColor0,$bgColor1) { $vntBlockstart=strpos($this->msTPL,"msTPL,"",$vntBlockstart); if ($vntBlockend!==false) { if ($vntBlockend<$vntBlockstart) return false; // jetzt block herausholen und gegen standard {dataset:blockname} ersetzen // in masValues[dataset:blockname] wird ein array angelegt, ["template"] und data! $sDatasetName="dataset:".$sBlockName.""; $vntBlockend+=7; $lBlockLen=$vntBlockend-$vntBlockstart; $lBlockStart=$vntBlockstart+strlen(""); $lBlockRealLen =$lBlockLen-7-strlen(""); $this->masValues[$sDatasetName]["template"] =substr($this->msTPL,$lBlockStart,$lBlockRealLen); $this->masValues[$sDatasetName]["data"] =$asData; $this->masValues[$sDatasetName]["bgcolor0"] =$bgColor0; $this->masValues[$sDatasetName]["bgcolor1"] =$bgColor1; $this->msTPL=substr_replace($this->msTPL,"{".$sDatasetName."}",$vntBlockstart,$lBlockLen); } else return 2; } else return 1; return 0; } function gsParse($doHTMLEntities=false) { if($this->mbShow===true) { echo htmlentities($this->msTPL); } $this->mbDoHTMLEntities=$doHTMLEntities; $sCompleted=$this->msParse($this->msTPL,$this->masValues); if(is_array($this->asButtons)) { foreach($this->asButtons as $sButtonName=>$asButtonData) { $this->setButton($sCompleted,$sButtonName,$asButtonData); } } if($doHTMLEntities===true) { $sCompleted=str_replace(chr(196),"Ä",$sCompleted); $sCompleted=str_replace(chr(228),"ä",$sCompleted); $sCompleted=str_replace(chr(214),"Ö",$sCompleted); $sCompleted=str_replace(chr(246),"ö",$sCompleted); $sCompleted=str_replace(chr(220),"Ü",$sCompleted); $sCompleted=str_replace(chr(252),"ü",$sCompleted); $sCompleted=str_replace(chr(223),"ß",$sCompleted); } return $sCompleted; } function setButton(&$sTemplate,$sName,$asData) { $sSearch=""; $sEnd=""; $lPosi=strpos($sTemplate,$sSearch); if($lPosi!==false) { $lEnd=strpos($sTemplate,$sEnd,$lPosi); $lRealLen=$lEnd+strlen($sEnd)-$lPosi; if($asData!==false) { $lLen=$lEnd-$lPosi-strlen($sSearch); $sButtonText=substr($sTemplate,$lPosi+strlen($sSearch),$lLen); if($asData!==true) $sButtonText=$this->gsSetValues($sButtonText,$asData); $sTemplate=substr_replace($sTemplate,$sButtonText,$lPosi,$lRealLen); } else { $sTemplate=substr_replace($sTemplate,"",$lPosi,$lRealLen); } } } function gsSetValues($sTemplate,$asData) { foreach($asData as $sPlaceholder=>$sValue) { $sTemplate=str_replace("{".$sPlaceholder."}",$sValue,$sTemplate); } return $sTemplate; } function msParse($sTemplate,$asValues,$jsFix=false) { if (is_array($asValues)) { foreach($asValues as $sPlaceholder=>$sValue) { if (is_array($sValue["data"])) { $sValuep=""; $lC=0; foreach($sValue["data"] as $sDataSetName=>$asDataSet) { $lC++; if($sValue["bgcolor0"]!==false) { $asDataSet["bgcolor"]=$lC&1?$sValue["bgcolor0"]:$sValue["bgcolor1"]; } $asDataSet["__XCounter__"]=$lC; $asDataSet["__IMAGES_URL__"]=URLIMAGEROOT; if($this->mlTABSPerLine==0) { $asDataSet["__TABINDEX__"]=$this->mlTabindex; $this->mlTabindex++; } else { for($tabCounter=0;$tabCounter<$this->mlTABSPerLine;$tabCounter++) { $x="__TABINDEX__".$tabCounter."_"; $asDataSet["__TABINDEX__".$tabCounter."_"]=$this->mlTabindex; $this->mlTabindex++; } } $sValuep.=$this->msParse($sValue["template"],$asDataSet); } $sValue=$sValuep; } $sTemplate=str_replace("{".$sPlaceholder."}",$sValue,$sTemplate); } } return $sTemplate; } function getLastTabIndex() { return $this->mlTabindex; } }