mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[feature/merging-style-components] Changing template class
Removing functions that are now handled by phpbb_style class, allowing to write $context, updating docblocks PHPBB3-10632
This commit is contained in:
parent
0b2abe5250
commit
5b149e93b9
1 changed files with 11 additions and 65 deletions
|
@ -35,7 +35,7 @@ class phpbb_style_template
|
||||||
* @var phpbb_style_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;
|
public $context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Path of the cache directory for the template
|
* @var string Path of the cache directory for the template
|
||||||
|
@ -63,7 +63,7 @@ class phpbb_style_template
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template locator
|
* Style resource locator
|
||||||
* @var phpbb_style_resource_locator
|
* @var phpbb_style_resource_locator
|
||||||
*/
|
*/
|
||||||
private $locator;
|
private $locator;
|
||||||
|
@ -74,13 +74,19 @@ class phpbb_style_template
|
||||||
*/
|
*/
|
||||||
private $provider;
|
private $provider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Location of templates directory within style directories
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $template_path = 'template/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @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_style_resource_locator $locator template locator
|
* @param phpbb_style_resource_locator $locator style resource locator
|
||||||
* @param phpbb_style_path_provider $provider template path provider
|
* @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_style_resource_locator $locator, phpbb_style_path_provider_interface $provider)
|
||||||
{
|
{
|
||||||
|
@ -89,70 +95,10 @@ class phpbb_style_template
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->locator = $locator;
|
$this->locator = $locator;
|
||||||
|
$this->template_path = $this->locator->template_path;
|
||||||
$this->provider = $provider;
|
$this->provider = $provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set template location based on (current) user's chosen style.
|
|
||||||
*/
|
|
||||||
public function set_template()
|
|
||||||
{
|
|
||||||
$template_name = $this->user->theme['style_path'];
|
|
||||||
$fallback_name = ($this->user->theme['style_parent_id']) ? array_reverse(explode('/', $this->user->theme['style_parent_tree'])) : false;
|
|
||||||
|
|
||||||
return $this->set_custom_template(false, $template_name, false, $fallback_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines a prefix to use for template paths in extensions
|
|
||||||
*
|
|
||||||
* @param string $ext_dir_prefix The prefix including trailing slash
|
|
||||||
* @return null
|
|
||||||
*/
|
|
||||||
public function set_ext_dir_prefix($ext_dir_prefix)
|
|
||||||
{
|
|
||||||
$this->provider->set_ext_dir_prefix($ext_dir_prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set custom template location (able to use directory outside of phpBB).
|
|
||||||
*
|
|
||||||
* Note: Templates are still compiled to phpBB's cache directory.
|
|
||||||
*
|
|
||||||
* @param string $template_path Path to template directory
|
|
||||||
* @param string $template_name Name of template
|
|
||||||
* @param string or array $fallback_template_path Path to fallback template
|
|
||||||
* @param string or array $fallback_template_name Name of fallback template
|
|
||||||
*/
|
|
||||||
public function set_custom_template($template_path, $template_name, $fallback_template_path = false, $fallback_template_name = false)
|
|
||||||
{
|
|
||||||
$templates = array($template_name => $template_path);
|
|
||||||
|
|
||||||
if (is_string($fallback_template_name))
|
|
||||||
{
|
|
||||||
$templates[$fallback_template_name] = $fallback_template_path;
|
|
||||||
}
|
|
||||||
if (is_array($fallback_template_name))
|
|
||||||
{
|
|
||||||
$i = 0;
|
|
||||||
foreach ($fallback_template_name as $fallback_template_name_item)
|
|
||||||
{
|
|
||||||
$templates[$fallback_template_name_item] = is_array($fallback_template_path) ? $fallback_template_path[$i] : $fallback_template_path;
|
|
||||||
$i ++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->provider->set_templates($templates, $this->phpbb_root_path);
|
|
||||||
$this->locator->set_paths($this->provider);
|
|
||||||
$this->locator->set_main_template($this->provider->get_main_template_path());
|
|
||||||
|
|
||||||
$this->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $template_name) . '_';
|
|
||||||
|
|
||||||
$this->context = new phpbb_style_template_context();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the template filenames for handles.
|
* Sets the template filenames for handles.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue