diff --git a/library/ZendAfi/Feed/SearchResultHeader.php b/library/ZendAfi/Feed/SearchResultHeader.php new file mode 100644 index 0000000000000000000000000000000000000000..612c725ec96ce36d7cc01b1aef665f4641188afb --- /dev/null +++ b/library/ZendAfi/Feed/SearchResultHeader.php @@ -0,0 +1,93 @@ +<?php +/** + * Copyright (c) 2012, 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 ZendAfi_Feed_SearchResultHeader { + use Trait_Translator; + + protected + $_header, + $_criterias = [], + $_description = ''; + + public function __construct($header) { + $this->_header = $header; + } + + public function visitSearchResult($search_result) { + $this->_description = $this->_plural($search_result->getRecordsCount(), + "Aucun résultat trouvé", + "Il y a %d résultat", + "Il y a %d résultats", + $search_result->getRecordsCount()); + + $search_result->acceptCriteresVisitor($this); + $this->_header->description = $this->_description + . '. ' + . implode('. ', $this->_criterias); + } + + + public function visitNoExtension($no_extension) {} + + public function hasErreur() {return false;} + + + public function setErreur($error) { + $this->addCriteria($this->_('Erreur'), $error); + } + + + public function visitSearchUrl($url) { + $this->_header->link = Class_Url::absolute($url); + } + + + public function visitExpression($expression) { + $this->_description .= ' ' . $this->_('pour: ') . $expression; + $this->_header->title = $this->_('Recherche') . ': ' . $expression; + } + + + public function visitFilterOnDomain($criterias) { } + + public function visitDomain($criterias) {} + + + public function visitDigitalLib($digital_lib) { + if ($digital_lib) + $this->addCriteria($this->_('Bibliothèque numérique seulement')); + } + + + public function visitTri($tri, $libelle) { + $this->addCriteria($this->_('Trié par: ') . $libelle); + } + + + public function visitFacette($facette) { + $facette = new Class_Notice_Facette($facette); + $this->addCriteria($facette->getCodeRubriqueLibelle(), $facette->getLibelleFacette()); + } + + + protected function addCriteria($name, $value = null) { + $this->_criterias []= $name . ($value ? (': ' . $value) : ''); + } +} \ No newline at end of file