diff --git a/VERSIONS_HOTLINE/116552 b/VERSIONS_HOTLINE/116552 new file mode 100644 index 0000000000000000000000000000000000000000..4d9d46eb23eeeb366b99533431476366677d3c96 --- /dev/null +++ b/VERSIONS_HOTLINE/116552 @@ -0,0 +1 @@ + - ticket #116552 : Magasin de thème : page blanche quand une boîte newsletter est incluse dans un menu de la page accueil \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Newsletter.php b/library/templates/Intonation/Library/View/Wrapper/Newsletter.php index bbccfa79700aa7d3507f2f227c37900639303539..2b527c2e77a866306a5b3c20e97fc0d3d0cf6c90 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Newsletter.php +++ b/library/templates/Intonation/Library/View/Wrapper/Newsletter.php @@ -38,11 +38,9 @@ class Intonation_Library_View_Wrapper_Newsletter extends Intonation_Library_View public function getMainLink() { - if (!$current_user = Class_Users::getIdentity()) - return ''; - - if ($current_user->isNewsletterDisabled()) - return ''; + if ((!$current_user = Class_Users::getIdentity()) + || $current_user->isNewsletterDisabled()) + return null; $params = $this->_model->hasRecipient($current_user) ? ['Url' => $this->_view->url(['controller' => 'abonne', diff --git a/library/templates/Intonation/View/CardifyWithOverlay.php b/library/templates/Intonation/View/CardifyWithOverlay.php index 27034c1f46ccfa6878a2be54feca54953af425d3..71f9d8d8008731ce7b988077b947dfac8ac6fea6 100644 --- a/library/templates/Intonation/View/CardifyWithOverlay.php +++ b/library/templates/Intonation/View/CardifyWithOverlay.php @@ -30,17 +30,17 @@ class Intonation_View_CardifyWithOverlay extends ZendAfi_View_Helper_BaseHelper protected function _cardWithPicture($element) { - $title = $element->getMainTitle(); - - $title = $this->_tag('div', - $title, - ['class' => 'card-title']); + if (!$main_link = $element->getMainLink()) + return ''; + $title = $element->getMainTitle(); + $title = $this->view->div(['class' => 'card-title'], $title); $content = [$title]; if ($author_name = $element->getSecondaryTitle()) $content [] = $this->view->div(['class' => 'card-subtitle'], - $element->getSecondaryIco() . $this->view->div(['class' => 'd-inline'], $author_name)); + $element->getSecondaryIco() + . $this->view->div(['class' => 'd-inline'], $author_name)); $doc_type = Class_Template::current() ->getIco($this->view, @@ -50,18 +50,15 @@ class Intonation_View_CardifyWithOverlay extends ZendAfi_View_Helper_BaseHelper $content = implode($content) . $doc_type; - $main_link = $element - ->getMainLink() + $main_link ->setText($content) ->setInlineText(1) ->setImage(''); $link = $this->view->tagAction($main_link); - $overlay = $this->_tag('div', - $element->getContentForJSSearch() - . $link, - ['class' => 'card-block card-img-overlay rounded text-center text-white']); + $overlay = $this->view->div(['class' => 'card-block card-img-overlay rounded text-center text-white'], + $element->getContentForJSSearch() . $link); $img = $this->view->tagMedia($element, ['class' => 'text-center img_as_background'], diff --git a/tests/scenarios/Templates/116552_profile_widget_in_menu.json b/tests/scenarios/Templates/116552_profile_widget_in_menu.json new file mode 100644 index 0000000000000000000000000000000000000000..f295acfbbc2ce3a3723ed9134fc04bef25e52e66 --- /dev/null +++ b/tests/scenarios/Templates/116552_profile_widget_in_menu.json @@ -0,0 +1,92 @@ +{ + "id": 64, + "id_profil": 64, + "browser": "opac", + "libelle": "Biblioth\u00e8ques Chemill\u00e9-en-Anjou", + "commentaire": "Bienvenue sur le portail des biblioth\u00e8ques de Chemill\u00e9-en-Anjou", + "titre_site": "Biblioth\u00e8ques Chemill\u00e9-en-Anjou", + "ref_tags": "m\u00e9diath\u00e8que ; biblioth\u00e8ques ;", + "ref_description": "", + "cfg_accueil": { + "modules": { + "15": { + "type_module": "MENU", + "preferences": { + "titre": "Menu volant", + "menu": "64-3", + "layout": "horizontal", + "boite": [ + "admin_tools_invert_colors", + "no_border", + "no_border_radius", + "no_shadow", + "position_fixed_top_right", + "tdm_flying_widget", + "z_index_11" + ], + "profile_id": "64", + "TerredumilieuExpandBreakpoint": "always", + "TerredumilieuWidthXsmall": "6", + "TerredumilieuWidthMedium": "4", + "TerredumilieuWidthLarge": "3", + "TerredumilieuVisibilityIndex": "1", + "TerredumilieuVisibilityRecherche": "1", + "TerredumilieuVisibilityAbonne": "1", + "TerredumilieuVisibilityCms": "1", + "TerredumilieuVisibilityBlog": "1", + "TerredumilieuVisibilityAuth": "1" + }, + "division": "4", + "id_module": "15", + "profile_id": "64" + } + }, + "use_parent_css": "1", + "sitemap": "1" + }, + "cfg_menus": { + "3": { + "type_menu": "MENU", + "libelle": "Menu volant", + "menus": [ + { + "type_module": "MODULE_ACCUEIL_NEWSLETTERS", + "type_menu": "MODULE_ACCUEIL_NEWSLETTERS", + "id_module": "5", + "preferences": { + "layout": "wall", + "rendering": "card-overlay", + "size": "1", + "all_layout": "list", + "all_rendering": "card-horizontal", + "titre": "Lettre d'information : je m'abonne", + "order": "titre asc", + "boite": [ + "titre_petit" + ], + "TerredumilieuExpandBreakpoint": "sm", + "TerredumilieuWidthXsmall": "3", + "TerredumilieuWidthLarge": "6", + "TerredumilieuVisibilityIndex": "1", + "TerredumilieuVisibilityRecherche": "1", + "TerredumilieuVisibilityAbonne": "1", + "TerredumilieuVisibilityCms": "1", + "TerredumilieuVisibilityBlog": "1", + "TerredumilieuVisibilityAuth": "1", + "TerredumilieuShowHeader": "1", + "TerredumilieuShowContent": "1", + "TerredumilieuShowFooter": "1" + } + } + ], + "children": "MODULE_ACCUEIL_NEWSLETTERS;", + "preferences": { + "type_module": "MENU", + "type_menu": "MENU", + "libelle": "Menu volant", + "children": "MODULE_ACCUEIL_NEWSLETTERS;" + } + } + }, + "template": "TERREDUMILIEU" +} diff --git a/tests/scenarios/Templates/TemplatesWidgetInMenusTest.php b/tests/scenarios/Templates/TemplatesWidgetInMenusTest.php new file mode 100644 index 0000000000000000000000000000000000000000..473b8e2eeeaa4700dd500614f481288f31ae0d94 --- /dev/null +++ b/tests/scenarios/Templates/TemplatesWidgetInMenusTest.php @@ -0,0 +1,47 @@ +<?php +/** + * Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +require_once 'TemplatesTest.php'; + +/** @see http://forge.afi-sa.fr/issues/116552 */ +class TemplatesWidgetInMenusNewsletterLoggedOutTest extends TemplatesIntonationTestCase { + + /** @test */ + public function pageShouldContainswidgetNewsletterInMenu() { + // widgets in menu is an activable feature, otherwise widget are ignored in menu rendering + Class_AdminVar::set('MENU_BOITE', 1); + + (new Class_Profil_Import($this->fixture('Class_Profil', ['id' => 7]))) + ->import(__DIR__ . '/116552_profile_widget_in_menu.json'); + + $this->fixture('Class_Newsletter', + ['id' => 42, + 'titre' => 'The answer', + 'mail_subject' => 'The answer']); + + ZendAfi_Auth::getInstance()->clearIdentity(); + $this->dispatch('/opac/index/index/id_profil/7'); + + $this->assertXPathContentContains('//li[@class="nav-item"]//div[@id="boite_3-0"]//div[contains(@class, "widget-header")]', + 'Lettre d\'information : je m\'abonne', + $this->_response->getBody()); + } +}