mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/11482] Implementation of advanced DEFINE tag
Implementation of advanced DEFINE tag and ENDDEFINE PHPBB3-11482
This commit is contained in:
parent
52a0f32d99
commit
29a5db25ec
1 changed files with 28 additions and 0 deletions
|
@ -329,6 +329,10 @@ class phpbb_template_filter extends php_user_filter
|
||||||
return '<?php ' . $this->compile_tag_define($matches[2], false) . ' ?>';
|
return '<?php ' . $this->compile_tag_define($matches[2], false) . ' ?>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'ENDDEFINE':
|
||||||
|
return '<?php ' . $this->compile_tag_enddefine() . ' ?>';
|
||||||
|
break;
|
||||||
|
|
||||||
case 'INCLUDE':
|
case 'INCLUDE':
|
||||||
return '<?php ' . $this->compile_tag_include($matches[2]) . ' ?>';
|
return '<?php ' . $this->compile_tag_include($matches[2]) . ' ?>';
|
||||||
break;
|
break;
|
||||||
|
@ -833,6 +837,16 @@ class phpbb_template_filter extends php_user_filter
|
||||||
$match = array();
|
$match = array();
|
||||||
preg_match('#^((?:' . self::REGEX_NS . '\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (.*?))?$#', $tag_args, $match);
|
preg_match('#^((?:' . self::REGEX_NS . '\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (.*?))?$#', $tag_args, $match);
|
||||||
|
|
||||||
|
if (!empty($match[2]) && !isset($match[3]) && $op)
|
||||||
|
{
|
||||||
|
// DEFINE tag with ENDDEFINE
|
||||||
|
$array = '$_tpldata[\'DEFINE\'][\'.vars\']';
|
||||||
|
$code = 'ob_start(); ';
|
||||||
|
$code .= 'if (!isset(' . $array . ')) { ' . $array . ' = array(); } ';
|
||||||
|
$code .= $array . '[] = \'' . $match[2] . '\'';
|
||||||
|
return $code;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($match[2]) || (!isset($match[3]) && $op))
|
if (empty($match[2]) || (!isset($match[3]) && $op))
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
|
@ -859,6 +873,20 @@ class phpbb_template_filter extends php_user_filter
|
||||||
return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ' = ' . $parsed_statement . ';';
|
return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ' = ' . $parsed_statement . ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile ENDDEFINE tag
|
||||||
|
*
|
||||||
|
* @return string compiled template code
|
||||||
|
*/
|
||||||
|
private function compile_tag_enddefine()
|
||||||
|
{
|
||||||
|
$array = '$_tpldata[\'DEFINE\'][\'.vars\']';
|
||||||
|
$code = 'if (!isset(' . $array . ') || !sizeof(' . $array . ')) { trigger_error(\'ENDDEFINE tag without DEFINE in \' . basename(__FILE__), E_USER_ERROR); }';
|
||||||
|
$code .= '$define_var = array_pop(' . $array . '); ';
|
||||||
|
$code .= '$_tpldata[\'DEFINE\'][\'.\'][$define_var] = ob_get_clean();';
|
||||||
|
return $code;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile INCLUDE tag
|
* Compile INCLUDE tag
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue