diff --git a/library/Class/CodifEmplacement.php b/library/Class/CodifEmplacement.php index 32bbeacbf6ad89bf165c2c2e61f4fbcd75325915..d4a7812aba9be0a98026a79a77f231b69e8db3fb 100644 --- a/library/Class/CodifEmplacement.php +++ b/library/Class/CodifEmplacement.php @@ -19,11 +19,24 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +class Class_CodifEmplacementLoader extends Storm_Model_Loader { + public function getLabel($id) { + return ($emplacement = Class_CodifEmplacement::find($id)) + ? $emplacement->getLibelle() + : ''; + } +} + + + + class Class_CodifEmplacement extends Storm_Model_Abstract { use Trait_Facetable; const CODE_FACETTE = 'E'; + protected $_loader_class = 'Class_CodifEmplacementLoader'; protected $_table_name = 'codif_emplacement'; protected $_table_primary = 'id_emplacement'; diff --git a/library/Class/CodifSection.php b/library/Class/CodifSection.php index 455b21229d81e84bd8946a5fc5f5e0247fddb68a..776117e8b14405ec7a9f67bf975a20eeacc20b4f 100644 --- a/library/Class/CodifSection.php +++ b/library/Class/CodifSection.php @@ -28,6 +28,13 @@ class Class_CodifSectionLoader extends Storm_Model_Loader { } + public function getLabel($id) { + return ($section = Class_CodifSection::find($id)) + ? $section->getLibelle() + : ''; + } + + public function getMultiOptions() { $datas = Class_CodifSection::findAllBy(['invisible' => 0, 'order' => 'libelle']); $items = ['' => $this->_('toutes')]; diff --git a/library/Class/Exemplaire.php b/library/Class/Exemplaire.php index 5a46de8ea8bc95ce042d56620ee2f22d1d3bac5c..8425d3e1f70c371a6f3730426d09b1958f8ee766 100644 --- a/library/Class/Exemplaire.php +++ b/library/Class/Exemplaire.php @@ -209,6 +209,48 @@ class Class_Exemplaire extends Storm_Model_Abstract { } + public function getHoldLink() { + $library = $this->hasBib() ? $this->getBib() : new Class_Bib(); + if (1 == $library->getInterdireResa()) + return ''; + + if (!$sigb_comm = $this->getSIGBComm()) + return Class_Url::assemble(['controller' => 'recherche', + 'action' => 'reservation', + 'id_int_bib' => $this->getIdIntBib(), + 'id_bib' => $this->getIdBib(), + 'id_notice' => $this->getIdNotice(), + 'cote' => $this->getCote()]); + + if (!$this->isReservable()) + return ''; + + return Class_Url::assemble(['controller' => 'recherche', + 'action' => 'reservation-pickup-ajax', + 'id_notice' => $this->getIdNotice(), + 'id_int_bib' => $this->getIdIntBib(), + 'id_bib' => $this->getIdBib(), + 'copy_id' => $this->getId(), + 'code_annexe' => $this->_getBranchCode()]); + } + + + protected function _getBranchCode() { + $item_branch_code = $this->getCodeAnnexe(); + + if(!Class_CosmoVar::isSiteRetraitResaChoiceEnabled()) + return $item_branch_code; + + if(!$user = Class_Users::getIdentity()) + return $item_branch_code; + + if(!$branch_code = $user->getLibraryCode()) + return $item_branch_code; + + return $branch_code; + } + + public function updateAvailabilityAndLocationFromSIGB() { if (!$sigb_exemplaire = $this->getSigbExemplaire()) return $this; diff --git a/library/ZendAfi/View/Helper/Notice/ReservationLink.php b/library/ZendAfi/View/Helper/Notice/ReservationLink.php index 04a89d8ff019508bb902e77a51aa4c82757193bb..71ac30704b16db169c707918ed46846ae87b9a37 100644 --- a/library/ZendAfi/View/Helper/Notice/ReservationLink.php +++ b/library/ZendAfi/View/Helper/Notice/ReservationLink.php @@ -37,17 +37,16 @@ class ZendAfi_View_Helper_Notice_ReservationLink extends ZendAfi_View_Helper_Bas * @return string modified html */ public function renderItemOn($ex, $html) { - if (1 == $this->_bib->getInterdireResa()) + if (!$url = $ex->getHoldLink()) return $this->_renderCellWith(' '); - $type_comm = ($int_bib = Class_IntBib::find($ex->getIdIntBib())) ? $int_bib->getCommSigb() : 0; - if (!$type_comm) - return $this->_renderCellWith($this->_renderStandardOn($ex)); + $attributes = ['href' => $url]; + if ($ex->hasSIGBComm()) + $attributes['data-popup'] = true; - if (!$ex->isReservable()) - return $this->_renderCellWith(' '); - - return $this->_renderCellWith($this->_renderAjaxOn($ex)); + return $this->_renderCellWith($this->_tag('a', + $this->_getHoldImage(), + $attributes)); } @@ -58,51 +57,6 @@ class ZendAfi_View_Helper_Notice_ReservationLink extends ZendAfi_View_Helper_Bas } - /** @return string */ - protected function _renderStandardOn($ex) { - $link = $this->view->url(['controller' => 'recherche', - 'action' => 'reservation', - 'id_int_bib' => $ex->getIdIntBib(), - 'id_bib' => $ex->getIdBib(), - 'id_notice' => $ex->getIdNotice(), - 'cote' => $ex->getCote()]); - - return $this - ->_tag('a', $this->_getHoldImage(), - ['href' => $link]); - } - - - /** @return string */ - protected function _renderAjaxOn($ex) { - $link = $this->view->url(['controller' => 'recherche', - 'action' => 'reservation-pickup-ajax', - 'id_int_bib' => $ex->getIdIntBib(), - 'id_bib' => $ex->getIdBib(), - 'copy_id' => $ex->getId(), - 'code_annexe' => $this->_getBranchCode($ex)]); - - return $this->_tag('a', $this->_getHoldImage(), ['href' => $link, - 'data-popup' => 'true']); - } - - - protected function _getBranchCode($item) { - $item_branch_code = $item->getCodeAnnexe(); - - if(!Class_CosmoVar::isSiteRetraitResaChoiceEnabled()) - return $item_branch_code; - - if(!$user = Class_Users::getIdentity()) - return $item_branch_code; - - if(!$branch_code = $user->getLibraryCode()) - return $item_branch_code; - - return $branch_code; - } - - /** @return string */ protected function _getHoldImageUrl() { return Class_Profil::getCurrentProfil()->getUrlImage(self::HOLD_IMG); diff --git a/library/templates/Intonation/Assets/css/intonation.css b/library/templates/Intonation/Assets/css/intonation.css index b2f1bce18f99e56f377f9571ea0a333b5766906e..9c9133134419624eb2abc5ba40e9302c677b195d 100644 --- a/library/templates/Intonation/Assets/css/intonation.css +++ b/library/templates/Intonation/Assets/css/intonation.css @@ -263,4 +263,34 @@ pre { .carousel-indicators { bottom: 5px; margin-bottom: 0; +} + +[id*='resources'] .list-group-item { + padding-left: 0; + padding-right: 0; +} + +[id*='resources'] .card-text { + * margin: 0; +} + +.list-group-item { + padding-bottom: 0; +} + +.list-group-item .card-title, +.list-group-item .card-text { + margin: 0; +} + +.list-group-item .text-muted { + font-size: 75%; +} + +.list-group-item .card-title, +.list-group-item .card-text, +.list-group-item .card-body, +.list-group-item .card-footer { + padding-bottom: 1px; + padding-top: 1px; } \ No newline at end of file diff --git a/library/templates/Intonation/Library/Link.php b/library/templates/Intonation/Library/Link.php new file mode 100644 index 0000000000000000000000000000000000000000..8295ec5a7fcba51f0420b76aa067402d4c6d0756 --- /dev/null +++ b/library/templates/Intonation/Library/Link.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright (c) 2012-2018, 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_Library_Link extends Class_Entity { + +} +?> \ No newline at end of file diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index 9ae8a69969207a00853bb9fb41e9b5e8ed99b14a..3938d198f70341a687b87f05e53216a3f28a94f6 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -108,7 +108,14 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { '10' => 'class fas fa-link'], 'icons_map_library' => ['author' => 'class fas fa-user', - 'search_more' => 'class fas fa-list'], + 'search_more' => 'class fas fa-list', + 'library' => 'class fas fa-landmark', + 'available' => 'class far fa-check-circle', + 'not-available' => 'class far fa-times-circle', + 'return-date' => 'class fas fa-dolly', + 'place' => 'class fas fa-map-signs', + 'cote' => 'class fas fa-crosshairs', + 'hold' => 'class fas fa-thumbtack'], 'icons_map_utils' => ['image_place_holder' => '/library/templates/Intonation/Assets/images/image_place_holder.png', 'previous' => 'class fas fa-chevron-left', @@ -135,7 +142,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { public function getHtmlAttribs() { return ['id' => 'site_web_wrapper', - 'class' => $this->_getResponsiveWidths()]; + 'class' => 'no_overflow ' . $this->_getResponsiveWidths()]; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/Abstract.php index e44d8620dc53821fcae4ede122c6d66671446526..883fb839070df65d9c9bfa5f54eead831277317f 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/Abstract.php @@ -38,4 +38,9 @@ class Intonation_Library_View_Wrapper_Abstract { $this->_model = $record; return $this; } + + + public function getSecondaryLink() { + return null; + } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Article.php b/library/templates/Intonation/Library/View/Wrapper/Article.php index ebd88bcd7256575b956f5c3ca495d172bf8ce66d..6ea46805acc0c44186bf43a613bb85a1eadf467a 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Article.php +++ b/library/templates/Intonation/Library/View/Wrapper/Article.php @@ -54,27 +54,24 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr } - public function getUrl() { - return $this->_model->getUrl(); + public function getMainLink() { + return new Intonation_Library_Link(['Url' => $this->_model->getUrl(), + 'Text' => $this->_('Lire l\'article'), + 'Title' => $this->_getMainLinkTitle()]); } - public function getLinkTitle() { + protected function _getMainLinkTitle() { if ($author = $this->getAuthor()) return $this->_('Lire l\'article "%s" écrit par "%s"', $this->getTitle(), $this->getAuthor()); - return $this->_('Lire l\'article "%s"', + return $this->_('Lire l\'article: %s', $this->getTitle()); } - public function getLinkText() { - return $this->_('Lire l\'article'); - } - - public function getPicture() { return $this->_model->getFirstImageAbsoluteURL(); } @@ -97,14 +94,4 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr 'author', 'library'); } - - - public function getAuthorLinkTitle() { - return ''; - } - - - public function getAuthorLink() { - return ''; - } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Item.php b/library/templates/Intonation/Library/View/Wrapper/Item.php index 4e417115f94306f0e411e313abbc515e32fd4c3c..7f214b6b006ab8f95d25e015581d477a9eed1fb3 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Item.php +++ b/library/templates/Intonation/Library/View/Wrapper/Item.php @@ -22,7 +22,22 @@ class Intonation_Library_View_Wrapper_Item extends Intonation_Library_View_Wrapper_Abstract { public function getTitle() { - return $this->_model->getBibLibelle() . ' : ' . $this->_model->getCodeBarres(); + return + $this->_view->tag('span', + Class_Template::current()->getIco($this->_view, + ($this->_model->isDisponible(true) + ? 'available' + : 'not-available'), + 'library'), + ['title' => $this->_model->getDisponibilite(), + 'class' => ($this->_model->isDisponible(true) + ? 'text-success' + : 'text-danger')]) + + . $this->_view->tag('span', + $this->_model->getBibLibelle(), + ['title' => $this->_('Bibliothèque de l\'exemplaire "%s"', + $this->_model->getCodeBarres())]); } @@ -31,12 +46,49 @@ class Intonation_Library_View_Wrapper_Item extends Intonation_Library_View_Wrapp } + protected function _iconOrNothing($icon, $content) { + if (!$content) + return ''; + + return + Class_Template::current()->getIco($this->_view, + $icon, + 'library') + . $content; + } + + public function getDescription() { - $badges = []; - $badges [] = ['tag' => 'span', - 'class' => $this->_model->isDisponible(true) ? 'success' : 'danger', - 'text' => $this->_model->getDisponibilite()]; - return $this->_view->renderBadges($badges); + $place_badges = [ + ['tag' => 'span', + 'class' => 'info', + 'text' => Class_CodifSection::getLabel($this->_model->getSection()), + 'title' => $this->_('Section de l\'exemplaire "%s"', + $this->_model->getCodeBarres())], + + ['tag' => 'span', + 'class' => 'secondary', + 'text' => $this->_iconOrNothing('place', + Class_CodifEmplacement::getLabel($this->_model->getEmplacement())), + 'title' => $this->_('Emplacement de l\'exemplaire "%s"', + $this->_model->getCodeBarres())], + + ['tag' => 'span', + 'class' => 'secondary', + 'text' => $this->_iconOrNothing('cote', + $this->_model->getCote()), + 'title' => $this->_('Cote de l\'exemplaire "%s"', + $this->_model->getCodeBarres())], + + + ['tag' => 'span', + 'class' => 'warning', + 'text' => $this->_iconOrNothing('return-date', + $this->_model->getDateRetour()), + 'title' => $this->_('Date de retour prévue de l\'exemplaire "%s"', + $this->_model->getCodeBarres())]]; + + return $this->_view->renderBadges($place_badges); } @@ -45,12 +97,19 @@ class Intonation_Library_View_Wrapper_Item extends Intonation_Library_View_Wrapp } - public function getUrl() { - return ''; + public function getMainLink() { + return ($hold_link = $this->_model->getHoldLink()) + ? new Intonation_Library_Link(['Url' => $hold_link, + 'Text' => $this->_iconOrNothing('hold', + $this->_('Réserver')), + 'Title' => $this->_('Réserver un exemplaire du document: %s', + $this->_model->getTitrePrincipal()), + 'Popup' => $this->_model->hasSIGBComm()]) + : null; } - public function getAuthorLink() { - return ''; + public function getSecondaryLink() { + return null; } } diff --git a/library/templates/Intonation/Library/View/Wrapper/Record.php b/library/templates/Intonation/Library/View/Wrapper/Record.php index b153777ce2916c1a8afab5363bcb0a7f8f3aeb86..f7a8c6ba9647058c26102460cc20f8ad70caee21 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record.php @@ -49,21 +49,13 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra } - public function getUrl() { - return $this->_model->getAbsoluteUrl(); - } - - - public function getLinkTitle() { - return $this->_('Voir le document "%s" de "%s" de type "%s"', - $this->getTitle(), - $this->getAuthor(), - $this->getDocTypeLabel()); - } - - - public function getLinkText() { - return $this->_('Voir le document'); + public function getMainLink() { + return new Intonation_Library_Link(['Url' => $this->_model->getAbsoluteUrl(), + 'Text' => $this->_('Voir le document'), + 'Title' => $this->_('Voir le document "%s" de "%s" de type "%s"', + $this->getTitle(), + $this->getAuthor(), + $this->getDocTypeLabel())]); } @@ -91,20 +83,17 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra } - public function getAuthorLinkTitle() { - return $this->_('Voir tous les documents de l\'auteur principal "%s"', - $this->getAuthor()); - } - - - public function getAuthorLink() { + public function getSecondaryLink() { if(!$author = $this->getAuthor()) - return ''; + return null; if (!$facet = Class_CodifAuteur::findWithFullName($author)) - return ''; + return null; - return (new Class_Notice_FieldAuthor($facet)) - ->getUrlParams(); + return new Intonation_Library_Link(['Url' => (new Class_Notice_FieldAuthor($facet)) + ->getUrlParams(), + 'Text' => $this->getAuthorIco() . $author, + 'Title' => $this->_('Voir tous les documents de l\'auteur principal "%s"', + $this->getAuthor())]); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/Abstract/Carousel.php b/library/templates/Intonation/View/Abstract/Carousel.php index 13cb3e471bdadedf2da48a3527099da82e96e06c..963bedf778534b00819620a2d39bae44da27036e 100644 --- a/library/templates/Intonation/View/Abstract/Carousel.php +++ b/library/templates/Intonation/View/Abstract/Carousel.php @@ -22,7 +22,7 @@ abstract class Intonation_View_Abstract_Carousel extends ZendAfi_View_Helper_BaseHelper { protected function _renderCarousel($collection, $callback) { - $id = 'carousel_' . uniqueid(); + $id = 'carousel_' . uniqid(); $content = $this->_indicators($this->_numberOfPages($collection), $id) . $this->_carouselInner($collection, $id, $callback) diff --git a/library/templates/Intonation/View/AddBootstrap.php b/library/templates/Intonation/View/AddBootstrap.php new file mode 100644 index 0000000000000000000000000000000000000000..845ced507c4142507d5a01bb97dfbbd8f7feb74d --- /dev/null +++ b/library/templates/Intonation/View/AddBootstrap.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright (c) 2012-2018, 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_AddBootstrap extends ZendAfi_View_Helper_BaseHelper { + public function addBootstrap($script_loader = null) { + $script_loader = $script_loader + ? $script_loader + : Class_ScriptLoader::getInstance(); + + $template = Class_Template::current(); + + if($template->getIntonationBootstrapCss()) + $script_loader->cssAddLine( + $this->_tag('link', + null, + ['rel' => 'stylesheet', + 'href' => 'https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css', + 'integrity' => 'sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS', + 'crossorigin' => 'anonymous'])); + + if($template->getIntonationBootstrapDependencyPopper()) + $script_loader->scriptsAddLine($this->view->tag('script', + '', + ['src' => 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js', + 'integrity' => 'sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut', + 'crossorigin' => 'anonymous'])); + + if($template->getIntonationBootstrapJs()) + $script_loader->scriptsAddLine($this->view->tag('script', + '', + ['src' => 'https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js', + 'integrity' => 'sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k', + 'crossorigin' => 'anonymous'])); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/View/Cardify.php b/library/templates/Intonation/View/Cardify.php index 1eb372a59e6257bb37858658550034836fde002c..f9da13f6c6ac17056a901de3a83acb0b776baeaf 100644 --- a/library/templates/Intonation/View/Cardify.php +++ b/library/templates/Intonation/View/Cardify.php @@ -37,11 +37,6 @@ class Intonation_View_Cardify extends ZendAfi_View_Helper_BaseHelper { : $this->_('Aïe, aïe, aïe ! Pas d\'image pour "%s".', $element->getTitle()))]); - return $img . $this->_card($element); - } - - - protected function _card($element) { - return $this->view->cardifyOnlyDescription($element); + return $img . $this->view->cardifyOnlyDescription($element); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/CardifyOnlyDescription.php b/library/templates/Intonation/View/CardifyOnlyDescription.php index 102be11347bf5d0fbc471dd2353b1aaef821ebcd..eb47012d7725d8fa6fa2c9111b391739b7a2dfe1 100644 --- a/library/templates/Intonation/View/CardifyOnlyDescription.php +++ b/library/templates/Intonation/View/CardifyOnlyDescription.php @@ -21,10 +21,14 @@ class Intonation_View_CardifyOnlyDescription extends ZendAfi_View_Helper_BaseHelper { + public function cardifyOnlyDescription($element) { - $content = [$title = $this->_tag('h5', - $element->getTitle(), - ['class' => 'card-title'])]; + $content = []; + + if ($title = $element->getTitle()) + $content [] = $title = $this->_tag('h5', + $title, + ['class' => 'card-title']); if ($author_name = $element->getAuthor()) $content [] = $this->_tag('h6', @@ -33,30 +37,37 @@ class Intonation_View_CardifyOnlyDescription extends ZendAfi_View_Helper_BaseHel ['class' => 'card-subtitle text-muted']); if ($summary = $element->getDescription()) - $content [] = $this->_tag('p', + $content [] = $this->_tag('div', $element->getDescription(), ['title' => strip_tags($element->getDescriptionTitle()), 'class' => 'card-text']); $links = []; - if ($url = $element->getUrl()) - $links []= $this->view->tagAnchor($url, - $element->getLinkText(), - ['title' => $element->getLinkTitle(), + if ($link = $element->getMainLink()) + $links []= $this->view->tagAnchor($link->getUrl(), + $link->getText(), + ['title' => $link->getTitle(), + 'data-popup' => $link->getPopup(), 'class' => 'card-link']); - if ($author_link = $element->getAuthorLink()) - $links [] = $this->view->tagAnchor($author_link, - $this->_('Voir l\'auteur'), - ['title' => $element->getAuthorLinkTitle(), + if ($second_link = $element->getSecondaryLink()) + $links [] = $this->view->tagAnchor($second_link->getUrl(), + $second_link->getText(), + ['title' => $second_link->getTitle(), 'class' => 'card-link']); - return $this->_tag('div', - implode($content), - ['class' => 'card-body']) - . $this->_tag('div', - implode($links), - ['class' => 'card-footer d-flex flex-column flex-md-row justify-content-between']); + $html = []; + + if (!empty($content)) + $html [] = $this->_tag('div', + implode($content), + ['class' => 'card-body']); + + if (!empty($links)) + $html [] = $this->_tag('div', + implode($links), + ['class' => 'card-footer d-flex flex-column flex-md-row justify-content-between']); + return implode($html); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/CardifyWithOverlay.php b/library/templates/Intonation/View/CardifyWithOverlay.php index be7db33887b9e32ee85e0abc15e3467c64c399ae..931bf4e3fba552a7767070c16f937d6f6ae91788 100644 --- a/library/templates/Intonation/View/CardifyWithOverlay.php +++ b/library/templates/Intonation/View/CardifyWithOverlay.php @@ -53,10 +53,11 @@ class Intonation_View_CardifyWithOverlay extends ZendAfi_View_Helper_BaseHelper $content = implode($content) . $doc_type; - $link = $this->view->tagAnchor($element->getUrl(), + $main_link = $element->getMainLink(); + $link = $this->view->tagAnchor($main_link->getUrl(), $content, ['class' => 'card-link', - 'title' => $element->getLinkTitle()]); + 'title' => $main_link->getTitle()]); $overlay = $this->_tag('div', $link, diff --git a/library/templates/Intonation/View/Iframe.php b/library/templates/Intonation/View/Iframe.php index 151ee1765af908cafc935f3554a9cb7545349f37..a96f82e6ded735ca0f05ffbc5253333fb1bce8b9 100644 --- a/library/templates/Intonation/View/Iframe.php +++ b/library/templates/Intonation/View/Iframe.php @@ -142,29 +142,7 @@ class Intonation_View_Iframe extends ZendAfi_View_Helper_BaseHelper { protected function _addBootstrap4($script_loader) { - if($this->_template->getIntonationBootstrapCss()) - $script_loader->cssAddLine( - $this->_tag('link', - null, - ['rel' => 'stylesheet', - 'href' => 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css', - 'integrity' => 'sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M', - 'crossorigin' => 'anonymous'])); - - if($this->_template->getIntonationBootstrapDependencyPopper()) - $script_loader->scriptsAddLine($this->view->tag('script', - '', - ['src' => 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js', - 'integrity' => 'sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4', - 'crossorigin' => 'anonymous'])); - - if($this->_template->getIntonationBootstrapJs()) - $script_loader->scriptsAddLine($this->view->tag('script', - '', - ['src' => 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js', - 'integrity' => 'sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1', - 'crossorigin' => 'anonymous'])); - + $this->view->addBootstrap($script_loader); return $this; } } \ No newline at end of file diff --git a/library/templates/Intonation/View/Notice/Exemplaires.php b/library/templates/Intonation/View/Notice/Exemplaires.php index dbbce86b6efe6e0c4b384df011b939ab3e62c45e..41bdeb663189d1d1cebbf0a8030345a41bc5e087 100644 --- a/library/templates/Intonation/View/Notice/Exemplaires.php +++ b/library/templates/Intonation/View/Notice/Exemplaires.php @@ -24,9 +24,21 @@ class Intonation_View_Notice_Exemplaires extends ZendAfi_View_Helper_BaseHelper public function Notice_Exemplaires($exemplaires, $nb_notices_oeuvre = 0, $aff = "normal") { $callback = function ($element) { - return $this->view->cardifyOnlyDescription($element); + return $this->_tag('div', + $this->view->cardifyOnlyDescription($element), + ['class' => 'card']); }; + + usort($exemplaires, + function($a, $b) + { + if ($a->getDisponibilite() == $b->getDisponibilite()) + return strcmp($a->getBibLibelle(), $b->getBibLibelle()); + + return $a->isDisponible(true) ? -1 : 1; + }); + $elements = array_map(function($element) { return (new Intonation_Library_View_Wrapper_Item) @@ -36,15 +48,4 @@ class Intonation_View_Notice_Exemplaires extends ZendAfi_View_Helper_BaseHelper return $this->view->renderList(new Storm_Collection($elements), $callback); } - - - protected function _renderItem($item) { - $html = [$this->_tag('h3', - $this->_('Exemplaire de "%s"', - $item->getLibraryLabel()))]; - - return $this->_tag('div', - implode($html), - ['class' => 'list-group-item']); - } } \ No newline at end of file diff --git a/library/templates/Intonation/View/Opac.php b/library/templates/Intonation/View/Opac.php index 892ea3eca86e858879d3f398348fc6d41a19b824..c774e861e39b64b2907ed66e2a66fc615947a71e 100644 --- a/library/templates/Intonation/View/Opac.php +++ b/library/templates/Intonation/View/Opac.php @@ -199,29 +199,7 @@ class Intonation_View_Opac extends ZendAfi_View_Helper_BaseHelper { protected function _addBootstrap4($script_loader) { - if($this->_template->getIntonationBootstrapCss()) - $script_loader->cssAddLine( - $this->_tag('link', - null, - ['rel' => 'stylesheet', - 'href' => 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css', - 'integrity' => 'sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M', - 'crossorigin' => 'anonymous'])); - - if($this->_template->getIntonationBootstrapDependencyPopper()) - $script_loader->scriptsAddLine($this->view->tag('script', - '', - ['src' => 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js', - 'integrity' => 'sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4', - 'crossorigin' => 'anonymous'])); - - if($this->_template->getIntonationBootstrapJs()) - $script_loader->scriptsAddLine($this->view->tag('script', - '', - ['src' => 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js', - 'integrity' => 'sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1', - 'crossorigin' => 'anonymous'])); - + $this->view->addBootstrap($script_loader); return $this; } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderBadges.php b/library/templates/Intonation/View/RenderBadges.php index 4ef78684ff0a8ed486872de825c15a010638f4bb..e619070de8d65dfec3c05e82755ad4bdc3109e09 100644 --- a/library/templates/Intonation/View/RenderBadges.php +++ b/library/templates/Intonation/View/RenderBadges.php @@ -21,8 +21,10 @@ class Intonation_View_RenderBadges extends ZendAfi_View_Helper_BaseHelper { + public function renderBadges($badges) { $instances = []; + foreach($badges as $data) if ($data['text']) $instances [] = new Class_Entity($data); @@ -41,9 +43,8 @@ class Intonation_View_RenderBadges extends ZendAfi_View_Helper_BaseHelper { }, $instances); - return $this->_tag('p', + return $this->_tag('div', implode($instances), ['class' => 'badge-group']); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderList.php b/library/templates/Intonation/View/RenderList.php index 09f71b141012f55582b9adaddc985e22d015a852..e315486d3e48a5a7ff40dda398cc0eb16158197c 100644 --- a/library/templates/Intonation/View/RenderList.php +++ b/library/templates/Intonation/View/RenderList.php @@ -28,11 +28,11 @@ class Intonation_View_RenderList extends ZendAfi_View_Helper_BaseHelper { { return $html . $this->_tag('div', $callback($element), - ['class' => 'list-group-item']); + ['class' => 'list-group-item bg-transparent border-0']); }); return $this->_tag('div', $html, - ['class' => 'list-group']); + ['class' => 'list-group bg-transparent border-0']); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderRecord.php b/library/templates/Intonation/View/RenderRecord.php index 770529c1244245193da96ca8bdc562624c230fff..ed9edf687a1e8d8327446e9a378d83ec792bc6bd 100644 --- a/library/templates/Intonation/View/RenderRecord.php +++ b/library/templates/Intonation/View/RenderRecord.php @@ -36,24 +36,114 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { $this->view->titre = $this->_wrapped->getTitle(); $html = [$this->_renderHead(), - ]; + $this->_renderContent()]; return implode($html); } - protected function _renderHead() { - $html = [$this->_tag('div', $this->_recordThumbnail(), ['class' => 'col-sm-5 col-md-3']), - $this->_tag('div', $this->_recordMetaData(), ['class' => 'col-sm-5 col-md-4']), - $this->_tag('div', $this->_recordItems(), ['class' => 'col-sm-10 col-md-3'])]; + protected function _renderContent() { + $html = [$this->_renderSummary(), + $this->_renderMedia(), + $this->_renderReviews(), + $this->_renderDetails(), + $this->_renderCollection(), + $this->_renderAuthor()]; + + $html = $this->_div(['class' => 'col-md-10 col-xl-8'], implode($html)); + + return $this->_grid($html, [], ['class' => 'justify-content-center']); + } + + + protected function _renderSummary() { + return $this->_renderBloc($this->_('Résumé'), + $this->_record->getResume()); + } + + protected function _div($attributes, $content = '') { return $this->_tag('div', - $this->_tag('div', - $this->_tag('div', - implode($html), - ['class' => 'row justify-content-center']), - ['class' => 'container-fluid']), - ['class' => 'jumbotron jumbotron-fluid w-100 no_overflow']); + $content, + $attributes); + } + + + protected function _grid($html, $container_attribs = [], $row_attribs = []) { + if (!isset($container_attribs['class'])) + $container_attribs ['class'] = ''; + + $container_attribs ['class'] .= ' container-fluid'; + + if (!isset($row_attribs['class'])) + $row_attribs ['class'] = ''; + + $row_attribs ['class'] .= ' row'; + + return $this->_div($container_attribs, + $this->_div($row_attribs, $html)); + } + + + protected function _renderMedia() { + return + $this->_renderBloc($this->_('Médias'), + $this->_grid($this->_renderAjaxBloc('resnumeriques') + . $this->_renderAjaxBloc('bandeannonce') + . $this->_renderAjaxBloc('morceaux') + . $this->_renderAjaxBloc('photos'))); + } + + + protected function _renderBloc($title, $html) { + return + $this->_div(['class' => 'border-bottom border-primary mb-3 pb-3'], + $this->_tag('h2', $title) . $html); + } + + + protected function _renderReviews() { + return $this->_renderBloc($this->_('Avis'), + $this->_renderAjaxBloc('avis')); + } + + + protected function _renderDetails() { + return + $this->_renderBloc($this->_('Description'), + $this->_grid($this->_renderAjaxBloc('recounts') + . $this->_renderAjaxBloc('detail'))); + } + + + protected function _renderCollection() { + return $this->_renderBloc($this->_('Voir Aussi'), + $this->_grid($this->_renderAjaxBloc('series') + . $this->_renderAjaxBloc('frbr') + . $this->_renderAjaxBloc('similaires'))); + } + + + protected function _renderAuthor() { + return + $this->_renderBloc($this->_('Auteur principal'), + $this->_renderAjaxBloc('biographie')); + } + + + + protected function _renderHead() { + $html = + $this->_div(['class' => 'col-12 col-md-4 col-lg-3 col-xl-2'], $this->_recordThumbnail()) +// . $this->_div(['class' => 'col-12 col-md-6 col-lg-7 col-xl-6'], +// $this->_div(['class' => 'row no-gutters'], + . $this->_div(['class' => 'col-12 col-md-6 col-lg-7 col-xl-4'], $this->_recordMetaData()) + . $this->_div(['class' => 'no-gutters col-12 col-md-10 col-xl-4'], $this->_recordItems()); + + return $this->_div(['class' => 'jumbotron jumbotron-fluid w-100 no_overflow'], + $this->_grid($html, + [], + ['class' => 'justify-content-center'])); } @@ -70,30 +160,29 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { protected function _recordItems() { - $items_id = 'items-'.uniqid(); + return $this->_renderAjaxBloc('resources'); + } + + + protected function _renderAjaxBloc($action) { + $id = $action . uniqid(); Class_ScriptLoader::getInstance()->addJQueryReady(sprintf('$("#%s").load("%s")', - $items_id, + $id, $this->view->url(['controller' => 'noticeajax', - 'action' => 'resources', + 'action' => $action, 'id' => $this->_record->getId()]))); - return $this->_tag('div', '', ['id' => $items_id]); + return $this->_div(['id' => $id, + 'class' => 'col-12'], ''); } - protected function _recordMetaData() { - return - $this->_tag('h1', - $this->view->titre) - . $this->view->tagAnchor($this->_wrapped->getAuthorLink(), - $this->_wrapped->getAuthorIco() - . $this->_wrapped->getAuthor(), - ['title' => $this->_wrapped->getAuthorLinkTitle(), - 'class' => 'card-link']) - . $this->view->renderRecordBadges($this->_record); + $html = $this->_tag('h1', $this->view->titre); + if ($author_link = $this->_wrapped->getSecondaryLink()) + $html .= $this->view->tagAnchor($author_link->getUrl(), + $author_link->getText(), + ['title' => $author_link->getTitle(), + 'class' => 'card-link']); + return $html . $this->view->renderRecordBadges($this->_record); } - - - - } \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index c32c86d73d88ccc5e7cb28fca347dcb2f8f8b5c1..2da6f99e5b5e2d1b7cf50d0a8019ed70325bf1a3 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -2365,6 +2365,8 @@ class NoticeAjaxControllerNanookSIGBWithHoldSiteEnabledTest extends AbstractCont $item_from_sigb = (new Class_Entity()) ->whenCalledDo('isValid', function() {return true;}) ->whenCalledDo('isReservable', function() {return true;}) + ->whenCalledDo('isPilonne', function() {return false;}) + ->whenCalledDo('isVisibleOPAC', function() {return true;}) ->whenCalledDo('isDisponible', function() {return false;}) ; diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index e382b64b215035cbc4bbd53c988eb23f43c14493..b556c4c4af290856b214d86b6edb879dbbb35d3a 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -1433,6 +1433,7 @@ class TemplatesImageWidgetTest extends TemplatesIntonationTestCase { + class TemplatesAdminToolsWidgetTest extends TemplatesIntonationTestCase { /** @test */ @@ -1451,6 +1452,7 @@ class TemplatesAdminToolsWidgetTest extends TemplatesIntonationTestCase { + class TemplatesCreditsWidgetTest extends TemplatesIntonationTestCase { /** @test */ @@ -1540,7 +1542,8 @@ class TemplatesRecordsWidgetTest extends TemplatesIntonationTestCase { $this->fixture('Class_Notice', ['id' => 456, - 'titre_principal' => 'Rahan']); + 'titre_principal' => 'Rahan', + 'auteur_principal' => 'Roger Lécureux']); $this->dispatch('/opac/index/index/id_profil/72', true); $this->assertXPathContentContains('//div', 'Rahan');