aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/style/resource_locator.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/style/resource_locator.php')
-rw-r--r--phpBB/includes/style/resource_locator.php66
1 files changed, 28 insertions, 38 deletions
diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php
index af261534c3..39505cedb5 100644
--- a/phpBB/includes/style/resource_locator.php
+++ b/phpBB/includes/style/resource_locator.php
@@ -39,12 +39,6 @@ class phpbb_style_resource_locator
private $roots = array();
/**
- * Index of the main style in the roots array.
- * @var int
- */
- private $main_root_id = 0;
-
- /**
* Location of templates directory within style directories.
* Must have trailing slash. Empty if templates are stored in root
* style directory, such as admin control panel templates.
@@ -70,17 +64,6 @@ class phpbb_style_resource_locator
private $filenames = array();
/**
- * Set main style location (must have been added through set_paths first).
- *
- * @param string $style_path Path to style directory
- * @return null
- */
- public function set_main_style($style_path)
- {
- $this->main_root_id = array_search($style_path, $this->roots, true);
- }
-
- /**
* Sets the list of style paths
*
* These paths will be searched for style files in the provided order.
@@ -95,16 +78,18 @@ class phpbb_style_resource_locator
$this->roots = array();
$this->files = array();
$this->filenames = array();
- $this->main_root_id = 0;
- foreach ($style_paths as $path)
+ foreach ($style_paths as $key => $paths)
{
- // Make sure $path has no ending slash
- if (substr($path, -1) === '/')
+ foreach ($paths as $path)
{
- $path = substr($path, 0, -1);
+ // Make sure $path has no ending slash
+ if (substr($path, -1) === '/')
+ {
+ $path = substr($path, 0, -1);
+ }
+ $this->roots[$key][] = $path;
}
- $this->roots[] = $path;
}
}
@@ -125,9 +110,12 @@ class phpbb_style_resource_locator
$this->filename[$handle] = $filename;
- foreach ($this->roots as $root_index => $root)
+ foreach ($this->roots as $root_key => $root_paths)
{
- $this->files[$root_index][$handle] = $root . '/' . $this->template_path . $filename;
+ foreach ($root_paths as $root_index => $root)
+ {
+ $this->files[$root_key][$root_index][$handle] = $root . '/' . $this->template_path . $filename;
+ }
}
}
}
@@ -174,12 +162,12 @@ class phpbb_style_resource_locator
public function get_virtual_source_file_for_handle($handle)
{
// If we don't have a file assigned to this handle, die.
- if (!isset($this->files[$this->main_root_id][$handle]))
+ if (!isset($this->files['style'][0][$handle]))
{
trigger_error("style resource locator: No file specified for handle $handle", E_USER_ERROR);
}
- $source_file = $this->files[$this->main_root_id][$handle];
+ $source_file = $this->files['style'][0][$handle];
return $source_file;
}
@@ -202,26 +190,28 @@ class phpbb_style_resource_locator
public function get_source_file_for_handle($handle)
{
// If we don't have a file assigned to this handle, die.
- if (!isset($this->files[$this->main_root_id][$handle]))
+ if (!isset($this->files['style'][0][$handle]))
{
trigger_error("style resource locator: No file specified for handle $handle", E_USER_ERROR);
}
// locate a source file that exists
- $source_file = $this->files[0][$handle];
+ $source_file = $this->files['style'][0][$handle];
$tried = $source_file;
- for ($i = 1, $n = count($this->roots); $i < $n && !file_exists($source_file); $i++)
+ foreach ($this->roots as $root_key => $root_paths)
{
- $source_file = $this->files[$i][$handle];
- $tried .= ', ' . $source_file;
+ foreach ($root_paths as $root_index => $root)
+ {
+ $source_file = $this->files[$root_key][$root_index][$handle];
+ if (file_exists($source_file))
+ {
+ return $source_file;
+ }
+ $tried .= ', ' . $source_file;
+ }
}
// search failed
- if (!file_exists($source_file))
- {
- trigger_error("style resource locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR);
- }
-
- return $source_file;
+ trigger_error("style resource locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR);
}
}