diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php index 68fcc879af570c8e7769c8592fd9686283af3181..533e27f4bdb8b2916d0c94a3b1c49dc6f35f5ca2 100644 --- a/application/modules/opac/controllers/NoticeajaxController.php +++ b/application/modules/opac/controllers/NoticeajaxController.php @@ -118,6 +118,8 @@ class NoticeAjaxController extends ZendAfi_Controller_Action { $notice->updateFacetsFromExemplaires() ->save(); + $exemplaires = (new Class_CommSigb())->getDispoExemplaires($exemplaires); + $this->_sendResponseWithScripts($this->view->Notice_Exemplaires($exemplaires, $nb_notices_oeuvre, $display)); } @@ -135,10 +137,12 @@ class NoticeAjaxController extends ZendAfi_Controller_Action { $session = Zend_Registry::get('session'); $cond['id_bib'] = $session->id_bibs; - if ($exemplaires = Class_Exemplaire::findAllBy(array_filter($cond))) - return $exemplaires; + $items = ($exemplaires = Class_Exemplaire::findAllBy(array_filter($cond))) + ? $exemplaires + : Class_Exemplaire::findAllBy($params); - return Class_Exemplaire::findAllBy($params); + return (new Class_Profil_ItemsFilter()) + ->select(Class_Profil::getCurrentProfil(), $items); } @@ -480,4 +484,11 @@ class NoticeAjaxController extends ZendAfi_Controller_Action { $this->getResponse()->setHeader('Content-Type', 'text/html;charset=utf-8'); $this->getResponse()->setBody($data); } + + + public function resourcesAction() { + return $this->notice->isRessourceNumerique() + ? $this->_forward('resnumeriques') + : $this->_forward('exemplaires'); + } } \ No newline at end of file diff --git a/library/Class/Exemplaire.php b/library/Class/Exemplaire.php index ff22fc58a85d2dda4419b5dce43a5b7c4367f49d..5a46de8ea8bc95ce042d56620ee2f22d1d3bac5c 100644 --- a/library/Class/Exemplaire.php +++ b/library/Class/Exemplaire.php @@ -92,7 +92,8 @@ class Class_Exemplaire extends Storm_Model_Abstract { 'date_nouveaute' => '', 'to_delete' => false, 'id_int_bib' => 0, - 'type' => Class_Notice::TYPE_BIBLIOGRAPHIC]; + 'type' => Class_Notice::TYPE_BIBLIOGRAPHIC, + 'cote' => '']; protected $_sigb_exemplaire; diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index 9d5b547f6e9503f561d6d9724474e10cd19d870f..9ae8a69969207a00853bb9fb41e9b5e8ed99b14a 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -84,6 +84,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'img class image_widget' => 'img-fluid', 'img class d-block' => '', 'img class card-img-top' => '', + 'img class img-thumbnail' => '', 'dl' => 'row', 'dt' => 'col-3', 'dd' => 'col-9', @@ -114,7 +115,8 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'next' => 'class fas fa-chevron-right', 'rss' => 'class fas fa-rss', 'embed' => 'class fas fa-code', - 'delete' => 'class fas fa-minus' + 'delete' => 'class fas fa-minus', + 'tag' => 'class fas fa-tag' ] ]; diff --git a/library/templates/Intonation/Library/View/Wrapper/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/Abstract.php new file mode 100644 index 0000000000000000000000000000000000000000..e44d8620dc53821fcae4ede122c6d66671446526 --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/Abstract.php @@ -0,0 +1,41 @@ +<?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_View_Wrapper_Abstract { + use Trait_Translator; + + protected + $_view, + $_model; + + + public function setView($view) { + $this->_view = $view; + return $this; + } + + + public function setModel($record) { + $this->_model = $record; + return $this; + } +} \ 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 926ac63b972d0498ada15e7f76a67e148f3c945b..ebd88bcd7256575b956f5c3ca495d172bf8ce66d 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Article.php +++ b/library/templates/Intonation/Library/View/Wrapper/Article.php @@ -20,25 +20,7 @@ */ -class Intonation_Library_View_Wrapper_Article { - use Trait_Translator; - - protected - $_view, - $_model; - - - public function setView($view) { - $this->_view = $view; - return $this; - } - - - public function setModel($article) { - $this->_model = $article; - return $this; - } - +class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wrapper_Abstract { public function getTitle() { return $this->_model->getTitre(); diff --git a/library/templates/Intonation/Library/View/Wrapper/Item.php b/library/templates/Intonation/Library/View/Wrapper/Item.php new file mode 100644 index 0000000000000000000000000000000000000000..4e417115f94306f0e411e313abbc515e32fd4c3c --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/Item.php @@ -0,0 +1,56 @@ +<?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_View_Wrapper_Item extends Intonation_Library_View_Wrapper_Abstract { + public function getTitle() { + return $this->_model->getBibLibelle() . ' : ' . $this->_model->getCodeBarres(); + } + + + public function getAuthor() { + return ''; + } + + + public function getDescription() { + $badges = []; + $badges [] = ['tag' => 'span', + 'class' => $this->_model->isDisponible(true) ? 'success' : 'danger', + 'text' => $this->_model->getDisponibilite()]; + return $this->_view->renderBadges($badges); + } + + + public function getDescriptionTitle() { + return ''; + } + + + public function getUrl() { + return ''; + } + + + public function getAuthorLink() { + return ''; + } +} diff --git a/library/templates/Intonation/Library/View/Wrapper/Record.php b/library/templates/Intonation/Library/View/Wrapper/Record.php index 940560aaa123da26f84de9aaaad0b518eddb1e6a..b153777ce2916c1a8afab5363bcb0a7f8f3aeb86 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record.php @@ -20,25 +20,7 @@ */ -class Intonation_Library_View_Wrapper_Record { - use Trait_Translator; - - protected - $_view, - $_model; - - - public function setView($view) { - $this->_view = $view; - return $this; - } - - - public function setModel($record) { - $this->_model = $record; - return $this; - } - +class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wrapper_Abstract { public function getTitle() { return $this->_model->getTitrePrincipal(' ') . $this->_model->getSubtitle(); diff --git a/library/templates/Intonation/View/Abstract/Carousel.php b/library/templates/Intonation/View/Abstract/Carousel.php index 30fd7a17e4ee0b808cf571788bbdeb654ddecbe7..13cb3e471bdadedf2da48a3527099da82e96e06c 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_' . md5(rand(1000, 9999)); + $id = 'carousel_' . uniqueid(); $content = $this->_indicators($this->_numberOfPages($collection), $id) . $this->_carouselInner($collection, $id, $callback) @@ -55,13 +55,13 @@ abstract class Intonation_View_Abstract_Carousel extends ZendAfi_View_Helper_Bas protected function _carouselInner($collection, $id, $callback) { - $html = array_filter($collection->injectInto([], function($html, $element) use ($callback) - { - $html [] = $this->_tag('div', - $callback($element), - ['class' => 'carousel-item'. (0 == count($html) ? ' active' : '')]); - return $html; - })); + $html = $collection->injectInto([], function($html, $element) use ($callback) + { + $html [] = $this->_tag('div', + $callback($element), + ['class' => 'carousel-item'. (0 == count($html) ? ' active' : '')]); + return $html; + }); return $this->_tag('div', implode($html), diff --git a/library/templates/Intonation/View/Cardify.php b/library/templates/Intonation/View/Cardify.php index 7974ee60bcf42d4af2c16c16fd7c6e444ffcddc4..1eb372a59e6257bb37858658550034836fde002c 100644 --- a/library/templates/Intonation/View/Cardify.php +++ b/library/templates/Intonation/View/Cardify.php @@ -42,66 +42,6 @@ class Intonation_View_Cardify extends ZendAfi_View_Helper_BaseHelper { protected function _card($element) { - $content = [$title = $this->_tag('h5', - $element->getTitle(), - ['class' => 'card-title'])]; - - if ($author_name = $element->getAuthor()) - $content [] = $this->_tag('h6', - $element->getAuthorIco() - . $author_name, - ['class' => 'card-subtitle text-muted']); - - if ($summary = $element->getDescription()) - $content [] = $this->_tag('p', - $element->getDescription(), - ['title' => strip_tags($element->getDescriptionTitle()), - 'class' => 'card-text']); - - $links = [$this->view->tagAnchor($element->getUrl(), - $element->getLinkText(), - ['title' => $element->getLinkTitle(), - 'class' => 'card-link'])]; - - if ($author_link = $element->getAuthorLink()) - $links [] = $this->view->tagAnchor($author_link, - $this->_('Voir l\'auteur'), - ['title' => $element->getAuthorLinkTitle(), - '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']); - } - - - protected function _getMainContent($element, $title) { - return [$this->_tag('div', - $this->_tag('div', - - $this->_tag('h4', - $this->view->tagAnchor($element->getUrl(), - $element->getTitle(), - ['title' => $element->getLinkTitle()]) - . $this->_tag('p', - $element->getAuthorIco() - . $this->view->authorAnchor($element->getAuthor(), - [], - ['title' => $element->getAuthorLinkTitle()])), - ['class' => 'card-title']), - ['class' => 'col-9 order-2']) - . $this->_tag('div', - Class_Template::current() - ->getIco($this->view, - $element->getDocType(), - 'doc_types', - ['title' => $this->_('Type de document : %s', $element->getDocTypeLabel())]), - ['class' => 'col-3 order-1']), - ['class' => 'row align-items-center justify-content-between']), - - ]; + return $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 new file mode 100644 index 0000000000000000000000000000000000000000..102be11347bf5d0fbc471dd2353b1aaef821ebcd --- /dev/null +++ b/library/templates/Intonation/View/CardifyOnlyDescription.php @@ -0,0 +1,62 @@ +<?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_CardifyOnlyDescription extends ZendAfi_View_Helper_BaseHelper { + public function cardifyOnlyDescription($element) { + $content = [$title = $this->_tag('h5', + $element->getTitle(), + ['class' => 'card-title'])]; + + if ($author_name = $element->getAuthor()) + $content [] = $this->_tag('h6', + $element->getAuthorIco() + . $author_name, + ['class' => 'card-subtitle text-muted']); + + if ($summary = $element->getDescription()) + $content [] = $this->_tag('p', + $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(), + 'class' => 'card-link']); + + if ($author_link = $element->getAuthorLink()) + $links [] = $this->view->tagAnchor($author_link, + $this->_('Voir l\'auteur'), + ['title' => $element->getAuthorLinkTitle(), + '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']); + + } +} \ No newline at end of file diff --git a/library/templates/Intonation/View/Notice/Exemplaires.php b/library/templates/Intonation/View/Notice/Exemplaires.php new file mode 100644 index 0000000000000000000000000000000000000000..dbbce86b6efe6e0c4b384df011b939ab3e62c45e --- /dev/null +++ b/library/templates/Intonation/View/Notice/Exemplaires.php @@ -0,0 +1,50 @@ +<?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_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); + }; + + $elements = array_map(function($element) + { + return (new Intonation_Library_View_Wrapper_Item) + ->setView($this->view) + ->setModel($element); + }, $exemplaires); + + 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/RenderArticleBadges.php b/library/templates/Intonation/View/RenderArticleBadges.php index d96cf8f5edb9a35d80ffb6702f949abf8975c903..7ecfa5661893f61dae2114691df599d7511d42eb 100644 --- a/library/templates/Intonation/View/RenderArticleBadges.php +++ b/library/templates/Intonation/View/RenderArticleBadges.php @@ -91,27 +91,6 @@ class Intonation_View_RenderArticleBadges extends ZendAfi_View_Helper_BaseHelper } } - $instances = []; - foreach($badges as $data) - if ($data['text']) - $instances [] = new Class_Entity($data); - - $instances = array_map(function($badge) - { - $attribs = ['title' => $badge->gettitle(), - 'class' => 'badge badge-' . $badge->getclass()]; - - if ($url = $badge->geturl()) - $attribs['href'] = $url; - - return $this->_tag($badge->gettag(), - $badge->gettext(), - $attribs); - }, - $instances); - - return $this->_tag('p', - implode($instances), - ['class' => 'badge-group']); + return $this->view->renderBadges($badges); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderBadges.php b/library/templates/Intonation/View/RenderBadges.php new file mode 100644 index 0000000000000000000000000000000000000000..4ef78684ff0a8ed486872de825c15a010638f4bb --- /dev/null +++ b/library/templates/Intonation/View/RenderBadges.php @@ -0,0 +1,49 @@ +<?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_RenderBadges extends ZendAfi_View_Helper_BaseHelper { + public function renderBadges($badges) { + $instances = []; + foreach($badges as $data) + if ($data['text']) + $instances [] = new Class_Entity($data); + + $instances = array_map(function($badge) + { + $attribs = ['title' => $badge->gettitle(), + 'class' => 'badge badge-' . $badge->getclass()]; + + if ($url = $badge->geturl()) + $attribs['href'] = $url; + + return $this->_tag($badge->gettag(), + $badge->gettext(), + $attribs); + }, + $instances); + + return $this->_tag('p', + implode($instances), + ['class' => 'badge-group']); + } +} +?> \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderList.php b/library/templates/Intonation/View/RenderList.php new file mode 100644 index 0000000000000000000000000000000000000000..09f71b141012f55582b9adaddc985e22d015a852 --- /dev/null +++ b/library/templates/Intonation/View/RenderList.php @@ -0,0 +1,38 @@ +<?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_RenderList extends ZendAfi_View_Helper_BaseHelper { + + public function renderList($collection, $callback) { + $html = $collection + ->injectInto('', function($html, $element) use ($callback) + { + return $html . $this->_tag('div', + $callback($element), + ['class' => 'list-group-item']); + }); + + return $this->_tag('div', + $html, + ['class' => 'list-group']); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderRecord.php b/library/templates/Intonation/View/RenderRecord.php index 2ba73ab00d3d09f937f3e7a8f00c917a8e5fecfe..770529c1244245193da96ca8bdc562624c230fff 100644 --- a/library/templates/Intonation/View/RenderRecord.php +++ b/library/templates/Intonation/View/RenderRecord.php @@ -43,16 +43,57 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { 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'])]; + return $this->_tag('div', $this->_tag('div', - $this->_tag('h1', - $this->view->titre, - ['class' => 'display-4']) - . $this->view->tagAnchor($this->_wrapped->getAuthorLink(), - $this->_('Voir l\'auteur'), - ['title' => $this->_wrapped->getAuthorLinkTitle(), - 'class' => 'card-link']), - ['class' => 'container']), - ['class' => 'col-12 jumbotron jumbotron-fluid']); + $this->_tag('div', + implode($html), + ['class' => 'row justify-content-center']), + ['class' => 'container-fluid']), + ['class' => 'jumbotron jumbotron-fluid w-100 no_overflow']); + } + + + protected function _recordThumbnail() { + $image = $this->_wrapped->getPicture(); + return $this->view->tagImg($image, + ['class' => 'img-thumbnail w-100', + 'alt' => ($image + ? $this->_('Couverture de %s', + $this->view->titre) + : $this->_('Aïe, aïe, aïe ! Pas d\'image pour "%s".', + $this->_wrapped->getTitle()))]); } + + + protected function _recordItems() { + $items_id = 'items-'.uniqid(); + Class_ScriptLoader::getInstance()->addJQueryReady(sprintf('$("#%s").load("%s")', + $items_id, + $this->view->url(['controller' => 'noticeajax', + 'action' => 'resources', + 'id' => $this->_record->getId()]))); + return $this->_tag('div', '', ['id' => $items_id]); + } + + + + 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); + } + + + + } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderRecordBadges.php b/library/templates/Intonation/View/RenderRecordBadges.php index 2d5484a3715214068587146a150575273dc03d63..9d032c638ebf1c8de14c72565f2c0c522671049f 100644 --- a/library/templates/Intonation/View/RenderRecordBadges.php +++ b/library/templates/Intonation/View/RenderRecordBadges.php @@ -66,6 +66,18 @@ class Intonation_View_RenderRecordBadges extends ZendAfi_View_Helper_BaseHelper 'title' => $this->_('Note moyenne des avis des abonnés sur le document "%s".', $record->getTitrePrincipal(' '))]; } + + foreach($this->_getFacets($record) as $facet) { + $badges []= ['tag' => 'a', + 'class' => 'primary', + 'text' => Class_Template::current()->getIco($this->view, + 'tag', + 'utils') . $facet->getLabel(), + 'title' => $facet->getTitle(), + 'url' => $facet->getUrlForLink()]; + } + + $instances = []; foreach($badges as $data) if ($data['text']) @@ -90,4 +102,21 @@ class Intonation_View_RenderRecordBadges extends ZendAfi_View_Helper_BaseHelper ['class' => 'badge-group']); } + + + + protected function _getFacets($record) { + $codes = [Class_CodifTags::CODE_FACETTE, + Class_CodifDewey::CODE_FACETTE, + Class_CodifPcdm4::CODE_FACETTE, + Class_CodifMatiere::CODE_FACETTE, + Class_CodifGenre::CODE_FACETTE, + Class_CodifCentreInteret::CODE_FACETTE]; + $facets =[]; + foreach($codes as $code) { + $facets = array_merge($facets, $record->getChampNotice($code, $record->getFacettes())); + } + + return $facets; + } } \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index 2a63f2ddb1e3734564386f2fbaf89f734bb27260..e382b64b215035cbc4bbd53c988eb23f43c14493 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -1716,15 +1716,60 @@ class TemplatesCmsArticleViewTest extends TemplatesIntonationTestCase { class TemplatesViewRecordTest extends TemplatesIntonationTestCase { + public function setUp() { + parent::setUp(); + $this->fixture('Class_CodifGenre', + ['id' => 13, + 'libelle' => 'Roman']); + + $this->fixture('Class_CodifMatiere', + ['id' => 12, + 'libelle' => 'Horreur']); + - /** @test */ - public function dispatchViewRecordShouldDisplayPsycho() { $this->fixture('Class_Notice', ['id' => 456, - 'titre_principal' => 'Psycho']); + 'titre_principal' => 'Psycho', + 'facettes' => 'G13 M12']); $this->dispatch('/opac/recherche/viewnotice/id/456/id_profil/72'); + } + + + /** @test */ + public function dispatchViewRecordShouldDisplayPsycho() { $this->assertXPathContentContains('//h1', 'Psycho'); } + + + /** @test */ + public function bagesShouldContainsTopicRoman() { + $this->assertXPathContentContains('//a[contains(@class, "badge")][contains(@href, "/recherche/simple/code_rebond/G13")]', 'Roman'); + } +} + + + +class TemplatesDispatchNoticeAjaxResourcesTest extends TemplatesIntonationTestCase { + /** @test */ + public function shouldDisplayItems() { + $this->fixture('Class_Notice', + ['id' => 34, + 'titre_principal' => 'Psycho', + ]); + + $this->fixture('Class_Exemplaire', + ['id' => 12, + 'id_notice' => 34 + ]); + + $this->fixture('Class_Exemplaire', + ['id' => 12, + 'id_notice' => 34 + ]); + + $this->dispatch('/noticeajax/resources/id/34/id_profil/72'); + $this->assertXPath('//div', $this->_response->getBody()); + } } \ No newline at end of file