mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-11 03:04:09 +02:00
[feature/template-engine] Get rid of orig_tpl_* in template engine.
The origins of orig_tpl_* are not pretty. Please see the following commits and associated tickets: r9823, r9839, r9847, r10150, r10460. In short, multiple hacks were required due to template engine reading inheritance/storedb flags from $user (global) even when the template that was being looked up or rendered was not the "active style of the current user". We no longer store templates in the database, removing half of the problem. This commit fixes the second half of the problem by deleting set_template_path function from template locator, and moving that logic back into the template class' set_template. set_template now calls set_custom_template, the latter only taking the template path and the fallback paths as parameters. With this change template locator no longer uses $user and does not use phpbb root path either. All logic involving setting the user's "active" template is now encapsulated in a single template class's function, set_template. Setting other templates is done via set_custom_template and the caller is responsible for determining and passing in fallback/inheritance path, if any. PHPBB3-9726
This commit is contained in:
@@ -58,56 +58,6 @@ class phpbb_template_locator
|
||||
*/
|
||||
private $files_inherit = array();
|
||||
|
||||
private $orig_tpl_inherits_id;
|
||||
|
||||
private $user;
|
||||
|
||||
public function __construct($phpbb_root_path, $user)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set template location.
|
||||
* @param string $style_name Name of style from which templates are to be taken
|
||||
*/
|
||||
public function set_template_path($style_name)
|
||||
{
|
||||
$relative_template_root = $this->relative_template_root_for_style($style_name);
|
||||
$template_root = $this->phpbb_root_path . $relative_template_root;
|
||||
if (!file_exists($template_root))
|
||||
{
|
||||
trigger_error('template locator: Template path could not be found: ' . $relative_template_root, E_USER_ERROR);
|
||||
}
|
||||
|
||||
$this->root = $template_root;
|
||||
|
||||
if ($this->orig_tpl_inherits_id === null)
|
||||
{
|
||||
$this->orig_tpl_inherits_id = $this->user->theme['template_inherits_id'];
|
||||
}
|
||||
|
||||
$this->user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id;
|
||||
|
||||
if ($this->user->theme['template_inherits_id'])
|
||||
{
|
||||
$this->inherit_root = $this->phpbb_root_path . $this->relative_template_root_for_style($this->user->theme['template_inherit_path']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a style name to relative (to board root) path to
|
||||
* the style's template files.
|
||||
*
|
||||
* @param $style_name string Style name
|
||||
* @return string Path to style template files
|
||||
*/
|
||||
private function relative_template_root_for_style($style_name)
|
||||
{
|
||||
return 'styles/' . $style_name . '/template';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom template location (able to use directory outside of phpBB).
|
||||
*
|
||||
@@ -134,11 +84,6 @@ class phpbb_template_locator
|
||||
}
|
||||
|
||||
$this->inherit_root = $fallback_template_path;
|
||||
$this->orig_tpl_inherits_id = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->orig_tpl_inherits_id = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user