|
|
|
|
|
|
|
/*
This is the TinyTemplate-Class.
This file is a part of the dot.orange WMS 2006.
copyrights by it.orange (c).
Author: Sascha Momcilovic
E-Mail: info@it-orange.de
www: http://www.it-orange.de
Date: 05.10.2006
*/
class TinyTemplate
{
var $HTMLBuffer;
var $HTMLBufferDyn;
var $HTMLBufferDynBlocks = array();
var $Buffer;
var $DYN = 0;
var $DYNPART;
var $DYN_Blocks = 1;
var $Terms = array();
var $TermsMarker;
var $TermsSwitch;
var $MainTemp = 1;
function replaceItems($defineArr) {
if(is_array($defineArr)) {
foreach($defineArr as $key => $val) {
$dot = str_replace($key, $val, $this->HTMLBuffer);
$this->HTMLBuffer = $dot;
}
}
if($this->DYN == 1) {
for($i=0; $i<$this->DYN_Blocks; $i++) {
$block = $this->DYN_Blocks == 1 ? "" : ($i + 1);
$DynBuffer = $this->DYN_Blocks == 1 ? $this->HTMLBufferDyn : $this->HTMLBufferDynBlocks[$i];
$dot = preg_replace('/(.*?)/ism', $DynBuffer, $this->HTMLBuffer);
# Oldtype: $dot = str_replace($this->DYNPART, $this->HTMLBufferDyn, $this->HTMLBuffer);
$this->HTMLBuffer = $dot;
}
return $this->HTMLBuffer;
} else {
return $this->HTMLBuffer;
}
}
function replaceItemsDyn($defineArr, $block='') {
$a = 1;
if(is_array($defineArr)) {
foreach($defineArr as $key => $val) {
if($this->DYN != 1) {
$buffer = $a == 1 ? $this->Buffer : $this->HTMLBufferDyn;
} else {
if($a == 1) {
preg_match_all('/(.*?)/ism', $this->HTMLBuffer, $dynBuffer);
$buffer = $dynBuffer[1][0];
$this->DYNPART = $dynBuffer[0][0];
} else {
$buffer = $this->HTMLBufferDyn;
}
}
$dot = str_replace($key, $val, $buffer);
$this->HTMLBufferDyn = $dot;
$a++;
}
}
return $this->HTMLBufferDyn;
}
function TermsFilter() {
preg_match_all('#(.*?)#ims', $this->HTMLBuffer, $TermsMatch);
$this->Terms = $TermsMatch;
$a=1;
foreach($TermsMatch[0] as $key => $val) {
$this->HTMLBuffer = preg_replace('#(.*?)#ims', "###T".$a."###", $this->HTMLBuffer);
$x = $a-1;
$this->TermsMarker[$x] = "###T".$a."###";
$a++;
}
foreach( $this->TermsMarker as $key => $val ) {
if($this->TermsSwitch[$key] == 1) {
$this->HTMLBuffer = preg_replace('/'.$val.'/ims', $this->Terms[1][$key], $this->HTMLBuffer);
} else {
$this->HTMLBuffer = preg_replace('/'.$val.'/ims', '', $this->HTMLBuffer);
}
}
if($this->MainTemp != 1) {
$this->HTMLBuffer = preg_replace('/(.*?)/ism', '', $this->HTMLBuffer);
}
return $this->HTMLBuffer;
}
}
# Intialisize class
$TT = new TinyTemplate;
?>
| | | | | |