From f75264798f38254f74d6c53f41a0f8a1064ccec5 Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Wed, 9 Jan 2019 15:03:23 +0100 Subject: [PATCH] dev #64573 start record page rendering --- .../opac/controllers/NoticeajaxController.php | 17 ++++- library/Class/Exemplaire.php | 3 +- .../templates/Intonation/Library/Settings.php | 4 +- .../Library/View/Wrapper/Abstract.php | 41 ++++++++++++ .../Library/View/Wrapper/Article.php | 20 +----- .../Intonation/Library/View/Wrapper/Item.php | 56 +++++++++++++++++ .../Library/View/Wrapper/Record.php | 20 +----- .../Intonation/View/Abstract/Carousel.php | 16 ++--- library/templates/Intonation/View/Cardify.php | 62 +------------------ .../View/CardifyOnlyDescription.php | 62 +++++++++++++++++++ .../Intonation/View/Notice/Exemplaires.php | 50 +++++++++++++++ .../Intonation/View/RenderArticleBadges.php | 23 +------ .../Intonation/View/RenderBadges.php | 49 +++++++++++++++ .../templates/Intonation/View/RenderList.php | 38 ++++++++++++ .../Intonation/View/RenderRecord.php | 59 +++++++++++++++--- .../Intonation/View/RenderRecordBadges.php | 29 +++++++++ tests/scenarios/Templates/TemplatesTest.php | 51 ++++++++++++++- 17 files changed, 454 insertions(+), 146 deletions(-) create mode 100644 library/templates/Intonation/Library/View/Wrapper/Abstract.php create mode 100644 library/templates/Intonation/Library/View/Wrapper/Item.php create mode 100644 library/templates/Intonation/View/CardifyOnlyDescription.php create mode 100644 library/templates/Intonation/View/Notice/Exemplaires.php create mode 100644 library/templates/Intonation/View/RenderBadges.php create mode 100644 library/templates/Intonation/View/RenderList.php diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php index 68fcc879af5..533e27f4bdb 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 ff22fc58a85..5a46de8ea8b 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 9d5b547f6e9..9ae8a699692 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 00000000000..e44d8620dc5 --- /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 926ac63b972..ebd88bcd725 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 00000000000..4e417115f94 --- /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 940560aaa12..b153777ce29 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 30fd7a17e4e..13cb3e471bd 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 7974ee60bcf..1eb372a59e6 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 00000000000..102be11347b --- /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 00000000000..dbbce86b6ef --- /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 d96cf8f5edb..7ecfa566189 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 00000000000..4ef78684ff0 --- /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 00000000000..09f71b14101 --- /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 2ba73ab00d3..770529c1244 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 2d5484a3715..9d032c638eb 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 2a63f2ddb1e..e382b64b215 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 -- GitLab