mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[feature/template-engine] Make INCLUDEPHP relative to board root.
PHPBB3-9726
This commit is contained in:
parent
d2ac05aa74
commit
94560d7086
5 changed files with 11 additions and 10 deletions
|
@ -513,7 +513,7 @@ class phpbb_template
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include a separate template
|
* Include a separate template
|
||||||
* @access private
|
* @access public
|
||||||
* @param string $filename Template filename to include
|
* @param string $filename Template filename to include
|
||||||
* @param bool $include True to include the file, false to just load it
|
* @param bool $include True to include the file, false to just load it
|
||||||
* @uses template_compile is used to compile uncached templates
|
* @uses template_compile is used to compile uncached templates
|
||||||
|
@ -543,9 +543,9 @@ class phpbb_template
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include a php-file
|
* Include a php-file
|
||||||
* @access private
|
* @access public
|
||||||
*/
|
*/
|
||||||
private function _php_include($filename)
|
public function _php_include($filename)
|
||||||
{
|
{
|
||||||
$file = $this->phpbb_root_path . $filename;
|
$file = $this->phpbb_root_path . $filename;
|
||||||
|
|
||||||
|
|
|
@ -667,7 +667,7 @@ class phpbb_template_filter extends php_user_filter
|
||||||
*/
|
*/
|
||||||
private function compile_tag_include_php($tag_args)
|
private function compile_tag_include_php($tag_args)
|
||||||
{
|
{
|
||||||
return "include('$tag_args');";
|
return "\$_template->_php_include('$tag_args');";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -438,16 +438,16 @@ class phpbb_template_template_test extends phpbb_test_case
|
||||||
$GLOBALS['config']['tpl_allow_php'] = false;
|
$GLOBALS['config']['tpl_allow_php'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_includephp()
|
public function test_includephp_relative()
|
||||||
{
|
{
|
||||||
$GLOBALS['config']['tpl_allow_php'] = true;
|
$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->template->set_filenames(array('test' => 'includephp_relative.html'));
|
||||||
$this->assertEquals('testing included php', $this->display('test'), "Testing INCLUDEPHP");
|
$this->assertEquals("Path is relative to board root.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
|
||||||
|
|
||||||
$GLOBALS['config']['tpl_allow_php'] = false;
|
$GLOBALS['config']['tpl_allow_php'] = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
<!-- INCLUDEPHP tests/template/templates/_dummy_include.php.inc -->
|
|
2
tests/template/templates/includephp_relative.html
Normal file
2
tests/template/templates/includephp_relative.html
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Path is relative to board root.
|
||||||
|
<!-- INCLUDEPHP ../tests/template/templates/_dummy_include.php.inc -->
|
Loading…
Add table
Reference in a new issue