aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorVjacheslav Trushkin <arty@phpbb.com>2012-03-31 22:07:04 +0300
committerVjacheslav Trushkin <arty@phpbb.com>2012-03-31 22:07:04 +0300
commit2ce73baeab35adc3515a04c1db38af62c98d5c93 (patch)
treee858be08b00e825971df67001a35e0193e3b95d5 /phpBB
parentb3f46b9565117940b79c7530a1c21336cd072073 (diff)
downloadforums-2ce73baeab35adc3515a04c1db38af62c98d5c93.tar
forums-2ce73baeab35adc3515a04c1db38af62c98d5c93.tar.gz
forums-2ce73baeab35adc3515a04c1db38af62c98d5c93.tar.bz2
forums-2ce73baeab35adc3515a04c1db38af62c98d5c93.tar.xz
forums-2ce73baeab35adc3515a04c1db38af62c98d5c93.zip
[ticket/10733] Extending get_source_file_for_handle
Extending resource locator's function get_source_file_for_handle to find all files. This modified function should be used by template events to locate all templates before compiling them. PHPBB3-10733
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/style/resource_locator.php31
1 files changed, 27 insertions, 4 deletions
diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php
index 39505cedb5..1b35752111 100644
--- a/phpBB/includes/style/resource_locator.php
+++ b/phpBB/includes/style/resource_locator.php
@@ -185,9 +185,12 @@ class phpbb_style_resource_locator
* handle to a path without any filesystem or styles tree checks.
*
* @param string $handle Template handle (i.e. "friendly" template name)
+ * @param bool $find_all If true, each root path will be checked and function
+ * will return array of files instead of string and will not
+ * trigger a error if template does not exist
* @return string Source file path
*/
- public function get_source_file_for_handle($handle)
+ public function get_source_file_for_handle($handle, $find_all = false)
{
// If we don't have a file assigned to this handle, die.
if (!isset($this->files['style'][0][$handle]))
@@ -198,20 +201,40 @@ class phpbb_style_resource_locator
// locate a source file that exists
$source_file = $this->files['style'][0][$handle];
$tried = $source_file;
+ $found = false;
+ $found_all = array();
foreach ($this->roots as $root_key => $root_paths)
{
foreach ($root_paths as $root_index => $root)
{
$source_file = $this->files[$root_key][$root_index][$handle];
+ $tried .= ', ' . $source_file;
if (file_exists($source_file))
{
- return $source_file;
+ $found = true;
+ break;
+ }
+ }
+ if ($found)
+ {
+ if ($find_all)
+ {
+ $found_all[] = $source_file;
+ $found = false;
+ }
+ else
+ {
+ break;
}
- $tried .= ', ' . $source_file;
}
}
// search failed
- trigger_error("style resource locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR);
+ if (!$found && !$find_all)
+ {
+ trigger_error("style resource locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR);
+ }
+
+ return ($find_all) ? $found_all : $source_file;
}
}