Index: nparser/nparser.php =================================================================== --- nparser/nparser.php (revision 12686) +++ nparser/nparser.php (working copy) @@ -50,8 +50,15 @@ var $CachePointers = array(); var $Cachable = array(); - + /** + * Parser parameter names, that are created via m_Capture tag are listed here + * + * @var Array + */ + var $Captures = array(); + + /** * Phrases, used on "Edit" buttons, that parser adds during block decoration * * @var Array @@ -291,9 +298,9 @@ function CompileTag($tag) { + $code = ''; $to_pass = $this->CompileParamsArray($tag['NP']); - - $code = ''; + if ($tag['prefix'] == '__auto__') { $prefix = $this->GetParam('PrefixSpecial'); $code .= '$_p_ =& $_parser->GetProcessor($PrefixSpecial);'."\n"; @@ -304,10 +311,12 @@ $code .= '$_p_ =& $_parser->GetProcessor("'.$tag['prefix'].'");'."\n"; $code .= 'echo $_p_->ProcessParsedTag(\''.$tag['name'].'\', '.$to_pass.', "'.$tag['prefix'].'", \''.$tag['file'].'\', '.$tag['line'].');'."\n"; } - if (isset($tag['NP']['result_to_var'])) { + + if (array_key_exists('result_to_var', $tag['NP']) && $tag['NP']['result_to_var']) { $code .= "\$params['{$tag['NP']['result_to_var']}'] = \$_parser->GetParam('{$tag['NP']['result_to_var']}');\n"; $code .= "\${$tag['NP']['result_to_var']} = \$params['{$tag['NP']['result_to_var']}'];\n"; } + if ($prefix && strpos($prefix, '$') === false) { $p =& $this->GetProcessor($prefix); if (!is_object($p) || !$p->CheckTag($tag['name'], $tag['prefix'])) { @@ -315,6 +324,7 @@ return false; } } + return $code; } @@ -490,6 +500,13 @@ $block_params = $this->Params; // input parameters, but modified inside rendered block $this->PopParams(); + if (array_key_exists('result_to_var', $flag_values) && $flag_values['result_to_var']) { + // when "result_to_var" used inside ParseBlock, then $$result_to_var parameter is set inside ParseBlock, + // but not outside it as expected and got lost at all after PopParams is called, so make it work by + // setting it's value on current parameter deep level (from where ParseBlock was called) + $this->SetParam($flag_values['result_to_var'], $block_params[ $flag_values['result_to_var'] ]); + } + $this->CheckNoData($ret, $params); $this->DataExists = $data_exists_bak || $this->DataExists; Index: nparser/ntags.php =================================================================== --- nparser/ntags.php (revision 12686) +++ nparser/ntags.php (working copy) @@ -400,8 +400,17 @@ $code[] = '$_tag_params = ' . $to_pass . ';'; $code[] = "\${$tag['NP']['name']} = \$_p_->PostProcess(\${$tag['NP']['name']}, \$_p_->PreparePostProcess(\$_tag_params));"; $code[] = "}"; - - if (array_key_exists('plus', $tag['NP'])) { + + if (array_key_exists('result_to_var', $tag['NP']) && $tag['NP']['result_to_var']) { + $code[] = "\$params['{$tag['NP']['result_to_var']}'] = \$_parser->GetParam('{$tag['NP']['result_to_var']}');"; + + if (array_key_exists('plus', $tag['NP'])) { + $code[] = "\$params['{$tag['NP']['result_to_var']}'] += {$tag['NP']['plus']};"; + } + + $code[] = "\${$tag['NP']['result_to_var']} = \$params['{$tag['NP']['result_to_var']}'];"; + } + elseif (array_key_exists('plus', $tag['NP'])) { $code[] = "\${$tag['NP']['name']} += {$tag['NP']['plus']};"; } Index: processors/main_processor.php =================================================================== --- processors/main_processor.php (revision 12686) +++ processors/main_processor.php (working copy) @@ -214,7 +214,7 @@ } /** - * Returns block parameter by name (used only as "check" parameter value for "m_if" tag !) + * Returns block parameter by name (used only as "check" parameter value for "m_if" tag!) * * @param Array $params * @return stirng @@ -224,17 +224,20 @@ { $name = $params['name']; - /*if (isset($this->Application->LateParsed[$name])) { - $f = $this->Application->PreParsedBlocks['capture_'.$name.$this->Application->LateParsed[$name]]; - $this->Application->Parser->SetParam($name, $f(array())); - }*/ - - $res = $this->Application->Parser->GetParam($params['name']); + if (array_key_exists($name, $this->Application->Parser->Captures)) { + $capture_params = $params; + $capture_params['name'] = '__capture_' . $name; + + $this->Application->Parser->SetParam($name, $this->Application->ParseBlock($capture_params)); + } + + $res = $this->Application->Parser->GetParam($name); + if ($res === false) { $res = ''; } - if (isset($params['plus'])) { + if (array_key_exists('plus', $params)) { $res += $params['plus']; }