mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/10799] Removing global variable from includejs
Removing global $phpbb_root_path from includejs implementation PHPBB3-10799
This commit is contained in:
parent
2a92fee06d
commit
63b41913a4
2 changed files with 8 additions and 3 deletions
|
@ -905,12 +905,12 @@ class phpbb_template_filter extends php_user_filter
|
|||
if (substr($filename, 0, strlen($this->phpbb_root_path)) != $this->phpbb_root_path)
|
||||
{
|
||||
// Absolute path, include as is
|
||||
return ' $_template->_js_include(\'' . addslashes($filename) . '\', false); ';
|
||||
return ' $_template->_js_include(\'' . addslashes($filename) . '\', false, false); ';
|
||||
}
|
||||
|
||||
// Relative path, remove root path from it
|
||||
$filename = substr($filename, strlen($this->phpbb_root_path));
|
||||
return ' global $phpbb_root_path; $_template->_js_include($phpbb_root_path . \'' . addslashes($filename) . '\', false); ';
|
||||
return ' $_template->_js_include(\'' . addslashes($filename) . '\', false, true); ';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -496,14 +496,19 @@ class phpbb_template
|
|||
*
|
||||
* @param string $file file name
|
||||
* @param bool $locate True if file needs to be located
|
||||
* @param bool $relative True if path is relative to phpBB root directory. Ignored if $locate == true
|
||||
*/
|
||||
public function _js_include($file, $locate = false)
|
||||
public function _js_include($file, $locate = false, $relative = false)
|
||||
{
|
||||
// Locate file
|
||||
if ($locate)
|
||||
{
|
||||
$file = $this->locator->get_first_file_location(array($file), true, true);
|
||||
}
|
||||
else if ($relative)
|
||||
{
|
||||
$file = $this->phpbb_root_path . $file;
|
||||
}
|
||||
|
||||
$file .= (strpos($file, '?') === false) ? '?' : '&';
|
||||
$file .= 'assets_version=' . $this->config['assets_version'];
|
||||
|
|
Loading…
Add table
Reference in a new issue