From c47f9d57444aff0ef8299db8d5fc4f5148f8ae35 Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Sat, 30 Nov 2019 13:22:11 +0100 Subject: [PATCH] [ticket/15538] Drop templates and icons folder, twig file extension PHPBB3-15538 --- phpBB/phpbb/template/twig/extension/icon.php | 10 +++++----- .../macros/icons/font.twig} | 0 .../macros/icons/iconify.twig} | 0 .../macros/icons/png.twig} | 0 .../macros/icons/svg.twig} | 0 tests/template/extension_test.php | 18 +++++++++--------- .../templates/{icons => }/svg/dirty.svg | 0 .../templates/{icons => }/svg/pencil.svg | 0 .../templates/{icons => }/svg/phone.svg | 0 9 files changed, 14 insertions(+), 14 deletions(-) rename phpBB/styles/all/{templates/macros/icons/font.html => template/macros/icons/font.twig} (100%) rename phpBB/styles/all/{templates/macros/icons/iconify.html => template/macros/icons/iconify.twig} (100%) rename phpBB/styles/all/{templates/macros/icons/png.html => template/macros/icons/png.twig} (100%) rename phpBB/styles/all/{templates/macros/icons/svg.html => template/macros/icons/svg.twig} (100%) rename tests/template/templates/{icons => }/svg/dirty.svg (100%) rename tests/template/templates/{icons => }/svg/pencil.svg (100%) rename tests/template/templates/{icons => }/svg/phone.svg (100%) diff --git a/phpBB/phpbb/template/twig/extension/icon.php b/phpBB/phpbb/template/twig/extension/icon.php index 92dcb38f3b..c4a8781db3 100644 --- a/phpBB/phpbb/template/twig/extension/icon.php +++ b/phpBB/phpbb/template/twig/extension/icon.php @@ -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, diff --git a/phpBB/styles/all/templates/macros/icons/font.html b/phpBB/styles/all/template/macros/icons/font.twig similarity index 100% rename from phpBB/styles/all/templates/macros/icons/font.html rename to phpBB/styles/all/template/macros/icons/font.twig diff --git a/phpBB/styles/all/templates/macros/icons/iconify.html b/phpBB/styles/all/template/macros/icons/iconify.twig similarity index 100% rename from phpBB/styles/all/templates/macros/icons/iconify.html rename to phpBB/styles/all/template/macros/icons/iconify.twig diff --git a/phpBB/styles/all/templates/macros/icons/png.html b/phpBB/styles/all/template/macros/icons/png.twig similarity index 100% rename from phpBB/styles/all/templates/macros/icons/png.html rename to phpBB/styles/all/template/macros/icons/png.twig diff --git a/phpBB/styles/all/templates/macros/icons/svg.html b/phpBB/styles/all/template/macros/icons/svg.twig similarity index 100% rename from phpBB/styles/all/templates/macros/icons/svg.html rename to phpBB/styles/all/template/macros/icons/svg.twig diff --git a/tests/template/extension_test.php b/tests/template/extension_test.php index 0b40eb9c38..e6c53ac34d 100644 --- a/tests/template/extension_test.php +++ b/tests/template/extension_test.php @@ -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', ], - 'Phone icon', + 'Phone icon', ], /** PNG: all options */ [ @@ -371,7 +371,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case [ 'ICON_PENCIL' => 'Pencil icon', ], - 'Pencil icon', + 'Pencil icon', ], /** PNG: Not found */ [ @@ -386,7 +386,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case [ 'ICON_USER' => 'User icon', ], - 'User icon', + 'User icon', ], /** SVG: default */ [ @@ -439,7 +439,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case 'attributes' => [], ], [], - 'Just a title', + 'Just a title', ], /** SVG: Sanitization */ [ diff --git a/tests/template/templates/icons/svg/dirty.svg b/tests/template/templates/svg/dirty.svg similarity index 100% rename from tests/template/templates/icons/svg/dirty.svg rename to tests/template/templates/svg/dirty.svg diff --git a/tests/template/templates/icons/svg/pencil.svg b/tests/template/templates/svg/pencil.svg similarity index 100% rename from tests/template/templates/icons/svg/pencil.svg rename to tests/template/templates/svg/pencil.svg diff --git a/tests/template/templates/icons/svg/phone.svg b/tests/template/templates/svg/phone.svg similarity index 100% rename from tests/template/templates/icons/svg/phone.svg rename to tests/template/templates/svg/phone.svg