diff --git a/VERSIONS_HOTLINE/137250 b/VERSIONS_HOTLINE/137250 new file mode 100644 index 0000000000000000000000000000000000000000..9a76cd9afa5130a24971a1a8e273e868ed16b5d3 --- /dev/null +++ b/VERSIONS_HOTLINE/137250 @@ -0,0 +1 @@ + - ticket #137250 : Magasin de thèmes : Amélioration de l'affichage des documents sans vignette. \ No newline at end of file diff --git a/library/templates/Intonation/Assets/css/intonation.css b/library/templates/Intonation/Assets/css/intonation.css index 98636073450a17ad4f4cdf534d84eef09a868207..e6a7f39d55fdedde3636cb175fe939738ee927fb 100644 --- a/library/templates/Intonation/Assets/css/intonation.css +++ b/library/templates/Intonation/Assets/css/intonation.css @@ -50,7 +50,11 @@ body { font-size: 1.25rem; } -.card-img-overlay { +.card-img-top .card-img-overlay.record_no_thumbnail { + position: relative; +} + +.card-img-overlay:not(.record_no_thumbnail) { background-color: var(--front-background-overlay); opacity: 0; transition: all 0.4s; @@ -74,10 +78,15 @@ div:hover > .img_as_background { font-size: 4em; } +.card-img-overlay:not(.record_no_thumbnail) a:not(.badge), +.card-img-overlay:not(.record_no_thumbnail) a:hover:not(.badge), +.card-img-overlay:not(.record_no_thumbnail) a:visited:not(.badge) { + color: var(--front-overlay-text); +} + .card-img-overlay a:not(.badge), .card-img-overlay a:hover:not(.badge), .card-img-overlay a:visited:not(.badge) { - color: var(--front-overlay-text); display: block; height: 100%; } diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index fbb4f3b29a440973dc996081392ba66d0cac7a2a..03d0709935db5a9ba808588001e6d1b85b8fd0e4 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -307,6 +307,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'div class library_opening' => 'col-12', 'div class library_opening_hours' => 'col-12 d-none', 'div class menu_with_carousel_layout' => 'overflow-visible', + 'div class record_no_thumbnail' => 'card card-img-overlay', ], 'icons_map_doc_types' => [], diff --git a/library/templates/Intonation/Library/View/Wrapper/Record.php b/library/templates/Intonation/Library/View/Wrapper/Record.php index 71d85f215b383c8a614205ef149f735b09a8303c..0f9c80f7c21fc818b4df7d9b70cee7f944a4b872 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record.php @@ -619,7 +619,10 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra public function getHtmlPicture() { - return ''; + return $this->_model->hasVignette() + ? '' + : $this->_view->div(['class' => 'record_no_thumbnail'], + $this->_view->renderOverlay($this)); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Work.php b/library/templates/Intonation/Library/View/Wrapper/Work.php index a709c250169ce004def33ca5d3ce0a0e307b80d1..2b59c496f2dc3a929f0516a4370be8bd294a9480 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Work.php +++ b/library/templates/Intonation/Library/View/Wrapper/Work.php @@ -64,7 +64,11 @@ class Intonation_Library_View_Wrapper_Work extends Intonation_Library_View_Wrapp public function getEmbedMedia() {} - public function getHtmlPicture() {} + + + public function getHtmlPicture() { + return $this->_getRecordWrapper()->getHtmlPicture(); + } public function getPicture() { diff --git a/library/templates/Intonation/View/CardifyWithOverlay.php b/library/templates/Intonation/View/CardifyWithOverlay.php index bd5966f31ba8d7b84c0740c3b47c0148a25dfaa6..bd362ede92e5dae08bed3253a36b0ca7ce013322 100644 --- a/library/templates/Intonation/View/CardifyWithOverlay.php +++ b/library/templates/Intonation/View/CardifyWithOverlay.php @@ -32,7 +32,7 @@ class Intonation_View_CardifyWithOverlay extends ZendAfi_View_Helper_BaseHelper protected function _cardWithPicture($element) { - if ( ! $overlay = $this->_overlay($element)) + if ( ! $overlay = $this->view->renderOverlay($element)) return ''; $img = $this->view->tagMedia($element, @@ -42,35 +42,4 @@ class Intonation_View_CardifyWithOverlay extends ZendAfi_View_Helper_BaseHelper return $img . $this->view->div(['class' => 'card_overlay'], $overlay); } - - - protected function _overlay($element) { - 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)); - - $doc_type = Class_Template::current() - ->getIco($this->view, - $element->getDocTypeLabel(), - 'doc_types', - ['class' => 'ico_xl']); - - $content = implode($content) . $doc_type; - - $main_link - ->setText($content) - ->beNotResponsiveText() - ->setImage(''); - - return $element->getContentForJSSearch() - . $this->view->tagAction($main_link); - } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderOverlay.php b/library/templates/Intonation/View/RenderOverlay.php new file mode 100644 index 0000000000000000000000000000000000000000..cdc9ade230ff62232a27546f7ead9f1bafc69662 --- /dev/null +++ b/library/templates/Intonation/View/RenderOverlay.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright (c) 2021-2031, 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 + */ + + +class Intonation_View_RenderOverlay extends ZendAfi_View_Helper_BaseHelper { + + public function renderOverlay($element){ + 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)); + + $doc_type = $this->_templateIco($element->getDocTypeLabel(), + 'doc_types', + ['class' => 'ico_xl doc_type_' . $element->getDocType()]); + + $content = implode($content) . $doc_type; + + $main_link + ->setText($content) + ->beNotResponsiveText() + ->setImage(''); + + return $element->getContentForJSSearch() + . $this->view->tagAction($main_link); + } +} diff --git a/library/templates/Intonation/View/RenderThumbnailWithAction.php b/library/templates/Intonation/View/RenderThumbnailWithAction.php index ef770c982fcd150685e61683562c2a1c6a739c2d..56eeef0352a2c99f6d7df4971d7aea38eb4fd80c 100644 --- a/library/templates/Intonation/View/RenderThumbnailWithAction.php +++ b/library/templates/Intonation/View/RenderThumbnailWithAction.php @@ -21,19 +21,29 @@ class Intonation_View_RenderThumbnailWithAction extends ZendAfi_View_Helper_BaseHelper { + public function renderThumbnailWithAction($element, $attributes = []) { + $admin_button = + $this->_div(['class' => 'position-absolute'], + $this->view->tagAction($element->getPictureAction())); + + if ( $html_image = $element->getHtmlPicture()) + return $admin_button . $html_image; + $image = $element->getPicture(); - return - $this->view->div(array_merge($attributes, - ['onclick' => '$(this).toggleClass(\'modal_image\');']), - $this->view->div(['class' => 'position-absolute'], - $this->view->tagAction($element->getPictureAction())) - . - $this->view->tagImg($image, - ['class' => 'img-thumbnail w-100', - 'alt' => ($image - ? $this->_('Couverture de %s', - $element->getMainTitle()) - : '')])); + + $thumbnail = $this->view->tagImg($image, + ['class' => 'img-thumbnail w-100', + 'alt' => ($image + ? $this->_('Couverture de %s', + $element->getMainTitle()) + : '')]); + + $attributes = array_merge($attributes, + ['onclick' => '$(this).toggleClass(\'modal_image\');']); + + $div_content = $admin_button . $thumbnail; + + return $this->_div($attributes, $div_content); } } diff --git a/library/templates/Intonation/View/TagMedia.php b/library/templates/Intonation/View/TagMedia.php index 5bb62ea3ebb7956e09e7956a2ce53d8046c2e3c4..1561f518211e17365a43dbf108aca10b2f552abe 100644 --- a/library/templates/Intonation/View/TagMedia.php +++ b/library/templates/Intonation/View/TagMedia.php @@ -49,7 +49,10 @@ class Intonation_View_TagMedia extends ZendAfi_View_Helper_BaseHelper { if ($picture = $instance->getPicture()) return $this->_div($attribs, - $this->view->tagImg($picture, $img_attribs)); + $this->view->tagImg($picture, + array_merge(['alt' => $this->_('Couverture de %s', + $instance->getMainTitle())], + $img_attribs))); return ''; } diff --git a/tests/scenarios/SearchByWork/SearchResultByWorkTest.php b/tests/scenarios/SearchByWork/SearchResultByWorkTest.php index 8ef46a83f7faf8aae09f34a7481a08a541455d17..ebdfc99d80addb8ff5f51d797a07cf0c219db573 100644 --- a/tests/scenarios/SearchByWork/SearchResultByWorkTest.php +++ b/tests/scenarios/SearchByWork/SearchResultByWorkTest.php @@ -169,7 +169,7 @@ class SearchResultByWorkWithTemplatingTest extends SearchResultByWorkTestCase { /** @test */ public function pageShouldContainsMedia() { - $this->assertXPath('//div[@class="img-thumbnail"]//img[contains(@src, "/recherche/raw-thumbnail/id/1")]'); + $this->assertXPath('//div[@class="img-thumbnail"]//div[contains(@class, "record_no_thumbnail")]'); } @@ -258,7 +258,7 @@ class SearchResultByWorkWithTemplatingWorkAccrocDuRocTest /** @test */ public function pageShouldContainsMedia() { - $this->assertXPath('//div[contains(@class, "jumbotron_thumbnail")]//img[contains(@src, "/recherche/raw-thumbnail/id/1")]'); + $this->assertXPath('//div[contains(@class, "jumbotron_thumbnail")]//div[@class="position-absolute"]/following-sibling::div[contains(@class, "record_no_thumbnail")]'); } diff --git a/tests/scenarios/Templates/TemplatesRecordsTest.php b/tests/scenarios/Templates/TemplatesRecordsTest.php index 2bf15e16c9d3f3c1ed05e35aa43a7a366a84ccc3..e7ca9c97e27e4e557a751146c4a36e7f00ab56b3 100644 --- a/tests/scenarios/Templates/TemplatesRecordsTest.php +++ b/tests/scenarios/Templates/TemplatesRecordsTest.php @@ -174,6 +174,37 @@ class TemplatesRecordsWidgetWithDescriptionLengthTest +class TemplatesRecords_Notice_NoThumbnailVignetteTest + extends TemplateRecordsWithDescriptionAndUnimarcTest { + + public function setUp(){ + parent::setUp(); + + $this->_buildTemplateProfil(['id' => 34, + 'template' => 'INTONATION']); + + $this->fixture('Class_Notice', + ['id' => 1, + 'titre' => 'Pomme et Ananas', + 'clef_alpha' => 'POMMEETANANAS', + 'facettes' => 'A1 Q9', + 'date_maj' => '01/01/2015', + 'unimarc' => '', + 'url_vignette' => Class_WebService_Vignette::NO_DATA]); + + $this->dispatch('/opac/recherche/viewnotice/clef/POMMEETANANAS/id/1/profile_id/34'); + } + + + /** @test */ + public function withoutUnimarcAndNoUrlVignettehtmlShouldContainsNothumbnail() { + $this->assertXPath('//div[@class = "record_no_thumbnail card card-img-overlay"]//i[@class="fas fa-book doc_types ico_xl doc_type_1"]'); + } +} + + + + class TemplatesRecordsViewnoticeTest extends TemplateRecordsWithDescriptionAndUnimarcTest { public function setUp() { @@ -405,6 +436,12 @@ class TemplatesRecordsViewnoticeBadgesTest extends TemplatesRecordsViewnoticeWit public function badgeFacetGenreShouldHaveClassesBadgePrimary() { $this->assertXPath('//div[contains(@class, "badge-group")]//a[@class = "badge_tag record_facets record_facet_genre text-left badge badge-primary"]'); } + + + /** @test */ + public function pageShouldContainsRecordNoThumbnail() { + $this->assertXPath('//div[contains(@class,"record_no_thumbnail")]'); + } } diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index 0757a6fbea7c5c403daa125ac38fb89f1372208c..59cd18ee234cc605819002088ee91add0069d413 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -1305,12 +1305,12 @@ class TemplatesRecordMediaDispatchTest extends TemplatesIntonationTestCase { $record = $this->fixture('Class_Notice', ['id' => 456, - 'titre_principal' => 'Psycho', 'unimarc' => $unimarc->render(), 'type_doc' => 8, 'clef_oeuvre' => 'PSYKO', 'url_vignette' => 'big_picture_300x300.jpg', - 'facettes' => 'G13 M12']); + 'facettes' => 'G13 M12']) + ->setTitrePrincipal('Psycho'); $this->dispatch('/opac/record/media/id/456/id_profil/72'); } @@ -1322,6 +1322,12 @@ class TemplatesRecordMediaDispatchTest extends TemplatesIntonationTestCase { } + /** @test */ + public function bigPictureShouldContainsAlt() { + $this->assertXPath('//div//img[contains(@src, "big_picture_300x300")][@alt="Couverture de Psycho"]'); + } + + /** @test */ public function subMenuAgendaShouldBeDisplay() { $this->assertXPathContentContains('//div[contains(@class, "button_text")]', 'agenda');