Index: trunk/kernel/include/parse.php =================================================================== diff -u -r1120 -r1566 --- trunk/kernel/include/parse.php (.../parse.php) (revision 1120) +++ trunk/kernel/include/parse.php (.../parse.php) (revision 1566) @@ -335,8 +335,21 @@ return $filename; } - function LoadFile($template_root="",$SupressError=FALSE) + function LoadFile($template_root="",$SupressError=FALSE, $tbody) { + if (class_exists('kApplication') ) { + if ( !isset($tbody) ) { + $application =& kApplication::Instance(); + $t = $this->name; + $t = preg_replace("/\.tpl$/", '', $t); + $tbody = $application->ParseBlock( Array('name' => $t, 'from_inportal' => true), null, true ); + } + $this->source = $tbody; + + return true; + } + + $filename = $this->TemplateFilename($template_root); if(file_exists($filename)) { @@ -422,7 +435,7 @@ return in_array($template,$this->stack) ? true : false; } - function GetTemplate($name,$SupressError=FALSE) + function GetTemplate($name,$SupressError=FALSE, $tbody=null) { if(!strlen($name)) { @@ -436,18 +449,23 @@ else { $ret = FALSE; - foreach($this->templates as $n => $t) - { - if($n == $name) + + if ( !isset($tbody) ) { //Kernel4 fix + $ret = isset($this->templates[$name]) ? $this->templates[$name] : false; + // this was original: + /*foreach($this->templates as $n => $t) { - $ret=$t; - break; - } + if($n == $name) + { + $ret = $t; + break; + } + }*/ } if(!is_object($ret)) { $ret = new clsTemplate($name); - if($ret->LoadFile($this->root_dir,$SupressError)) + if($ret->LoadFile($this->root_dir, $SupressError, $tbody)) { $this->templates[$name]=$ret; } @@ -812,6 +830,28 @@ unset($t); return $html; } + + function ParseTemplateFromBuffer($tname, $tbody, $NoCache=0, $NoStack=0,$SupressError=FALSE) + { + $html = ""; + if( defined('TEMPLATE_PREFIX') ) $tname = TEMPLATE_PREFIX.'/'.$tname; + $t = $this->GetTemplate($tname, $SupressError, $tbody); + + if(is_object($t)) + { + if(!$NoStack) + array_push($this->stack,$tname); + $html = $t->source; + $html = $this->ParseTemplateText($html); + if(!$NoStack) + array_pop($this->stack); + $t->out = $html; + if(!$NoCache) + $this->SaveTemplateCache($t); + } + unset($t); + return $html; + } } class clsAdminTemplateList extends clsTemplateList