[ticket/15538] Drop templates and icons folder, twig file extension

PHPBB3-15538
This commit is contained in:
mrgoldy 2019-11-30 13:22:11 +01:00
parent ac2b95c1fa
commit c47f9d5744
9 changed files with 14 additions and 14 deletions

View file

@ -98,9 +98,9 @@ class icon extends \Twig\Extension\AbstractExtension
// Iterate over the user's styles and check for icon existance
foreach ($this->get_style_list() as $style_path)
{
if ($filesystem->exists("{$root_path}styles/{$style_path}/theme/icons/png/{$icon}.png"))
if ($filesystem->exists("{$root_path}styles/{$style_path}/theme/png/{$icon}.png"))
{
$source = "{$base_path}styles/{$style_path}/theme/icons/png/{$icon}.png";
$source = "{$base_path}styles/{$style_path}/theme/png/{$icon}.png";
break;
}
@ -114,7 +114,7 @@ class icon extends \Twig\Extension\AbstractExtension
try
{
// Try to load and prepare the SVG icon
$file = $environment->load('icons/svg/' . $icon . '.svg');
$file = $environment->load('svg/' . $icon . '.svg');
$source = $this->prepare_svg($file);
}
catch (\Twig\Error\LoaderError $e)
@ -142,14 +142,14 @@ class icon extends \Twig\Extension\AbstractExtension
$base_path = $board_url ? generate_board_url() . '/' : $environment->get_web_root_path();
}
$source = "{$base_path}styles/all/imgs/icons/png/404.png";
$source = "{$base_path}styles/all/imgs/png/404.png";
$type = 'png';
$icon = '404';
}
try
{
return $environment->render("macros/icons/{$type}.html", [
return $environment->render("macros/icons/{$type}.twig", [
'ATTRIBUTES' => (string) $this->implode_attributes($attributes),
'CLASSES' => (string) $classes,
'ICON' => (string) $icon,

View file

@ -43,11 +43,11 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
$filesystem = $this->createMock('\phpbb\filesystem\filesystem');
$filesystem->expects($this->any())
->method('exists')
->with($this->stringContains('theme/icons/png/'))
->with($this->stringContains('theme/png/'))
->will($this->returnValueMap([
['phpBB/styles/chameleon/theme/icons/png/phone.png', true],
['phpBB/styles/chameleon/theme/icons/png/pencil.png', true],
['phpBB/styles/chameleon/theme/icons/png/user.png', false],
['phpBB/styles/chameleon/theme/png/phone.png', true],
['phpBB/styles/chameleon/theme/png/pencil.png', true],
['phpBB/styles/chameleon/theme/png/user.png', false],
]));
$request = new phpbb_mock_request;
$symfony_request = new \phpbb\symfony_request(
@ -117,7 +117,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
$this->template->set_custom_style('tests', [
$this->template_path,
$phpbb_root_path . 'styles/all/templates',
$phpbb_root_path . 'styles/all/template',
]);
}
@ -354,7 +354,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
[
'ICON_PHONE' => 'Phone icon',
],
'<img class="o-icon o-icon-png png-phone" src="phpBB/styles/chameleon/theme/icons/png/phone.png" alt="Phone icon" />',
'<img class="o-icon o-icon-png png-phone" src="phpBB/styles/chameleon/theme/png/phone.png" alt="Phone icon" />',
],
/** PNG: all options */
[
@ -371,7 +371,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
[
'ICON_PENCIL' => 'Pencil icon',
],
'<img class="o-icon o-icon-png png-pencil my-class" src="phpBB/styles/chameleon/theme/icons/png/pencil.png" alt="Pencil icon" data-url="my-test-url/test-page.php?u=2" />',
'<img class="o-icon o-icon-png png-pencil my-class" src="phpBB/styles/chameleon/theme/png/pencil.png" alt="Pencil icon" data-url="my-test-url/test-page.php?u=2" />',
],
/** PNG: Not found */
[
@ -386,7 +386,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
[
'ICON_USER' => 'User icon',
],
'<img class="o-icon o-icon-png png-404 my-class" src="phpBB/styles/all/imgs/icons/png/404.png" alt="User icon" />',
'<img class="o-icon o-icon-png png-404 my-class" src="phpBB/styles/all/imgs/png/404.png" alt="User icon" />',
],
/** SVG: default */
[
@ -439,7 +439,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
'attributes' => [],
],
[],
'<img class="o-icon o-icon-png png-404" src="phpBB/styles/all/imgs/icons/png/404.png" alt="Just a title" />',
'<img class="o-icon o-icon-png png-404" src="phpBB/styles/all/imgs/png/404.png" alt="Just a title" />',
],
/** SVG: Sanitization */
[

View file

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

View file

Before

Width:  |  Height:  |  Size: 317 B

After

Width:  |  Height:  |  Size: 317 B

View file

Before

Width:  |  Height:  |  Size: 425 B

After

Width:  |  Height:  |  Size: 425 B