diff --git a/composer.json b/composer.json index 764fb0f837f0bae0ae30c4df3162e5c008578203..08461b3273e8f4e7cfee5eb1de26c7e34b80b9c8 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "openeuropa/oe_contact_forms": "~1.1", "openeuropa/oe_corporate_blocks": "^4.4", "openeuropa/oe_multilingual": "^1.9", - "openeuropa/oe_starter_content": "1.x-dev", + "openeuropa/oe_starter_content": "1.x-dev#5a4a77b", "openeuropa/task-runner-drupal-project-symlink": "^1.0-beta5", "phpspec/prophecy-phpunit": "^1 || ^2" }, diff --git a/config/optional/block.block.oe_whitelabel_ec_corporate_footer.yml b/config/optional/block.block.oe_whitelabel_ec_corporate_footer.yml index 34d701e6aaab206e2e31a7952eb728bb36a54ff9..d52ef57935895e1a13ef3600f215c23beb2f1393 100644 --- a/config/optional/block.block.oe_whitelabel_ec_corporate_footer.yml +++ b/config/optional/block.block.oe_whitelabel_ec_corporate_footer.yml @@ -16,4 +16,9 @@ settings: label: 'EC Footer block' provider: oe_corporate_blocks label_display: '0' -visibility: { } +visibility: + oe_whitelabel_helper_current_component_library: + id: oe_whitelabel_helper_current_component_library + component_library: ec + negate: false + context_mapping: { } diff --git a/config/optional/block.block.oe_whitelabel_eu_corporate_footer.yml b/config/optional/block.block.oe_whitelabel_eu_corporate_footer.yml new file mode 100644 index 0000000000000000000000000000000000000000..1eaa3c403d45bc92ae949f091172175b662a3107 --- /dev/null +++ b/config/optional/block.block.oe_whitelabel_eu_corporate_footer.yml @@ -0,0 +1,24 @@ +langcode: en +status: true +dependencies: + module: + - oe_corporate_blocks + theme: + - oe_whitelabel +id: oe_whitelabel_eu_corporate_footer +theme: oe_whitelabel +region: footer +weight: 0 +provider: null +plugin: oe_corporate_blocks_eu_footer +settings: + id: oe_corporate_blocks_eu_footer + label: 'EU Footer block' + provider: oe_corporate_blocks + label_display: '0' +visibility: + oe_whitelabel_helper_current_component_library: + id: oe_whitelabel_helper_current_component_library + component_library: eu + negate: false + context_mapping: { } diff --git a/config/optional/block.block.oe_whitelabel_neutral_footer.yml b/config/optional/block.block.oe_whitelabel_neutral_footer.yml new file mode 100644 index 0000000000000000000000000000000000000000..372470a5a8658bf797abe514987b4515e33607a6 --- /dev/null +++ b/config/optional/block.block.oe_whitelabel_neutral_footer.yml @@ -0,0 +1,24 @@ +langcode: en +status: true +dependencies: + module: + - oe_whitelabel_helper + theme: + - oe_whitelabel +id: oe_whitelabel_neutral_footer +theme: oe_whitelabel +region: footer +weight: 0 +provider: null +plugin: oe_corporate_blocks_neutral_footer +settings: + id: oe_corporate_blocks_neutral_footer + label: 'Neutral Footer block' + provider: oe_whitelabel_helper + label_display: '0' +visibility: + oe_whitelabel_helper_current_component_library: + id: oe_whitelabel_helper_current_component_library + component_library: neutral + negate: false + context_mapping: { } diff --git a/modules/oe_whitelabel_helper/config/schema/oe_whitelabel_helper.schema.yml b/modules/oe_whitelabel_helper/config/schema/oe_whitelabel_helper.schema.yml index a965f717939116d4e39aa5afb88e92dbd4b2f187..df4af465acd511f0073361be579047d19cb767d9 100644 --- a/modules/oe_whitelabel_helper/config/schema/oe_whitelabel_helper.schema.yml +++ b/modules/oe_whitelabel_helper/config/schema/oe_whitelabel_helper.schema.yml @@ -5,3 +5,8 @@ field.formatter.settings.oe_whitelabel_helper_address_inline: delimiter: type: string label: 'Delimiter for address items.' +condition.plugin.oe_whitelabel_helper_current_component_library: + type: condition.plugin + mapping: + component_library: + type: string diff --git a/modules/oe_whitelabel_helper/oe_whitelabel_helper.info.yml b/modules/oe_whitelabel_helper/oe_whitelabel_helper.info.yml index 0127dc76d2e8a5dda70c8af4a1a001d28185dae5..91e0809845712c12b102571ef83639e3166ab6ee 100644 --- a/modules/oe_whitelabel_helper/oe_whitelabel_helper.info.yml +++ b/modules/oe_whitelabel_helper/oe_whitelabel_helper.info.yml @@ -6,5 +6,6 @@ core_version_requirement: ^9.2 dependencies: - oe_bootstrap_theme:oe_bootstrap_theme_helper + - openeuropa:oe_corporate_blocks 'interface translation project': oe_whitelabel_helper diff --git a/modules/oe_whitelabel_helper/oe_whitelabel_helper.module b/modules/oe_whitelabel_helper/oe_whitelabel_helper.module index 57670247301aa5173e8dd5c1f93fd169be2f6586..d257da954ebd5a07b4d6d24b0b3893d79e1b3c09 100644 --- a/modules/oe_whitelabel_helper/oe_whitelabel_helper.module +++ b/modules/oe_whitelabel_helper/oe_whitelabel_helper.module @@ -26,5 +26,14 @@ function oe_whitelabel_helper_theme($existing, $type, $theme, $path) { 'address_delimiter' => NULL, ], ], + 'oe_corporate_blocks_neutral_footer' => [ + 'variables' => [ + 'corporate_footer' => [], + 'site_specific_footer' => [], + ], + 'preprocess functions' => [ + 'oe_corporate_blocks_preprocess_set_site_owner', + ], + ], ]; } diff --git a/modules/oe_whitelabel_helper/src/Plugin/Block/NeutralFooterBlock.php b/modules/oe_whitelabel_helper/src/Plugin/Block/NeutralFooterBlock.php new file mode 100644 index 0000000000000000000000000000000000000000..03ef209c3a7e1977fe2bed3cf478935f5f7021c1 --- /dev/null +++ b/modules/oe_whitelabel_helper/src/Plugin/Block/NeutralFooterBlock.php @@ -0,0 +1,44 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\oe_whitelabel_helper\Plugin\Block; + +use Drupal\Component\Utility\NestedArray; +use Drupal\Core\Cache\CacheableMetadata; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\oe_corporate_blocks\Plugin\Block\FooterBlockBase; + +/** + * Provides the Neutral footer block. + * + * @Block( + * id = "oe_corporate_blocks_neutral_footer", + * admin_label = @Translation("Neutral Footer block"), + * category = @Translation("Corporate blocks"), + * ) + */ +class NeutralFooterBlock extends FooterBlockBase implements ContainerFactoryPluginInterface { + + /** + * {@inheritdoc} + */ + public function build() { + $cache = new CacheableMetadata(); + $cache->addCacheContexts(['languages:language_interface']); + + $config = $this->configFactory->get('oe_corporate_blocks.ec_data.footer'); + $cache->addCacheableDependency($config); + + $build['#theme'] = 'oe_corporate_blocks_neutral_footer'; + + NestedArray::setValue($build, ['#corporate_footer', 'content_owner_details'], $config->get('content_owner_details')); + + $this->setSiteSpecificFooter($build, $cache); + + $cache->applyTo($build); + + return $build; + } + +} diff --git a/modules/oe_whitelabel_helper/src/Plugin/Condition/CurrentComponentLibraryCondition.php b/modules/oe_whitelabel_helper/src/Plugin/Condition/CurrentComponentLibraryCondition.php new file mode 100644 index 0000000000000000000000000000000000000000..b15d6cc197fe32b40c52a663d1b3e123088fa187 --- /dev/null +++ b/modules/oe_whitelabel_helper/src/Plugin/Condition/CurrentComponentLibraryCondition.php @@ -0,0 +1,151 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\oe_whitelabel_helper\Plugin\Condition; + +use Drupal\Core\Cache\Cache; +use Drupal\Core\Condition\ConditionPluginBase; +use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\Core\Theme\ThemeManagerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * Provides a configurable 'Current component library' condition. + * + * This condition checks if the current component library is equal to a given + * value. + * + * @Condition( + * id = "oe_whitelabel_helper_current_component_library", + * label = @Translation("Current component library") + * ) + */ +class CurrentComponentLibraryCondition extends ConditionPluginBase implements ContainerFactoryPluginInterface { + + /** + * The configuration factory service. + * + * @var \Drupal\Core\Config\ConfigFactoryInterface + */ + protected $configFactory; + + /** + * The theme manager. + * + * @var \Drupal\Core\Theme\ThemeManagerInterface + */ + protected $themeManager; + + /** + * Constructs a CurrentComponentLibraryCondition condition plugin. + * + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin_id for the plugin instance. + * @param mixed $plugin_definition + * The plugin implementation definition. + * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory + * The configuration factory service. + * @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager + * The theme manager. + */ + public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, ThemeManagerInterface $theme_manager) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + $this->configFactory = $config_factory; + $this->themeManager = $theme_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('config.factory'), + $container->get('theme.manager') + ); + } + + /** + * {@inheritdoc} + */ + public function defaultConfiguration() { + return [ + 'component_library' => '', + ] + parent::defaultConfiguration(); + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + // We allow for an empty value to be set. By doing that we make sure that + // no settings about this condition is actually saved in block visibility + // settings, unless the user explicitly sets one. + $form['component_library'] = [ + '#type' => 'select', + '#title' => $this->t('Component library'), + '#options' => [ + '' => $this->t('- Any -'), + 'neutral' => $this->t('Neutral'), + 'ec' => $this->t('European Commission'), + 'eu' => $this->t('European Union'), + ], + '#default_value' => $this->configuration['component_library'], + '#description' => t('Choose with which component library this condition should be met.'), + ]; + return parent::buildConfigurationForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { + $this->configuration['component_library'] = $form_state->getValue('component_library'); + parent::submitConfigurationForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function evaluate() { + if (empty($this->configuration['component_library'])) { + return TRUE; + } + $theme_name = $this->themeManager->getActiveTheme()->getName(); + + $component_library = $this->configFactory->get($theme_name . '.settings')->get('component_library'); + return $component_library === $this->configuration['component_library']; + } + + /** + * {@inheritdoc} + */ + public function summary() { + if (empty($this->configuration['component_library'])) { + return $this->t('The current component library can be set to anything'); + } + + if ($this->isNegated()) { + return $this->t('The current component library is not @component_library', ['@component_library' => $this->configuration['component_library']]); + } + + return $this->t('The current component library is @component_library', ['@component_library' => $this->configuration['component_library']]); + } + + /** + * {@inheritdoc} + */ + public function getCacheTags() { + $theme_name = $this->themeManager->getActiveTheme()->getName(); + + return Cache::mergeTags(['config:' . $theme_name . '.settings'], parent::getCacheTags()); + } + +} diff --git a/modules/oe_whitelabel_helper/src/TwigExtension/TwigExtension.php b/modules/oe_whitelabel_helper/src/TwigExtension/TwigExtension.php index 16dd9244ea3b2532c7b61624383cda7148b582ca..944b17e5fa625af94525c1631f9d1a6d2eb700e2 100644 --- a/modules/oe_whitelabel_helper/src/TwigExtension/TwigExtension.php +++ b/modules/oe_whitelabel_helper/src/TwigExtension/TwigExtension.php @@ -7,6 +7,7 @@ namespace Drupal\oe_whitelabel_helper\TwigExtension; use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\StringTranslation\PluralTranslatableMarkup; use Drupal\oe_whitelabel_helper\EuropeanUnionLanguages; +use Drupal\Core\Url; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; use Twig\TwigFunction; @@ -122,6 +123,9 @@ class TwigExtension extends AbstractExtension { $altered_links = []; foreach ($links as $link) { + if ($link['href'] instanceof Url) { + $link['href'] = $link['href']->toString(); + } $altered_link = [ 'label' => $link['label'], 'path' => $link['href'], @@ -168,6 +172,8 @@ class TwigExtension extends AbstractExtension { * * @return array * The block render array. + * + * @deprecated Use Twig Tweak instead. */ public function bclBlock(string $id, array $configuration = []): array { $configuration += ['label_display' => 'hidden']; diff --git a/oe_whitelabel.theme b/oe_whitelabel.theme index 9c95a19ff7167f200760d72ed46b37bafc6fe7ec..bb3573db88c1c8272ed4c67c45aacaa350bf9519 100644 --- a/oe_whitelabel.theme +++ b/oe_whitelabel.theme @@ -111,7 +111,7 @@ function oe_whitelabel_form_system_theme_settings_alter(&$form, FormStateInterfa 'ec' => t('European Commission'), 'eu' => t('European Union'), ], - '#default_value' => theme_get_setting('component_library'), + '#default_value' => theme_get_setting('component_library') ?? 'neutral', '#description' => t('Choose "European Commission" for websites hosted under the ec.europa.eu domain and "European Union" for websites hosted under the europa.eu domain.'), ]; $form['header_style'] = [ diff --git a/templates/layouts/ec_footer_bottom_left.html.twig b/templates/layouts/ec_footer_bottom_left.html.twig deleted file mode 100644 index 3e71e42d8eb6067ef71e122796f706da93e74cc9..0000000000000000000000000000000000000000 --- a/templates/layouts/ec_footer_bottom_left.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -<div class="col-12 col-lg-4 pb-lg-4"> - <p class="fw-bold pb-2 mb-2"> {{ 'European Commission'|t }} </p> -</div> diff --git a/templates/layouts/ec_footer_bottom_middle.html.twig b/templates/layouts/ec_footer_bottom_middle.html.twig deleted file mode 100644 index ee6f5c3095e66a86174b6af625e6484f3708173b..0000000000000000000000000000000000000000 --- a/templates/layouts/ec_footer_bottom_middle.html.twig +++ /dev/null @@ -1,7 +0,0 @@ -{% if links is defined and links is not empty and links is iterable %} - <div class="col-12 col-lg-4"> - {% for link in links %} - {{ pattern('link', link) }} - {% endfor %} - </div> -{% endif %} diff --git a/templates/layouts/ec_footer_bottom_right.html.twig b/templates/layouts/ec_footer_bottom_right.html.twig deleted file mode 100644 index ee6f5c3095e66a86174b6af625e6484f3708173b..0000000000000000000000000000000000000000 --- a/templates/layouts/ec_footer_bottom_right.html.twig +++ /dev/null @@ -1,7 +0,0 @@ -{% if links is defined and links is not empty and links is iterable %} - <div class="col-12 col-lg-4"> - {% for link in links %} - {{ pattern('link', link) }} - {% endfor %} - </div> -{% endif %} diff --git a/templates/layouts/ec_footer_middle_row.html.twig b/templates/layouts/ec_footer_middle_row.html.twig deleted file mode 100644 index a8dcecbbea1045da0318d32fa68457650fab9c48..0000000000000000000000000000000000000000 --- a/templates/layouts/ec_footer_middle_row.html.twig +++ /dev/null @@ -1,8 +0,0 @@ -<div class="col-12 col-lg-4"> - <p class="fw-bold pb-2 mb-2"> {{ 'More information on:'|t }}</p> - {% if links is defined and links is not empty and links is iterable %} - {% for link in links %} - {{ pattern('link', link) }} - {% endfor %} - {% endif %} -</div> diff --git a/templates/layouts/eu_footer_left.html.twig b/templates/layouts/eu_footer_left.html.twig deleted file mode 100644 index f1c952e87de704c7caf5fdfd22b058e574669308..0000000000000000000000000000000000000000 --- a/templates/layouts/eu_footer_left.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -<div class="col-12 col-lg-4 pb-4"> - {{ bcl_block('whitelabel_eu_logo_block') }} -</div> diff --git a/templates/layouts/eu_footer_middle.html.twig b/templates/layouts/eu_footer_middle.html.twig deleted file mode 100644 index 50fcb5265c2d509b9c23898e42ebcb96ce1df354..0000000000000000000000000000000000000000 --- a/templates/layouts/eu_footer_middle.html.twig +++ /dev/null @@ -1,22 +0,0 @@ -<div class="col-12 col-lg-4"> - <p class="fw-bold border-bottom pb-2 mb-2"> {{ contact_eu_title }} </p> - {% if contact_eu_links is defined and contact_eu_links is not empty and contact_eu_links is iterable %} - {% for contact_link in contact_eu_links %} - {{ pattern('link', contact_link) }} - {% endfor %} - {% endif %} - - <p class="fw-bold border-bottom pb-2 pt-3 mb-2"> {{ social_media_title }} </p> - {% if social_media_links is defined and social_media_links is not empty and social_media_links is iterable %} - {% for social_link in social_media_links %} - {{ pattern('link', social_link) }} - {% endfor %} - {% endif %} - - <p class="fw-bold border-bottom pb-2 pt-3 mb-2"> {{ legal_title }} </p> - {% if legal_links is defined and legal_links is not empty and legal_links is iterable %} - {% for legal_link in legal_links %} - {{ pattern('link', legal_link) }} - {% endfor %} - {% endif %} -</div> diff --git a/templates/layouts/eu_footer_right.html.twig b/templates/layouts/eu_footer_right.html.twig deleted file mode 100644 index 8e84a2b05a57613c656bf801fb0fef03c4a57745..0000000000000000000000000000000000000000 --- a/templates/layouts/eu_footer_right.html.twig +++ /dev/null @@ -1,8 +0,0 @@ -<div class="col-12 col-lg-4"> - <p class="fw-bold border-bottom pb-2 pt-4 pt-lg-0 mb-2"> {{ eu_institutions_title }} </p> - {% if eu_institutions_links is defined and eu_institutions_links is not empty and eu_institutions_links is iterable %} - {% for eu_link in eu_institutions_links %} - {{ pattern('link', eu_link) }} - {% endfor %} - {% endif %} -</div> diff --git a/templates/layouts/footer_top_left.html.twig b/templates/layouts/footer_top_left.html.twig deleted file mode 100644 index 1cf54e41a5df5b7e98ad83eb58face514083adbe..0000000000000000000000000000000000000000 --- a/templates/layouts/footer_top_left.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -<div class="col-12 col-lg-4"> - <p class="fw-bold mb-2">{{ title.link.label }}</p> - <p> {{ description }} </p> -</div> diff --git a/templates/layouts/footer_top_middle.html.twig b/templates/layouts/footer_top_middle.html.twig deleted file mode 100644 index 29fd539e79f4d090d8d0a3236f21075216294e75..0000000000000000000000000000000000000000 --- a/templates/layouts/footer_top_middle.html.twig +++ /dev/null @@ -1,29 +0,0 @@ -{% if sections is defined and sections is not empty and sections is iterable %} - <div class="col-12 col-lg-4 pb-4 pb-lg-0"> - {% for section in sections %} - {% if loop.first %} - <p class="fw-bold border-bottom pb-2 mb-2">{{ section.title }}</p> - {% else %} - <p class="fw-bold border-bottom pb-2 mb-2 mt-3">{{ section.title }}</p> - {% endif %} - {% if section.links is defined and section.links is not empty and section.links is iterable %} - {% set attributes = { - 'class': [ - 'text-decoration-none', - 'd-block', - 'mb-1' - ] - } %} - {% for link in section.links %} - {{ pattern('link', { - label: link.label, - path: link.path|render, - icon: link.icon, - icon_position: link.icon_position, - attributes: attributes - }) }} - {% endfor %} - {% endif %} - {% endfor %} - </div> -{% endif %} diff --git a/templates/layouts/footer_top_right.html.twig b/templates/layouts/footer_top_right.html.twig deleted file mode 100644 index 18adffdd0851ffd7b7ac46e062b91af86614b044..0000000000000000000000000000000000000000 --- a/templates/layouts/footer_top_right.html.twig +++ /dev/null @@ -1,29 +0,0 @@ -{% if sections is defined and sections is not empty and sections is iterable %} - <div class="col-12 col-lg-4"> - {% for section in sections %} - {% if loop.first %} - <p class="fw-bold border-bottom pb-2 mb-2">{{ section.title }}</p> - {% else %} - <p class="fw-bold border-bottom pb-2 mb-2 mt-3">{{ section.title }}</p> - {% endif %} - {% if section.links is defined and section.links is not empty and section.links is iterable %} - {% set attributes = { - 'class': [ - 'text-decoration-none', - 'd-block', - 'mb-1' - ] - } %} - {% for link in section.links %} - {{ pattern('link', { - label: link.label, - path: link.path|render, - icon: link.icon, - icon_position: link.icon_position, - attributes: attributes, - }) }} - {% endfor %} - {% endif %} - {% endfor %} - </div> -{% endif %} diff --git a/templates/overrides/navigation/block--oe-corporate-blocks-ec_footer.html.twig b/templates/overrides/navigation/block--oe-corporate-blocks-ec_footer.html.twig deleted file mode 100644 index cddd07099f28542c78aa9081959f54425ddf6c36..0000000000000000000000000000000000000000 --- a/templates/overrides/navigation/block--oe-corporate-blocks-ec_footer.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ content }} diff --git a/templates/overrides/navigation/block--oe-corporate-blocks-eu_footer.html.twig b/templates/overrides/navigation/block--oe-corporate-blocks-eu_footer.html.twig deleted file mode 100644 index cddd07099f28542c78aa9081959f54425ddf6c36..0000000000000000000000000000000000000000 --- a/templates/overrides/navigation/block--oe-corporate-blocks-eu_footer.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ content }} diff --git a/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig index 5a4dd8bd7b8581210a43f030351c0844510ff44e..56b7d37218655fe97e822aea395b5abc526953bc 100644 --- a/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig +++ b/templates/overrides/navigation/oe-corporate-blocks-ec-footer.html.twig @@ -1,121 +1,69 @@ -{# -/** - * @file - * Default theme implementation for rendering corporate blocks footer. - * - * Available variables: - * - site_owner: Site's owner. - * - site_specific_footer: Array (optional) with structure of the site specific footer compatible with the ECL ec-components-footer component. - * - site_identity: Site identity for custom footer. - * - social_links: Social media links for custom footer. - * - other_links: Other links for custom footer. - * - corporate_footer: Array with structure of corporate footer compatible with the ECL ec-components-footer component. - * - corporate_site_link: Corporate site link. - * - class_navigation: Provides the user with navigation through class names. - * - service_navigation: Contains services links - consistent throughout the family sites. - * - legal_navigation: Contains legal information links - consistent throughout the family sites. - * - * @ingroup themeable - */ -#} - -{% set _section_2 = [] %} -{% set _section_3 = [] %} - -{# First we parse the other_links, we make a simple grid. #} -{% for section in site_specific_footer.other_links %} - {% if loop.index is odd %} - {% set _section_2 = _section_2|merge([{ - 'title': section.label, - 'links': bcl_footer_links(section.links), - }]) %} - {% else %} - {% set _section_3 = _section_3|merge([{ - 'title': section.label, - 'links': bcl_footer_links(section.links), - }]) %} - {% endif %} -{% endfor %} - -{# When follow section is present. #} -{% if site_specific_footer.social_links is not empty %} - {# If section numbers are odd, then we flip the last row so to have the follow as first. #} - {% if _section_2|length > _section_3|length %} - {% set _last_in_section_2 = _section_2|last %} - - {# Compensate for bug in twig where _section_2[1:] returns empty if _section_2|length is 1. #} - {% if _last_in_section_2 is empty %} - {% set _last_in_section_2 = _section_2[0] %} - {% set _section_2 = [] %} - {% endif %} - - {% set _section_2 = _section_2[:_section_2|length - 1] %} - {% set _section_3 = _section_3|merge([_last_in_section_2]) %} - - {% endif %} - - {# Follow section must always be the last on the left. #} - {% set _section_2 = _section_2|merge([{ - 'title': 'Follow us on social media'|t, - 'links': bcl_footer_links(site_specific_footer.social_links), - }]) %} -{% endif %} +{% extends "@oe_whitelabel/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig" %} +{% block content %} + {% set _top_sections = { + 'extra_classes': 'pt-4 pt-lg-5', + 'cols': [ + { + 'classes': 'col-12 col-lg-4', + 'items': [ + { + 'type': 'content', + 'content': footer_top_left_content, + }, + ], + }, + { + 'classes': 'col-12 col-lg-4 pb-4 pb-lg-0', + 'items': _section_2, + }, + { + 'classes': 'col-12 col-lg-4', + 'items': _section_3, + } + ], + } %} -{% set _top_sections = [ - { - 'section_id': 'footer_top_left', - 'title': { - 'link': { - 'label': site_specific_footer.site_identity, - 'path': url('<front>')|render - } - }, - 'description': site_owner ? 'This site is managed by the @name'|t({'@name': site_owner}), - }, - { - 'section_id': 'footer_top_middle', - 'sections': _section_2 - }, - { - 'section_id': 'footer_top_right', - 'sections': _section_3 - } -] %} + {% set site_identity_content %} + <p class="fw-bold pb-2 mb-2">{{ 'European Commission'|t }}</p> + {% endset %} -{% set _bottom_sections = [ - { - 'section_id': 'ec_footer_bottom_left', - 'title': { - 'link': { - 'label': site_specific_footer.site_identity, - 'path': url('<front>')|render, + {% set _bottom_sections = { + 'extra_classes': 'pb-4 pb-lg-5 bcl-footer__bordered-row row mt-4', + 'cols': [ + { + 'classes': 'col-12 col-lg-4 pb-lg-4', + 'items': [ + { + 'type': 'content', + 'content': site_identity_content, + }, + ], + }, + { + 'classes': 'col-12 col-lg-4', + 'items': [ + { + 'type': 'links', + 'links': bcl_footer_links(corporate_footer.service_navigation), + } + ], + }, + { + 'classes': 'col-12 col-lg-4', + 'items': [ + { + 'type': 'links', + 'links': bcl_footer_links(corporate_footer.legal_navigation), + } + ], } - } - }, - { - 'section_id': 'ec_footer_bottom_middle', - 'links': bcl_footer_links(corporate_footer.service_navigation), - }, - { - 'section_id': 'ec_footer_bottom_right', - 'links': bcl_footer_links(corporate_footer.legal_navigation) - } -] %} + ], + } %} -{% set _middle_sections = [ - { - 'section_id': 'ec_footer_middle_row', - 'links': bcl_footer_links(corporate_footer.class_navigation), - } -] %} -<footer class="bcl-footer bcl-footer--ec mt-4"> - <div class="container"> - {{ pattern('footer', { - 'variant': 'ec', - 'top_sections': _top_sections, - 'middle_sections': _middle_sections, - 'bottom_sections': _bottom_sections, - }) }} - </div> -</footer> + {% include '@oe-bcl/footer' with { + 'variant': 'ec', + 'rows': [_top_sections, _bottom_sections], + 'attributes': attributes, + } only %} +{% endblock %} diff --git a/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig index 6c7ce854708b2139a54f774e7b391650b5312b09..cc8a6d0751aed668dd9d13794c2ddd97c42f5f2b 100644 --- a/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig +++ b/templates/overrides/navigation/oe-corporate-blocks-eu-footer.html.twig @@ -1,110 +1,97 @@ -{# -/** - * @file - * Default theme implementation for rendering corporate blocks footer. - * - * Available variables: - * - corporate_footer: Array with structure compatible to ECL ec-components-footer component. - * - contact: EU contact data for corporate footer. - * - social_media_title: Title for social media links column. - * - social_media: Social media links for corporate footer. - * - institution_links_title: Title for institution links column. - * - institution_links: EU institutions links for corporate footer. - * - legal_links_title: Title for legal links column. - * - legal_links: Legal links for corporate footer. - * - * @ingroup themeable - */ -#} - -{% set _section_2 = [] %} -{% set _section_3 = [] %} - -{# First we parse the other_links, we make a simple grid. #} -{% for section in site_specific_footer.other_links %} - {% if loop.index is odd %} - {% set _section_2 = _section_2|merge([{ - 'title': section.label, - 'links': bcl_footer_links(section.links), - }]) %} - {% else %} - {% set _section_3 = _section_3|merge([{ - 'title': section.label, - 'links': bcl_footer_links(section.links), - }]) %} - {% endif %} -{% endfor %} - -{# When follow section is present. #} -{% if site_specific_footer.social_links is not empty %} - {# If section numbers are odd, then we flip the last row so to have the follow as first. #} - {% if _section_2|length > _section_3|length %} - {% set _last_in_section_2 = _section_2|last %} - - {# Compensate for bug in twig where _section_2[1:] returns empty if _section_2|length is 1. #} - {% if _last_in_section_2 is empty %} - {% set _last_in_section_2 = _section_2[0] %} - {% set _section_2 = [] %} - {% endif %} - - {% set _section_2 = _section_2[:_section_2|length - 1] %} - {% set _section_3 = _section_3|merge([_last_in_section_2]) %} - - {% endif %} +{% extends "@oe_whitelabel/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig" %} +{% block content %} + {% set _top_sections = { + 'extra_classes': 'pt-4 pt-lg-5', + 'cols': [ + { + 'classes': 'col-12 col-lg-4', + 'items': [ + { + 'type': 'content', + 'content': footer_top_left_content, + }, + ], + }, + { + 'classes': 'col-12 col-lg-4 pb-4 pb-lg-0', + 'items': _section_2, + }, + { + 'classes': 'col-12 col-lg-4', + 'items': _section_3, + } + ], + } %} - {# Follow section must always be the last on the left. #} - {% set _section_2 = _section_2|merge([{ - 'title': 'Follow us on social media'|t, - 'links': bcl_footer_links(site_specific_footer.social_links), - }]) %} -{% endif %} + {% set eu_logo %} + <picture> + <source media="(max-width: 992px)" + srcset="{{ bcl_logo_path ~ 'eu/mobile/logo-eu--' ~ current_language_id|to_internal_language_id ~ '.svg' }}"> + <img src="{{ bcl_logo_path ~ 'eu/logo-eu--' ~ current_language_id|to_internal_language_id ~ '.svg' }}" + alt="{{ site_logo_alt }}" title="{{ site_logo_title }}"/> + </picture> + {% endset %} -{% set _top_sections = [ - { - 'section_id': 'footer_top_left', - 'title': { - 'link': { - 'label': site_specific_footer.site_identity, - 'path': url('<front>')|render + {% set _bottom_sections = { + 'extra_classes': 'pb-4 pb-lg-5 mt-4 mt-lg-5 bcl-footer__bordered-row row', + 'cols': [ + { + 'classes': 'col-12 col-lg-4 pb-4', + 'items': [ + { + 'type': 'content', + 'content': eu_logo, + }, + ], + }, + { + 'classes': 'col-12 col-lg-4', + 'items': [ + { + 'type': 'content', + 'content': _self.bcl_title(corporate_footer.contact_title, 'fw-bold border-bottom pb-2 mb-2'), + }, + { + 'type': 'links', + 'links': bcl_footer_links(corporate_footer.contact), + }, + { + 'type': 'content', + 'content': _self.bcl_title(corporate_footer.social_media_title, 'fw-bold border-bottom pb-2 pt-3 mb-2'), + }, + { + 'type': 'links', + 'links': bcl_footer_links(corporate_footer.social_media), + }, + { + 'type': 'content', + 'content': _self.bcl_title(corporate_footer.legal_links_title, 'fw-bold border-bottom pb-2 pt-3 mb-2'), + }, + { + 'type': 'links', + 'links': bcl_footer_links(corporate_footer.legal_links), + }, + ], + }, + { + 'classes': 'col-12 col-lg-4', + 'items': [ + { + 'type': 'content', + 'content': _self.bcl_title(corporate_footer.institution_links_title, 'fw-bold border-bottom pb-2 mb-2'), + }, + { + 'type': 'links', + 'links': bcl_footer_links(corporate_footer.institution_links), + }, + ], } - }, - 'description': site_owner ? 'This site is managed by the @name'|t({'@name': site_owner}), - }, - { - 'section_id': 'footer_top_middle', - 'sections': _section_2 - }, - { - 'section_id': 'footer_top_right', - 'sections': _section_3 - } -] %} + ], + } %} -{% set _bottom_sections = [ - { - 'section_id': 'eu_footer_left' - }, - { - 'section_id': 'eu_footer_middle', - 'contact_eu_title': corporate_footer.contact_title, - 'contact_eu_links': bcl_footer_links(corporate_footer.contact), - 'social_media_title': corporate_footer.social_media_title, - 'social_media_links': bcl_footer_links(corporate_footer.social_media), - 'legal_title': corporate_footer.legal_links_title, - 'legal_links': bcl_footer_links(corporate_footer.legal_links) - }, - { - 'section_id': 'eu_footer_right', - 'eu_institutions_title': corporate_footer.institution_links_title, - 'eu_institutions_links': bcl_footer_links(corporate_footer.institution_links) - } -] %} -<footer class="bcl-footer bcl-footer--eu mt-4"> - <div class="container"> - {{ pattern('footer', { - 'variant': 'eu', - 'top_sections': _top_sections, - 'bottom_sections': _bottom_sections, - }) }} - </div> -</footer> + {% include '@oe-bcl/footer' with { + 'variant': 'eu', + 'rows': [_top_sections, _bottom_sections], + 'attributes': attributes, + } only %} +{% endblock %} diff --git a/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig b/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..a42d85ab8b662aed4975dda976e16bce7818905d --- /dev/null +++ b/templates/overrides/navigation/oe-corporate-blocks-neutral-footer.html.twig @@ -0,0 +1,106 @@ +{# +/** + * @file + * Neutral footer. + */ +#} + +{% macro bcl_title(title, classes) %} + <p class="{{ classes }}">{{ title }}</p> +{% endmacro %} + +{% set _section_2 = [] %} +{% set _section_3 = [] %} +{# First we parse the other_links, we make a simple grid. #} +{% for section in site_specific_footer.other_links %} + {% if loop.index is even %} + {% set _section_2 = _section_2|merge([ + { + 'type': 'content', + 'content': _self.bcl_title(section.label,'fw-bold border-bottom pb-2 mb-2 mt-3'), + }, + { + 'type': 'links', + 'links': bcl_footer_links(section.links), + } + ]) %} + {% else %} + {% set _section_3 = _section_3|merge([ + { + 'type': 'content', + 'content': _self.bcl_title(section.label,'fw-bold border-bottom pb-2 mb-2 mt-3'), + }, + { + 'type': 'links', + 'links': bcl_footer_links(section.links), + } + ]) %} + {% endif %} +{% endfor %} + +{# When follow section is present. #} +{% if site_specific_footer.social_links is not empty %} + {# If section numbers are odd, then we flip the last row so to have the follow as first. #} + {% if _section_2|length > _section_3|length %} + {% set _last_in_section_2 = _section_2|last %} + + {# Compensate for bug in twig where _section_2[1:] returns empty if _section_2|length is 1. #} + {% if _last_in_section_2 is empty %} + {% set _last_in_section_2 = _section_2[0] %} + {% set _section_2 = [] %} + {% endif %} + + {% set _section_2 = _section_2[:_section_2|length - 1] %} + {% set _section_3 = _section_3|merge([_last_in_section_2]) %} + + {% endif %} + + {# Follow section must always be the last on the left. #} + {% set _section_2 = _section_2|merge([ + { + 'type': 'content', + 'content': _self.bcl_title('Follow us on social media', 'fw-bold border-bottom pb-2 mb-2 mt-3'), + }, + { + 'type': 'links', + 'links': bcl_footer_links(site_specific_footer.social_links), + }]) %} +{% endif %} + +{% set footer_top_left_content %} + <p class="fw-bold mb-2">{{ site_specific_footer.site_identity }}</p> + <p> {{ site_owner ? 'This site is managed by the @name'|t({'@name': site_owner}) }} </p> +{% endset %} + +{% set attributes = create_attribute().addClass(['pb-4', 'mt-4']) %} + +{% block content %} + {% set _top_sections = { + 'extra_classes': 'pt-4 pt-lg-5', + 'cols': [ + { + 'classes': 'col-12 col-lg-4', + 'items': [ + { + 'type': 'content', + 'content': footer_top_left_content, + }, + ], + }, + { + 'classes': 'col-12 col-lg-4 pb-4 pb-lg-0', + 'items': _section_2, + }, + { + 'classes': 'col-12 col-lg-4', + 'items': _section_3, + } + ], + } %} + + {% include '@oe-bcl/footer' with { + 'variant': 'neutral', + 'rows': [_top_sections], + 'attributes': attributes, + } only %} +{% endblock %} diff --git a/templates/patterns/footer/footer.ui_patterns.yml b/templates/patterns/footer/footer.ui_patterns.yml deleted file mode 100644 index 4ef07ce926309d8803de8be91e0a20dbe24748f8..0000000000000000000000000000000000000000 --- a/templates/patterns/footer/footer.ui_patterns.yml +++ /dev/null @@ -1,18 +0,0 @@ -footer: - label: Footer - description: Footer for oe_corporate blocks - variants: - ec: - label: European Commission - eu: - label: European Union - fields: - top_sections: - type: array - label: Sections at the top row of the footer - middle_sections: - type: array - label: Sections at the middle row the footer - bottom_sections: - type: array - label: Sections at the bottom row of the footer diff --git a/templates/patterns/footer/pattern-footer--variant-ec.html.twig b/templates/patterns/footer/pattern-footer--variant-ec.html.twig deleted file mode 100644 index f987fd2abb79fb67958be86b195620014bbbaa9b..0000000000000000000000000000000000000000 --- a/templates/patterns/footer/pattern-footer--variant-ec.html.twig +++ /dev/null @@ -1,41 +0,0 @@ -<div class="pt-4 pt-lg-5 row"> - {% for section in top_sections %} - {% set section_id = section.section_id %} - {% include '@oe_whitelabel/layouts/' ~ section_id ~ '.html.twig' with { - title: section.title, - description: section.description, - sections: section.sections - } %} - {% endfor %} -</div> -{% if middle_sections is defined and middle_sections is not empty and middle_sections is iterable %} - <div class="pb-4 pb-lg-5 mt-4 mt-lg-5 bcl-footer__bordered-row row"> - {% for section in middle_sections %} - {% set section_id = section.section_id %} - {% include '@oe_whitelabel/layouts/' ~ section_id ~ '.html.twig' with { - title: section.title, - links: section.links, - } %} - {% endfor %} - </div> -{% endif %} -{% if bottom_sections is defined and bottom_sections is not empty and bottom_sections is iterable %} - <div class="pb-4 pb-lg-5 bcl-footer__bordered-row row"> - {% for section in bottom_sections %} - {% set section_id = section.section_id %} - {% include '@oe_whitelabel/layouts/' ~ section_id ~ '.html.twig' with { - title: section.title, - links: section.links, - contact_eu_title: section.contact_eu_title, - contact_eu_links: section.contact_eu_links, - social_media_title: section.social_media_title, - social_media_links: section.social_media_links, - social_media_link: section.social_media_link, - legal_title: section.legal_title, - legal_links: section.legal_links, - eu_institutions_title: section.eu_institutions_title, - eu_institutions_links: section.eu_institutions_links - } %} - {% endfor %} - </div> -{% endif %} diff --git a/templates/patterns/footer/pattern-footer--variant-eu.html.twig b/templates/patterns/footer/pattern-footer--variant-eu.html.twig deleted file mode 100644 index a9db3f98c34e311029486b423b7149181fc4e84f..0000000000000000000000000000000000000000 --- a/templates/patterns/footer/pattern-footer--variant-eu.html.twig +++ /dev/null @@ -1,41 +0,0 @@ -<div class="pt-4 pt-lg-5 row"> - {% for section in top_sections %} - {% set section_id = section.section_id %} - {% include '@oe_whitelabel/layouts/' ~ section_id ~ '.html.twig' with { - title: section.title, - description: section.description, - sections: section.sections - } %} - {% endfor %} -</div> -{% if middle_sections is defined and middle_sections is not empty and middle_sections is iterable %} - <div class="pb-4 pb-lg-5 mt-4 mt-lg-5 bcl-footer__bordered-row row"> - {% for section in middle_sections %} - {% set section_id = section.section_id %} - {% include '@oe_whitelabel/layouts/' ~ section_id ~ '.html.twig' with { - title: section.title, - links: section.links, - } %} - {% endfor %} - </div> -{% endif %} -{% if bottom_sections is defined and bottom_sections is not empty and bottom_sections is iterable %} - <div class="pb-4 pb-lg-5 mt-4 mt-lg-5 bcl-footer__bordered-row row"> - {% for section in bottom_sections %} - {% set section_id = section.section_id %} - {% include '@oe_whitelabel/layouts/' ~ section_id ~ '.html.twig' with { - title: section.title, - links: section.links, - contact_eu_title: section.contact_eu_title, - contact_eu_links: section.contact_eu_links, - social_media_title: section.social_media_title, - social_media_links: section.social_media_links, - social_media_link: section.social_media_link, - legal_title: section.legal_title, - legal_links: section.legal_links, - eu_institutions_title: section.eu_institutions_title, - eu_institutions_links: section.eu_institutions_links - } %} - {% endfor %} - </div> -{% endif %} diff --git a/tests/src/Kernel/FooterBlockTest.php b/tests/src/Kernel/FooterBlockTest.php index ff29c276ff08cb5bbe3efc5ae7de3cf8be7ea5c1..74d63e5c172616e70a5a0ae659c6ed2201217036 100644 --- a/tests/src/Kernel/FooterBlockTest.php +++ b/tests/src/Kernel/FooterBlockTest.php @@ -17,16 +17,12 @@ class FooterBlockTest extends SparqlKernelTestBase { */ protected static $modules = [ 'block', - 'multivalue_form_element', 'oe_bootstrap_theme_helper', 'oe_corporate_blocks', 'oe_corporate_site_info', 'oe_whitelabel_helper', 'rdf_skos', 'system', - 'ui_patterns', - 'ui_patterns_library', - 'ui_patterns_settings', 'user', ]; @@ -63,12 +59,13 @@ class FooterBlockTest extends SparqlKernelTestBase { $crawler = new Crawler($render->__toString()); // For now we assert only minimal till we have a footer component. + $this->assertCount(1, $crawler->filter('footer.bcl-footer--ec')); $rows = $crawler->filter('.row'); - $this->assertCount(3, $rows); + $this->assertCount(2, $rows); $borderedSections = $crawler->filter('.bcl-footer__bordered-row'); - $this->assertCount(2, $borderedSections); + $this->assertCount(1, $borderedSections); $sectionTitles = $crawler->filter('p.fw-bold.mb-2'); - $this->assertCount(3, $sectionTitles); + $this->assertCount(2, $sectionTitles); $sectionLinks = $crawler->filter('div.col-12.col-lg-4:nth-child(2) a.text-underline-hover.d-block.mb-1'); $this->assertCount(3, $sectionLinks); } @@ -98,6 +95,7 @@ class FooterBlockTest extends SparqlKernelTestBase { $crawler = new Crawler($render->__toString()); // For now we assert only minimal till we have a footer component. + $this->assertCount(1, $crawler->filter('footer.bcl-footer--eu')); $rows = $crawler->filter('.row'); $this->assertCount(2, $rows); $borderedSections = $crawler->filter('.bcl-footer__bordered-row'); @@ -108,4 +106,36 @@ class FooterBlockTest extends SparqlKernelTestBase { $this->assertCount(10, $sectionLinks); } + /** + * Tests the rendering of blocks. + */ + public function testNeutralFooterBlockRendering(): void { + $entity_type_manager = $this->container + ->get('entity_type.manager') + ->getStorage('block'); + $entity = $entity_type_manager->create([ + 'id' => 'neutralfooterblock', + 'theme' => 'oe_whitelabel', + 'plugin' => 'oe_corporate_blocks_neutral_footer', + 'settings' => [ + 'id' => 'oe_corporate_blocks_neutral_footer', + 'label' => 'Neutral Footer block', + 'provider' => 'oe_corporate_blocks', + 'label_display' => '0', + ], + ]); + $entity->save(); + $builder = \Drupal::entityTypeManager()->getViewBuilder('block'); + $build = $builder->view($entity, 'block'); + $render = $this->container->get('renderer')->renderRoot($build); + $crawler = new Crawler($render->__toString()); + + // For now we assert only minimal till we have a footer component. + $this->assertCount(1, $crawler->filter('footer.bcl-footer--neutral')); + $rows = $crawler->filter('.row'); + $this->assertCount(1, $rows); + $sectionTitles = $crawler->filter('p.fw-bold.mb-2'); + $this->assertCount(1, $sectionTitles); + } + }