From 94560d708649df876f8486d4ba5361475037f1ff Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 12 May 2011 20:09:41 -0400 Subject: [PATCH] [feature/template-engine] Make INCLUDEPHP relative to board root. PHPBB3-9726 --- phpBB/includes/template.php | 6 +++--- phpBB/includes/template/compile.php | 2 +- tests/template/template_test.php | 10 +++++----- tests/template/templates/includephp.html | 1 - tests/template/templates/includephp_relative.html | 2 ++ 5 files changed, 11 insertions(+), 10 deletions(-) delete mode 100644 tests/template/templates/includephp.html create mode 100644 tests/template/templates/includephp_relative.html diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 64a3b80f07..f2b1cccd2c 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -513,7 +513,7 @@ class phpbb_template /** * Include a separate template - * @access private + * @access public * @param string $filename Template filename to include * @param bool $include True to include the file, false to just load it * @uses template_compile is used to compile uncached templates @@ -543,9 +543,9 @@ class phpbb_template /** * Include a php-file - * @access private + * @access public */ - private function _php_include($filename) + public function _php_include($filename) { $file = $this->phpbb_root_path . $filename; diff --git a/phpBB/includes/template/compile.php b/phpBB/includes/template/compile.php index 18a52e87a6..46a30d26d3 100644 --- a/phpBB/includes/template/compile.php +++ b/phpBB/includes/template/compile.php @@ -667,7 +667,7 @@ class phpbb_template_filter extends php_user_filter */ private function compile_tag_include_php($tag_args) { - return "include('$tag_args');"; + return "\$_template->_php_include('$tag_args');"; } /** diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 9b4023c62c..a9850cd5ef 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -438,16 +438,16 @@ class phpbb_template_template_test extends phpbb_test_case $GLOBALS['config']['tpl_allow_php'] = false; } - public function test_includephp() + public function test_includephp_relative() { $GLOBALS['config']['tpl_allow_php'] = true; - $cache_file = $this->template->cachepath . 'includephp.html.php'; + $cache_file = $this->template->cachepath . 'includephp_relative.html.php'; - $this->run_template('includephp.html', array(), array(), array(), 'testing included php', $cache_file); + $this->run_template('includephp_relative.html', array(), array(), array(), "Path is relative to board root.\ntesting included php", $cache_file); - $this->template->set_filenames(array('test' => 'includephp.html')); - $this->assertEquals('testing included php', $this->display('test'), "Testing INCLUDEPHP"); + $this->template->set_filenames(array('test' => 'includephp_relative.html')); + $this->assertEquals("Path is relative to board root.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP"); $GLOBALS['config']['tpl_allow_php'] = false; } diff --git a/tests/template/templates/includephp.html b/tests/template/templates/includephp.html deleted file mode 100644 index 0a8c1a070c..0000000000 --- a/tests/template/templates/includephp.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tests/template/templates/includephp_relative.html b/tests/template/templates/includephp_relative.html new file mode 100644 index 0000000000..297c9efcb0 --- /dev/null +++ b/tests/template/templates/includephp_relative.html @@ -0,0 +1,2 @@ +Path is relative to board root. +