From 234e5d6402978ba1a7cfbb3d163512657c7b87fc Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Wed, 14 Mar 2012 23:22:02 +0200 Subject: [PATCH] [feature/merging-style-components] Implementing unlimited parent templates Implementing possibility of unlimited levels of parent templates. Paths are stored in style_parent_tree, entries are separated by / PHPBB3-10632 --- phpBB/includes/style/template.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/style/template.php b/phpBB/includes/style/template.php index a8c5139dd0..02fa0bd250 100644 --- a/phpBB/includes/style/template.php +++ b/phpBB/includes/style/template.php @@ -97,8 +97,8 @@ class phpbb_style_template */ public function set_template() { - $template_name = $this->user->theme['template_path']; - $fallback_name = ($this->user->theme['template_inherits_id']) ? $this->user->theme['template_inherit_path'] : false; + $template_name = $this->user->theme['style_path']; + $fallback_name = ($this->user->theme['style_parent_id']) ? array_reverse(explode('/', $this->user->theme['style_parent_tree'])) : false; return $this->set_custom_template(false, $template_name, false, $fallback_name); } @@ -121,17 +121,26 @@ class phpbb_style_template * * @param string $template_path Path to template directory * @param string $template_name Name of template - * @param string $fallback_template_path Path to fallback template - * @param string $fallback_template_name Name of fallback template + * @param string or array $fallback_template_path Path to fallback template + * @param string or array $fallback_template_name Name of fallback template */ public function set_custom_template($template_path, $template_name, $fallback_template_path = false, $fallback_template_name = false) { $templates = array($template_name => $template_path); - if ($fallback_template_name !== false) + if (is_string($fallback_template_name)) { $templates[$fallback_template_name] = $fallback_template_path; } + if (is_array($fallback_template_name)) + { + $i = 0; + foreach ($fallback_template_name as $fallback_template_name_item) + { + $templates[$fallback_template_name_item] = is_array($fallback_template_path) ? $fallback_template_path[$i] : $fallback_template_path; + $i ++; + } + } $this->provider->set_templates($templates, $this->phpbb_root_path); $this->locator->set_paths($this->provider);