[ticket/10933] Add mutators for template_path to style resource locator.

template_path is now private.

Change semantics of passing false for template path - now this resets
template path to default which I think makes sense.

PHPBB3-10933
This commit is contained in:
Oleg Pudeyev 2012-06-12 00:02:30 -04:00
parent 6295b014d3
commit 09794c6821
2 changed files with 27 additions and 5 deletions

View file

@ -44,7 +44,7 @@ class phpbb_style_resource_locator implements phpbb_template_locator
* style directory, such as admin control panel templates.
* @var string
*/
public $template_path = 'template/';
private $template_path;
/**
* Map from root index to handles to source template file paths.
@ -63,6 +63,11 @@ class phpbb_style_resource_locator implements phpbb_template_locator
*/
private $filenames = array();
public function __construct()
{
$this->set_default_template_path();
}
/**
* Sets the list of style paths
*
@ -93,6 +98,19 @@ class phpbb_style_resource_locator implements phpbb_template_locator
}
}
/**
* Sets the location of templates directory within style directories.
*/
public function set_template_path($template_path)
{
$this->template_path = $template_path;
}
public function set_default_template_path()
{
$this->template_path = 'template/';
}
/**
* {@inheritDoc}
*/

View file

@ -110,7 +110,7 @@ class phpbb_style
*
* @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver"
* @param array or string $paths Array of style paths, relative to current root directory
* @param string $template_path Path to templates, relative to style directory. False if path should not be changed.
* @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/).
*/
public function set_custom_style($name, $paths, $template_path = false)
{
@ -122,12 +122,16 @@ class phpbb_style
$this->provider->set_styles($paths);
$this->locator->set_paths($this->provider);
$this->template->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $name) . '_';
if ($template_path !== false)
{
$this->locator->template_path = $template_path;
$this->locator->set_template_path($template_path);
}
else
{
$this->locator->set_default_template_path();
}
$this->template->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $name) . '_';
return true;
}