aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/includes/template/locator.php55
-rw-r--r--phpBB/includes/template/template.php41
2 files changed, 28 insertions, 68 deletions
diff --git a/phpBB/includes/template/locator.php b/phpBB/includes/template/locator.php
index d9c95ec4ff..804fd07537 100644
--- a/phpBB/includes/template/locator.php
+++ b/phpBB/includes/template/locator.php
@@ -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;
}
}
diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php
index 6a60ff34d6..ad5581499d 100644
--- a/phpBB/includes/template/template.php
+++ b/phpBB/includes/template/template.php
@@ -42,8 +42,6 @@ class phpbb_template
*/
public $cachepath = '';
- public $orig_tpl_inherits_id;
-
/**
* @var string phpBB root path
*/
@@ -81,7 +79,7 @@ class phpbb_template
$this->phpEx = $phpEx;
$this->config = $config;
$this->user = $user;
- $this->locator = new phpbb_template_locator($phpbb_root_path, $user);
+ $this->locator = new phpbb_template_locator();
}
/**
@@ -89,18 +87,28 @@ class phpbb_template
*/
public function set_template()
{
- $template_path = $style_name = $this->user->theme['template_path'];
- $this->locator->set_template_path($style_name);
+ $style_name = $this->user->theme['template_path'];
+
+ $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);
+ }
- if (file_exists($this->phpbb_root_path . 'styles/' . $template_path . '/template'))
+ if ($this->user->theme['template_inherits_id'])
{
- $this->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $template_path) . '_';
+ $fallback_template_path = $this->phpbb_root_path . $this->relative_template_root_for_style($this->user->theme['template_inherit_path']);
}
else
{
- trigger_error('Template path could not be found: styles/' . $template_path . '/template', E_USER_ERROR);
+ $fallback_template_path = null;
}
+ $this->locator->set_custom_template($template_root, $fallback_template_path);
+
+ $this->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $style_name) . '_';
+
$this->context = new phpbb_template_context();
return true;
@@ -127,6 +135,18 @@ class phpbb_template
}
/**
+ * 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';
+ }
+
+ /**
* Sets the template filenames for handles. $filename_array
* should be a hash of handle => filename pairs.
* @param array $filname_array Should be a hash of handle => filename pairs.
@@ -274,11 +294,6 @@ class phpbb_template
$virtual_source_file = $this->locator->get_virtual_source_file_for_handle($handle);
$source_file = null;
- // reload this setting to have the values they had when this object was initialised
- // using set_template or set_custom_template, they might otherwise have been overwritten
- // by other template class instances in between.
- $this->user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id;
-
$compiled_path = $this->cachepath . str_replace('/', '.', $virtual_source_file) . '.' . $this->phpEx;
$recompile = defined('DEBUG_EXTRA') ||