diff options
author | Oleg Pudeyev <oleg@bsdpower.com> | 2012-06-11 23:43:00 -0400 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2012-11-02 19:37:52 -0400 |
commit | 615d5ef628767ec127735fb4797171de3f886de2 (patch) | |
tree | 0eb5317ef4ed5407c38310c1cb1113d58fee20bb /phpBB/includes | |
parent | 816c546666b9ee27a717efc4f5640afc4794cff6 (diff) | |
download | forums-615d5ef628767ec127735fb4797171de3f886de2.tar forums-615d5ef628767ec127735fb4797171de3f886de2.tar.gz forums-615d5ef628767ec127735fb4797171de3f886de2.tar.bz2 forums-615d5ef628767ec127735fb4797171de3f886de2.tar.xz forums-615d5ef628767ec127735fb4797171de3f886de2.zip |
[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
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/style/resource_locator.php | 27 | ||||
-rw-r--r-- | phpBB/includes/template/template.php | 16 |
2 files changed, 28 insertions, 15 deletions
diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php index 8658fe4a36..e3bcf4d9c4 100644 --- a/phpBB/includes/style/resource_locator.php +++ b/phpBB/includes/style/resource_locator.php @@ -229,4 +229,31 @@ class phpbb_style_resource_locator implements phpbb_template_locator // search failed 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); + } } diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index 5d3ce4c82b..9e44c5609b 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -508,22 +508,8 @@ class phpbb_template */ 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 - 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); } /** |