aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/template
diff options
context:
space:
mode:
authorPatrick Webster <noxwizard@phpbb.com>2011-09-08 16:51:22 -0500
committerPatrick Webster <noxwizard@phpbb.com>2011-09-08 16:51:22 -0500
commitfbec7c9b2b594e8bc750c5bf12a1f58a5577f8d8 (patch)
tree3686dcc4084cb3c90ab44869348fcefede9acaf2 /phpBB/includes/template
parent56bd8f27cdca2b2ba55a95307fc7dcfb83c17866 (diff)
downloadforums-fbec7c9b2b594e8bc750c5bf12a1f58a5577f8d8.tar
forums-fbec7c9b2b594e8bc750c5bf12a1f58a5577f8d8.tar.gz
forums-fbec7c9b2b594e8bc750c5bf12a1f58a5577f8d8.tar.bz2
forums-fbec7c9b2b594e8bc750c5bf12a1f58a5577f8d8.tar.xz
forums-fbec7c9b2b594e8bc750c5bf12a1f58a5577f8d8.zip
[ticket/10322] Fix dynamic template includes
Dynamic template includes from variables was not implemented in the new templating system. PHPBB3-10322
Diffstat (limited to 'phpBB/includes/template')
-rw-r--r--phpBB/includes/template/filter.php27
1 files changed, 26 insertions, 1 deletions
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 '<?php ' . $this->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 '<?php ' . $this->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');";
}