aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/style/template.php
diff options
context:
space:
mode:
authorIgor Wiedler <igor@wiedler.ch>2012-04-01 18:22:55 +0200
committerIgor Wiedler <igor@wiedler.ch>2012-04-01 18:22:55 +0200
commit2b3cfa0f7b9690907e5a72f6e94e2dc51afbe96b (patch)
tree547f9b51a93714e1fa8a19b410f10cce220ae21b /phpBB/includes/style/template.php
parent31dbe94f86a6789ad462c0b7043b669de2e929b5 (diff)
parenteaba2ed9ca6025358de0432bb569cfb2e3ca6985 (diff)
downloadforums-2b3cfa0f7b9690907e5a72f6e94e2dc51afbe96b.tar
forums-2b3cfa0f7b9690907e5a72f6e94e2dc51afbe96b.tar.gz
forums-2b3cfa0f7b9690907e5a72f6e94e2dc51afbe96b.tar.bz2
forums-2b3cfa0f7b9690907e5a72f6e94e2dc51afbe96b.tar.xz
forums-2b3cfa0f7b9690907e5a72f6e94e2dc51afbe96b.zip
Merge remote-tracking branch 'cyberalien/ticket/10733' into develop
* cyberalien/ticket/10733: [ticket/10733] Fixing test [ticket/10733] Removing static from data providers [ticket/10733] Adding test for locator [ticket/10733] Adding functions to locate resources [ticket/10733] Extending get_source_file_for_handle
Diffstat (limited to 'phpBB/includes/style/template.php')
-rw-r--r--phpBB/includes/style/template.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/phpBB/includes/style/template.php b/phpBB/includes/style/template.php
index 21a2e821dd..aebf1da603 100644
--- a/phpBB/includes/style/template.php
+++ b/phpBB/includes/style/template.php
@@ -456,4 +456,40 @@ class phpbb_style_template
}
include($file);
}
+
+ /**
+ * Locates source template path, accounting for styles tree and verifying that
+ * the path exists.
+ *
+ * @param string or array $files List of templates to locate. If there is only
+ * one template, $files can be a string to make code easier to read.
+ * @param bool $return_default Determines what to return if template does not
+ * exist. If true, function will return location where template is
+ * supposed to be. If false, function will return false.
+ * @param bool $return_full_path If true, function will return full path
+ * to template. If false, function will return template file name.
+ * This parameter can be used to check which one of set of template
+ * files is available.
+ * @return string or boolean Source template path if template exists or $return_default is
+ * true. False if template does not exist and $return_default is false
+ */
+ public function locate($files, $return_default = false, $return_full_path = true)
+ {
+ // add tempalte 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);
+ }
}