[feature/merging-style-components] Renaming template classes

Changing template classes prefixes from phpbb_template to phpbb_style (for classes that will work with styles) or phpbb_style_template (for classes that are specific to templates)

PHPBB3-10632
This commit is contained in:
Vjacheslav Trushkin 2012-03-14 23:12:11 +02:00
parent 7d414d04ca
commit b7d84a586c
19 changed files with 57 additions and 57 deletions

View file

@ -120,9 +120,9 @@ set_config_count(null, null, null, $config);
// load extensions // load extensions
$phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver()); $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver());
$phpbb_template_locator = new phpbb_template_locator(); $phpbb_style_locator = new phpbb_style_locator();
$phpbb_template_path_provider = new phpbb_template_extension_path_provider($phpbb_extension_manager, new phpbb_template_path_provider()); $phpbb_style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider());
$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_template_locator, $phpbb_template_path_provider); $template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_locator, $phpbb_style_path_provider);
// Add own hook handler // Add own hook handler
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);

View file

@ -132,9 +132,9 @@ class bbcode
{ {
$this->template_bitfield = new bitfield($user->theme['bbcode_bitfield']); $this->template_bitfield = new bitfield($user->theme['bbcode_bitfield']);
$template_locator = new phpbb_template_locator(); $template_locator = new phpbb_style_locator();
$template_path_provider = new phpbb_template_extension_path_provider($phpbb_extension_manager, new phpbb_template_path_provider()); $template_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider());
$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $template_locator, $template_path_provider); $template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $template_locator, $template_path_provider);
$template->set_template(); $template->set_template();
$template_locator->set_filenames(array('bbcode.html' => 'bbcode.html')); $template_locator->set_filenames(array('bbcode.html' => 'bbcode.html'));
$this->template_filename = $template_locator->get_source_file_for_handle('bbcode.html'); $this->template_filename = $template_locator->get_source_file_for_handle('bbcode.html');

View file

@ -208,9 +208,9 @@ class messenger
// tpl_msg now holds a template object we can use to parse the template file // tpl_msg now holds a template object we can use to parse the template file
if (!isset($this->tpl_msg[$template_lang . $template_file])) if (!isset($this->tpl_msg[$template_lang . $template_file]))
{ {
$template_locator = new phpbb_template_locator(); $template_locator = new phpbb_style_locator();
$template_path_provider = new phpbb_template_extension_path_provider($phpbb_extension_manager, new phpbb_template_path_provider()); $template_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider());
$this->tpl_msg[$template_lang . $template_file] = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $template_locator, $template_path_provider); $this->tpl_msg[$template_lang . $template_file] = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $template_locator, $template_path_provider);
$tpl = &$this->tpl_msg[$template_lang . $template_file]; $tpl = &$this->tpl_msg[$template_lang . $template_file];
$fallback_template_path = false; $fallback_template_path = false;

View file

@ -22,7 +22,7 @@ if (!defined('IN_PHPBB'))
* *
* @package phpBB3 * @package phpBB3
*/ */
class phpbb_template_extension_path_provider extends phpbb_extension_provider implements phpbb_template_path_provider_interface class phpbb_style_extension_path_provider extends phpbb_extension_provider implements phpbb_style_path_provider_interface
{ {
/** /**
* Optional prefix for template paths searched within extensions. * Optional prefix for template paths searched within extensions.
@ -36,7 +36,7 @@ class phpbb_template_extension_path_provider extends phpbb_extension_provider im
/** /**
* A provider of paths to be searched for templates * A provider of paths to be searched for templates
* @var phpbb_template_path_provider * @var phpbb_style_path_provider
*/ */
protected $base_path_provider; protected $base_path_provider;
@ -44,10 +44,10 @@ class phpbb_template_extension_path_provider extends phpbb_extension_provider im
* Constructor stores extension manager * Constructor stores extension manager
* *
* @param phpbb_extension_manager $extension_manager phpBB extension manager * @param phpbb_extension_manager $extension_manager phpBB extension manager
* @param phpbb_template_path_provider $base_path_provider A simple path provider * @param phpbb_style_path_provider $base_path_provider A simple path provider
* to provide paths to be located in extensions * to provide paths to be located in extensions
*/ */
public function __construct(phpbb_extension_manager $extension_manager, phpbb_template_path_provider $base_path_provider) public function __construct(phpbb_extension_manager $extension_manager, phpbb_style_path_provider $base_path_provider)
{ {
parent::__construct($extension_manager); parent::__construct($extension_manager);
$this->base_path_provider = $base_path_provider; $this->base_path_provider = $base_path_provider;

View file

@ -25,7 +25,7 @@ if (!defined('IN_PHPBB'))
* *
* @package phpBB3 * @package phpBB3
*/ */
class phpbb_template_locator class phpbb_style_locator
{ {
/** /**
* Paths to directories that templates are stored in. * Paths to directories that templates are stored in.

View file

@ -22,7 +22,7 @@ if (!defined('IN_PHPBB'))
* *
* @package phpBB3 * @package phpBB3
*/ */
class phpbb_template_path_provider implements IteratorAggregate, phpbb_template_path_provider_interface class phpbb_style_path_provider implements IteratorAggregate, phpbb_style_path_provider_interface
{ {
protected $main_template_name = ''; protected $main_template_name = '';
protected $paths = array(); protected $paths = array();

View file

@ -22,7 +22,7 @@ if (!defined('IN_PHPBB'))
* *
* @package phpBB3 * @package phpBB3
*/ */
interface phpbb_template_path_provider_interface extends Traversable interface phpbb_style_path_provider_interface extends Traversable
{ {
/** /**
* Defines a prefix to use for template paths in extensions * Defines a prefix to use for template paths in extensions

View file

@ -29,10 +29,10 @@ if (!defined('IN_PHPBB'))
* Base Template class. * Base Template class.
* @package phpBB3 * @package phpBB3
*/ */
class phpbb_template class phpbb_style_template
{ {
/** /**
* @var phpbb_template_context Template context. * @var phpbb_style_template_context Template context.
* Stores template data used during template rendering. * Stores template data used during template rendering.
*/ */
private $context; private $context;
@ -64,13 +64,13 @@ class phpbb_template
/** /**
* Template locator * Template locator
* @var phpbb_template_locator * @var phpbb_style_locator
*/ */
private $locator; private $locator;
/** /**
* Template path provider * Template path provider
* @var phpbb_template_path_provider * @var phpbb_style_path_provider
*/ */
private $provider; private $provider;
@ -79,10 +79,10 @@ class phpbb_template
* *
* @param string $phpbb_root_path phpBB root path * @param string $phpbb_root_path phpBB root path
* @param user $user current user * @param user $user current user
* @param phpbb_template_locator $locator template locator * @param phpbb_style_locator $locator template locator
* @param phpbb_template_path_provider $provider template path provider * @param phpbb_style_path_provider $provider template path provider
*/ */
public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_template_locator $locator, phpbb_template_path_provider_interface $provider) public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_style_locator $locator, phpbb_style_path_provider_interface $provider)
{ {
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
$this->phpEx = $phpEx; $this->phpEx = $phpEx;
@ -139,7 +139,7 @@ class phpbb_template
$this->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $template_name) . '_'; $this->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $template_name) . '_';
$this->context = new phpbb_template_context(); $this->context = new phpbb_style_template_context();
return true; return true;
} }
@ -298,15 +298,15 @@ class phpbb_template
* configuration setting may be used to force templates to be always * configuration setting may be used to force templates to be always
* recompiled. * recompiled.
* *
* Returns an object implementing phpbb_template_renderer, or null * Returns an object implementing phpbb_style_template_renderer, or null
* if template loading or compilation failed. Call render() on the * if template loading or compilation failed. Call render() on the
* renderer to display the template. This will result in template * renderer to display the template. This will result in template
* contents sent to the output stream (unless, of course, output * contents sent to the output stream (unless, of course, output
* buffering is in effect). * buffering is in effect).
* *
* @param string $handle Handle of the template to load * @param string $handle Handle of the template to load
* @return phpbb_template_renderer Template renderer object, or null on failure * @return phpbb_style_template_renderer Template renderer object, or null on failure
* @uses phpbb_template_compile is used to compile template source * @uses phpbb_style_template_compile is used to compile template source
*/ */
private function _tpl_load($handle) private function _tpl_load($handle)
{ {
@ -330,18 +330,18 @@ class phpbb_template
// Recompile page if the original template is newer, otherwise load the compiled version // Recompile page if the original template is newer, otherwise load the compiled version
if (!$recompile) if (!$recompile)
{ {
return new phpbb_template_renderer_include($output_file, $this); return new phpbb_style_template_renderer_include($output_file, $this);
} }
$compile = new phpbb_template_compile($this->config['tpl_allow_php']); $compile = new phpbb_style_template_compile($this->config['tpl_allow_php']);
if ($compile->compile_file_to_file($source_file, $output_file) !== false) if ($compile->compile_file_to_file($source_file, $output_file) !== false)
{ {
$renderer = new phpbb_template_renderer_include($output_file, $this); $renderer = new phpbb_style_template_renderer_include($output_file, $this);
} }
else if (($code = $compile->compile_file($source_file)) !== false) else if (($code = $compile->compile_file($source_file)) !== false)
{ {
$renderer = new phpbb_template_renderer_eval($code, $this); $renderer = new phpbb_style_template_renderer_eval($code, $this);
} }
else else
{ {
@ -403,7 +403,7 @@ class phpbb_template
$this->context->append_var($varname, $varval); $this->context->append_var($varname, $varval);
} }
// Docstring is copied from phpbb_template_context method with the same name. // Docstring is copied from phpbb_style_template_context method with the same name.
/** /**
* Assign key variable pairs from an array to a specified block * Assign key variable pairs from an array to a specified block
* @param string $blockname Name of block to assign $vararray to * @param string $blockname Name of block to assign $vararray to
@ -414,7 +414,7 @@ class phpbb_template
return $this->context->assign_block_vars($blockname, $vararray); return $this->context->assign_block_vars($blockname, $vararray);
} }
// Docstring is copied from phpbb_template_context method with the same name. // Docstring is copied from phpbb_style_template_context method with the same name.
/** /**
* Change already assigned key variable pair (one-dimensional - single loop entry) * Change already assigned key variable pair (one-dimensional - single loop entry)
* *

View file

@ -15,7 +15,7 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
stream_filter_register('phpbb_template', 'phpbb_template_filter'); stream_filter_register('phpbb_template', 'phpbb_style_template_filter');
/** /**
* Extension of template class - Functions needed for compiling templates only. * Extension of template class - Functions needed for compiling templates only.
@ -23,7 +23,7 @@ stream_filter_register('phpbb_template', 'phpbb_template_filter');
* @package phpBB3 * @package phpBB3
* @uses template_filter As a PHP stream filter to perform compilation of templates * @uses template_filter As a PHP stream filter to perform compilation of templates
*/ */
class phpbb_template_compile class phpbb_style_template_compile
{ {
/** /**
* Whether <!-- PHP --> tags are allowed * Whether <!-- PHP --> tags are allowed

View file

@ -20,7 +20,7 @@ if (!defined('IN_PHPBB'))
* *
* @package phpBB3 * @package phpBB3
*/ */
class phpbb_template_context class phpbb_style_template_context
{ {
/** /**
* variable that holds all the data we'll be substituting into * variable that holds all the data we'll be substituting into
@ -86,7 +86,7 @@ class phpbb_template_context
* Returns a reference to template data array. * Returns a reference to template data array.
* *
* This function is public so that template renderer may invoke it. * This function is public so that template renderer may invoke it.
* Users should alter template variables via functions in phpbb_template. * Users should alter template variables via functions in phpbb_style_template.
* *
* Note: modifying returned array will affect data stored in the context. * Note: modifying returned array will affect data stored in the context.
* *

View file

@ -35,7 +35,7 @@ if (!defined('IN_PHPBB'))
* @see template_compile * @see template_compile
* @package phpBB3 * @package phpBB3
*/ */
class phpbb_template_filter extends php_user_filter class phpbb_style_template_filter extends php_user_filter
{ {
const REGEX_NS = '[a-z_][a-z_0-9]+'; const REGEX_NS = '[a-z_][a-z_0-9]+';

View file

@ -23,12 +23,12 @@ if (!defined('IN_PHPBB'))
* *
* @package phpBB3 * @package phpBB3
*/ */
interface phpbb_template_renderer interface phpbb_style_template_renderer
{ {
/** /**
* Displays the template managed by this renderer. * Displays the template managed by this renderer.
* *
* @param phpbb_template_context $context Template context to use * @param phpbb_style_template_context $context Template context to use
* @param array $lang Language entries to use * @param array $lang Language entries to use
*/ */
public function render($context, $lang); public function render($context, $lang);

View file

@ -21,7 +21,7 @@ if (!defined('IN_PHPBB'))
* *
* @package phpBB3 * @package phpBB3
*/ */
class phpbb_template_renderer_eval implements phpbb_template_renderer class phpbb_style_template_renderer_eval implements phpbb_style_template_renderer
{ {
/** /**
* Template code to be eval'ed. * Template code to be eval'ed.
@ -33,7 +33,7 @@ class phpbb_template_renderer_eval implements phpbb_template_renderer
* Template includes are delegated to template object $template. * Template includes are delegated to template object $template.
* *
* @param string $code php code of the template * @param string $code php code of the template
* @param phpbb_template $template template object * @param phpbb_style_template $template template object
*/ */
public function __construct($code, $template) public function __construct($code, $template)
{ {
@ -45,7 +45,7 @@ class phpbb_template_renderer_eval implements phpbb_template_renderer
* Displays the template managed by this renderer by eval'ing php code * Displays the template managed by this renderer by eval'ing php code
* of the template. * of the template.
* *
* @param phpbb_template_context $context Template context to use * @param phpbb_style_template_context $context Template context to use
* @param array $lang Language entries to use * @param array $lang Language entries to use
*/ */
public function render($context, $lang) public function render($context, $lang)

View file

@ -22,7 +22,7 @@ if (!defined('IN_PHPBB'))
* *
* @package phpBB3 * @package phpBB3
*/ */
class phpbb_template_renderer_include implements phpbb_template_renderer class phpbb_style_template_renderer_include implements phpbb_style_template_renderer
{ {
/** /**
* Template path to be included. * Template path to be included.
@ -45,7 +45,7 @@ class phpbb_template_renderer_include implements phpbb_template_renderer
* Displays the template managed by this renderer by including * Displays the template managed by this renderer by including
* the php file containing the template. * the php file containing the template.
* *
* @param phpbb_template_context $context Template context to use * @param phpbb_style_template_context $context Template context to use
* @param array $lang Language entries to use * @param array $lang Language entries to use
*/ */
public function render($context, $lang) public function render($context, $lang)

View file

@ -201,9 +201,9 @@ $config = new phpbb_config(array(
'load_tplcompile' => '1' 'load_tplcompile' => '1'
)); ));
$phpbb_template_locator = new phpbb_template_locator(); $phpbb_style_locator = new phpbb_style_locator();
$phpbb_template_path_provider = new phpbb_template_path_provider(); $phpbb_style_path_provider = new phpbb_style_path_provider();
$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_template_locator, $phpbb_template_path_provider); $template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_locator, $phpbb_style_path_provider);
$template->set_ext_dir_prefix('adm/'); $template->set_ext_dir_prefix('adm/');
$template->set_custom_template('../adm/style', 'admin'); $template->set_custom_template('../adm/style', 'admin');
$template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_ASSETS_PATH', '../assets');

View file

@ -13,8 +13,8 @@ class phpbb_template_renderer_eval_test extends phpbb_test_case
{ {
$compiled_code = '<a href="<?php echo \'Test\'; ?>">'; $compiled_code = '<a href="<?php echo \'Test\'; ?>">';
$valid_code = '<a href="Test">'; $valid_code = '<a href="Test">';
$context = new phpbb_template_context(); $context = new phpbb_style_template_context();
$template = new phpbb_template_renderer_eval($compiled_code, NULL); $template = new phpbb_style_template_renderer_eval($compiled_code, NULL);
ob_start(); ob_start();
try try
{ {

View file

@ -16,7 +16,7 @@ class phpbb_template_template_compile_test extends phpbb_test_case
protected function setUp() protected function setUp()
{ {
$this->template_compile = new phpbb_template_compile(false); $this->template_compile = new phpbb_style_template_compile(false);
$this->template_path = dirname(__FILE__) . '/templates'; $this->template_path = dirname(__FILE__) . '/templates';
} }

View file

@ -71,9 +71,9 @@ class phpbb_template_template_inheritance_test extends phpbb_template_template_t
$this->template_path = dirname(__FILE__) . '/templates'; $this->template_path = dirname(__FILE__) . '/templates';
$this->parent_template_path = dirname(__FILE__) . '/parent_templates'; $this->parent_template_path = dirname(__FILE__) . '/parent_templates';
$this->template_locator = new phpbb_template_locator(); $this->template_locator = new phpbb_style_locator();
$this->template_provider = new phpbb_template_path_provider(); $this->template_provider = new phpbb_style_path_provider();
$this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator, $this->template_provider); $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator, $this->template_provider);
$this->template->set_custom_template($this->template_path, 'tests', $this->parent_template_path, 'parent'); $this->template->set_custom_template($this->template_path, 'tests', $this->parent_template_path, 'parent');
} }
} }

View file

@ -63,9 +63,9 @@ class phpbb_template_template_test_case extends phpbb_test_case
$config = new phpbb_config(array_merge($defaults, $new_config)); $config = new phpbb_config(array_merge($defaults, $new_config));
$this->template_path = dirname(__FILE__) . '/templates'; $this->template_path = dirname(__FILE__) . '/templates';
$this->template_locator = new phpbb_template_locator(); $this->template_locator = new phpbb_style_locator();
$this->template_provider = new phpbb_template_path_provider(); $this->template_provider = new phpbb_style_path_provider();
$this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator, $this->template_provider); $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator, $this->template_provider);
$this->template->set_custom_template($this->template_path, 'tests'); $this->template->set_custom_template($this->template_path, 'tests');
} }