mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-03 22:27:54 +02:00
[feature/merging-style-components] Creating style class
Creating phpbb_style class, changing template initialization to style initialization PHPBB3-10632
This commit is contained in:
parent
39944a08b9
commit
3997ffac2a
@ -120,9 +120,9 @@ set_config_count(null, null, null, $config);
|
||||
// load extensions
|
||||
$phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver());
|
||||
|
||||
$phpbb_style_locator = new phpbb_style_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_locator, $phpbb_style_path_provider);
|
||||
// Initialize style
|
||||
$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager);
|
||||
$template = $style->template;
|
||||
|
||||
// Add own hook handler
|
||||
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
|
||||
|
@ -132,12 +132,11 @@ class bbcode
|
||||
{
|
||||
$this->template_bitfield = new bitfield($user->theme['bbcode_bitfield']);
|
||||
|
||||
$template_locator = new phpbb_style_locator();
|
||||
$template_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, $template_locator, $template_path_provider);
|
||||
$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager);
|
||||
$template = $style->template;
|
||||
$template->set_template();
|
||||
$template_locator->set_filenames(array('bbcode.html' => 'bbcode.html'));
|
||||
$this->template_filename = $template_locator->get_source_file_for_handle('bbcode.html');
|
||||
$template->set_filenames(array('bbcode.html' => 'bbcode.html'));
|
||||
$this->template_filename = $style->locator->get_source_file_for_handle('bbcode.html');
|
||||
}
|
||||
|
||||
$bbcode_ids = $rowset = $sql = array();
|
||||
|
@ -208,10 +208,9 @@ class messenger
|
||||
// tpl_msg now holds a template object we can use to parse the template file
|
||||
if (!isset($this->tpl_msg[$template_lang . $template_file]))
|
||||
{
|
||||
$template_locator = new phpbb_style_locator();
|
||||
$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_style_template($phpbb_root_path, $phpEx, $config, $user, $template_locator, $template_path_provider);
|
||||
$this->tpl_msg[$template_lang . $template_file] = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager);
|
||||
$tpl = &$this->tpl_msg[$template_lang . $template_file];
|
||||
$tpl = $tpl->template;
|
||||
|
||||
$fallback_template_path = false;
|
||||
|
||||
@ -237,6 +236,7 @@ class messenger
|
||||
}
|
||||
|
||||
$this->tpl_obj = &$this->tpl_msg[$template_lang . $template_file];
|
||||
$this->tpl_obj = $this->tpl_obj->template;
|
||||
$this->vars = &$this->tpl_obj->_rootref;
|
||||
$this->tpl_msg = '';
|
||||
|
||||
|
89
phpBB/includes/style/style.php
Normal file
89
phpBB/includes/style/style.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2005 phpBB Group, sections (c) 2001 ispi of Lincoln Inc
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base Style class.
|
||||
* @package phpBB3
|
||||
*/
|
||||
class phpbb_style
|
||||
{
|
||||
/**
|
||||
* @var phpbb_style_template Template class.
|
||||
* Handles everything related to templates.
|
||||
*/
|
||||
public $template;
|
||||
|
||||
/**
|
||||
* @var string Path of the cache directory for the template
|
||||
*/
|
||||
public $cachepath = '';
|
||||
|
||||
/**
|
||||
* @var string phpBB root path
|
||||
*/
|
||||
private $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* @var phpEx PHP file extension
|
||||
*/
|
||||
private $phpEx;
|
||||
|
||||
/**
|
||||
* @var phpbb_config phpBB config instance
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var user current user
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Style resource locator
|
||||
* @var phpbb_style_resource_locator
|
||||
* This item is temporary public, until locate() function is implemented
|
||||
*/
|
||||
public $locator;
|
||||
|
||||
/**
|
||||
* Style path provider
|
||||
* @var phpbb_style_path_provider
|
||||
*/
|
||||
private $provider;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param user $user current user
|
||||
* @param phpbb_extension_manager $phpbb_extension_manager extension manager. Set it to false if extension manager should not be used.
|
||||
*/
|
||||
public function __construct($phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager = false)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->phpEx = $phpEx;
|
||||
$this->config = $config;
|
||||
$this->user = $user;
|
||||
$this->locator = new phpbb_style_locator();
|
||||
$this->provider = new phpbb_style_path_provider();
|
||||
if ($phpbb_extension_manager !== false)
|
||||
{
|
||||
$this->provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, $this->provider);
|
||||
}
|
||||
$this->template = new phpbb_style_template($this->phpbb_root_path, $this->phpEx, $this->config, $this->user, $this->locator, $this->provider);
|
||||
}
|
||||
}
|
@ -201,9 +201,8 @@ $config = new phpbb_config(array(
|
||||
'load_tplcompile' => '1'
|
||||
));
|
||||
|
||||
$phpbb_style_locator = new phpbb_style_locator();
|
||||
$phpbb_style_path_provider = new phpbb_style_path_provider();
|
||||
$template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_locator, $phpbb_style_path_provider);
|
||||
$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, false);
|
||||
$template = $style->template;
|
||||
$template->set_ext_dir_prefix('adm/');
|
||||
$template->set_custom_template('../adm/style', 'admin');
|
||||
$template->assign_var('T_ASSETS_PATH', '../assets');
|
||||
|
@ -71,9 +71,8 @@ class phpbb_template_template_inheritance_test extends phpbb_template_template_t
|
||||
|
||||
$this->template_path = dirname(__FILE__) . '/templates';
|
||||
$this->parent_template_path = dirname(__FILE__) . '/parent_templates';
|
||||
$this->template_locator = new phpbb_style_locator();
|
||||
$this->template_provider = new phpbb_style_path_provider();
|
||||
$this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator, $this->template_provider);
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, false);
|
||||
$this->template = $this->style->template;
|
||||
$this->template->set_custom_template($this->template_path, 'tests', $this->parent_template_path, 'parent');
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,9 @@ require_once dirname(__FILE__) . '/../mock/extension_manager.php';
|
||||
|
||||
class phpbb_template_template_test_case extends phpbb_test_case
|
||||
{
|
||||
protected $style;
|
||||
protected $template;
|
||||
protected $template_path;
|
||||
protected $template_locator;
|
||||
protected $template_provider;
|
||||
|
||||
// Keep the contents of the cache for debugging?
|
||||
const PRESERVE_CACHE = true;
|
||||
@ -63,9 +62,8 @@ class phpbb_template_template_test_case extends phpbb_test_case
|
||||
$config = new phpbb_config(array_merge($defaults, $new_config));
|
||||
|
||||
$this->template_path = dirname(__FILE__) . '/templates';
|
||||
$this->template_locator = new phpbb_style_locator();
|
||||
$this->template_provider = new phpbb_style_path_provider();
|
||||
$this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator, $this->template_provider);
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, false);
|
||||
$this->template = $this->style->template;
|
||||
$this->template->set_custom_template($this->template_path, 'tests');
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user