return $this->objfile;
}
function getTpl($file) {
$subdir = ($pos = strpos($file, ''/'')) === false ? '''' : substr($file, 0, $pos);
$file = $subdir ? substr($file, $pos + 1) : $file;
$tplfile = $this->tpldir.''/''.($subdir ? $subdir.''/'' : '''').$file.''.htm'';
if(@filemtime($tplfile) === FALSE) {
$tplfile = $this->defaulttpldir.''/''.($subdir ? $subdir.''/'' : '''').$file.''.htm'';
}
return $tplfile;
}
function compile() {
$var_regexp = "\@?\\\$[a-zA-Z_]\w*(?:\[[\w\.\"\''\[\]\$]+\])*";
$vtag_regexp = "\<\?=(\@?\\\$[a-zA-Z_]\w*(?:\[[\w\.\"\''\[\]\$]+\])*)\?\>";
$const_regexp = "\{([\w]+)\}";
$template = file_get_contents($this->tplfile);
for($i = 1; $i <= 3; $i++) {
if(strpos($template, ''{subtpl'') !== FALSE) {
if(DEBUG == 2) {
$template = str_replace(''{subtpl '', ''{tpl '', $template);
} else {
$template = preg_replace("/[\n\r\t]*\{subtpl\s+([a-z0-9_:\/]+)\}[\n\r\t]*/ies", "file_get_contents(\$this->getTpl(''\\1''))", $template);
}
}
}
$remove = array(
''/(^|\r|\n)\/\*.+?(\r|\n)\*\/(\r|\n)/is'',
''/\/\/note.+?(\r|\n)/i'',
''/\/\/debug.+?(\r|\n)/i'',
''/(^|\r|\n)(\s|\t)+/'',
''/(\r|\n)/'',
);
$this->removeblanks && $template = preg_replace($remove, '''', $template);
$template = preg_replace("/\<\!\-\-\{(.+?)\}\-\-\>/s", "{\\1}", $template);
$template = preg_replace("/\{($var_regexp)\}/", "<?=\\1?>", $template);
$template = preg_replace("/\{($const_regexp)\}/", "<?=\\1?>", $template);
$template = preg_replace("/(?<!\<\?\=|\\\\)$var_regexp/", "<?=\\0?>", $template);
$template = preg_replace("/\<\?=(\@?\\\$[a-zA-Z_]\w*)((\[[\\$\[\]\w]+\])+)\?\>/ies", "\$this->arrayindex(''\\1'', ''\\2'')", $template);
$template = preg_replace("/\{\{eval (.*?)\}\}/ies", "\$this->stripvtag(''<? \\1?>'')", $template);
$template = preg_replace("/\{eval (.*?)\}/ies", "\$this->stripvtag(''<? \\1?>'')", $template);
$template = preg_replace("/[\n\r\t]*\{echo\s+(.+?)\}[\n\r\t]*/ies", "\$this->stripvtag(''<? echo \\1; ?>'','''')", $template);
$template = preg_replace("/\{for (.*?)\}/ies", "\$this->stripvtag(''<? for(\\1) {?>'')", $template);
$template = preg_replace("/\{elseif\s+(.+?)\}/ies", "\$this->stripvtag(''<? } elseif(\\1) { ?>'')", $template);
for($i=0; $i<2; $i++) {
$template = preg_replace("/\{loop\s+$vtag_regexp\s+$vtag_regexp\s+$vtag_regexp\}(.+?)\{\/loop\}/ies", "\$this->loopsection(''\\1'', ''\\2'', ''\\3'', ''\\4'')", $template);
$template = preg_replace("/\{loop\s+$vtag_regexp\s+$vtag_regexp\}(.+?)\{\/loop\}/ies", "\$this->loopsection(''\\1'', '''', ''\\2'', ''\\3'')", $template);
}
$template = preg_replace("/\{if\s+(.+?)\}/ies", "\$this->stripvtag(''<? if(\\1) { ?>'')", $template);
$template = preg_replace("/\{tpl\s+(\w+?)\}/is", "<? include \$this->getObj(\"\\1\");?>", $template);
$template = preg_replace("/\{tpl\s+(.+?)\}/ise", "\$this->stripvtag(''<? include \$this->getObj(\"\\1\"); ?>'')", $template);
$