diff --git a/.gitattributes b/.gitattributes index 1ffdda707a54818611da98bc6a45f1c090802253..c4670d88afbf82263ffde640816fafef0d82faf6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -706,6 +706,7 @@ application/modules/telephone/views/scripts/recherche/bibliotheque.phtml -text application/modules/telephone/views/scripts/recherche/biographie.phtml -text application/modules/telephone/views/scripts/recherche/detail.phtml -text application/modules/telephone/views/scripts/recherche/exemplaires.phtml -text +application/modules/telephone/views/scripts/recherche/frbr.phtml -text application/modules/telephone/views/scripts/recherche/grandeimage.phtml -text application/modules/telephone/views/scripts/recherche/index.phtml -text application/modules/telephone/views/scripts/recherche/pickup-location.phtml -text @@ -2082,6 +2083,7 @@ library/ZendAfi/View/Helper/FileInfos.php -text library/ZendAfi/View/Helper/FonctionsAdmin.php -text library/ZendAfi/View/Helper/FormRadioButtons.php -text library/ZendAfi/View/Helper/FormUrl.php -text +library/ZendAfi/View/Helper/Frbr.php -text library/ZendAfi/View/Helper/GallicaPlayer.php -text library/ZendAfi/View/Helper/HistoriqueRecherche.php -text library/ZendAfi/View/Helper/HumanDate.php -text diff --git a/application/modules/telephone/controllers/RechercheController.php b/application/modules/telephone/controllers/RechercheController.php index e6544ff5b0edc771c230db99d2764eeb8965af98..fd9dfa6a6f709bbbe27bb5c61745a35a61b3fe61 100644 --- a/application/modules/telephone/controllers/RechercheController.php +++ b/application/modules/telephone/controllers/RechercheController.php @@ -162,11 +162,23 @@ class Telephone_RechercheController extends RechercheController { } + public function frbrAction() { + $this->view->notice = Class_Notice::getLoader()->find($this->_getParam('id')); + + + + } + + + public function bibliothequeAction() { $this->view->bib = Class_Bib::getLoader()->find($this->_getParam('id')); } + + + protected function _loadUrlRetourForExemplaire($id_exemplaire) { $exemplaire = Class_Exemplaire::getLoader()->find($id_exemplaire); $this->view->url_retour = $this->view->url(array('controller' => 'recherche', @@ -193,5 +205,5 @@ class Telephone_RechercheController extends RechercheController { ->setParam('b', $params['b']) ->setParam('e', $params['e']) ->setParam('a', $params['a']); - } -} + }} + diff --git a/application/modules/telephone/views/scripts/recherche/frbr.phtml b/application/modules/telephone/views/scripts/recherche/frbr.phtml new file mode 100644 index 0000000000000000000000000000000000000000..8e28f566b6d1392387743e0c83da930b4b2cbdc8 --- /dev/null +++ b/application/modules/telephone/views/scripts/recherche/frbr.phtml @@ -0,0 +1,9 @@ +<?php +echo $this->toolbar($this->_("Notice liées"), array('action' => 'vienotice') ,true); +echo '<h1>'.$this->notice->getTitrePrincipal().'</h1>'; + +echo $this->frbr($this->notice); +?> + + + diff --git a/library/ZendAfi/View/Helper/Frbr.php b/library/ZendAfi/View/Helper/Frbr.php new file mode 100644 index 0000000000000000000000000000000000000000..87b27b7d136a772774fce1beec72e19a4c84d3e4 --- /dev/null +++ b/library/ZendAfi/View/Helper/Frbr.php @@ -0,0 +1,111 @@ +<?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 + */ + +class ZendAfi_View_Helper_Frbr extends Zend_View_Helper_HtmlElement{ + const NO_RESULT_MESSAGE = 'Aucun lien n\'a été trouvé'; + + /** + * Retourne les notices liées + * + * @param $model Class_Notice + * @return string + */ + public function frbr($model) { + $this->notice_html = new Class_NoticeHtml(); + $sourceLinks = $model->getLinksAsSource(); + $targetLinks = $model->getLinksAsTarget(); + + if (0 == count($sourceLinks) and 0 == count($targetLinks)) { + + return self::NO_RESULT_MESSAGE; } + + + $html = ''; + foreach ($this->_getLinksBySourceTypes($sourceLinks) as $label => $links) + $html .= $this->_getTargetTypeLinks($label, $links); + + foreach ($this->_getLinksByTargetTypes($targetLinks) as $label => $links) + $html .= $this->_getSourceTypeLinks($label, $links); + return $html; + } + + + protected function _getLinksBySourceTypes($links) { + return $this->_getLinksByType($links, function ($link) { + return $link->getTypeLabelFromSource(); + }); + } + + + protected function _getLinksByTargetTypes($links) { + return $this->_getLinksByType($links, function ($link) { + return $link->getTypeLabelFromTarget(); + }); + } + + + protected function _getLinksByType($links, $callback) { + $byTypes = []; + foreach ($links as $link) { + $typeLabel = $callback($link); + if (!array_key_exists($typeLabel, $byTypes)) + $byTypes[$typeLabel] = []; + + $byTypes[$typeLabel][] = $link; + } + return $byTypes; + } + + + protected function _getTargetTypeLinks($label, $links) { + return $this->_getTypeLinks($label, $links, function($link) { + return $link->getTargetNotice(); + }); + } + + + protected function _getSourceTypeLinks($label, $links) { + return $this->_getTypeLinks($label, $links, function($link) { + return $link->getSourceNotice(); + }); + } + + + protected function _getTypeLinks($label, $links, $callback) { + $html = ''; + if (!$links) + return $html; + + $html .= '<div class="notice_info_titre">' . $label . '</div>'; + $notices = []; + foreach ($links as $link) + $notices[] = $callback($link); + + $html .= $this->notice_html->getListeNotices($notices, $this->view); + + return $html; + } + + +} + + +?>