Index: trunk/kernel/include/parse.php =================================================================== diff -u -r3282 -r3428 --- trunk/kernel/include/parse.php (.../parse.php) (revision 3282) +++ trunk/kernel/include/parse.php (.../parse.php) (revision 3428) @@ -55,7 +55,7 @@ return FALSE; } } - + function SetAttributeByName($attr,$value) { if(!is_array($this->attributes)) @@ -83,15 +83,15 @@ return FALSE; } } - + function ParseAttributes($attributes) { unset($output); $attribute = ""; $attributes = str_replace("\\>",">",$attributes); $attributes = str_replace("\\<","<",$attributes); $attributes = str_replace("\\\\","\\",$attributes); - + while(strpos($attributes,"=")>0) { $pos = strpos($attributes,"="); @@ -101,7 +101,7 @@ $pos3 = strpos($attributes,"'"); if(!($pos3===false) and !($pos2===false) and ($pos3<$pos2)) $pos2 = $pos3; if(!($pos3===false) and ($pos2===false) and (($pos3<$pos) or ($pos==0))) $pos2 = $pos3; - + if(!($pos2===false) and (($pos2<$pos) or ($pos==0))) { if (substr($attributes,0,1) == "\"") @@ -122,18 +122,18 @@ $pos = $pos1-(strlen($val)-$pos1a); $val = substr($val,0,$pos1a); } - + while (strpos($attribute," ")>0) { $pos1 = strpos($attribute," "); $attr1 = substr($attribute,0,$pos1); $output[$attr1] = null; $attribute = trim(substr($attribute,$pos1+1)); } - + $output[strtolower($attribute)] = $val; $attributes = trim(substr($attributes,$pos+1)); - + } elseif ($pos>0) { @@ -146,7 +146,7 @@ { $val = $attributes; } - + $pos2 = strrpos($val," "); if($pos2>0) { @@ -159,15 +159,15 @@ $len = strlen($val); $attributes = trim(substr($attributes,$len)); } - + while (strpos($attribute," ")>0) { $pos1 = strpos($attribute," "); $attr1 = substr($attribute,0,$pos1); $output[$attr1] = null; $attribute = trim(substr($attribute,$pos1+1)); - } - $output[strtolower($attribute)] = $val; + } + $output[strtolower($attribute)] = $val; } else { @@ -181,7 +181,7 @@ $output[strtolower($attribute)] = $attributes; } } - + if(strlen(trim($attributes))>0) { while (strpos($attribute," ")>0) @@ -190,13 +190,13 @@ $attr1 = substr($attribute,0,$pos1); $output[$attr1] = null; $attribute = trim(substr($attribute,$pos1+1)); - } - $output[strtolower($attributes)] = null; + } + $output[strtolower($attributes)] = null; } - - if (isset($output)) + + if (isset($output)) return($output); - } + } function parse() { @@ -249,17 +249,17 @@ function Execute() { - $func = $this->name; + $func = $this->name; $override = "_".$func; if( function_exists($override) ) - { + { $ret = @$override($this->attributes); } - else - { + else + { if(function_exists($func)) - { + { $ret = @$func($this->attributes); } else @@ -278,7 +278,7 @@ var $name; var $out; var $error; - + function clsTemplate($template=NULL) { $this->name=$template; @@ -301,8 +301,8 @@ } else { - if(!$SupressError) - $this->error = "lu_read_error"; + if(!$SupressError) + $this->error = "lu_read_error"; return FALSE; } } @@ -317,7 +317,7 @@ function HasExtension() { $t = strtolower($this->name); - + if(strlen($t)) { return (substr($t,-4)==".tpl"); @@ -327,16 +327,16 @@ } function TemplateFilename($template_root) - { + { if(!$this->HasExtension()) { $filename = $template_root.$this->name.".tpl"; } else $filename = $template_root.$this->name; return $filename; - } - + } + function LoadFile($template_root="",$SupressError=FALSE, $tbody) { if (class_exists('kApplication') ) { @@ -347,11 +347,11 @@ $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)) { @@ -368,14 +368,14 @@ else { if(!$SupressError) - $this->error = "lu_read_error"; + $this->error = "lu_read_error"; return FALSE; } } else { if(!$SupressError) - $this->error = "lu_missing_error"; + $this->error = "lu_missing_error"; return FALSE; } } @@ -397,16 +397,16 @@ } if(strlen($this->out)) - { + { $fp = @fopen($filename, "w"); if($fp) - { + { fwrite($fp,$this->out); fclose($fp); return TRUE; } else - return FALSE; + return FALSE; } else return TRUE; @@ -451,7 +451,7 @@ else { $ret = FALSE; - + if ( !isset($tbody) ) { //Kernel4 fix $ret = isset($this->templates[$name]) ? $this->templates[$name] : false; // this was original: @@ -493,6 +493,9 @@ { global $CurrentTheme, $pathtoroot; $ret = ''; + if(!is_object($CurrentTheme)) { + $CurrentTheme = $objThemes->GetItem($m_var_list["theme"]); + } if( $CurrentTheme->Get("CacheTimeout") > 0) { $id = $CurrentTheme->GetTemplateId($template); @@ -543,7 +546,7 @@ function IncludeTemplate($tag, $SupressError=FALSE) { global $LogLevel, $objSession,$objLanguages, $var_list; - + $t = ''; $ret = ''; $SupressError = ($SupressError || $tag->GetAttributeByName("_supresserror")); @@ -559,7 +562,7 @@ for($p=0;$pHasCatPermission(trim($plist[$p]))) { $value = 1; @@ -589,7 +592,7 @@ } } break; - + case "lang_include": $lang = $tag->GetAttributeByName("_language"); if(strlen($lang)) @@ -604,12 +607,12 @@ break; case 'include': $t = $tag->GetAttributeByName("_template"); - break; + break; } LogEntry("Parsing $t\n"); $LogLevel++; - + if($t) { if(!$this->InStack($t)) @@ -728,7 +731,7 @@ } function ParseTemplateText($text) - { + { $html = $text; $search = "",$closer+1); } $end_tag = strpos($html,"/>",$next_tag); - + if(($end_tag < $closer || $closer == 0)) { $tagtext = substr($html,$next_tag,($end_tag - $next_tag)+2); @@ -754,54 +757,54 @@ } else { - + $OldTagStyle = ""; - + ## Try to find end of TagName $TagNameEnd = strpos($html, " ", $next_tag); - + ## Support Old version -// $closer = strpos(strtolower($html),"",$next_tag); +// $closer = strpos(strtolower($html),"",$next_tag); if ($TagNameEnd) - { + { $Tag = strtolower(substr($html, $next_tag, $TagNameEnd-$next_tag)); - $TagName = explode(":", $Tag); + $TagName = explode(":", $Tag); if (strlen($TagName[1])) $CloserTag = ""; - } + } else { $CloserTag = $OldTagStyle; - } - + } + $closer = strpos(strtolower($html), $CloserTag, $next_tag); - + ## Try to find old tag closer if (!$closer && ($CloserTag != $OldTagStyle)) { $CloserTag = $OldTagStyle; - $closer = strpos(strtolower($html), $CloserTag, $next_tag); + $closer = strpos(strtolower($html), $CloserTag, $next_tag); } - + $end_tag = strpos($html,">",$next_tag); - + $tagtext = substr($html,$next_tag,($end_tag - $next_tag)+1); $pre = substr($html,0,$next_tag); $inner = substr($html,$end_tag+1,$closer-($end_tag+1)); $post = substr($html,$end_tag+1+strlen($inner) + strlen($CloserTag)); $parsed = trim($this->ParseTag($tagtext)); - + if(strlen($parsed)) { - + $html = $pre.$this->ParseTemplateText($inner).$post; } else $html = $pre.$post; } - - - + + + //$next_tag = strpos($html,"clsTemplateList($rootdir); - $this->Dependencies = Array(); + $this->Dependencies = Array(); $this->Tags = array(); $this->TemplateType="global"; //default } - + function ParseTag($text) { $this->Tags[] = new clsHtmlTag($text); - + return ""; } - + function ParseTemplateText($text) - { + { $html = $text; $search = "InitParser(); - + $this->Tags[]=Array(); $this->ParseTemplate($tname,1,1,TRUE); return $this->Tags; } - + function GetTemplateType($tname) { global $ItemTypePrefixes; - + $ret = "global"; $this->ReadTemplateTags($tname); if(count($this->Tags)>0) @@ -977,25 +980,25 @@ $ret = $t->name; break; } - } + } } return $ret; } - - function IncludeTemplate($tag, $SupressError=FALSE) + + function IncludeTemplate($tag, $SupressError=FALSE) { $this->AddDependency($tag->GetAttributeByName("_template")); - $this->AddDependency($tag->GetAttributeByName("_noaccess")); + $this->AddDependency($tag->GetAttributeByName("_noaccess")); } - + function ModuleInclude($tag) { - + } - + function AddDependency($template) { - $template = strtolower($template); + $template = strtolower($template); if(!in_array($template,$this->Dependencies)) $this->Dependencies[] = $template; }