aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorVjacheslav Trushkin <cyberalien@gmail.com>2013-04-07 19:12:04 +0300
committerVjacheslav Trushkin <cyberalien@gmail.com>2013-04-07 19:12:04 +0300
commit29a5db25ec21a8b349195d01bdd0cfea09814653 (patch)
treef2485eb10ce4fae7e838ffb7d5a00608260105f1 /phpBB
parent52a0f32d99bf87075049600b15c40147ab698a61 (diff)
downloadforums-29a5db25ec21a8b349195d01bdd0cfea09814653.tar
forums-29a5db25ec21a8b349195d01bdd0cfea09814653.tar.gz
forums-29a5db25ec21a8b349195d01bdd0cfea09814653.tar.bz2
forums-29a5db25ec21a8b349195d01bdd0cfea09814653.tar.xz
forums-29a5db25ec21a8b349195d01bdd0cfea09814653.zip
[ticket/11482] Implementation of advanced DEFINE tag
Implementation of advanced DEFINE tag and ENDDEFINE PHPBB3-11482
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/template/filter.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php
index 9e8ad2fef0..a3894905e5 100644
--- a/phpBB/includes/template/filter.php
+++ b/phpBB/includes/template/filter.php
@@ -329,6 +329,10 @@ class phpbb_template_filter extends php_user_filter
return '<?php ' . $this->compile_tag_define($matches[2], false) . ' ?>';
break;
+ case 'ENDDEFINE':
+ return '<?php ' . $this->compile_tag_enddefine() . ' ?>';
+ break;
+
case 'INCLUDE':
return '<?php ' . $this->compile_tag_include($matches[2]) . ' ?>';
break;
@@ -833,6 +837,16 @@ class phpbb_template_filter extends php_user_filter
$match = array();
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))
{
return '';
@@ -860,6 +874,20 @@ class phpbb_template_filter extends php_user_filter
}
/**
+ * 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
*
* @param string $tag_args Expression given with INCLUDE in source template