1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 05:50:42 +02:00

[ticket/10733] Adding functions to locate resources

Adding $style->locate() and $template->locate() functions

PHPBB3-10733
This commit is contained in:
Vjacheslav Trushkin
2012-04-01 09:52:55 +03:00
parent 2ce73baeab
commit f80512f106
3 changed files with 115 additions and 0 deletions

View File

@@ -150,4 +150,32 @@ class phpbb_style
{
$this->provider->set_ext_dir_prefix($ext_dir_prefix);
}
/**
* Locates source file path, accounting for styles tree and verifying that
* the path exists.
*
* @param string or array $files List of files to locate. If there is only
* one file, $files can be a string to make code easier to read.
* @param bool $return_default Determines what to return if file does not
* exist. If true, function will return location where file is
* supposed to be. If false, function will return false.
* @param bool $return_full_path If true, function will return full path
* to file. If false, function will return file name. This
* parameter can be used to check which one of set of files
* is available.
* @return string or boolean Source file path if file exists or $return_default is
* true. False if file does not exist and $return_default is false
*/
public function locate($files, $return_default = false, $return_full_path = true)
{
// convert string to array
if (is_string($files))
{
$files = array($files);
}
// use resource locator to find files
return $this->locator->get_first_file_location($files, $return_default, $return_full_path);
}
}