mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
Merge pull request #1324 from nickvergessen/ticket/10844-2
Ticket/10844 Extensions are not located when front-end file has a diffferent phpbb_root_path
This commit is contained in:
commit
81daf21dc0
8 changed files with 92 additions and 4 deletions
|
@ -247,6 +247,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @ext.manager
|
- @ext.manager
|
||||||
- @style.path_provider
|
- @style.path_provider
|
||||||
|
- %core.root_path%
|
||||||
|
|
||||||
style.path_provider:
|
style.path_provider:
|
||||||
class: phpbb_style_path_provider
|
class: phpbb_style_path_provider
|
||||||
|
|
|
@ -133,7 +133,7 @@ class bbcode
|
||||||
$this->template_bitfield = new bitfield($user->style['bbcode_bitfield']);
|
$this->template_bitfield = new bitfield($user->style['bbcode_bitfield']);
|
||||||
|
|
||||||
$style_resource_locator = new phpbb_style_resource_locator();
|
$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());
|
$style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider(), $phpbb_root_path);
|
||||||
$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, new phpbb_template_context(), $phpbb_extension_manager);
|
$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, new phpbb_template_context(), $phpbb_extension_manager);
|
||||||
$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $template);
|
$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $template);
|
||||||
$style->set_style();
|
$style->set_style();
|
||||||
|
|
|
@ -209,7 +209,7 @@ class messenger
|
||||||
if (!isset($this->tpl_msg[$template_lang . $template_file]))
|
if (!isset($this->tpl_msg[$template_lang . $template_file]))
|
||||||
{
|
{
|
||||||
$style_resource_locator = new phpbb_style_resource_locator();
|
$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());
|
$style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider(), $phpbb_root_path);
|
||||||
$tpl = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, new phpbb_template_context(), $phpbb_extension_manager);
|
$tpl = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, new phpbb_template_context(), $phpbb_extension_manager);
|
||||||
$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $tpl);
|
$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $tpl);
|
||||||
|
|
||||||
|
|
|
@ -40,17 +40,22 @@ class phpbb_style_extension_path_provider extends phpbb_extension_provider imple
|
||||||
*/
|
*/
|
||||||
protected $base_path_provider;
|
protected $base_path_provider;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $phpbb_root_path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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_style_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
|
||||||
|
* @param string $phpbb_root_path phpBB root path
|
||||||
*/
|
*/
|
||||||
public function __construct(phpbb_extension_manager $extension_manager, phpbb_style_path_provider $base_path_provider)
|
public function __construct(phpbb_extension_manager $extension_manager, phpbb_style_path_provider $base_path_provider, $phpbb_root_path)
|
||||||
{
|
{
|
||||||
parent::__construct($extension_manager);
|
parent::__construct($extension_manager);
|
||||||
$this->base_path_provider = $base_path_provider;
|
$this->base_path_provider = $base_path_provider;
|
||||||
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,10 +96,23 @@ class phpbb_style_extension_path_provider extends phpbb_extension_provider imple
|
||||||
$directories['style'][] = $path;
|
$directories['style'][] = $path;
|
||||||
if ($path && !phpbb_is_absolute($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)
|
$result = $finder->directory('/' . $this->ext_dir_prefix . $path)
|
||||||
->get_directories(true, false, true);
|
->get_directories(true, false, true);
|
||||||
foreach ($result as $ext => $ext_path)
|
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;
|
$directories[$ext][] = $ext_path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
bertie rules!
|
|
@ -67,7 +67,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
|
||||||
public function test_prefix_get_directories()
|
public function test_prefix_get_directories()
|
||||||
{
|
{
|
||||||
$dirs = $this->finder
|
$dirs = $this->finder
|
||||||
->prefix('t')
|
->prefix('ty')
|
||||||
->get_directories();
|
->get_directories();
|
||||||
|
|
||||||
sort($dirs);
|
sort($dirs);
|
||||||
|
|
50
tests/extension/style_path_provider_test.php
Normal file
50
tests/extension/style_path_provider_test.php
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<?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());
|
||||||
|
}
|
||||||
|
}
|
18
tests/extension/subdir/style_path_provider_test.php
Normal file
18
tests/extension/subdir/style_path_provider_test.php
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?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__) . '/../style_path_provider_test.php';
|
||||||
|
|
||||||
|
class phpbb_extension_subdir_style_path_provider_test extends phpbb_extension_style_path_provider_test
|
||||||
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->relative_root_path = '../';
|
||||||
|
$this->root_path = dirname(__FILE__) . '/../';
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue