aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/template/twig/node/includephp.php
diff options
context:
space:
mode:
authorNathaniel Guse <nathaniel.guse@gmail.com>2013-07-02 11:08:52 -0500
committerNathaniel Guse <nathaniel.guse@gmail.com>2013-07-02 11:08:52 -0500
commit02a8150bb615b6319bcdfd170e3febe34117f16c (patch)
tree3ecbb8319843166d7acdab00752ca441f7e23c6b /phpBB/includes/template/twig/node/includephp.php
parent59d13d0535ab3687725d36f2dbe2ee64de294df8 (diff)
downloadforums-02a8150bb615b6319bcdfd170e3febe34117f16c.tar
forums-02a8150bb615b6319bcdfd170e3febe34117f16c.tar.gz
forums-02a8150bb615b6319bcdfd170e3febe34117f16c.tar.bz2
forums-02a8150bb615b6319bcdfd170e3febe34117f16c.tar.xz
forums-02a8150bb615b6319bcdfd170e3febe34117f16c.zip
[feature/twig] INCLUDEPHP behavior now supports local relative paths
As a last resort, now we use the Twig Loader to find the correct file to include to (most specific file first, then parent styles). Also allows using @namespace convention. This is ONLY done if the specified path is not an absolute path AND the file does not exist relative to the phpBB root path. PHPBB3-11598
Diffstat (limited to 'phpBB/includes/template/twig/node/includephp.php')
-rw-r--r--phpBB/includes/template/twig/node/includephp.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/phpBB/includes/template/twig/node/includephp.php b/phpBB/includes/template/twig/node/includephp.php
index 33142bf05a..a19ce43653 100644
--- a/phpBB/includes/template/twig/node/includephp.php
+++ b/phpBB/includes/template/twig/node/includephp.php
@@ -52,12 +52,19 @@ class phpbb_template_twig_node_includephp extends Twig_Node
->raw(";\n")
->write("if (phpbb_is_absolute(\$location)) {\n")
->indent()
+ // Absolute path specified
->write("require(\$location);\n")
->outdent()
- ->write("} else {\n")
+ ->write("} else if (file_exists(\$this->getEnvironment()->get_phpbb_root_path() . \$location)) {\n")
->indent()
+ // PHP file relative to phpbb_root_path
->write("require(\$this->getEnvironment()->get_phpbb_root_path() . \$location);\n")
->outdent()
+ ->write("} else {\n")
+ ->indent()
+ // Local path (behaves like INCLUDE)
+ ->write("require(\$this->getEnvironment()->getLoader()->getCacheKey(\$location));\n")
+ ->outdent()
->write("}\n")
;