aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2011-05-12 20:09:41 -0400
committerOleg Pudeyev <oleg@bsdpower.com>2011-05-12 20:13:32 -0400
commit94560d708649df876f8486d4ba5361475037f1ff (patch)
tree6c24ddd25b5ba07383e24beff032c3f45f77a3db
parentd2ac05aa74d3a1c9723be41a4c0ffe86542f223f (diff)
downloadforums-94560d708649df876f8486d4ba5361475037f1ff.tar
forums-94560d708649df876f8486d4ba5361475037f1ff.tar.gz
forums-94560d708649df876f8486d4ba5361475037f1ff.tar.bz2
forums-94560d708649df876f8486d4ba5361475037f1ff.tar.xz
forums-94560d708649df876f8486d4ba5361475037f1ff.zip
[feature/template-engine] Make INCLUDEPHP relative to board root.
PHPBB3-9726
-rw-r--r--phpBB/includes/template.php6
-rw-r--r--phpBB/includes/template/compile.php2
-rw-r--r--tests/template/template_test.php10
-rw-r--r--tests/template/templates/includephp.html1
-rw-r--r--tests/template/templates/includephp_relative.html2
5 files changed, 11 insertions, 10 deletions
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 @@
-<!-- INCLUDEPHP tests/template/templates/_dummy_include.php.inc -->
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.
+<!-- INCLUDEPHP ../tests/template/templates/_dummy_include.php.inc -->