Index: trunk/core/kernel/parser/tags.php =================================================================== diff -u -r2245 -r2596 --- trunk/core/kernel/parser/tags.php (.../tags.php) (revision 2245) +++ trunk/core/kernel/parser/tags.php (.../tags.php) (revision 2596) @@ -1,21 +1,18 @@ _Tag)) { $this->_Tag =& new Tag($tag_data, $parser, $inp_tag); @@ -28,7 +25,7 @@ } return $this->_Tag; } - + } class Tag extends kBase { @@ -44,7 +41,7 @@ */ var $Parser; var $TagData = ''; - + function Tag($tag_data, &$parser, $inp_tag=0) { parent::kBase(); @@ -53,7 +50,7 @@ if ($tag_data != '') $this->ParseTagData($tag_data); $this->NP =& $this->NamedParams; } - + function CopyFrom(&$tag) { $this->Processor = $tag->Processor; @@ -63,12 +60,12 @@ $this->NamedParams = $tag->NamedParams; $this->Parser =& $tag->Parser; } - + function GetFullTag() { return '<%'.$this->TagData.'%>'; } - + function RebuildTagData() { $res = $this->Processor.':'.$this->Tag.' '; @@ -77,7 +74,7 @@ } return $res; } - + /** * Escape chars in phrase translation, that could harm parser to process tag * @@ -91,8 +88,8 @@ $replacement = Array('\"',"\'"); // \= return str_replace($reserved,$replacement,$text); } - - + + function ReplaceParams($tag_data) { //print_pre($this->Parser->Pattern, $tag_data); @@ -101,14 +98,14 @@ { $values[$param_name] = $this->EscapeReservedChars($param_value); } - + if (is_array($this->Parser->Params)) { $tag_data = preg_replace($this->Parser->Pattern, $values, $tag_data); } //echo "got: $tag_data
"; return $tag_data; } - + function PreParseReplaceParams($tag_data) { //print_pre($this->Parser->Pattern, $tag_data); @@ -117,14 +114,14 @@ { $values[$param_name] = $this->EscapeReservedChars($param_value); } - + /*$patterns = Array(); - if ( is_array($this->Parser->Args) ) { + if ( is_array($this->Parser->Args) ) { foreach ($this->Parser->Args as $arg) { - + } }*/ - + if ($this->Parser->SkipMode == parse) { if (is_array($this->Parser->Params)) { $tag_data = preg_replace($this->Parser->Pattern, $values, $tag_data); @@ -133,15 +130,15 @@ //echo "got: $tag_data
"; return $tag_data; } - + function CmpParams($a, $b) { $a_len = strlen($a); $b_len = strlen($b); if ($a_len == $b_len) return 0; return $a_len > $b_len ? -1 : 1; } - + /** * Set's Prefix and Special for Tag object * based on ones from tagname @@ -152,46 +149,46 @@ function ParseTagData($tag_data) { if (defined('EXPERIMENTAL_PRE_PARSE') ) { - $tag_data = $this->PreParseReplaceParams($tag_data) . ' '; + $tag_data = $this->PreParseReplaceParams($tag_data) . ' '; } else { $tag_data = $this->ReplaceParams($tag_data) . ' '; // $tag_data = $this->Application->ReplaceLanguageTags($tag_data); } - + list ($key_data, $params) = split("[ \t\n]{1}", $tag_data, 2); $key_data = trim($key_data); - + $tmp=explode(':',$key_data); $this->Tag=$tmp[1]; - + $tmp=$this->Application->processPrefix($tmp[0]); $this->Prefix=$tmp['prefix']; $this->Special=$tmp['special']; $this->Processor=$this->Prefix; - + if ($params != '') { $this->ParseNamedParams($params); } else { $this->NamedParams = array(); } } - + function ParseNamedParams($params_str) { $params =& new Params($params_str); $this->NamedParams = $params->_Params; } - + function GetParam($param) { - if (isset($this->NP[$param])) + if (isset($this->NP[$param])) return $this->NP[$param]; - else + else return false; } - + /** * Process IF tags in specific way * @@ -212,7 +209,7 @@ $this->Tag == 'ifnot' || $this->Tag == 'else' || $this->Tag == 'elseif' - ) + ) { if ( defined('EXPERIMENTAL_PRE_PARSE') ) { $this->Parser->AppendCompiledCode( $this->GetCode() ); @@ -248,7 +245,7 @@ } } } - + /** * Set's Prefix and Special for TagProcessor * based on tag beeing processed @@ -260,27 +257,27 @@ { // $tag->Prefix - l_TagProcessor $tmp = $this->Application->processPrefix($this->Processor); - + $processor =& $this->Application->recallObject($tmp['prefix'].'_TagProcessor'); // $this->Processor - + $tmp=explode('_',$tmp['prefix'],2); $processor->Prefix=$tmp[0]; $processor->Special=$this->Special; - + // pass_params for non ParseBlock tags :) $parser_params = $this->Application->Parser->Params; if( getArrayValue($this->NamedParams,'pass_params') ) { unset( $this->NamedParams['pass_params'] ); $this->NamedParams = array_merge_recursive2($parser_params, $this->NamedParams); } - + return $processor->ProcessTag($this); } - + function ProcessTag() { - $o = $this->DoProcessTag(); + $o = $this->DoProcessTag(); if ($o !== false) { $this->Parser->AppendOutput($o); @@ -290,31 +287,31 @@ trigger_error('can\'t process tag '.$this->Tag,E_USER_WARNING); } } - + function GetCode($echo=false) { $pass_params = $this->NP; - + $code = Array(); $to_pass = 'Array('; foreach ($pass_params as $name => $val) { $to_pass .= '"'.$name.'" => "'.str_replace('"', '\"', $val).'",'; } $to_pass .= ')'; - + if ($echo) $code[] = '$o = '."'';\n"; - + switch ( $this->Tag ) { case 'param': - $code[] = '$o .= $params["'.$this->NP['name'].'"];'; + $code[] = '$o .= $params["'.$this->NP['name'].'"];'; return $code; case 'if': if (isset($this->NP['_closing_tag_'])) { $code[] = ' }'; } else { - + $check = $this->GetParam('check'); if ($check) { if (strpos($check, '_') !== false) { @@ -329,13 +326,13 @@ $prefix = $this->GetParam('prefix'); $function = $this->GetParam('function'); } - + $code[] = '$tmp = $application->processPrefix("'.$prefix.'");'."\n"; - $code[] = '$__tag_processor = $tmp[\'prefix\'].\'_TagProcessor\';'."\n"; - $code[] = '$processor =& $application->recallObject($__tag_processor);'."\n"; - $code[] = '$processor->Prefix = $tmp[\'prefix\'];'."\n"; - $code[] = '$processor->Special = $tmp[\'special\'];'."\n"; - $code[] = '$if_result = $processor->ProcessParsedTag(\''.$function.'\', '.$to_pass.', "'.$prefix.'");'."\n"; + $code[] = '$__tp = $tmp[\'prefix\'].\'_TagProcessor\';'."\n"; + $code[] = '$p =& $application->recallObject($__tp);'."\n"; + $code[] = '$p->Prefix = $tmp[\'prefix\'];'."\n"; + $code[] = '$p->Special = $tmp[\'special\'];'."\n"; + $code[] = '$if_result = $p->ProcessParsedTag(\''.$function.'\', '.$to_pass.', "'.$prefix.'");'."\n"; if (isset($pass_params['inverse'])) { $code[] = 'if (!$if_result) {'; } @@ -344,7 +341,7 @@ } } return $code; - + case 'endif': $code[] = ' }'; return $code; @@ -354,26 +351,26 @@ $code[] = ' else {'; return $code; } - + if (!$this->Processor) { echo ''; } $code[] = '$tmp = $application->processPrefix("'.$this->getPrefixSpecial().'");'."\n"; - $code[] = '$__tag_processor = $tmp[\'prefix\'].\'_TagProcessor\';'."\n"; - $code[] = '$processor =& $application->recallObject($__tag_processor);'."\n"; - $code[] = '$processor->Prefix = $tmp[\'prefix\'];'."\n"; - $code[] = '$processor->Special = $tmp[\'special\'];'."\n"; - + $code[] = '$__tp = $tmp[\'prefix\'].\'_TagProcessor\';'."\n"; + $code[] = '$p =& $application->recallObject($__tp);'."\n"; + $code[] = '$p->Prefix = $tmp[\'prefix\'];'."\n"; + $code[] = '$p->Special = $tmp[\'special\'];'."\n"; + $tag_func = $this->Tag; if ($tag_func == 'include') $tag_func = 'MyInclude'; - - $code[] = '$o .= $processor->ProcessParsedTag(\''.$tag_func.'\', '.$to_pass.', "'.$this->Processor.'");'."\n"; - + + $code[] = '$o .= $p->ProcessParsedTag(\''.$tag_func.'\', '.$to_pass.', "'.$this->Processor.'");'."\n"; + /*$code = ' $processor =& $application->recallObject(\''.$this->Processor.'_TagProcessor\'); $o .= $processor->ProcessParsedTag(\''.$this->Tag.'\', unserialize(\''.serialize($this->NP).'\'));';*/ - + if ($echo) $code[] = ' echo $o;'."\n"; - + return $code; //return '$o .= \'tag:'. $this->Tag .'\''; }