diff --git a/oe_theme.theme b/oe_theme.theme index 02afad7bb8..aead637705 100644 --- a/oe_theme.theme +++ b/oe_theme.theme @@ -1721,6 +1721,30 @@ function oe_theme_theme_suggestions_oe_corporate_blocks_eu_footer_alter(array &$ * Implements hook_preprocess_HOOK(). */ function oe_theme_preprocess_oe_corporate_blocks_ec_footer(array &$variables) { + $site_logo_href = 'https://commission.europa.eu'; + // Ensure the site logo falls back to english version if the language is + // not EU language. + $language_code = \Drupal::languageManager()->getCurrentLanguage()->getId(); + if (!EuropeanUnionLanguages::hasLanguage($language_code)) { + if ($language_code === 'nb') { + // Set correct icon for Norwegian language. + $variables['current_language_id'] = 'no'; + } + else { + // Check whether ECL provides a logo for the language. + $ecl_logo = DRUPAL_ROOT . '/' . drupal_get_path('theme', 'oe_theme') . '/dist/' . $variables['ecl_component_library'] . '/images/logo/'; + $ecl_logo .= $variables['ecl_component_library'] === 'eu' ? 'standard-version/positive/' : 'positive/'; + $ecl_logo .= 'logo-' . $variables['ecl_component_library'] . '--' . $language_code . '.svg'; + if (!file_exists($ecl_logo)) { + // Provide fallback "en" icon if language logo doesn't exist. + $variables['current_language_id'] = 'en'; + } + } + } + else { + $site_logo_href .= '/index_' . EuropeanUnionLanguages::getInternalLanguageCode($variables['current_language_id']); + } + $variables['path'] = $site_logo_href; _oe_theme_preprocess_site_specific_footer_links($variables); } diff --git a/templates/navigation/oe-corporate-blocks-ec-footer--core.html.twig b/templates/navigation/oe-corporate-blocks-ec-footer--core.html.twig index a846cd83c9..fa5440c7cc 100644 --- a/templates/navigation/oe-corporate-blocks-ec-footer--core.html.twig +++ b/templates/navigation/oe-corporate-blocks-ec-footer--core.html.twig @@ -13,12 +13,14 @@ {% set _first_column = [ { - 'title': { - 'link': { - 'label': corporate_footer.corporate_site_link.label, - 'path': corporate_footer.corporate_site_link.href, + 'logo': { + 'aria_label': 'Home'|t ~ ' - ' ~ 'European Commission'|t, + 'alt': 'European Commission logo'|t, + 'title': 'European Commission'|t, + 'language': current_language_id, + 'path': path, + 'src_desktop': ecl_logo_path ~ '/negative/logo-ec--' ~ current_language_id|to_internal_language_id ~ '.svg', }, - }, 'description': site_owner ? 'This site is managed by the @name'|t({'@name': site_owner}), }, ] %} @@ -36,7 +38,6 @@ }, ] %} - {% block content %} {% include '@ecl-twig/site-footer' with { 'rows': [[_first_column, _second_column]], diff --git a/templates/navigation/oe-corporate-blocks-ec-footer--standardised.html.twig b/templates/navigation/oe-corporate-blocks-ec-footer--standardised.html.twig index 83d56b9b7d..b6ff54b9ea 100644 --- a/templates/navigation/oe-corporate-blocks-ec-footer--standardised.html.twig +++ b/templates/navigation/oe-corporate-blocks-ec-footer--standardised.html.twig @@ -78,12 +78,14 @@ {% set _bottom_row = [ [ { - 'title': { - 'link': { - 'label': corporate_footer.corporate_site_link.label, - 'path': corporate_footer.corporate_site_link.href, + 'logo': { + 'aria_label': 'Home'|t ~ ' - ' ~ 'European Commission'|t, + 'alt': 'European Commission logo'|t, + 'title': 'European Commission'|t, + 'language': current_language_id, + 'path': path, + 'src_desktop': ecl_logo_path ~ '/negative/logo-ec--' ~ current_language_id|to_internal_language_id ~ '.svg', }, - }, } ], [ diff --git a/tests/features/corporate-blocks.feature b/tests/features/corporate-blocks.feature index 6f1bb8c97d..7a934d1b3f 100644 --- a/tests/features/corporate-blocks.feature +++ b/tests/features/corporate-blocks.feature @@ -17,7 +17,7 @@ Feature: Corporate blocks feature Scenario Outline: By default the European Commission footer is displayed. Given I am an anonymous user When I am on "" - Then I should see the European Commission footer with link "https://ec.europa.eu/info/index_en" + Then I should see the "European Commission" footer with link "https://commission.europa.eu/index_en" label "Home - European Commission" image alt "European Commission logo" title "European Commission" Examples: | page | @@ -27,18 +27,18 @@ Feature: Corporate blocks feature Scenario Outline: Changing the site's style will display either the European Commission or the European Union footer. Given I am an anonymous user When I am on "" - Then I should see the European Commission footer with link "https://ec.europa.eu/info/index_en" + Then I should see the "European Commission" footer with link "https://commission.europa.eu/index_en" label "Home - European Commission" image alt "European Commission logo" title "European Commission" And I should not see the "European Union" footer When the theme is configured to use the "European Union" style And I reload the page Then I should not see the "European Commission" footer - But I should see the European Union footer with link "https://european-union.europa.eu/index_en" label "Home - European Union" image alt "European Union flag" title "European Union" + But I should see the "European Union" footer with link "https://european-union.europa.eu/index_en" label "Home - European Union" image alt "European Union flag" title "European Union" When the theme is configured to use the "European Commission" style And I reload the page Then I should not see the "European Union" footer - But I should see the European Commission footer with link "https://ec.europa.eu/info/index_en" + But I should see the "European Commission" footer with link "https://commission.europa.eu/index_en" label "Home - European Commission" image alt "European Commission logo" title "European Commission" Examples: | page | diff --git a/tests/src/Behat/OeThemeTestContext.php b/tests/src/Behat/OeThemeTestContext.php index c2286b74f7..75c7db5483 100644 --- a/tests/src/Behat/OeThemeTestContext.php +++ b/tests/src/Behat/OeThemeTestContext.php @@ -284,29 +284,13 @@ protected function getDemoPageByTitle(string $title): NodeInterface { /** * Assert given corporate footer presence on page. * - * @Then I should see the European Commission footer with link :link + * @Then I should see the :component_library footer with link :link label :label image alt :img_alt title :img_title */ - public function assertEuropeanCommissionFooterBlockOnPage(string $link): void { - // Make sure a corporate footer is present on the page. - $this->assertSession()->elementExists('css', 'footer.ecl-site-footer'); - // European Commission footer is presented. - Assert::assertEquals('European Commission', $this->getFooterType(), 'European Commission footer is not presented on the page.'); - - // Assert footer data. - $title_link = $this->getSession()->getPage()->find('css', '.ecl-site-footer__title-link[href="' . $link . '"]'); - Assert::assertNotEmpty($title_link, 'European Commission footer link is not found.'); - } - - /** - * Assert given corporate footer presence on page. - * - * @Then I should see the European Union footer with link :link label :label image alt :img_alt title :img_title - */ - public function assertEuropeanUnionFooterBlockOnPage(string $link, string $label, string $img_alt, string $img_title): void { + public function assertEuropeanFooterBlockOnPage(string $component_library, string $link, string $label, string $img_alt, string $img_title): void { // Make sure a corporate footer is present on the page. $this->assertSession()->elementExists('css', 'footer.ecl-site-footer'); // European Union footer is presented. - Assert::assertEquals('European Union', $this->getFooterType(), 'European Union footer is not presented on the page.'); + Assert::assertEquals($component_library, $this->getFooterType(), 'European Union footer is not presented on the page.'); // Assert footer data. $page = $this->getSession()->getPage(); @@ -371,17 +355,17 @@ public function setCorporateLibrary(string $component_library): void { * Determines footer type. * * The ECL doesn't provide a way to determine type of the footer except as - * to check the existence of the logo. - * 'European Union' has logo, 'European Commission' doesn't. + * to check the attributes of the logo. * * @return string * 'European Union' or 'European Commission'. */ protected function getFooterType(): string { - $logo = $this->getSession() - ->getPage() - ->find('css', 'footer.ecl-site-footer img.ecl-site-footer__logo-image-desktop'); - return empty($logo) ? 'European Commission' : 'European Union'; + $logo = $this->getSession()->getPage()->find('css', 'footer.ecl-site-footer .ecl-site-footer__logo-link'); + if ($logo->getAttribute('aria-label') === 'Home - European Union') { + return 'European Union'; + } + return 'European Commission'; } /**