From fbec7c9b2b594e8bc750c5bf12a1f58a5577f8d8 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Thu, 8 Sep 2011 16:51:22 -0500 Subject: [PATCH] [ticket/10322] Fix dynamic template includes Dynamic template includes from variables was not implemented in the new templating system. PHPBB3-10322 --- phpBB/includes/template/filter.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php index 1d1d92378e..47394cf9ff 100644 --- a/phpBB/includes/template/filter.php +++ b/phpBB/includes/template/filter.php @@ -273,7 +273,26 @@ class phpbb_template_filter extends php_user_filter break; case 'INCLUDE': - return 'compile_tag_include($matches[2]) . ' ?>'; + // Dynamic includes + // Cheap match rather than a full blown regexp, we already know + // the format of the input so just use string manipulation. + $temp = $matches[2]; + if ($temp[0] == '{') + { + $file = false; + + if ($temp[1] == '$') + { + $var = substr($temp, 2, -1); + $temp = "\$_tpldata['DEFINE']['.']['$var']"; + } + else + { + $var = substr($temp, 1, -1); + $temp = "\$_rootref['$var']"; + } + } + return 'compile_tag_include($temp) . ' ?>'; break; case 'INCLUDEPHP': @@ -725,6 +744,12 @@ class phpbb_template_filter extends php_user_filter */ private function compile_tag_include($tag_args) { + // Process dynamic includes + if ($tag_args[0] == '$') + { + return "if (isset($tag_args)) { \$_template->_tpl_include($tag_args); }"; + } + return "\$_template->_tpl_include('$tag_args');"; }