aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/template
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2012-11-20 23:19:51 -0600
committerNathan Guse <nathaniel.guse@gmail.com>2012-11-20 23:19:51 -0600
commit61aa53f91aaf11bb2fdfac3a9cdc24b074b4463e (patch)
tree210fe8026aecc70a45d48e52c58ef77d43b85787 /phpBB/includes/template
parent570c5ad3c08378f377385aaff7d3810ccb8db3ff (diff)
parentb453f359ff6dab58b0eaf94548c4e58110fb02ec (diff)
downloadforums-61aa53f91aaf11bb2fdfac3a9cdc24b074b4463e.tar
forums-61aa53f91aaf11bb2fdfac3a9cdc24b074b4463e.tar.gz
forums-61aa53f91aaf11bb2fdfac3a9cdc24b074b4463e.tar.bz2
forums-61aa53f91aaf11bb2fdfac3a9cdc24b074b4463e.tar.xz
forums-61aa53f91aaf11bb2fdfac3a9cdc24b074b4463e.zip
Merge branch 'develop' of git://github.com/phpbb/phpbb3 into ticket/11103
Conflicts: phpBB/config/services.yml phpBB/index.php
Diffstat (limited to 'phpBB/includes/template')
-rw-r--r--phpBB/includes/template/locator.php52
-rw-r--r--phpBB/includes/template/template.php75
2 files changed, 47 insertions, 80 deletions
diff --git a/phpBB/includes/template/locator.php b/phpBB/includes/template/locator.php
index 01c79eec4e..42db91efb2 100644
--- a/phpBB/includes/template/locator.php
+++ b/phpBB/includes/template/locator.php
@@ -99,12 +99,54 @@ interface phpbb_template_locator
public function get_source_file_for_handle($handle, $find_all = false);
/**
- * Locates source file path, accounting for styles tree and verifying that
- * the path exists.
+ * Obtains a complete filesystem path for a file in a style.
*
- * Unlike previous functions, this function works without template handle
- * and it can search for more than one file. If more than one file name is
- * specified, it will return location of file that it finds first.
+ * This function traverses the style tree (selected style and
+ * its parents in order, if inheritance is being used) and finds
+ * the first file on the filesystem matching specified relative path,
+ * or the first of the specified paths if more than one path is given.
+ *
+ * This function can be used to determine filesystem path of any
+ * file under any style, with the consequence being that complete
+ * relative to the style directory path must be provided as an argument.
+ *
+ * In particular, this function can be used to locate templates
+ * and javascript files.
+ *
+ * For locating templates get_first_template_location should be used
+ * as it prepends the configured template path to the template basename.
+ *
+ * Note: "selected style" is whatever style the style resource locator
+ * is configured for.
+ *
+ * The return value then will be a path, relative to the current
+ * directory or absolute, to the first existing file in the selected
+ * style or its closest parent.
+ *
+ * If the selected style does not have the file being searched,
+ * (and if inheritance is involved, none of the parents have it either),
+ * false will be returned.
+ *
+ * Multiple files can be specified, in which case the first file in
+ * the list that can be found on the filesystem is returned.
+ *
+ * If multiple files are specified and inheritance is involved,
+ * first each of the specified files is checked in the selected style,
+ * then each of the specified files is checked in the immediate parent,
+ * etc.
+ *
+ * Specifying true for $return_default will cause the function to
+ * return the first path which was checked for existence in the event
+ * that the template file was not found, instead of false.
+ * This is always a path in the selected style itself, not any of its
+ * parents.
+ *
+ * If $return_full_path is false, then instead of returning a usable
+ * path (when the file is found) the file's path relative to the style
+ * directory will be returned. This is the same path as was given to
+ * the function as a parameter. This can be used to check which of the
+ * files specified in $files exists. Naturally this requires passing
+ * more than one file in $files.
*
* @param array $files List of files to locate.
* @param bool $return_default Determines what to return if file does not
diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php
index 8a7dc6b2f3..5396ddbfad 100644
--- a/phpBB/includes/template/template.php
+++ b/phpBB/includes/template/template.php
@@ -75,12 +75,6 @@ class phpbb_template
private $locator;
/**
- * Location of templates directory within style directories
- * @var string
- */
- public $template_path = 'template/';
-
- /**
* Constructor.
*
* @param string $phpbb_root_path phpBB root path
@@ -95,7 +89,6 @@ class phpbb_template
$this->config = $config;
$this->user = $user;
$this->locator = $locator;
- $this->template_path = $this->locator->template_path;
$this->context = $context;
}
@@ -459,74 +452,6 @@ class phpbb_template
}
/**
- * Obtains filesystem path for a template file.
- *
- * The simplest use is specifying a single template file as a string
- * in the first argument. This template file should be a basename
- * of a template file in the selected style, or its parent styles
- * if template inheritance is being utilized.
- *
- * Note: "selected style" is whatever style the style resource locator
- * is configured for.
- *
- * The return value then will be a path, relative to the current
- * directory or absolute, to the template file in the selected style
- * or its closest parent.
- *
- * If the selected style does not have the template file being searched,
- * (and if inheritance is involved, none of the parents have it either),
- * false will be returned.
- *
- * Specifying true for $return_default will cause the function to
- * return the first path which was checked for existence in the event
- * that the template file was not found, instead of false.
- * This is the path in the selected style itself, not any of its
- * parents.
- *
- * $files can be given an array of templates instead of a single
- * template. When given an array, the function will try to resolve
- * each template in the array to a path, and will return the first
- * path that exists, or false if none exist.
- *
- * If $return_full_path is false, then instead of returning a usable
- * path (when the template is found) only the template's basename
- * will be returned. This can be used to check which of the templates
- * specified in $files exists, provided different file names are
- * used for different templates.
- *
- * @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 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);
- }
-
- /**
* Include JS file
*
* @param string $file file name