[ticket/10933] Add get_first_template_location.

This localizes template_path to style resource locator.

locate function on template will be removed in a subsequent commit.

PHPBB3-10933
This commit is contained in:
Oleg Pudeyev 2012-06-11 23:43:00 -04:00
parent 816c546666
commit 615d5ef628
2 changed files with 28 additions and 15 deletions

View file

@ -229,4 +229,31 @@ class phpbb_style_resource_locator implements phpbb_template_locator
// search failed // search failed
return $default_result; return $default_result;
} }
/**
* Just like get_first_file_location but works on a list of templates,
* not files.
*
* The templates given in the first argument first are prepended with
* the template path (property in this class), then given to
* get_first_file_location for the rest of the processing.
*/
public function get_first_template_location($templates, $return_default = false, $return_full_path = true)
{
// add template path prefix
$files = array();
if (is_string($templates))
{
$files[] = $this->template_path . $templates;
}
else
{
foreach ($templates as $template)
{
$files[] = $this->template_path . $template;
}
}
return $this->get_first_file_location($files, $return_default, $return_full_path);
}
} }

View file

@ -508,22 +508,8 @@ class phpbb_template
*/ */
public function locate($files, $return_default = false, $return_full_path = true) public function locate($files, $return_default = false, $return_full_path = true)
{ {
// add template path prefix
$templates = array();
if (is_string($files))
{
$templates[] = $this->template_path . $files;
}
else
{
foreach ($files as $file)
{
$templates[] = $this->template_path . $file;
}
}
// use resource locator to find files // use resource locator to find files
return $this->locator->get_first_file_location($templates, $return_default, $return_full_path); return $this->locator->get_first_template_location($files, $return_default, $return_full_path);
} }
/** /**