From 733018f99a7d8c6200921f31c683606c6f01fe76 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 3 Apr 2012 11:23:09 +0300 Subject: [PATCH 1/6] [ticket/10756] Moving template classes Moving template class files from includes/style/ to includes/template/ and removing template_ file prefix PHPBB3-10756 --- .../includes/{style/template_compile.php => template/compile.php} | 0 .../includes/{style/template_context.php => template/context.php} | 0 phpBB/includes/{style/template_filter.php => template/filter.php} | 0 .../{style/template_renderer.php => template/renderer.php} | 0 .../template_renderer_eval.php => template/renderer_eval.php} | 0 .../renderer_include.php} | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename phpBB/includes/{style/template_compile.php => template/compile.php} (100%) rename phpBB/includes/{style/template_context.php => template/context.php} (100%) rename phpBB/includes/{style/template_filter.php => template/filter.php} (100%) rename phpBB/includes/{style/template_renderer.php => template/renderer.php} (100%) rename phpBB/includes/{style/template_renderer_eval.php => template/renderer_eval.php} (100%) rename phpBB/includes/{style/template_renderer_include.php => template/renderer_include.php} (100%) diff --git a/phpBB/includes/style/template_compile.php b/phpBB/includes/template/compile.php similarity index 100% rename from phpBB/includes/style/template_compile.php rename to phpBB/includes/template/compile.php diff --git a/phpBB/includes/style/template_context.php b/phpBB/includes/template/context.php similarity index 100% rename from phpBB/includes/style/template_context.php rename to phpBB/includes/template/context.php diff --git a/phpBB/includes/style/template_filter.php b/phpBB/includes/template/filter.php similarity index 100% rename from phpBB/includes/style/template_filter.php rename to phpBB/includes/template/filter.php diff --git a/phpBB/includes/style/template_renderer.php b/phpBB/includes/template/renderer.php similarity index 100% rename from phpBB/includes/style/template_renderer.php rename to phpBB/includes/template/renderer.php diff --git a/phpBB/includes/style/template_renderer_eval.php b/phpBB/includes/template/renderer_eval.php similarity index 100% rename from phpBB/includes/style/template_renderer_eval.php rename to phpBB/includes/template/renderer_eval.php diff --git a/phpBB/includes/style/template_renderer_include.php b/phpBB/includes/template/renderer_include.php similarity index 100% rename from phpBB/includes/style/template_renderer_include.php rename to phpBB/includes/template/renderer_include.php From ef295a28606789874b524445f9fa690408c8eafc Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 3 Apr 2012 11:27:15 +0300 Subject: [PATCH 2/6] [ticket/10756] Renaming template classes Renaming template classes from phpbb_style_template_ to phpbb_template_ PHPBB3-10756 --- phpBB/includes/style/style.php | 2 +- phpBB/includes/style/template.php | 20 ++++++++++---------- phpBB/includes/template/compile.php | 4 ++-- phpBB/includes/template/context.php | 2 +- phpBB/includes/template/filter.php | 2 +- phpBB/includes/template/renderer.php | 4 ++-- phpBB/includes/template/renderer_eval.php | 4 ++-- phpBB/includes/template/renderer_include.php | 4 ++-- tests/template/renderer_eval_test.php | 4 ++-- tests/template/template_compile_test.php | 2 +- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index 5ac61c9f10..4bfb9eaa07 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -119,7 +119,7 @@ class phpbb_style $this->template->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $name) . '_'; - $this->template->context = new phpbb_style_template_context(); + $this->template->context = new phpbb_template_context(); if ($template_path !== false) { diff --git a/phpBB/includes/style/template.php b/phpBB/includes/style/template.php index 9d476e74b9..ad4c452268 100644 --- a/phpBB/includes/style/template.php +++ b/phpBB/includes/style/template.php @@ -32,7 +32,7 @@ if (!defined('IN_PHPBB')) class phpbb_style_template { /** - * @var phpbb_style_template_context Template context. + * @var phpbb_template_context Template context. * Stores template data used during template rendering. */ public $context; @@ -253,15 +253,15 @@ class phpbb_style_template * configuration setting may be used to force templates to be always * recompiled. * - * Returns an object implementing phpbb_style_template_renderer, or null + * Returns an object implementing phpbb_template_renderer, or null * if template loading or compilation failed. Call render() on the * renderer to display the template. This will result in template * contents sent to the output stream (unless, of course, output * buffering is in effect). * * @param string $handle Handle of the template to load - * @return phpbb_style_template_renderer Template renderer object, or null on failure - * @uses phpbb_style_template_compile is used to compile template source + * @return phpbb_template_renderer Template renderer object, or null on failure + * @uses phpbb_template_compile is used to compile template source */ private function _tpl_load($handle) { @@ -285,18 +285,18 @@ class phpbb_style_template // Recompile page if the original template is newer, otherwise load the compiled version if (!$recompile) { - return new phpbb_style_template_renderer_include($output_file, $this); + return new phpbb_template_renderer_include($output_file, $this); } - $compile = new phpbb_style_template_compile($this->config['tpl_allow_php'], $this->locator, $this->phpbb_root_path); + $compile = new phpbb_template_compile($this->config['tpl_allow_php'], $this->locator, $this->phpbb_root_path); if ($compile->compile_file_to_file($source_file, $output_file) !== false) { - $renderer = new phpbb_style_template_renderer_include($output_file, $this); + $renderer = new phpbb_template_renderer_include($output_file, $this); } else if (($code = $compile->compile_file($source_file)) !== false) { - $renderer = new phpbb_style_template_renderer_eval($code, $this); + $renderer = new phpbb_template_renderer_eval($code, $this); } else { @@ -358,7 +358,7 @@ class phpbb_style_template $this->context->append_var($varname, $varval); } - // Docstring is copied from phpbb_style_template_context method with the same name. + // Docstring is copied from phpbb_template_context method with the same name. /** * Assign key variable pairs from an array to a specified block * @param string $blockname Name of block to assign $vararray to @@ -369,7 +369,7 @@ class phpbb_style_template return $this->context->assign_block_vars($blockname, $vararray); } - // Docstring is copied from phpbb_style_template_context method with the same name. + // Docstring is copied from phpbb_template_context method with the same name. /** * Change already assigned key variable pair (one-dimensional - single loop entry) * diff --git a/phpBB/includes/template/compile.php b/phpBB/includes/template/compile.php index fa0928f424..82b301c1a2 100644 --- a/phpBB/includes/template/compile.php +++ b/phpBB/includes/template/compile.php @@ -15,7 +15,7 @@ if (!defined('IN_PHPBB')) exit; } -stream_filter_register('phpbb_template', 'phpbb_style_template_filter'); +stream_filter_register('phpbb_template', 'phpbb_template_filter'); /** * Extension of template class - Functions needed for compiling templates only. @@ -23,7 +23,7 @@ stream_filter_register('phpbb_template', 'phpbb_style_template_filter'); * @package phpBB3 * @uses template_filter As a PHP stream filter to perform compilation of templates */ -class phpbb_style_template_compile +class phpbb_template_compile { /** * Array of parameters to forward to template filter diff --git a/phpBB/includes/template/context.php b/phpBB/includes/template/context.php index b22f77da2e..5e0b1d4a7e 100644 --- a/phpBB/includes/template/context.php +++ b/phpBB/includes/template/context.php @@ -20,7 +20,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class phpbb_style_template_context +class phpbb_template_context { /** * variable that holds all the data we'll be substituting into diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php index 6ef9d80a3d..4a2593b757 100644 --- a/phpBB/includes/template/filter.php +++ b/phpBB/includes/template/filter.php @@ -35,7 +35,7 @@ if (!defined('IN_PHPBB')) * @see template_compile * @package phpBB3 */ -class phpbb_style_template_filter extends php_user_filter +class phpbb_template_filter extends php_user_filter { const REGEX_NS = '[a-z_][a-z_0-9]+'; diff --git a/phpBB/includes/template/renderer.php b/phpBB/includes/template/renderer.php index bd2a786e86..30e234a733 100644 --- a/phpBB/includes/template/renderer.php +++ b/phpBB/includes/template/renderer.php @@ -23,12 +23,12 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -interface phpbb_style_template_renderer +interface phpbb_template_renderer { /** * Displays the template managed by this renderer. * - * @param phpbb_style_template_context $context Template context to use + * @param phpbb_template_context $context Template context to use * @param array $lang Language entries to use */ public function render($context, $lang); diff --git a/phpBB/includes/template/renderer_eval.php b/phpBB/includes/template/renderer_eval.php index 3e08b06e69..62dfbc3708 100644 --- a/phpBB/includes/template/renderer_eval.php +++ b/phpBB/includes/template/renderer_eval.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class phpbb_style_template_renderer_eval implements phpbb_style_template_renderer +class phpbb_template_renderer_eval implements phpbb_template_renderer { /** * Template code to be eval'ed. @@ -45,7 +45,7 @@ class phpbb_style_template_renderer_eval implements phpbb_style_template_rendere * Displays the template managed by this renderer by eval'ing php code * of the template. * - * @param phpbb_style_template_context $context Template context to use + * @param phpbb_template_context $context Template context to use * @param array $lang Language entries to use */ public function render($context, $lang) diff --git a/phpBB/includes/template/renderer_include.php b/phpBB/includes/template/renderer_include.php index 91c1a1bb65..f5c9026abf 100644 --- a/phpBB/includes/template/renderer_include.php +++ b/phpBB/includes/template/renderer_include.php @@ -22,7 +22,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class phpbb_style_template_renderer_include implements phpbb_style_template_renderer +class phpbb_template_renderer_include implements phpbb_template_renderer { /** * Template path to be included. @@ -45,7 +45,7 @@ class phpbb_style_template_renderer_include implements phpbb_style_template_rend * Displays the template managed by this renderer by including * the php file containing the template. * - * @param phpbb_style_template_context $context Template context to use + * @param phpbb_template_context $context Template context to use * @param array $lang Language entries to use */ public function render($context, $lang) diff --git a/tests/template/renderer_eval_test.php b/tests/template/renderer_eval_test.php index 9b4f74c824..7ebb8b9bda 100644 --- a/tests/template/renderer_eval_test.php +++ b/tests/template/renderer_eval_test.php @@ -13,8 +13,8 @@ class phpbb_template_renderer_eval_test extends phpbb_test_case { $compiled_code = ''; $valid_code = ''; - $context = new phpbb_style_template_context(); - $template = new phpbb_style_template_renderer_eval($compiled_code, NULL); + $context = new phpbb_template_context(); + $template = new phpbb_template_renderer_eval($compiled_code, NULL); ob_start(); try { diff --git a/tests/template/template_compile_test.php b/tests/template/template_compile_test.php index e2264fb1b7..0cfcd6ceb5 100644 --- a/tests/template/template_compile_test.php +++ b/tests/template/template_compile_test.php @@ -16,7 +16,7 @@ class phpbb_template_template_compile_test extends phpbb_test_case protected function setUp() { - $this->template_compile = new phpbb_style_template_compile(false, null, ''); + $this->template_compile = new phpbb_template_compile(false, null, ''); $this->template_path = dirname(__FILE__) . '/templates'; } From ea3a2ef2234095e9db2d79f8c1d17bf1dfda1a23 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 3 Apr 2012 13:19:03 +0300 Subject: [PATCH 3/6] [ticket/10756] Creating locator interface Creating locator interface to be used in template class PHPBB3-10756 --- phpBB/includes/style/resource_locator.php | 2 +- phpBB/includes/style/template.php | 8 +- phpBB/includes/template/locator.php | 133 ++++++++++++++++++++++ 3 files changed, 138 insertions(+), 5 deletions(-) create mode 100644 phpBB/includes/template/locator.php diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php index 3e6dd5d6aa..fafa11c352 100644 --- a/phpBB/includes/style/resource_locator.php +++ b/phpBB/includes/style/resource_locator.php @@ -30,7 +30,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class phpbb_style_resource_locator +class phpbb_style_resource_locator implements phpbb_template_locator { /** * Paths to style directories. diff --git a/phpBB/includes/style/template.php b/phpBB/includes/style/template.php index ad4c452268..1967ec7d96 100644 --- a/phpBB/includes/style/template.php +++ b/phpBB/includes/style/template.php @@ -63,8 +63,8 @@ class phpbb_style_template private $user; /** - * Style resource locator - * @var phpbb_style_resource_locator + * Template locator + * @var phpbb_template_locator */ private $locator; @@ -85,10 +85,10 @@ class phpbb_style_template * * @param string $phpbb_root_path phpBB root path * @param user $user current user - * @param phpbb_style_resource_locator $locator style resource locator + * @param phpbb_template_locator $locator template locator * @param phpbb_style_path_provider $provider style path provider */ - public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_style_resource_locator $locator, phpbb_style_path_provider_interface $provider) + public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_template_locator $locator, phpbb_style_path_provider_interface $provider) { $this->phpbb_root_path = $phpbb_root_path; $this->phpEx = $phpEx; diff --git a/phpBB/includes/template/locator.php b/phpBB/includes/template/locator.php new file mode 100644 index 0000000000..836046e92b --- /dev/null +++ b/phpBB/includes/template/locator.php @@ -0,0 +1,133 @@ + filename pairs. + * + * @param array $filname_array Should be a hash of handle => filename pairs. + */ + public function set_filenames(array $filename_array); + + /** + * Determines the filename for a template handle. + * + * The filename comes from array used in a set_filenames call, + * which should have been performed prior to invoking this function. + * Return value is a file basename (without path). + * + * @param $handle string Template handle + * @return string Filename corresponding to the template handle + */ + public function get_filename_for_handle($handle); + + /** + * Determines the source file path for a template handle without + * regard for styles tree. + * + * This function returns the path in "primary" style directory + * corresponding to the given template handle. That path may or + * may not actually exist on the filesystem. Because this function + * does not perform stat calls to determine whether the path it + * returns actually exists, it is faster than get_source_file_for_handle. + * + * Use get_source_file_for_handle to obtain the actual path that is + * guaranteed to exist (which might come from the parent style + * directory if primary style has parent styles). + * + * This function will trigger an error if the handle was never + * associated with a template file via set_filenames. + * + * @param $handle string Template handle + * @return string Path to source file path in primary style directory + */ + public function get_virtual_source_file_for_handle($handle); + + /** + * Determines the source file path for a template handle, accounting + * for styles tree and verifying that the path exists. + * + * This function returns the actual path that may be compiled for + * the specified template handle. It will trigger an error if + * the template handle was never associated with a template path + * via set_filenames or if the template file does not exist on the + * filesystem. + * + * Use get_virtual_source_file_for_handle to just resolve a template + * 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, $find_all = false); + + /** + * Locates source file path, accounting for styles tree and verifying that + * the path exists. + * + * 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. + * + * @param array $files List of files to locate. + * @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 get_first_file_location($files, $return_default = false, $return_full_path = true); +} From 6cecc91326135fbb36eb9d73aa25fc40cfdfb54b Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 3 Apr 2012 13:23:08 +0300 Subject: [PATCH 4/6] [ticket/10756] Removing path provider from template class Removing path provider from template class because it is not used by template class PHPBB3-10756 --- phpBB/common.php | 3 ++- phpBB/includes/bbcode.php | 2 +- phpBB/includes/functions_messenger.php | 4 +++- phpBB/includes/style/template.php | 10 +--------- phpBB/install/index.php | 2 +- tests/template/template_test_case.php | 2 +- tests/template/template_test_case_with_tree.php | 2 +- 7 files changed, 10 insertions(+), 15 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index a00e3e82a8..7694620b36 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -124,7 +124,8 @@ $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_ro // Initialize style $phpbb_style_resource_locator = new phpbb_style_resource_locator(); $phpbb_style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); -$template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider); + +$template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator); $phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template); $phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 612ced8ad6..3adf9582d6 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -134,7 +134,7 @@ class bbcode $style_resource_locator = new phpbb_style_resource_locator(); $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); - $template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider); + $template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator); $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $template); $style->set_style(); $template->set_filenames(array('bbcode.html' => 'bbcode.html')); diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index f608c95fe4..de14703817 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -210,8 +210,10 @@ class messenger { $style_resource_locator = new phpbb_style_resource_locator(); $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); - $tpl = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider); + + $tpl = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator); $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $tpl); + $this->tpl_msg[$template_lang . $template_file] = $tpl; $fallback_template_path = false; diff --git a/phpBB/includes/style/template.php b/phpBB/includes/style/template.php index 1967ec7d96..6dd588c17b 100644 --- a/phpBB/includes/style/template.php +++ b/phpBB/includes/style/template.php @@ -68,12 +68,6 @@ class phpbb_style_template */ private $locator; - /** - * Template path provider - * @var phpbb_style_path_provider - */ - private $provider; - /** * Location of templates directory within style directories * @var string @@ -86,9 +80,8 @@ class phpbb_style_template * @param string $phpbb_root_path phpBB root path * @param user $user current user * @param phpbb_template_locator $locator template locator - * @param phpbb_style_path_provider $provider style path provider */ - public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_template_locator $locator, phpbb_style_path_provider_interface $provider) + public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_template_locator $locator) { $this->phpbb_root_path = $phpbb_root_path; $this->phpEx = $phpEx; @@ -96,7 +89,6 @@ class phpbb_style_template $this->user = $user; $this->locator = $locator; $this->template_path = $this->locator->template_path; - $this->provider = $provider; } /** diff --git a/phpBB/install/index.php b/phpBB/install/index.php index bb10521bba..be5ebc53b5 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -202,7 +202,7 @@ $config = new phpbb_config(array( $phpbb_style_resource_locator = new phpbb_style_resource_locator(); $phpbb_style_path_provider = new phpbb_style_path_provider(); -$template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider); +$template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator); $phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template); $phpbb_style->set_ext_dir_prefix('adm/'); $phpbb_style->set_custom_style('admin', '../adm/style', ''); diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index a87e531a07..4170fdf278 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -66,7 +66,7 @@ class phpbb_template_template_test_case extends phpbb_test_case $this->template_path = dirname(__FILE__) . '/templates'; $this->style_resource_locator = new phpbb_style_resource_locator(); $this->style_provider = new phpbb_style_path_provider(); - $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); + $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator); $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); $this->style->set_custom_style('tests', $this->template_path, ''); } diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index e76d9436cf..536ac394a8 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -22,7 +22,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; $this->style_resource_locator = new phpbb_style_resource_locator(); $this->style_provider = new phpbb_style_path_provider(); - $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); + $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator); $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); $this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), ''); } From d91abbb146d3a808764bf19b9e6adc6e14db1751 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 3 Apr 2012 13:57:12 +0300 Subject: [PATCH 5/6] [ticket/10756] Renaming phpbb_style_template to phpbb_template Renaming phpbb_style_template to phpbb_template PHPBB3-10756 --- phpBB/common.php | 3 +-- phpBB/includes/bbcode.php | 2 +- phpBB/includes/functions_messenger.php | 3 +-- phpBB/includes/style/style.php | 6 +++--- phpBB/includes/template/context.php | 2 +- phpBB/includes/template/renderer_eval.php | 2 +- phpBB/includes/{style => template}/template.php | 2 +- phpBB/install/index.php | 2 +- tests/template/template_test_case.php | 2 +- tests/template/template_test_case_with_tree.php | 2 +- 10 files changed, 12 insertions(+), 14 deletions(-) rename phpBB/includes/{style => template}/template.php (99%) diff --git a/phpBB/common.php b/phpBB/common.php index 7694620b36..81fe275008 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -124,8 +124,7 @@ $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_ro // Initialize style $phpbb_style_resource_locator = new phpbb_style_resource_locator(); $phpbb_style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); - -$template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator); +$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator); $phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template); $phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 3adf9582d6..fde917e5b1 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -134,7 +134,7 @@ class bbcode $style_resource_locator = new phpbb_style_resource_locator(); $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); - $template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator); + $template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator); $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $template); $style->set_style(); $template->set_filenames(array('bbcode.html' => 'bbcode.html')); diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index de14703817..e9073553d0 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -210,8 +210,7 @@ class messenger { $style_resource_locator = new phpbb_style_resource_locator(); $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); - - $tpl = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator); + $tpl = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator); $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $tpl); $this->tpl_msg[$template_lang . $template_file] = $tpl; diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index 4bfb9eaa07..2be4cb8855 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -22,7 +22,7 @@ if (!defined('IN_PHPBB')) class phpbb_style { /** - * @var phpbb_style_template Template class. + * @var phpbb_template Template class. * Handles everything related to templates. */ private $template; @@ -66,9 +66,9 @@ class phpbb_style * @param user $user current user * @param phpbb_style_resource_locator $locator style resource locator * @param phpbb_style_path_provider $provider style path provider - * @param phpbb_style_template $template template + * @param phpbb_template $template template */ - public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_style_resource_locator $locator, phpbb_style_path_provider_interface $provider, phpbb_style_template $template) + public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_style_resource_locator $locator, phpbb_style_path_provider_interface $provider, phpbb_template $template) { $this->phpbb_root_path = $phpbb_root_path; $this->phpEx = $phpEx; diff --git a/phpBB/includes/template/context.php b/phpBB/includes/template/context.php index 5e0b1d4a7e..ec09da1cf3 100644 --- a/phpBB/includes/template/context.php +++ b/phpBB/includes/template/context.php @@ -86,7 +86,7 @@ class phpbb_template_context * Returns a reference to template data array. * * This function is public so that template renderer may invoke it. - * Users should alter template variables via functions in phpbb_style_template. + * Users should alter template variables via functions in phpbb_template. * * Note: modifying returned array will affect data stored in the context. * diff --git a/phpBB/includes/template/renderer_eval.php b/phpBB/includes/template/renderer_eval.php index 62dfbc3708..f8e4cb7b10 100644 --- a/phpBB/includes/template/renderer_eval.php +++ b/phpBB/includes/template/renderer_eval.php @@ -33,7 +33,7 @@ class phpbb_template_renderer_eval implements phpbb_template_renderer * Template includes are delegated to template object $template. * * @param string $code php code of the template - * @param phpbb_style_template $template template object + * @param phpbb_template $template template object */ public function __construct($code, $template) { diff --git a/phpBB/includes/style/template.php b/phpBB/includes/template/template.php similarity index 99% rename from phpBB/includes/style/template.php rename to phpBB/includes/template/template.php index 6dd588c17b..0a3e992b03 100644 --- a/phpBB/includes/style/template.php +++ b/phpBB/includes/template/template.php @@ -29,7 +29,7 @@ if (!defined('IN_PHPBB')) * Base Template class. * @package phpBB3 */ -class phpbb_style_template +class phpbb_template { /** * @var phpbb_template_context Template context. diff --git a/phpBB/install/index.php b/phpBB/install/index.php index be5ebc53b5..f992b67bb7 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -202,7 +202,7 @@ $config = new phpbb_config(array( $phpbb_style_resource_locator = new phpbb_style_resource_locator(); $phpbb_style_path_provider = new phpbb_style_path_provider(); -$template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator); +$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator); $phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template); $phpbb_style->set_ext_dir_prefix('adm/'); $phpbb_style->set_custom_style('admin', '../adm/style', ''); diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 4170fdf278..d660aa3f56 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -66,7 +66,7 @@ class phpbb_template_template_test_case extends phpbb_test_case $this->template_path = dirname(__FILE__) . '/templates'; $this->style_resource_locator = new phpbb_style_resource_locator(); $this->style_provider = new phpbb_style_path_provider(); - $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator); + $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator); $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); $this->style->set_custom_style('tests', $this->template_path, ''); } diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index 536ac394a8..9522c97330 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -22,7 +22,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; $this->style_resource_locator = new phpbb_style_resource_locator(); $this->style_provider = new phpbb_style_path_provider(); - $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator); + $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator); $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); $this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), ''); } From ed9a58a6ccea5b9b2685488ff0cfc45f0ccdbeb5 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 3 Apr 2012 14:32:49 +0300 Subject: [PATCH 6/6] [ticket/10756] Fixing variable declarations in style and template classes Fixing variable declaration, removing function from template locator that does not belong there PHPBB3-10756 --- phpBB/includes/style/style.php | 15 ++++++++++----- phpBB/includes/template/locator.php | 12 ------------ phpBB/includes/template/template.php | 18 ++++++++++++------ 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index 2be4cb8855..3f470015f6 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -22,28 +22,33 @@ if (!defined('IN_PHPBB')) class phpbb_style { /** - * @var phpbb_template Template class. + * Template class. * Handles everything related to templates. + * @var phpbb_template */ private $template; /** - * @var string phpBB root path + * phpBB root path + * @var string */ private $phpbb_root_path; /** - * @var phpEx PHP file extension + * PHP file extension + * @var string */ private $phpEx; /** - * @var phpbb_config phpBB config instance + * phpBB config instance + * @var phpbb_config */ private $config; /** - * @var user current user + * Current user + * @var phpbb_user */ private $user; diff --git a/phpBB/includes/template/locator.php b/phpBB/includes/template/locator.php index 836046e92b..01c79eec4e 100644 --- a/phpBB/includes/template/locator.php +++ b/phpBB/includes/template/locator.php @@ -35,18 +35,6 @@ if (!defined('IN_PHPBB')) */ interface phpbb_template_locator { - /** - * Sets the list of style paths - * - * These paths will be searched for style files in the provided order. - * Paths may be outside of phpBB, but templates loaded from these paths - * will still be cached. - * - * @param array $style_paths An array of paths to style directories - * @return null - */ - public function set_paths($style_paths); - /** * Sets the template filenames for handles. $filename_array * should be a hash of handle => filename pairs. diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index 0a3e992b03..e6512c8417 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -32,33 +32,39 @@ if (!defined('IN_PHPBB')) class phpbb_template { /** - * @var phpbb_template_context Template context. + * Template context. * Stores template data used during template rendering. + * @var phpbb_template_context */ public $context; /** - * @var string Path of the cache directory for the template + * Path of the cache directory for the template + * @var string */ public $cachepath = ''; /** - * @var string phpBB root path + * phpBB root path + * @var string */ private $phpbb_root_path; /** - * @var phpEx PHP file extension + * PHP file extension + * @var string */ private $phpEx; /** - * @var phpbb_config phpBB config instance + * phpBB config instance + * @var phpbb_config */ private $config; /** - * @var user current user + * Current user + * @var phpbb_user */ private $user;