diff --git a/.gitattributes b/.gitattributes index 2d9fd2d2f17d6df133543adc97c80a04f484d24b..df108f8a1f7f2f919885cb7ae6447a72830be9c9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3858,6 +3858,7 @@ tests/library/ZendAfi/Form/Element/ImageDeleteTest.php -text tests/library/ZendAfi/Form/Element/ImageTest.php -text tests/library/ZendAfi/TranslateTest.php -text tests/library/ZendAfi/Validate/IsbnTest.php -text +tests/library/ZendAfi/View/Helper/Abonne/AbonnementTest.php -text tests/library/ZendAfi/View/Helper/Accueil/BibNumeriqueTest.php -text tests/library/ZendAfi/View/Helper/Accueil/CacheTest.php -text tests/library/ZendAfi/View/Helper/Accueil/CalendarTest.php -text diff --git a/library/ZendAfi/View/Helper/Abonne/Abonnement.php b/library/ZendAfi/View/Helper/Abonne/Abonnement.php index a2ca1a997e6316687357fe14131c131b05612ded..655cd1b45331439c65cff09b83c9cf6c5368f300 100644 --- a/library/ZendAfi/View/Helper/Abonne/Abonnement.php +++ b/library/ZendAfi/View/Helper/Abonne/Abonnement.php @@ -20,14 +20,17 @@ */ class ZendAfi_View_Helper_Abonne_Abonnement extends ZendAfi_View_Helper_Abonne_Abstract { public function abonne_abonnement($user) { - if (!$user->isAbonne()) + $date_fin=formatDate($user->getDateFin(),"1"); + + if (!$user->isAbonne() || !$date_fin) return ''; - $date_fin=formatDate($user->getDateFin(),"1"); - if ($user->isAbonnementValid()) - return $this->tagFicheAbonne($this->view->_("Votre abonnement est valide jusqu'au %s.", $date_fin)); - return $this->tagFicheAbonne($this->view->_("Votre abonnement est terminé depuis le %s.", $date_fin)); + $html = $user->isAbonnementValid() + ? $this->tagFicheAbonne($this->view->_("Votre abonnement est valide jusqu'au %s.", $date_fin)) + : $this->tagFicheAbonne($this->view->_("Votre abonnement est terminé depuis le %s.", $date_fin)); + + return '<div class="abonnement">'.$html.'</div>'; } } diff --git a/library/ZendAfi/View/Helper/TagSlideshow.php b/library/ZendAfi/View/Helper/TagSlideshow.php index 37dba2be34cf8ed87114ef93e3c0b678e8f60d8d..2f15897a081d187ada9d0850345992ebda757799 100644 --- a/library/ZendAfi/View/Helper/TagSlideshow.php +++ b/library/ZendAfi/View/Helper/TagSlideshow.php @@ -66,6 +66,7 @@ class ZendAfi_View_Helper_TagSlideshow extends Zend_View_Helper_HtmlElement { public function renderSlideShowScripts() { + return $this; if (!$this->_album) return $this; @@ -169,11 +170,7 @@ class ZendAfi_View_Helper_TagSlideshow extends Zend_View_Helper_HtmlElement { null, true); - $content = $this->view->tagImg($url_media, - array('style' => sprintf('width: %spx', - $this->_preferences['op_largeur_img']), - 'title' => htmlspecialchars($media->getTitre()), - 'alt' => htmlspecialchars($media->getDescription()))); + $content = $this->_mediaTag($url_media, $media); $datas = array('titre' => $media->getTitre(), 'content' => $content, @@ -184,11 +181,11 @@ class ZendAfi_View_Helper_TagSlideshow extends Zend_View_Helper_HtmlElement { $media->getLinkTo(), $data); } else { - $datas['content'] = sprintf('<a href="%s" rel="prettyphoto[%s]" title="%s">%s</a>', + $datas['content'] = sprintf('<a href="%s" rel="prettyPhoto[%s]" title="%s">%s</a>', $this->view->url(array('module' => 'opac', 'controller' => 'bib-numerique', 'action' => 'get-resource', - 'id' => $media->getId())), + 'id' => $media->getId())).'.'.$media->getFileExtension(), htmlentities($media->getAlbum()->getTitre()), $media->getTitre(), $content); @@ -207,12 +204,24 @@ class ZendAfi_View_Helper_TagSlideshow extends Zend_View_Helper_HtmlElement { } + protected function _mediaTag($url_media, $media) { + if ($media->isImage()) + return $this->view->tagImg($url_media, + ['style' => sprintf('width: %spx', + $this->_preferences['op_largeur_img']), + 'title' => htmlspecialchars($media->getTitre()), + 'alt' => htmlspecialchars($media->getDescription())]); + + return ''; + } + + public function _getMedias($album) { if (null === $album) return array(); - $medias = $album->getImages(); + $medias = $album->getRessources(); if (array_key_exists('order', $this->_preferences) && Class_Systeme_ModulesAccueil_BibliothequeNumerique::ORDER_RANDOM == $this->_preferences['order']) { diff --git a/public/opac/css/global.css b/public/opac/css/global.css index 5bab8709e11c102d48259331ce908174f7c93a80..9904e29fa76844557d9c2119c48879f0b7d883a1 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -1078,6 +1078,12 @@ body.abonne_multimedia-hold-view .actions a { } +.abonne_fiche .abonnement .abonneFiche { + text-align: center; + width: 100%; + margin-bottom: 10px; +} + #header .share { position: absolute; @@ -1086,4 +1092,5 @@ body.abonne_multimedia-hold-view .actions a { top: 0px; cursor: pointer; z-index: 101; -} \ No newline at end of file +} + diff --git a/tests/library/ZendAfi/View/Helper/Abonne/AbonnementTest.php b/tests/library/ZendAfi/View/Helper/Abonne/AbonnementTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a749bf2e603a3999a16b160c6ed685103fe74580 --- /dev/null +++ b/tests/library/ZendAfi/View/Helper/Abonne/AbonnementTest.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 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). + * + * AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php'; + +class View_Helper_Abonne_AbonnementTest extends ViewHelperTestCase { + /** + * @var ZendAfi_View_Helper_Abonne_Abonnement + */ + private $_helper; + + public function setUp() { + parent::setUp(); + $this->_helper = new ZendAfi_View_Helper_Abonne_Abonnement(); + $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); + } + + + /** @test */ + public function userWithNoDateFinAbonnementShouldReturnEmpty() { + $this->assertEmpty($this->_helper->abonne_abonnement(Class_Users::newInstanceWithId(3) + ->beAbonneSIGB())); + } + + + /** @test */ + public function userDateFinAbonnementShouldReturnAbonnementValid() { + $this->assertXPathContentContains($this->_helper->abonne_abonnement(Class_Users::newInstanceWithId(3) + ->beAbonneSIGB() + ->setDateFin('2019-08-19')), + '//div[@class="abonnement"]', + 'Votre abonnement est valide'); + } + +} + +?> \ No newline at end of file