mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/11628] Remove style path provider
No longer used since Twig was implemented. PHPBB3-11628
This commit is contained in:
parent
98b385bc1c
commit
44a82dd083
12 changed files with 7 additions and 346 deletions
|
@ -258,19 +258,8 @@ services:
|
|||
- %core.php_ext%
|
||||
- @config
|
||||
- @user
|
||||
- @style.path_provider_ext
|
||||
- @template
|
||||
|
||||
style.path_provider_ext:
|
||||
class: phpbb_style_extension_path_provider
|
||||
arguments:
|
||||
- @ext.manager
|
||||
- @style.path_provider
|
||||
- %core.root_path%
|
||||
|
||||
style.path_provider:
|
||||
class: phpbb_style_path_provider
|
||||
|
||||
template:
|
||||
class: phpbb_template_twig
|
||||
arguments:
|
||||
|
|
|
@ -132,9 +132,8 @@ class bbcode
|
|||
{
|
||||
$this->template_bitfield = new bitfield($user->style['bbcode_bitfield']);
|
||||
|
||||
$style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider(), $phpbb_root_path);
|
||||
$template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager);
|
||||
$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_path_provider, $template);
|
||||
$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $template);
|
||||
$style->set_style();
|
||||
$template->set_filenames(array('bbcode.html' => 'bbcode.html'));
|
||||
$this->template_filename = $template->get_source_file_for_handle('bbcode.html');
|
||||
|
|
|
@ -212,10 +212,8 @@ $config = new phpbb_config(array(
|
|||
'load_tplcompile' => '1'
|
||||
));
|
||||
|
||||
$phpbb_style_path_provider = new phpbb_style_path_provider();
|
||||
$template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context());
|
||||
$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_path_provider, $template);
|
||||
$phpbb_style->set_ext_dir_prefix('adm/');
|
||||
$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $template);
|
||||
$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), '');
|
||||
$template->assign_var('T_ASSETS_PATH', '../assets');
|
||||
$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
|
||||
|
|
|
@ -1,137 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a style resource locator with core style paths and extension style paths
|
||||
*
|
||||
* Finds installed style paths and makes them available to the resource locator.
|
||||
*
|
||||
* @package phpBB3
|
||||
*/
|
||||
class phpbb_style_extension_path_provider extends phpbb_extension_provider implements phpbb_style_path_provider_interface
|
||||
{
|
||||
/**
|
||||
* Optional prefix for style paths searched within extensions.
|
||||
*
|
||||
* Empty by default. Relative to the extension directory. As an example, it
|
||||
* could be adm/ for admin style.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $ext_dir_prefix = '';
|
||||
|
||||
/**
|
||||
* A provider of paths to be searched for styles
|
||||
* @var phpbb_style_path_provider
|
||||
*/
|
||||
protected $base_path_provider;
|
||||
|
||||
/** @var string */
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* Constructor stores extension manager
|
||||
*
|
||||
* @param phpbb_extension_manager $extension_manager phpBB extension manager
|
||||
* @param phpbb_style_path_provider $base_path_provider A simple path provider
|
||||
* to provide paths to be located in extensions
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
*/
|
||||
public function __construct(phpbb_extension_manager $extension_manager, phpbb_style_path_provider $base_path_provider, $phpbb_root_path)
|
||||
{
|
||||
parent::__construct($extension_manager);
|
||||
$this->base_path_provider = $base_path_provider;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a prefix for style paths searched within extensions.
|
||||
*
|
||||
* The prefix is inserted between the extension's path e.g. ext/foo/ and
|
||||
* the looked up style path, e.g. styles/bar/. So it should not have a
|
||||
* leading slash, but should have a trailing slash.
|
||||
*
|
||||
* @param string $ext_dir_prefix The prefix including trailing slash
|
||||
* @return null
|
||||
*/
|
||||
public function set_ext_dir_prefix($ext_dir_prefix)
|
||||
{
|
||||
$this->ext_dir_prefix = $ext_dir_prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds style paths using the extension manager
|
||||
*
|
||||
* Locates a path (e.g. styles/prosilver/) in all active extensions.
|
||||
* Then appends the core style paths based in the current working
|
||||
* directory.
|
||||
*
|
||||
* @return array List of style paths
|
||||
*/
|
||||
public function find()
|
||||
{
|
||||
$directories = array();
|
||||
|
||||
$finder = $this->extension_manager->get_finder();
|
||||
foreach ($this->base_path_provider as $key => $paths)
|
||||
{
|
||||
if ($key == 'style')
|
||||
{
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$directories['style'][] = $path;
|
||||
if ($path && !phpbb_is_absolute($path))
|
||||
{
|
||||
// Remove phpBB root path from the style path,
|
||||
// so the finder is able to find extension styles,
|
||||
// when the root path is not ./
|
||||
if (strpos($path, $this->phpbb_root_path) === 0)
|
||||
{
|
||||
$path = substr($path, strlen($this->phpbb_root_path));
|
||||
}
|
||||
|
||||
$result = $finder->directory('/' . $this->ext_dir_prefix . $path)
|
||||
->get_directories(true, false, true);
|
||||
foreach ($result as $ext => $ext_path)
|
||||
{
|
||||
// Make sure $ext_path has no ending slash
|
||||
if (substr($ext_path, -1) === '/')
|
||||
{
|
||||
$ext_path = substr($ext_path, 0, -1);
|
||||
}
|
||||
$directories[$ext][] = $ext_path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $directories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the current style paths
|
||||
*
|
||||
* @param array $styles An array of style paths. The first element is the main style.
|
||||
* @return null
|
||||
*/
|
||||
public function set_styles(array $styles)
|
||||
{
|
||||
$this->base_path_provider->set_styles($styles);
|
||||
$this->items = null;
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a style resource locator with paths
|
||||
*
|
||||
* Finds installed style paths and makes them available to the resource locator.
|
||||
*
|
||||
* @package phpBB3
|
||||
*/
|
||||
class phpbb_style_path_provider implements IteratorAggregate, phpbb_style_path_provider_interface
|
||||
{
|
||||
protected $paths = array();
|
||||
|
||||
/**
|
||||
* Ignores the extension dir prefix
|
||||
*
|
||||
* @param string $ext_dir_prefix The prefix including trailing slash
|
||||
* @return null
|
||||
*/
|
||||
public function set_ext_dir_prefix($ext_dir_prefix)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the current style paths
|
||||
*
|
||||
* The first element of the passed styles map, is considered the main
|
||||
* style.
|
||||
*
|
||||
* @param array $styles An array of style paths. The first element is the main style.
|
||||
* @return null
|
||||
*/
|
||||
public function set_styles(array $styles)
|
||||
{
|
||||
$this->paths = array('style' => $styles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an iterator over all style paths
|
||||
*
|
||||
* @return ArrayIterator An iterator for the array of style paths
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->paths);
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a style resource locator with paths
|
||||
*
|
||||
* Finds installed style paths and makes them available to the resource locator.
|
||||
*
|
||||
* @package phpBB3
|
||||
*/
|
||||
interface phpbb_style_path_provider_interface extends Traversable
|
||||
{
|
||||
/**
|
||||
* Defines a prefix to use for style paths in extensions
|
||||
*
|
||||
* @param string $ext_dir_prefix The prefix including trailing slash
|
||||
* @return null
|
||||
*/
|
||||
public function set_ext_dir_prefix($ext_dir_prefix);
|
||||
|
||||
/**
|
||||
* Overwrites the current style paths
|
||||
*
|
||||
* @param array $styles An array of style paths. The first element is the main style.
|
||||
* @return null
|
||||
*/
|
||||
public function set_styles(array $styles);
|
||||
}
|
|
@ -52,27 +52,19 @@ class phpbb_style
|
|||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* 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_style_path_provider $provider style path provider
|
||||
* @param phpbb_template $template template
|
||||
*/
|
||||
public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_style_path_provider_interface $provider, phpbb_template $template)
|
||||
public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_template $template)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->config = $config;
|
||||
$this->user = $user;
|
||||
$this->provider = $provider;
|
||||
$this->template = $template;
|
||||
}
|
||||
|
||||
|
@ -121,8 +113,6 @@ class phpbb_style
|
|||
}
|
||||
}
|
||||
|
||||
$this->provider->set_styles($paths);
|
||||
|
||||
$new_paths = array();
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
|
@ -158,8 +148,6 @@ class phpbb_style
|
|||
}
|
||||
$this->names = $names;
|
||||
|
||||
$this->provider->set_styles($paths);
|
||||
|
||||
$new_paths = array();
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
|
@ -184,15 +172,4 @@ class phpbb_style
|
|||
{
|
||||
return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a prefix to use for style 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,12 +48,9 @@ class phpbb_controller_helper_url_test extends phpbb_test_case
|
|||
global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
|
||||
|
||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
|
||||
$this->style_resource_locator = new phpbb_style_resource_locator();
|
||||
$this->user = $this->getMock('phpbb_user');
|
||||
$this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, new phpbb_template_context());
|
||||
$this->style_resource_locator = new phpbb_style_resource_locator();
|
||||
$this->style_provider = new phpbb_style_path_provider();
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, new phpbb_config(array()), $this->user, $this->style_resource_locator, $this->style_provider, $this->template);
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, new phpbb_config(array()), $this->user, $this->template);
|
||||
|
||||
$helper = new phpbb_controller_helper($this->template, $this->user, '', 'php');
|
||||
$this->assertEquals($helper->url($route, $params, $is_amp, $session_id), $expected);
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_extension_style_path_provider_test extends phpbb_test_case
|
||||
{
|
||||
protected $relative_root_path;
|
||||
protected $root_path;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->relative_root_path = './';
|
||||
$this->root_path = dirname(__FILE__) . '/';
|
||||
}
|
||||
|
||||
public function test_find()
|
||||
{
|
||||
$phpbb_style_path_provider = new phpbb_style_path_provider();
|
||||
$phpbb_style_path_provider->set_styles(array($this->relative_root_path . 'styles/prosilver'));
|
||||
$phpbb_style_extension_path_provider = new phpbb_style_extension_path_provider(new phpbb_mock_extension_manager(
|
||||
$this->root_path,
|
||||
array(
|
||||
'foo' => array(
|
||||
'ext_name' => 'foo',
|
||||
'ext_active' => '1',
|
||||
'ext_path' => 'ext/foo/',
|
||||
),
|
||||
'bar' => array(
|
||||
'ext_name' => 'bar',
|
||||
'ext_active' => '1',
|
||||
'ext_path' => 'ext/bar/',
|
||||
),
|
||||
)), $phpbb_style_path_provider, $this->relative_root_path);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'style' => array(
|
||||
$this->relative_root_path . 'styles/prosilver',
|
||||
),
|
||||
'bar' => array(
|
||||
$this->root_path . 'ext/bar/styles/prosilver',
|
||||
),
|
||||
), $phpbb_style_extension_path_provider->find());
|
||||
}
|
||||
}
|
|
@ -103,13 +103,11 @@ Zeta test event in all',
|
|||
$config = new phpbb_config(array_merge($defaults, $new_config));
|
||||
|
||||
$this->template_path = dirname(__FILE__) . "/datasets/$dataset/styles/silver/template";
|
||||
$this->style_resource_locator = new phpbb_style_resource_locator();
|
||||
$this->extension_manager = new phpbb_mock_filesystem_extension_manager(
|
||||
dirname(__FILE__) . "/datasets/$dataset/"
|
||||
);
|
||||
$this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context, $this->extension_manager);
|
||||
$this->style_provider = new phpbb_style_path_provider();
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->template);
|
||||
$this->style->set_custom_style('silver', array($this->template_path), $style_names, '');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@ class phpbb_template_template_test_case extends phpbb_test_case
|
|||
protected $style;
|
||||
protected $template;
|
||||
protected $template_path;
|
||||
protected $style_resource_locator;
|
||||
protected $style_provider;
|
||||
protected $user;
|
||||
|
||||
protected $test_path = 'tests/template';
|
||||
|
@ -67,10 +65,8 @@ class phpbb_template_template_test_case extends phpbb_test_case
|
|||
$this->user = new phpbb_user;
|
||||
|
||||
$this->template_path = $this->test_path . '/templates';
|
||||
$this->style_resource_locator = new phpbb_style_resource_locator();
|
||||
$this->style_provider = new phpbb_style_path_provider();
|
||||
$this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, new phpbb_template_context());
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $this->user, $this->style_resource_locator, $this->style_provider, $this->template);
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $this->user, $this->template);
|
||||
$this->style->set_custom_style('tests', $this->template_path, array(), '');
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,8 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
|
|||
|
||||
$this->template_path = $this->test_path . '/templates';
|
||||
$this->parent_template_path = $this->test_path . '/parent_templates';
|
||||
$this->style_resource_locator = new phpbb_style_resource_locator();
|
||||
$this->style_provider = new phpbb_style_path_provider();
|
||||
$this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context());
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->template);
|
||||
$this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), array(), '');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue