diff --git a/VERSIONS_WIP/14141 b/VERSIONS_WIP/14141 new file mode 100644 index 0000000000000000000000000000000000000000..0a6edb228747fdf4c67dd65e3176447af1aad544 --- /dev/null +++ b/VERSIONS_WIP/14141 @@ -0,0 +1 @@ + - ticket #14141 : Résultat de recherche : ajout d'un flag de disponibilité sur les documents. \ No newline at end of file diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index 994fe77db95508dc045f5b4011a395b544224034..3498df89531c852ceca3b7e0737d6654b3814295 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -22,7 +22,6 @@ class RechercheController extends ZendAfi_Controller_Action { protected $moteur, - $liste, $preferences; @@ -60,10 +59,8 @@ class RechercheController extends ZendAfi_Controller_Action { public function simpleAction() { - if ($this->view->statut == "saisie") { - $this->_redirect('opac/recherche/saisie'); - return; - } + if ($this->view->statut == "saisie") + return $this->_redirect('opac/recherche/saisie'); $params = $this->_request->getParams(); if (isset($params['q'])) { @@ -82,6 +79,7 @@ class RechercheController extends ZendAfi_Controller_Action { $search_start_time = microtime(true); $criteres_recherche = $this->newCriteresRecherches($params); + if ($this->view->statut == 'guidee') $criteres_recherche->updateRubrique('guidee'); @@ -92,18 +90,30 @@ class RechercheController extends ZendAfi_Controller_Action { && $ig->isEnabled()) $ig->logRecord($this->view->searchInspector($this->moteur)); - if ('json' == $this->_getParam('format', '')) { - $this->_renderJsonResult($search_result); - return; - } + if ('json' == $this->_getParam('format', '')) + return $this->_renderJsonResult($search_result); - if ('atom' == $this->_getParam('format', '')) { - $this->_renderAtomResult($search_result); - return; - } + if ('atom' == $this->_getParam('format', '')) + return $this->_renderAtomResult($search_result); - $this->_renderHtmlResult($search_result); - $this->view->search_duration = microtime(true) - $search_start_time; + $this->getFrontController()->getRouter()->getCurrentRoute() + ->match(str_replace(BASE_URL, + '', + $this->view->url($criteres_recherche->getCriteres()))); + + $this->view->titre = $this->getTitreRechercheSimple($criteres_recherche); + + if($criteres_recherche->getPertinence()) + $this->view->titre .= $this->_(' (recherche élargie triée par pertinence)'); + + $this->preferences['liste_format'] = $this->_getParam('liste_format', $this->preferences['liste_format']); + + if (!$search_result->isError()) + $this->addHistoRecherche(1, $criteres_recherche); + + $this->view->search_result = $search_result + ->setDuration(microtime(true) - $search_start_time) + ->setSettings($this->preferences); } @@ -120,24 +130,6 @@ class RechercheController extends ZendAfi_Controller_Action { } - protected function _renderHtmlResult($search_result) { - $criteres_recherche = $search_result->getCriteresRecherche(); - $this->getFrontController()->getRouter()->getCurrentRoute() - ->match(str_replace(BASE_URL, - '', - $this->view->url($criteres_recherche->getCriteres()))); - - $this->view->titre = $this->getTitreRechercheSimple($criteres_recherche); - - - $this->view->current_domain = $criteres_recherche->getCatalogue(); - - $this->showDomainBreadcrumbOnDomainBrowsing(); - $this->showCVSSearchResults($criteres_recherche); - $this->renderResultatRecherche($search_result); - } - - protected function _renderAtomResult($search_result) { $this->getHelper('ViewRenderer')->setNoRender(); @@ -166,30 +158,6 @@ class RechercheController extends ZendAfi_Controller_Action { } - protected function showDomainBreadcrumbOnDomainBrowsing() { - $id_module = $this->_getParam('id_module'); - if (($config = Class_Profil::getCurrentProfil()->getLocalModuleAccueilConfig($id_module)) - && ($config['type_module'] == 'DOMAIN_BROWSER')) { - $this->view->show_domain_browser = true; - $this->view->domain_id_module = $id_module; - $this->view->domain_preferences = $config['preferences']; - } - } - - - protected function showCVSSearchResults($criteres_recherche) { - $preferences = Class_Profil::getCurrentProfil()->getSearchResultSettings(); - $this->view->accessCVS = false; - if ( (new Class_AdminVar_CVS())->isCVSAccessOrDemo() - && !$preferences['cvs_display_position'] == 0) { - $this->view->accessCVS = true; - - Class_ScriptLoader::getInstance() - ->addJQueryReady("$('<div></div>').load('".$this->view->url($criteres_recherche->getCVSUrlCriteresWithFacettes(),null,true)."').appendTo($('.cvs_container'))"); - } - } - - protected function getTitreRechercheSimple($criteres_recherche) { if($title = $this->getTitleForPage($criteres_recherche)) return $title; @@ -251,42 +219,6 @@ class RechercheController extends ZendAfi_Controller_Action { } - public function renderResultatRecherche($search_result) { - $criteres_recherche = $search_result->getCriteresRecherche(); - - $this->view->criteres_recherche = $criteres_recherche; - $this->view->url_facette=$this->view->url($criteres_recherche->getUrlCriteresWithFacettes(), - null, - true); - $this->view->url_retour = $this->view->url($criteres_recherche->getUrlRetourListe()); - $this->view->search_result = $search_result; - $this->view->tags = []; - $this->view->facettes = []; - - if ($search_result->isError()) - return; - - $this->addHistoRecherche(1, $criteres_recherche); - - $facettes_and_tags = $search_result->fetchFacetsAndTags($this->preferences); - $facettes = $facettes_and_tags['facettes']; - $tags = $facettes_and_tags['tags']; - - $this->view->getHelper('PageContext')->setContextHelper('Notice_FacettesTypeDoc', - [$facettes]); - - $this->view->_current_module['preferences']['liste_format'] = $this->_getParam('liste_format', - $this->preferences['liste_format']); - - $this->view->is_pertinence = $criteres_recherche->getPertinence(); - $this->view->tri = $criteres_recherche->getTri(); - $this->view->facettes = $facettes; - $this->view->tags = $tags; - $this->view->bookmarks = $facettes_and_tags['bookmarks']; - $this->view->suggests = $facettes_and_tags['suggests']; - } - - public function avanceeAction() { $annexes = Class_CodifAnnexe::findAllBy(['invisible' => 0, 'order' => 'libelle']); diff --git a/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml b/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml index 57607f6b61c472f5b53828ce8a6e53bcaca66559..17c12220253400607b6ebdbdd4864aa47b73db08 100644 --- a/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml +++ b/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml @@ -1,145 +1,6 @@ <?php -$preferences = $this->_current_module["preferences"]; - -$hasFacettes = (1 == $preferences["facettes_actif"]) && $this->search_result->getRecordsCount(); -$hasTags = (1 == $preferences["tags_actif"]) && $this->search_result->getRecordsCount(); -$tagsPosition = $preferences["tags_position"]; - -if ($this->is_pertinence) { - $this->titre .= $this->_(" (recherche élargie triée par pertinence)"); -} - $this->openBoite($this->titre); -?> -<div class="resultats_page"> - <?php - echo $this->tagTriRecherche($this->criteres_recherche); - echo $this->tagTitreEtNombreDeResultats($this->search_result, $this->search_duration); - echo $this->tagNombreDePages($this->criteres_recherche->getPage()); - - if ($this->search_result->getRubrics() || $this->search_result->getBreadcrumb()) { - echo $this->render('recherche/guidee.phtml'); - } else { - echo $this->tagCriteresRecherche($this->criteres_recherche); - } - - if ($this->show_domain_browser) - echo $this->renderDomainBrowser($this->current_domain, - $this->domain_id_module, - $this->domain_preferences); - ?> - - <div class="recherche_actions"> - <span> - <?php - echo $this->tagAnchor($this->url($this->criteres_recherche->getUrlRetourRechercheInitiale(), null, true), - $this->_('Retour à la recherche initiale'), - ['title' => $this->_('Accéder au formulaire de recherche pré-rempli avec les critères actuels')]);?> - </span> - <span> - <?php echo $this->tagAnchor($this->url($this->criteres_recherche->getUrlNouvelleRecherche(), null, true), - $this->_('Nouvelle recherche'), - ['title' => $this->_('Lancer une recherche avec réinitialisation des paramètres')]); ?> - </span> - <?php - if ((int)$preferences['suggestion_achat'] == 1 && !Class_AdminVar::areSuggestionsDisabled()) - echo $this->tag('span', - $this->tagAnchor(['controller' => 'abonne', - 'action' => 'suggestion-achat'], - $this->_('Suggérer un achat'), - ['title' => $this->_('Envoyer une demande d\'achat de document')])); - ?> - <span class="print"> - <?php - echo $this->tagPrintLink($this->search_result->fetchRecords(), 'Notice_List'); - ?> - </span> - </div> - <?php echo $this->tagSearchExtension($this->criteres_recherche); ?> -</div> - -<?php +echo $this->Search_Header($this->search_result); $this->closeBoite(); -?> - - -<?php -$html_liste_notices = $this->listeNotices($this->search_result->fetchRecords(), - $this->search_result->getRecordsCount(), - $this->criteres_recherche->getPage(), - $preferences, - $this->criteres_recherche); - -$html_pager = $this->pager($this->search_result->getRecordsCount(), - $this->criteres_recherche->getPageSize(), - $this->criteres_recherche->getPage(), - array_merge($this->criteres_recherche->getUrlRetourListe(), - ['controller' => 'recherche', - 'action' => 'simple'])); - -$nuage_tags_title = $preferences["tags_message"] - ? $this->tag('h2', $preferences["tags_message"]) - : ''; - -$html_nuage_tags = $this->tag('div', - $nuage_tags_title - . $this->nuageTags($this->tags, null, $this->criteres_recherche), - ['class' => 'facette_outer nuage_outer']); - -$html_facettes = '<div class="facette_outer" style="margin-left:10px;margin-top:17px">'. - ($preferences["facettes_message"] - ? ('<h2>'.$preferences["facettes_message"].'</h2>') - : '') - . $this->facettes($this->facettes, - $preferences, - $this->criteres_recherche) - . '</div>'; -?> - - - -<div style="width:100%" class="conteneur_simple"> - - <?php - $html_result='<div class="resultat_recherche">'. - (!$preferences['cvs_autres_resultats'] == '' - ? '<h1>'.$preferences['cvs_autres_resultats'].'</h1>' - : ''); - - if (Class_AdminVar::displayPagerOnTop()) $html_result .= $html_pager; - $html_result .= $html_liste_notices; - if (Class_AdminVar::displayPagerOnBottom()) $html_result .= $html_pager; - $html_result .= '</div>'; - - $html_suggests = $this->suggests($this->suggests, $this->criteres_recherche); - $html_bookmarks = $this->bookmarks($this->bookmarks, $this->criteres_recherche, $preferences); - - $html_filters = ''; - if ($hasFacettes || $hasTags) { - $html_filters .= '<div class="filtre_recherche">'; - $html_filters .= $html_suggests; - $html_filters .= $html_bookmarks; - if ($hasTags && (1 == $tagsPosition)) $html_filters.= $html_nuage_tags; - if ($hasFacettes) $html_filters.= $html_facettes; - if ($hasTags && (2 == $tagsPosition)) $html_filters.= $html_nuage_tags; - $html_filters.= '</div>'; - } - ?> - <?php - $html_cvs=''; - if ($this->accessCVS) - $html_cvs .= '<div class="cvs_container position_'.$preferences['cvs_display_position'].'" style="display:none">'. - '<h1>'.$preferences['cvs_resultat_titre'].'</h1>'. - '</div>'; - - ?> - <?php - echo $this->Search_Result($preferences, $html_result, $html_filters, $html_cvs); - ?> - - <div class="clear"></div> -</div> - -<?php Class_ScriptLoader::getInstance() - ->addOPACScript('recherche') - ->addSkinStyleSheet('recherche'); ?> +echo $this->Search_Result($this->search_result); +?> \ No newline at end of file diff --git a/application/modules/telephone/views/scripts/recherche/simple.phtml b/application/modules/telephone/views/scripts/recherche/simple.phtml index abcca721d40c233497b051ffe78e67cb1a5c73d7..73acb99fa83bc114c769810bbd57c8cb7d8a504e 100644 --- a/application/modules/telephone/views/scripts/recherche/simple.phtml +++ b/application/modules/telephone/views/scripts/recherche/simple.phtml @@ -1,16 +1,19 @@ <ul data-role="listview"> <?php -echo $this->toolbar("Recherche", $this->url(array(), null, true)); -echo $this->tagTitreEtNombreDeResultats($this->search_result, $this->search_duration); +$criteria = $this->search_result->getCriteresRecherche(); +$settings = $this->search_result->getSettings(); + +echo $this->toolbar($this->_('Recherche'), $this->url([], null, true)); +echo $this->tagTitreEtNombreDeResultats($this->search_result, $this->search_result->getDuration()); echo $this->listeNotices($this->search_result->fetchRecords(), $this->search_result->getRecordsCount(), - $this->criteres_recherche->getPage(), - $this->preferences); + $criteria->getPage(), + $settings); echo $this->pager($this->search_result->getRecordsCount(), - $this->preferences["liste_nb_par_page"], - $this->criteres_recherche->getPage()); + $criteria->getPageSize(), + $criteria->getPage()); ?> </ul> diff --git a/library/Class/CriteresRecherche.php b/library/Class/CriteresRecherche.php index 13f47b790d0ccd70376a14cfd9f33e5e404127fd..0db437f09cfe9acc8d3bca0c6828bcb4c6cf7ae4 100644 --- a/library/Class/CriteresRecherche.php +++ b/library/Class/CriteresRecherche.php @@ -823,6 +823,11 @@ class Class_CriteresRecherche { } + public function getIdModule() { + return $this->getParam('id_module', 0); + } + + function updateRubrique($rubrique) { return $this->_params['rubrique']=$rubrique; } diff --git a/library/Class/MoteurRecherche/Result.php b/library/Class/MoteurRecherche/Result.php index ca7b2c8427f1833d05b4584957b0c41777bf1155..7cf041e9656adfcaf0516c5d882fecbbdfa9dd6f 100644 --- a/library/Class/MoteurRecherche/Result.php +++ b/library/Class/MoteurRecherche/Result.php @@ -33,7 +33,9 @@ class Class_MoteurRecherche_Result { $_error_message = '', $_records_query = '', $_facets, - $_criteres_recherche; + $_criteres_recherche, + $_duration, + $_settings; public function __construct($search_engine, $criteres_recherche) { $this->_criteres_recherche = $criteres_recherche; @@ -101,6 +103,11 @@ class Class_MoteurRecherche_Result { } + public function getRecords() { + return $this->_records; + } + + public function recordsDo($closure) { $this->fetchRecords(); array_map($closure, $this->_records); @@ -172,6 +179,26 @@ class Class_MoteurRecherche_Result { public function getWordCount() { return $this->_word_count; } -} -?> \ No newline at end of file + + public function getDuration() { + return $this->_duration; + } + + + public function setDuration($duration) { + $this->_duration = $duration; + return $this; + } + + + public function getSettings() { + return $this->_settings; + } + + + public function setSettings($settings) { + $this->_settings = $settings; + return $this; + } +} \ No newline at end of file diff --git a/library/Class/Notice.php b/library/Class/Notice.php index a987a5a9d1dcc74a9902c8dd7cfbf4cb3a79cdb3..028ba8b7baff0bd5eb15607d45ca04fd61316582 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -1676,6 +1676,7 @@ class Class_Notice extends Storm_Model_Abstract { return $enreg; } + public function hasExemplaireDisponible() { foreach ($this->getExemplaires() as $exemplaire) if ($exemplaire->isDisponible()) @@ -1683,6 +1684,35 @@ class Class_Notice extends Storm_Model_Abstract { return false; } + + public function getAvailabilityFromFacet() { + $existing = $this->getAvailableLibrariesFromFacet(); + return !empty($existing); + } + + + public function getAvailableLibrariesFromFacet() { + $existing = array_filter( + Class_Notice_Facette::parseFacettesFromNoticeField($this->getFacettes()), + function($facet) { + return $facet->isAvailability(); + }); + + $values = array_unique( + array_filter( + array_map(function($facet) + { + return $facet->getValue(); + }, + $existing))); + + if(!$values) + return []; + + return Class_Bib::findAllBy(['id_site' => $values]); + } + + public function hasExemplaireReservable() { foreach ($this->getExemplaires() as $exemplaire) if ($exemplaire->isReservable()) @@ -1792,7 +1822,6 @@ class Class_Notice extends Storm_Model_Abstract { $facettes []= $f; } - $facettes []= Class_CodifTypeDoc::CODE_FACETTE. $this->getTypeDoc(); $date_nouveaute = ""; diff --git a/library/Class/Notice/Facette.php b/library/Class/Notice/Facette.php index f82d93c8207b5773fdc024d1b1526f18deba6e0f..3335598fb256ae59caa49f162e0a45b210ead9dd 100644 --- a/library/Class/Notice/Facette.php +++ b/library/Class/Notice/Facette.php @@ -98,4 +98,9 @@ class Class_Notice_Facette { [Class_CodifThesaurus::fixedIdOf('LibraryNovelty'), Class_CodifThesaurus::fixedIdOf('AnnexeNovelty')]); } + + + public function isAvailability() { + return Class_Codification::CODE_AVAILABILITY == $this->getGroupCodeFromKey(); + } } \ No newline at end of file diff --git a/library/Class/Systeme/ModulesAppli.php b/library/Class/Systeme/ModulesAppli.php index 2c5bc6383b727bb68a6a379af7d6225bc56b52af..b092975a7ce68ac3e86f6bacee8d95f2033f36c3 100644 --- a/library/Class/Systeme/ModulesAppli.php +++ b/library/Class/Systeme/ModulesAppli.php @@ -32,6 +32,12 @@ class Class_Systeme_ModulesAppli extends Class_Systeme_ModulesAbstract { const LISTE_FORMAT_MUR = 4; const LISTE_FORMAT_CHRONO = 5; + const + CVS_NONE = 0, + CVS_TOP_OF_FACETS = 1, + CVS_BOTTOM_OF_FACETS = 2, + CVS_TOP_OF_RESULT = 3, + CVS_BOTTOM_OF_RESULT = 4; /** @@ -168,6 +174,16 @@ class Class_Systeme_ModulesAppli extends Class_Systeme_ModulesAbstract { } + public static function getCVSPosition() { + $instance = new static(); + return [Class_Systeme_ModulesAppli::CVS_NONE => $instance->_('Ne pas afficher'), + Class_Systeme_ModulesAppli::CVS_TOP_OF_FACETS => $instance->_('Afficher au dessus des facettes'), + Class_Systeme_ModulesAppli::CVS_BOTTOM_OF_FACETS => $instance->_('Afficher au dessous des facettes'), + Class_Systeme_ModulesAppli::CVS_TOP_OF_RESULT => $instance->_('Afficher au dessus des résultats'), + Class_Systeme_ModulesAppli::CVS_BOTTOM_OF_RESULT => $instance->_('Afficher au dessous des résultats')]; + } + + /** * @param string $type_module * @param string $action diff --git a/library/ZendAfi/Form/Configuration/SearchResult.php b/library/ZendAfi/Form/Configuration/SearchResult.php index 01c66c341675c27bc4571b83184b9773db9fa8ea..98503bd944e92da72a7584593f73391c1da4afcb 100644 --- a/library/ZendAfi/Form/Configuration/SearchResult.php +++ b/library/ZendAfi/Form/Configuration/SearchResult.php @@ -270,11 +270,7 @@ class ZendAfi_Form_Configuration_SearchResult extends ZendAfi_Form { ->addElement('select' , 'cvs_display_position', ['label' => $this->_('Affichage'), - 'multiOptions' => ['0' => $this->_('Ne pas afficher'), - '1' => $this->_('Afficher au dessus des facettes'), - '2' => $this->_('Afficher au dessous des facettes'), - '3' => $this->_('Afficher au dessus des résultats'), - '4' => $this->_('Afficher au dessous des résultats')]]) + 'multiOptions' => Class_Systeme_ModulesAppli::getCVSPosition()]) ->addElement('text', 'cvs_resultat_titre', ['label' => $this->_('Titre de la boîte'), diff --git a/library/ZendAfi/View/Helper/Bookmarks.php b/library/ZendAfi/View/Helper/Bookmarks.php index 78c80f1c5b8a927231b5b7be247c779c2ab17727..8d07da3285f25ec361a87fc4ca965e7cb857bc1d 100644 --- a/library/ZendAfi/View/Helper/Bookmarks.php +++ b/library/ZendAfi/View/Helper/Bookmarks.php @@ -23,7 +23,11 @@ class ZendAfi_View_Helper_Bookmarks extends ZendAfi_View_Helper_BaseHelper { protected $_bookmarks, $_criteres; - public function bookmarks($bookmarks, $criteres, $preferences) { + public function bookmarks($search_result) { + $preferences = $search_result->getSettings(); + $bookmarks = $search_result->fetchFacetsAndTags($preferences)['bookmarks']; + $criteres = $search_result->getCriteresRecherche(); + if(!$preferences['bookmarks_enabled']) return ''; diff --git a/library/ZendAfi/View/Helper/ListeCVSNotices.php b/library/ZendAfi/View/Helper/ListeCVSNotices.php index a90f9d7969bb91e43218c1641301fdb39fc862f8..1651510413d7a0609839f299681980283499c4f4 100644 --- a/library/ZendAfi/View/Helper/ListeCVSNotices.php +++ b/library/ZendAfi/View/Helper/ListeCVSNotices.php @@ -16,7 +16,7 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -24,13 +24,11 @@ class ZendAfi_View_Helper_ListeCVSNotices extends ZendAfi_View_Helper_ListeNotices { public function listeCVSNotices($notices,$nombre_resultats,$page,$preferences) { - return - !$nombre_resultats - ? '<span>'. - $this->view->_('Aucun document trouvé'). - '</span>' - : '<div class="cvs_record_list">'. - $this->displayList('',$notices,$preferences). - '</div>'; + return $nombre_resultats + ? $this->_tag('div', + $this->_displayList($notices, $preferences), + ['class' => 'cvs_record_list']) + : $this->_tag('span', + $this->_('Aucun document trouvé')); } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ListeNotices.php b/library/ZendAfi/View/Helper/ListeNotices.php index d70c7ceb1a2f2968ffdd1de52d371f81c164d6e3..8c93a26a5bda68b33ee2dc123bfde246bb16ad98 100644 --- a/library/ZendAfi/View/Helper/ListeNotices.php +++ b/library/ZendAfi/View/Helper/ListeNotices.php @@ -16,7 +16,7 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ ////////////////////////////////////////////////////////////////////////////////////////// // OPAC3 : Liste de notices @@ -27,39 +27,57 @@ ////////////////////////////////////////////////////////////////////////////////////////// class ZendAfi_View_Helper_ListeNotices extends ZendAfi_View_Helper_BaseHelper { - /** - * @param array $notices - * @param int $nombre_resultats - * @param int $page - * @param array $preferences - * @param string $url - * @param string $tri - * @return string - */ - public function listeNotices($notices, $nombre_resultats, $page, $preferences, $criteres_recherche) { - $html = '<div class="liste_notices" >'; - // Message d'erreur - if (!$notices) { - return $html.'<h2>'.$this->view->_('Aucun résultat trouvé').'</h2></div>'; - } + public function listeNotices($search_result) { + $criteres_recherche = $search_result->getCriteresRecherche(); + $notices = $search_result->getRecords(); + $nombre_resultats = $search_result->getRecordsCount(); + $page = $criteres_recherche->getPage(); + $preferences = $search_result->getSettings(); - return $html.$this->displayList($html,$notices,$preferences).'</div>'; + $html = $this->_tag('div', + $this->_recordsList($notices, $preferences), + ['class' => 'liste_notices']); + + if((!Class_AdminVar::displayPagerOnTop()) + &&(!Class_AdminVar::displayPagerOnBottom())) + return $html; + + $pager = $this->view->pager($nombre_resultats, + $criteres_recherche->getPageSize(), + $criteres_recherche->getPage(), + array_merge($criteres_recherche->getUrlRetourListe(), + ['controller' => 'recherche', + 'action' => 'simple'])); + + + if (Class_AdminVar::displayPagerOnTop()) + $html = $pager . $html; + + if (Class_AdminVar::displayPagerOnBottom()) + $html .= $pager; + + return $html; } - - public function displayList($html,$notices,$preferences) { + + protected function _recordsList($records, $settings) { + return $records + ? $this->_displayList($records, $settings) + : $this->_tag('h2', $this->_('Aucun résultat trouvé')); + } + + + protected function _displayList($notices,$preferences) { $helpers = [ - Class_Systeme_ModulesAppli::LISTE_FORMAT_TABLEAU => 'ListeNotices_Tableau', - Class_Systeme_ModulesAppli::LISTE_FORMAT_ACCORDEON => 'ListeNotices_Accordeon', - Class_Systeme_ModulesAppli::LISTE_FORMAT_VIGNETTES => 'ListeNotices_Vignettes', - Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR => 'ListeNotices_Mur', - Class_Systeme_ModulesAppli::LISTE_FORMAT_CHRONO => 'ListeNotices_Chrono', - ]; + Class_Systeme_ModulesAppli::LISTE_FORMAT_TABLEAU => 'ListeNotices_Tableau', + Class_Systeme_ModulesAppli::LISTE_FORMAT_ACCORDEON => 'ListeNotices_Accordeon', + Class_Systeme_ModulesAppli::LISTE_FORMAT_VIGNETTES => 'ListeNotices_Vignettes', + Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR => 'ListeNotices_Mur', + Class_Systeme_ModulesAppli::LISTE_FORMAT_CHRONO => 'ListeNotices_Chrono', + ]; $helper = $helpers[$preferences['liste_format']]; return call_user_func_array([$this->view, $helper], [$notices, $preferences]); } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ListeNotices/Abstract.php b/library/ZendAfi/View/Helper/ListeNotices/Abstract.php index 79f6dc8dbece1b67b2f07bbcef0d2c1a181da050..e9121cf77ed11931cb31da1af79bb78f73a7948a 100644 --- a/library/ZendAfi/View/Helper/ListeNotices/Abstract.php +++ b/library/ZendAfi/View/Helper/ListeNotices/Abstract.php @@ -16,9 +16,48 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ abstract class ZendAfi_View_Helper_ListeNotices_Abstract extends ZendAfi_View_Helper_BaseHelper { + + protected function _divRecord($html, $record, $class) { + return $this->_tag('div', + $html, + array_merge( + ['class' => $class, + 'data-id' => $record->getId(), + 'data-type' => $record->getTypeDoc()], + $this->_getDataAvailability($record))); + } + + + protected function _getDataAvailability($record) { + if(!$this->_isAllowedToDisplayAvailabilty($record)) + return []; + + return ['data-availability' => $record->getAvailabilityFromFacet()]; + } + + + protected function _recordAvailability($record) { + if(!$this->_isAllowedToDisplayAvailabilty($record)) + return ''; + + return $this->view->Notice_Availability($record); + } + + + protected function _isAllowedToDisplayAvailabilty($record) { + if(!Class_AdminVar::isAfficherDispoSurRechercheEnabled()) + return false; + + if($record->isRessourceNumerique()) + return false; + + return true; + } + + public function loadScript(){ Class_ScriptLoader::getInstance() ->addInlineScript("var resumeAjaxBaseUrl='".$this->view->url(['controller' => 'noticeajax', 'action' => 'resumenotice'],null,true)."';") @@ -31,7 +70,7 @@ abstract class ZendAfi_View_Helper_ListeNotices_Abstract extends ZendAfi_View_He ->addJQueryReady("vignetteHover($('.liste_vignettes .vignette[data-id]'));"); else Class_ScriptLoader::getInstance()->addInlineScript("var disponibiliteAjaxBaseUrl;"); - + } } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ListeNotices/Mur.php b/library/ZendAfi/View/Helper/ListeNotices/Mur.php index cd87599be8f25c14a682ff3cdcf06215a32a2b32..1797c20dd56cb989078850dc7ae09f5ec77d0679 100644 --- a/library/ZendAfi/View/Helper/ListeNotices/Mur.php +++ b/library/ZendAfi/View/Helper/ListeNotices/Mur.php @@ -16,17 +16,120 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_ListeNotices_Mur extends ZendAfi_View_Helper_ListeNotices_Abstract { - public function listeNotices_Mur($data, $preferences=[]) { + + public function ListeNotices_Mur($data, $preferences=[]) { $this->loadScript(); $notices = []; foreach($data as $notice) - $notices []= $this->view->notice_Mur($notice, $preferences); + $notices[] = $this->_notice_mur($notice, $preferences); + + return $this->_tag('div', + implode($notices) + . $this->_tag('div', '', ['class' => 'clear']), + ['class' => 'liste_mur']); + } + + + protected function _notice_mur($notice, $preferences=[]) { + $champs = isset($preferences['liste_codes']) + ? $preferences['liste_codes'] + : 'TANE'; + + $datas = [$this->_tag('span', + $this->view->tagAnchor($this->view->urlNotice($notice, $preferences), + $notice->getTitreEtSousTitre(), + ['title' => $this->_('Afficher "%s"', + $notice->getTitrePrincipal())]), + ['class' => 'notice_titre'])]; + + $datas [] = $this->_tag('span', + $this->view->notice_LienRebondAuteur($notice), + ['class' => 'notice_auteur']); + + $datas []= + (strrchr($champs,'9') && $notice->isNouveaute()) + ? $this->_tag('span', + $this->_('Nouveauté'), + ['class' => 'notice_nouveaute']) + : '' ; + + $html = $this->_tag('div', + $this->view->iconeSupport($notice->getTypeDoc())) + . $this->view->notice_Vignette($notice, $preferences) + . $this->_tag('div', + implode($datas), + ['class' => 'titre_auteur']) + . $this->barreDeLien($notice); + + $html = $this->_divRecord($html, $notice, 'notice'); + + return $this->_tag('div', + $html, + ['class' => 'notice_wrapper']); + } + + + protected function barreDeLien($notice){ + $html = + $this->barreDeLienAvis($this->view->url(['controller'=>'noticeajax', + 'action' => 'avis-abonne', + 'id_notice' => $notice->getId()], null, true) . '?iframe=true', + $notice->numberOfAvisAbonne(), + $this->_('Avis des abonnés')) + . $this->barreDeLienAvis($this->view->url(['controller'=>'noticeajax', + 'action' => 'avis-bibliothecaire', + 'id_notice' => $notice->getId()], null, true) . '?iframe=true', + $notice->numberOfAvisBibliothecaire(), + $this->_('Coups de coeur')) + . $this->view->tag('li', + $this->view->tagAnchor($this->view->urlNotice($notice) .'#reseaux-sociaux', + ' ', + ['data-mur-partager' => $notice->getId(), + 'title' => $this->view->_('Partager "%s" sur les réseaux sociaux', + $notice->getTitrePrincipal())])) + . $this->barreDeLienPanier($notice) + . $this->barreDeLienReserver($notice); + + return + $this->_recordAvailability($notice) + . $this->_tag('ul', + $html, + ['class' => 'barre-de-lien']) + . $this->view->reseauxSociaux($notice); + } + + + protected function barreDeLienReserver($notice) { + if ($notice->isRessourceNumerique() || $notice->isSite() || $notice->isArticleCms() || $notice->isRSS()) + return ''; + + $holdable = ($link = $this->view->Notice_LienReserver($notice)) + ? 'true' + : 'false'; + + return $this->_tag('li ', + $link, + ['data-reservable' => $holdable]); + } + + + protected function barreDeLienAvis($url, $count, $title) { + if (!$count) + return ''; + + return $this->_tag('li', + $this->view->tagAnchor($url, + $this->_tag('span', $count), + ['title' => $this->_('Voir les avis du document "%s"', $title)]), + ['data-avis' => 'true']); + } + - return '<div class="liste_mur">'.implode($notices).'<div class="clear"></div></div>'; + protected function barreDeLienPanier($notice) { + return $this->view->tag('li', $this->view->tagAddToCart($notice)); } } -?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php b/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php index 32bf40001c8ef097afd8615fe0089ba489503432..fdcb5e83d94bb16bdcfbc06ee4ddf67987e07eb9 100644 --- a/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php +++ b/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php @@ -42,6 +42,7 @@ class ZendAfi_View_Helper_ListeNotices_Vignettes extends ZendAfi_View_Helper_Lis $html = $this->_hold($notice) . $this->_cart($notice) + . $this->_recordAvailability($notice) . $this->_title($notice, $url_notice) . $this->_author($notice, $url_notice) . $this->_docType($notice, $type_doc) @@ -50,8 +51,7 @@ class ZendAfi_View_Helper_ListeNotices_Vignettes extends ZendAfi_View_Helper_Lis . $this->_info($notice, $champs) . $this->_pcTag($notice); - return $this->_tag('div', $html, ['class' => 'vignette', - 'data-id' => $notice->getId()]); + return $this->_divRecord($html, $notice, 'vignette'); } diff --git a/library/ZendAfi/View/Helper/Notice/Availability.php b/library/ZendAfi/View/Helper/Notice/Availability.php new file mode 100644 index 0000000000000000000000000000000000000000..7a9b22f47af0796ef4b90b384893c4504ecef94a --- /dev/null +++ b/library/ZendAfi/View/Helper/Notice/Availability.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright (c) 2012-2014, 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_View_Helper_Notice_Availability extends ZendAfi_View_Helper_BaseHelper { + public function Notice_Availability($record) { + return $this->_tag('div', + $this->_getLibraries($record), + ['class' => 'record_availability']); + } + + + protected function _getLibraries($record) { + $html = []; + foreach($record->getAvailableLibrariesFromFacet() as $library) + $html [] = $this->_tag('li', $library->getLabel()); + + $count = count($html); + return $this->_tag('div', + $this->_tag('p', $this->view->_plural($count, + 'Le document n\'est pas disponible', + 'Document disponible dans la bibliothèque suivante :', + 'Document disponible dans les bibliothèques suivantes :')) + . ($count ? $this->_tag('ul', implode($html)) : ''), + ['class' => 'tooltip']); + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Notice/Mur.php b/library/ZendAfi/View/Helper/Notice/Mur.php deleted file mode 100644 index e71a459fabf375ae70edca2ff7e6b1c112e45b29..0000000000000000000000000000000000000000 --- a/library/ZendAfi/View/Helper/Notice/Mur.php +++ /dev/null @@ -1,109 +0,0 @@ -<?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_View_Helper_Notice_Mur extends Zend_View_Helper_HtmlElement { - use Trait_Translator; - - public function notice_Mur($notice, $preferences=[]) { - $champs = isset($preferences['liste_codes']) ? $preferences['liste_codes'] : 'TANE'; - - $datas = $this->view->tag('span', - $this->view->tagAnchor($this->view->urlNotice($notice, $preferences), - $notice->getTitreEtSousTitre(), - ['title' => $this->_('Afficher "%s"', - $notice->getTitrePrincipal())]), - ['class' => 'notice_titre']); - - $datas .= sprintf('- <span class="notice_auteur">%s</span>', - $this->view->notice_LienRebondAuteur($notice)); - - $datas .= - (strrchr($champs,'9') && $notice->isNouveaute()) - ? sprintf('- <span class="notice_nouveaute">%s</span>', $this->_('Nouveauté')) - : '' ; - - $html= '<div class="notice_wrapper">'; - $html.='<div class="notice" data-id="'.$notice->getId().'" data-type="'.$notice->getTypeDoc().'">'. - '<div>'.$this->view->iconeSupport($notice->getTypeDoc()).'</div>'. - $this->view->notice_Vignette($notice, $preferences). - '<div class="titre_auteur">'.$datas. - '</div>'. - $this->barreDeLien($notice). - '</div>'; - - return $html.'</div>'; - } - - - public function barreDeLien($notice){ - $html = '<ul class="barre-de-lien">'; - $html .= $this->barreDeLienAvis($this->view->url(['controller'=>'noticeajax', - 'action' => 'avis-abonne', - 'id_notice' => $notice->getId()], null, true) . '?iframe=true', - $notice->numberOfAvisAbonne(), - 'avis des abonnés'); - - $html .= $this->barreDeLienAvis($this->view->url(['controller'=>'noticeajax', - 'action' => 'avis-bibliothecaire', - 'id_notice' => $notice->getId()], null, true) . '?iframe=true', - $notice->numberOfAvisBibliothecaire(), - 'coups de coeur'); - - $html .= $this->view->tag('li', - $this->view->tagAnchor($this->view->urlNotice($notice) .'#reseaux-sociaux', - ' ', - ['data-mur-partager' => $notice->getId(), - 'title' => $this->view->_('Partager "%s" sur les réseaux sociaux', $notice->getTitrePrincipal())])); - - $html .= $this->barreDeLienPanier($notice); - - $html .= $this->barreDeLienReserver($notice); - - return $html.'</ul>'.$this->view->reseauxSociaux($notice); - } - - - public function barreDeLienReserver($notice) { - if ($notice->isRessourceNumerique() || $notice->isSite() || $notice->isArticleCms() || $notice->isRSS()) - return ''; - - $css='data-reservable='; - $lien=$this->view->Notice_LienReserver($notice); - if($lien!='') - $css .= '"true"'; - else - $css.= '"false"'; - return '<li '.$css.' >'.$lien.'</li>'; - } - - - public function barreDeLienAvis($url, $count, $title) { - if (0 < $count) - return '<li data-avis="true"><a href="' . $url .'" title="'.$this->_("Voir les ". $title ."").'"><span>'. sprintf('%02s', $count) . '</span></a></li>'; - return '<li></li>'; - } - - - public function barreDeLienPanier($notice) { - return $this->view->tag('li', $this->view->tagAddToCart($notice)); - } -} - -?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Search/Header.php b/library/ZendAfi/View/Helper/Search/Header.php new file mode 100644 index 0000000000000000000000000000000000000000..346928ede44e6cb6132e755b112c619fe584c66b --- /dev/null +++ b/library/ZendAfi/View/Helper/Search/Header.php @@ -0,0 +1,105 @@ +<?php +/** + * Copyright (c) 2012-2017, 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_View_Helper_Search_Header extends ZendAfi_View_Helper_BaseHelper { + protected $_criteria, + $_search_result, + $_settings; + + + public function Search_Header($search_result) { + $this->_criteria = $search_result->getCriteresRecherche(); + $this->_search_result = $search_result; + $this->_settings = $search_result->getSettings(); + + $html = [$this->view->tagTriRecherche($this->_criteria), + $this->view->tagTitreEtNombreDeResultats($this->_search_result), + $this->view->tagNombreDePages($this->_criteria->getPage()), + $this->_tagCriteria(), + $this->_tagDomainBrowser(), + $this->_tagSearchActions(), + $this->view->tagSearchExtension($this->_criteria)]; + + return $this->_tag('div', + implode($html), + ['class' => 'resultats_page']); + } + + + protected function _tagCriteria() { + if ($this->_search_result->getRubrics() || $this->_search_result->getBreadcrumb()) + return $this->view->render('recherche/guidee.phtml'); + + return $this->view->tagCriteresRecherche($this->_criteria); + } + + + protected function _tagDomainBrowser() { + if(!$id_module = $this->_criteria->getIdModule()) + return ''; + + if (!$config = Class_Profil::getCurrentProfil()->getLocalModuleAccueilConfig($id_module)) + return ''; + + if(!isset($config['type_module'])) + return ''; + + if($config['type_module'] != 'DOMAIN_BROWSER') + return ''; + + return $this->view->renderDomainBrowser($this->_criteria->getCatalogue(), + $id_module, + $config['preferences']); + } + + + protected function _tagSearchActions() { + $actions = [$this->_tag('span', + $this->view->tagAnchor($this->view->url($this->_criteria->getUrlRetourRechercheInitiale(), null, true), + $this->_('Retour à la recherche initiale'), + ['title' => $this->_('Accéder au formulaire de recherche pré-rempli avec les critères actuels')])), + $this->_tag('span', + $this->view->tagAnchor($this->view->url($this->_criteria->getUrlNouvelleRecherche(), null, true), + $this->_('Nouvelle recherche'), + ['title' => $this->_('Lancer une recherche avec réinitialisation des paramètres')])), + $this->_tagSuggestAction(), + $this->_tag('span', + $this->view->tagPrintLink($this->_search_result->fetchRecords(), 'Notice_List'), + ['class' => 'print']) + ]; + + return $this->_tag('div', + implode($actions), + ['class' => 'recherche_actions']); + } + + + protected function _tagSuggestAction() { + if ((int)$this->_settings['suggestion_achat'] == 1 && !Class_AdminVar::areSuggestionsDisabled()) + return $this->_tag('span', + $this->view->tagAnchor(['controller' => 'abonne', + 'action' => 'suggestion-achat'], + $this->_('Suggérer un achat'), + ['title' => $this->_('Envoyer une demande d\'achat de document')])); + return ''; + } +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Search/Result.php b/library/ZendAfi/View/Helper/Search/Result.php index fb90456e2c0cddafb1b4c3e9c3430be94638901d..5bb9f9fcb275e2c4e97f28aa65aa650443034bc7 100644 --- a/library/ZendAfi/View/Helper/Search/Result.php +++ b/library/ZendAfi/View/Helper/Search/Result.php @@ -16,51 +16,169 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -////////////////////////////////////////////////////////////////////////////////////////// -// OPAC3 : Liste de notices -// formats : 1=liste normale -// 2=liste accordéon -// 3=liste vignette -// 4=Liste images mur -////////////////////////////////////////////////////////////////////////////////////////// class ZendAfi_View_Helper_Search_Result extends ZendAfi_View_Helper_BaseHelper { - /** - * @param array $notices - * @param int $nombre_resultats - * @param int $page - * @param array $preferences - * @param string $url - * @param string $tri - * @return string - */ - public function Search_Result($settings, $html_result, $html_filters, $html_cvs) { - $html = - $html_filters. - $html_result. - $html_cvs; - - if($settings['cvs_display_position']=='1') - $html= - $html_result. - $html_cvs. - $html_filters; - - if($settings['cvs_display_position']=='2' || $settings['cvs_display_position']=='4') - $html= - $html_result. - $html_filters. - $html_cvs; - - if($settings['cvs_display_position']=='3') - $html= - $html_cvs. - $html_result. - $html_filters; - - return $html; - + protected $_criteria, + $_settings, + $_search_result; + + + public function Search_Result($search_result) { + if(!$this->_search_result = $search_result) + return ''; + + $this->_criteria = $this->_search_result->getCriteresRecherche(); + $this->_settings = $this->_search_result->getSettings(); + + Class_ScriptLoader::getInstance() + ->addOPACScript('recherche') + ->addSkinStyleSheet('recherche'); + + return $this->_tag('div', + $this->_render(), + ['class' => 'conteneur_simple']); + } + + + protected function _render() { + return $this->_sort($this->_getResultWidget(), + $this->_getFilterWidgets(), + $this->_getCVSWidget()) + . $this->_tag('div', '', ['class' => 'clear']); + } + + + protected function _sort($result_widget, $filters_widget, $CVS_widget) { + $html = $result_widget . $filters_widget; + + if(!$cvs = $this->_settings['cvs_display_position']) + return $html; + + if(Class_Systeme_ModulesAppli::CVS_TOP_OF_FACETS == $cvs) + return $result_widget + . $CVS_widget + . $filters_widget; + + if(Class_Systeme_ModulesAppli::CVS_BOTTOM_OF_FACETS == $cvs + || Class_Systeme_ModulesAppli::CVS_BOTTOM_OF_RESULT == $cvs) + return $result_widget + . $filters_widget + . $CVS_widget; + + if(Class_Systeme_ModulesAppli::CVS_TOP_OF_RESULT == $cvs) + return $CVS_widget + . $result_widget + . $filters_widget; + } + + + protected function _CVSTitle() { + if(!$title = $this->_settings['cvs_autres_resultats']) + return ''; + + return $this->_tag('h1', $title); + } + + + protected function _getResultWidget() { + $html_result = [$this->_CVSTitle(), + $this->view->listeNotices($this->_search_result)]; + + return $this->_tag('div', + implode($html_result), + ['class' => 'resultat_recherche']); + } + + + protected function _cloudOfTags() { + $nuage_tags_title = $this->_settings["tags_message"] + ? $this->_tag('h2', $this->_settings["tags_message"]) + : ''; + $tags = $this->_search_result->fetchFacetsAndTags($this->_settings)['tags']; + return $this->_tag('div', + $nuage_tags_title + . $this->view->nuageTags($tags, null, $this->_criteria), + ['class' => 'facette_outer nuage_outer']); + } + + + protected function _facets() { + $title = ($this->_settings["facettes_message"] + ? $this->_tag('h2', $this->_settings["facettes_message"]) + : ''); + + $facets = $this->_search_result->fetchFacetsAndTags($this->_settings)['facettes']; + + return $this->_tag('div', + $title + . $this->view->facettes($facets, + $this->_settings, + $this->_criteria), + ['class' => 'facette_outer']); + } + + + protected function _getFilterWidgets() { + return $this->_tag('div', + $this->_orderFilterWidgets(), + ['class' => 'filtre_recherche']); + } + + + protected function _orderFilterWidgets() { + if(!$this->_search_result->getRecordsCount()) + return ''; + + $has_facettes = $this->_settings['facettes_actif']; + $has_tags = $this->_settings['tags_actif']; + + if((!$has_tags) && (!$has_facettes)) + return ''; + + $tags_position = $this->_settings['tags_position']; + + $html_suggests = $this->view->suggests($this->_search_result); + $html_bookmarks = $this->view->bookmarks($this->_search_result); + $html_nuage_tags = $this->_cloudOfTags(); + $html_facettes = $this->_facets(); + + $html_filters = [$html_suggests, + $html_bookmarks]; + + if ($has_tags && (1 == $tags_position)) + $html_filters[] = $html_nuage_tags; + + if ($has_facettes) + $html_filters[] = $html_facettes; + + if ($has_tags && (2 == $tags_position)) + $html_filters[] = $html_nuage_tags; + + return implode($html_filters); + } + + + protected function _getCVSWidget() { + if(!(new Class_AdminVar_CVS())->isCVSAccessOrDemo()) + return ''; + + if(!$this->_settings['cvs_display_position']) + return ''; + + $url = $this->view->url($this->_criteria->getCVSUrlCriteresWithFacettes(), + null, + true); + + Class_ScriptLoader::getInstance() + ->addJQueryReady(sprintf("$('<div></div>').load('%s').appendTo($('.cvs_container'))", + $url)); + + return $this->_tag('div', + $this->_tag('h1', + $this->_settings['cvs_resultat_titre']), + ['class' => sprintf('cvs_container position_%s', + $this->_settings['cvs_display_position'])]); } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Suggests.php b/library/ZendAfi/View/Helper/Suggests.php index 7d0653b6ac1a5e6223b550e32a1fb3dc1767951d..c2c1bafc813329c5221896a97df531e4a240f5cc 100644 --- a/library/ZendAfi/View/Helper/Suggests.php +++ b/library/ZendAfi/View/Helper/Suggests.php @@ -20,7 +20,9 @@ */ class ZendAfi_View_Helper_Suggests extends ZendAfi_View_Helper_BaseHelper { - public function suggests($suggests, $criteres) { + public function suggests($search_result) { + $suggests = $search_result->fetchFacetsAndTags($search_result->getSettings())['suggests']; + $criteres = $search_result->getCriteresRecherche(); if (empty($suggests)) return ''; diff --git a/library/ZendAfi/View/Helper/TagTitreEtNombreDeResultats.php b/library/ZendAfi/View/Helper/TagTitreEtNombreDeResultats.php index 0cac7a7300ad018b14afbb56980c162eddcb6e2d..1b9f001c84b02d9116dcd70a6b168089dc31e9a5 100644 --- a/library/ZendAfi/View/Helper/TagTitreEtNombreDeResultats.php +++ b/library/ZendAfi/View/Helper/TagTitreEtNombreDeResultats.php @@ -20,7 +20,8 @@ */ class ZendAfi_View_Helper_TagTitreEtNombreDeResultats extends ZendAfi_View_Helper_BaseHelper { - public function tagTitreEtNombreDeResultats($search_result, $search_duration){ + public function tagTitreEtNombreDeResultats($search_result){ + $search_duration = $search_result->getDuration(); $criteres_recherche = $search_result->getCriteresRecherche(); $expression_recherche = $this->_getExpressionRecherche($criteres_recherche); diff --git a/public/opac/css/global.css b/public/opac/css/global.css index f8c2f98749a1853e95e9a8cac908b5305a98ab5b..be3d94192414f3123296fb76926a12d1501ff498 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -1726,7 +1726,7 @@ body.abonne_multimedia-hold-view .actions a { overflow: hidden; } -.liste_mur .notice>a + div + div { +.liste_mur .notice > a + div + div:not(.record_availability) { position: absolute; top: 86px; left: 0px; @@ -3490,3 +3490,50 @@ th.actions { margin: 1em auto; } +[data-availability] .record_availability { + display: block; + width: 16px; + height: 16px; + position: absolute; + border-radius: 50px; + top: 5px; + left: 5px; + z-index: 1; +} + +[data-availability="1"] .record_availability { + background-color: #21ff00; +} + +[data-availability=""] .record_availability { + background-color: red; +} + +.liste_mur [data-availability] .record_availability { + top: auto; + bottom: 5px; +} + +.liste_mur [data-availability] .record_availability .tooltip { + bottom: 2em; + left: 0; +} + +[data-availability] .record_availability .tooltip { + display: none; + position: absolute; + z-index: 101; + padding-left: 1em; + min-width: 300px; + background-color: #fff; + box-shadow: 1px 1px 5px rgba(0, 0 , 0 ,0.3); + left: 2em; +} + +[data-availability] .record_availability:hover .tooltip { + display: block; +} + +[data-availability] .record_availability:hover .tooltip ul { + padding-left: 1em; +} diff --git a/public/opac/js/liste_notices_mur.js b/public/opac/js/liste_notices_mur.js index c57079f4cd4e90009d71d562954bfc28777c47a6..cb11aea4fd8fe9e0cf751cabddc5379aa3093e60 100644 --- a/public/opac/js/liste_notices_mur.js +++ b/public/opac/js/liste_notices_mur.js @@ -40,8 +40,9 @@ function popupResumeAndDispo(context, resume, dispo, id) { if( window.noticeMurTooltip == undefined) { function noticeMurTooltip(item) { var id = $(item).data('id'); + $('.notice-mur-tooltip').hide(); $(item).tooltip({ - show:{delay:250}, + show:{delay:200}, content:'<div style="text-align:center;padding:15px;"><img src="' + imagesUrl +'patience.gif" /></div>', open:function(event, ui){ var context = $(this); diff --git a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php index a79c352713387dbd46a0b91806fffd713a5c7a65..48fb3b8be0faf09b761c94e887dcbffb27beb59b 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php @@ -23,13 +23,13 @@ class RechercheControllerPrintActionLinkTest extends AbstractControllerTestCase protected $_storm_default_to_volatile = true; public function setUp() { - parent::setUp(); + parent::setUp(); - $this->fixture('Class_ModeleFusion', ['id' => 1, - 'nom' => 'recherche', - 'contenu' => '<p> {notices.each[<img src="{url_vignette}"/> {titre_principal} <div>{article.contenu}</div> + $this->fixture('Class_ModeleFusion', ['id' => 1, + 'nom' => 'recherche', + 'contenu' => '<p> {notices.each[<img src="{url_vignette}"/> {titre_principal} <div>{article.contenu}</div> ]}</p>', - 'type' => 'Notice_List']); + 'type' => 'Notice_List']); $this->fixture('Class_Catalogue', ['id'=>3, @@ -63,27 +63,27 @@ class RechercheControllerPrintActionWithRecordsTest extends AbstractControllerTe protected $_storm_default_to_volatile = true; public function setUp() { - parent::setUp(); + parent::setUp(); - $this->fixture('Class_ModeleFusion', ['id' => 1, - 'nom' => 'recherche', - 'contenu' => '<p> {notices.each[<img src="{url_vignette}"/> <h1>{titre_principal}</h1> <div>{article.contenu}</div> <div>{resume}</div> + $this->fixture('Class_ModeleFusion', ['id' => 1, + 'nom' => 'recherche', + 'contenu' => '<p> {notices.each[<img src="{url_vignette}"/> <h1>{titre_principal}</h1> <div>{article.contenu}</div> <div>{resume}</div> ]}</p>']); - Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 10, - 'titre' => 'pomme', - 'contenu' => '<p>blabla</p>', - 'notice' => new Class_Notice(), - 'type_doc_id' => Class_TypeDoc::ARTICLE])); + Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 10, + 'titre' => 'pomme', + 'contenu' => '<p>blabla</p>', + 'notice' => new Class_Notice(), + 'type_doc_id' => Class_TypeDoc::ARTICLE])); - Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 12, - 'titre' => 'transmetropolitan', - 'contenu' => '<p>bd</p>', - 'notice' => new Class_Notice(), - 'type_doc_id' => Class_TypeDoc::ARTICLE])); + Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 12, + 'titre' => 'transmetropolitan', + 'contenu' => '<p>bd</p>', + 'notice' => new Class_Notice(), + 'type_doc_id' => Class_TypeDoc::ARTICLE])); - $this->dispatch("/recherche/print/expressionRecherche/pomme/strategy/Notice_List/ids/2;1/modele_fusion/1",true); + $this->dispatch("/recherche/print/expressionRecherche/pomme/strategy/Notice_List/ids/2;1/modele_fusion/1",true); } @@ -131,49 +131,49 @@ class RechercheControllerViewNoticePrintActionWithRecordsTest extends AbstractCo protected $_storm_default_to_volatile = true; public function setUp() { - parent::setUp(); - Class_AdminVar::set("AVIS_MIN_SAISIE", 5); - Class_AdminVar::set("AVIS_MAX_SAISIE", 500); - $this->fixture('Class_ModeleFusion', ['id' => 1, - 'nom' => 'article', - 'contenu' => '<p><h1> {notice.titre_principal}</h1> <div>{notice.article.contenu} </div> + parent::setUp(); + Class_AdminVar::set("AVIS_MIN_SAISIE", 5); + Class_AdminVar::set("AVIS_MAX_SAISIE", 500); + $this->fixture('Class_ModeleFusion', ['id' => 1, + 'nom' => 'article', + 'contenu' => '<p><h1> {notice.titre_principal}</h1> <div>{notice.article.contenu} </div> <div>{notice.resume} </div> {notice.avis[<p>{avis}</p>]} </p>', - 'type' => 'Notice_View']); - - - Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 12, - 'titre' => 'transmetropolitan', - 'contenu' => '<p>bd</p>', - 'notice' => new Class_Notice(), - 'type_doc_id' => Class_TypeDoc::ARTICLE])); - $avis = [ - $this->fixture('Class_AvisNotice', [ - 'id' => 1, - 'id_user' => 1, - 'avis' => 'Lies are news and truth is obsolete.', - 'entete' => 'quotes', - 'note' => 4, - 'clef_oeuvre' => 'TRANSMETROPOLITAN---', - 'notice' => 1, - 'date_avis' => '2012-01-01', - ]), - $this->fixture('Class_AvisNotice', [ - 'id' => 2, - 'id_user' => 1, - 'avis' => "The point is, the only real tools we have are our eyes and our heads. It's not the act of seeing with our eyes alone; it's correctly comprehending what we see. Treating life as an autopsy", - 'entete' => 'quotes', - 'note' => 4, - 'notice' => 1, - 'clef_oeuvre' => 'TRANSMETROPOLITAN---', - 'date_avis' => '2012-01-01', - ]), - ]; - - - - $this->dispatch("/recherche/print/expressionRecherche/pomme/strategy/Notice_View/id/1/modele_fusion/1",true); + 'type' => 'Notice_View']); + + + Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 12, + 'titre' => 'transmetropolitan', + 'contenu' => '<p>bd</p>', + 'notice' => new Class_Notice(), + 'type_doc_id' => Class_TypeDoc::ARTICLE])); + $avis = [ + $this->fixture('Class_AvisNotice', [ + 'id' => 1, + 'id_user' => 1, + 'avis' => 'Lies are news and truth is obsolete.', + 'entete' => 'quotes', + 'note' => 4, + 'clef_oeuvre' => 'TRANSMETROPOLITAN---', + 'notice' => 1, + 'date_avis' => '2012-01-01', + ]), + $this->fixture('Class_AvisNotice', [ + 'id' => 2, + 'id_user' => 1, + 'avis' => "The point is, the only real tools we have are our eyes and our heads. It's not the act of seeing with our eyes alone; it's correctly comprehending what we see. Treating life as an autopsy", + 'entete' => 'quotes', + 'note' => 4, + 'notice' => 1, + 'clef_oeuvre' => 'TRANSMETROPOLITAN---', + 'date_avis' => '2012-01-01', + ]), + ]; + + + + $this->dispatch("/recherche/print/expressionRecherche/pomme/strategy/Notice_View/id/1/modele_fusion/1",true); } diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index bdcd45d9bd9578424bfef618f896618df157d179..d42a1f45c57a4631fbd0ce6af86892514a81f26a 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -209,7 +209,7 @@ class RechercheControllerPagerTest extends RechercheControllerNoticeTestCase { Class_Profil::getCurrentProfil()->setCfgModules(['recherche' => ['resultatsimple' => ['search_term_editable' => 0]]]); $this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/*/facette/T3/liste_format/4', true); - $this->assertXPath('//div[@class="expression-recherche"][contains(text(), "pomme")]',$this->_response->getBody()); + $this->assertXPath('//div[@class="resultats_page"]//div[@class="expression-recherche"][contains(text(), "pomme")]',$this->_response->getBody()); } @@ -232,7 +232,7 @@ class RechercheControllerPagerTest extends RechercheControllerNoticeTestCase { public function pagerShouldBeDisplayedOnBottom() { Class_AdminVar::newInstanceWithId('SEARCH_PAGINATE_POSITION', ['valeur' => 'BOTTOM']); $this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/*/facette/T3/liste_format/4', true); - $this->assertXPath('//div[@class="liste_notices"]/following-sibling::node()[@class="pager"]'); + $this->assertXPath('//div[@class="liste_notices"]/following-sibling::node()[@class="pager"]', $this->_response->getBody()); } @@ -1179,8 +1179,22 @@ class RechercheAvanceeControllerSimpleActionWithDefaultConfigTest extends Recher "id" => "M12", "libelle" => "DVD", "nombre" => 5], + ]]) - ]]); + ->whenCalled('setDuration') + ->answers($mock_search_result) + + ->whenCalled('getDuration') + ->answers(0.4) + + ->whenCalled('setSettings') + ->answers($mock_search_result) + + ->whenCalled('getSettings') + ->answers(Class_Profil::getCurrentProfil()->getSearchResultSettings()) + + ->whenCalled('getRecords') + ->answers([]); $mock_moteur_recherche ->whenCalled('lancerRecherche') @@ -1431,12 +1445,12 @@ abstract class RechercheControllerSimpleActionListeFormatTestCase extends Abstra 'label' => 'Livres']); $this->fixture('Class_TypeDoc' , [ 'id' => 2, 'label' => 'Périodique']); - - } } + + class RechercheControllerSimpleActionWithListeFormatMurTest extends RechercheControllerSimpleActionListeFormatTestCase { protected $_liste_format = Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR, @@ -1450,7 +1464,7 @@ class RechercheControllerSimpleActionWithListeFormatMurTest extends RechercheCon /** @test **/ public function resumeNoticeLinkShouldBeReset() { - $this->assertXPathContentContains('//head/script', "/noticeajax/resumenotice';"); + $this->assertXPathContentContains('//head/script', "/noticeajax/resumenotice';", $this->_response->getBody()); } @@ -2178,8 +2192,10 @@ class RechercheControllerSimpleActionWithCatalogueAndDomainBrowserWidgetTest ext return $mock_search_result; }); - $mock_search_result + $settings = Class_Profil::getCurrentProfil()->getSearchResultSettings(); + $settings['liste_format'] = 3; + $mock_search_result ->whenCalled('isError') ->answers(false) @@ -2199,7 +2215,24 @@ class RechercheControllerSimpleActionWithCatalogueAndDomainBrowserWidgetTest ext ->answers(['facettes' => [], 'tags' => [], 'suggests' => [], - 'bookmarks' => []]); + 'bookmarks' => []]) + + ->whenCalled('setDuration') + ->answers($mock_search_result) + + ->whenCalled('getDuration') + ->answers(0.5) + + ->whenCalled('setSettings') + ->answers($mock_search_result) + + ->whenCalled('getSettings') + ->answers($settings) + + ->whenCalled('getRecords') + ->answers([$this->fixture('Class_Notice', + ['id' => 1])]) +; Class_MoteurRecherche::setInstance($mock_moteur_recherche); @@ -2383,7 +2416,7 @@ class RechercheControllerAjoutNoticePanierUrlMurTest extends RechercheController public function setUp() { parent::setUp(); ZendAfi_Auth::getInstance()->clearIdentity(); - $this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/alpha_auteur',true); + $this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/alpha_auteur', true); } @@ -2703,6 +2736,7 @@ class RechercheControllerSimpleActionWithCvsActivatedTest extends RechercheContr public function setUp() { parent::setUp(); $this->dispatch('/recherche/simple/expressionRecherche/potter/facettes/T1/facette/B1/page/2', true); + Class_Profil::getCurrentProfil() ->setCfgModules(['recherche' => ['resultatsimple' => [ 'cvs_autres_resultats' => 'Results from opac', @@ -2746,6 +2780,7 @@ class RechercheControllerSimpleActionWithCvsActivatedTest extends RechercheContr return $xml; } + /** @test **/ public function titleResultFromOpacShouldBeDiplay() { $this->assertXPathContentContains('//h1','Results from opac'); diff --git a/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php b/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php index fff38f0f996e96209a6516dc3cf7a1d7936b44b0..cde47ac96c764a5d902e2dbc95f35cb0202f5517 100644 --- a/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php +++ b/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php @@ -20,7 +20,6 @@ */ abstract class TelephoneAbstractControllerTestCase extends AbstractControllerTestCase { - public function setUp() { parent::setUp(); $_SERVER['HTTP_USER_AGENT'] = 'iPhone'; diff --git a/tests/library/ZendAfi/View/Helper/Notice/MurTest.php b/tests/library/ZendAfi/View/Helper/ListeNotices/MurTest.php similarity index 85% rename from tests/library/ZendAfi/View/Helper/Notice/MurTest.php rename to tests/library/ZendAfi/View/Helper/ListeNotices/MurTest.php index 6127a6258961a40e71ed96dcb83ad72fdfab134c..7d75142917c7eea00e8c54a7e629ceb5391029c9 100644 --- a/tests/library/ZendAfi/View/Helper/Notice/MurTest.php +++ b/tests/library/ZendAfi/View/Helper/ListeNotices/MurTest.php @@ -20,15 +20,17 @@ */ -abstract class ZendAfi_View_Helper_Notice_MurTestCase extends ViewHelperTestCase { +abstract class ZendAfi_View_Helper_ListeNotices_MurTestCase extends ViewHelperTestCase { protected $_html; public function setUp() { parent::setUp(); - + $this->fixture('Class_AdminVar', ['id'=>'AFFICHER_DISPONIBILITE_SUR_RECHERCHE', 'valeur'=>1] ); defineConstant("PATH_SKIN", "./public/opac/skins/original/"); - - $this->_helper = new ZendAfi_View_Helper_Notice_Mur(); + $this->fixture('Class_Bib', + ['id' => 2, + 'libelle' => 'Boussy']); + $this->_helper = new ZendAfi_View_Helper_ListeNotices_Mur(); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); } } @@ -36,7 +38,7 @@ abstract class ZendAfi_View_Helper_Notice_MurTestCase extends ViewHelperTestCase -class ZendAfi_View_Helper_Notice_MurForNoticeTest extends ZendAfi_View_Helper_Notice_MurTestCase { +class ZendAfi_View_Helper_ListeNotices_MurForNoticeTest extends ZendAfi_View_Helper_ListeNotices_MurTestCase { public function setUp() { parent::setUp(); $time_source = new TimeSourceForTest('2013-12-14 09:00:00'); @@ -46,11 +48,11 @@ class ZendAfi_View_Helper_Notice_MurForNoticeTest extends ZendAfi_View_Helper_No ['unimarc' => "00627nam0 22002291 450 00100080000001000180000802100070002610000410003310100130007410500390008720000690012621000360019521500290023122500230026067600060028368600100028970000290029983000270032883500060035593000140036193200220037500028922 a2-07-052818-9 aFR a20010130 d 0frea01 ba1 afreceng 1[2001-01-30-00.00.00.000000][][][]1 aHarry Potter et le prisonnier d'AzkabanfJoanne Kathleen Rowling aPariscGallimard jeunessed2000 a465 p.3465cill.d18 cm 2aFolio juniorv1006 10 aR ROW1 aRowlingbJoanne Kathleen 1A32A partir de 10 ans aJ aRomans4R aSorcier-Sorcière", 'url_vignette' => 'hp.png', 'url_image' => 'hp_big.png', - 'facettes' => 'D123 A400 Y2', + 'facettes' => 'D123 A400 Y2 V2 T2', 'clef_oeuvre' => 'HPELPA', 'date_creation' => '2013-12-27 00:00:00', 'exemplaires' => []]); - $this->_html = $this->_helper->notice_Mur($potter, ['liste_codes' =>'ATEN9']); + $this->_html = $this->_helper->listeNotices_Mur([$potter], ['liste_codes' =>'ATEN9']); } @@ -93,12 +95,29 @@ class ZendAfi_View_Helper_Notice_MurForNoticeTest extends ZendAfi_View_Helper_No $this->assertXPathContentContains($this->_html, '//div//span[@class="notice_nouveaute"]','Nouveaut',$this->_html); } + + + /** @test */ + public function recordShouldBeAvailable() { + $this->assertXpath($this->_html, '//div[@class="notice"][@data-availability="1"]', $this->_html); + } + + + /** @test */ + public function boussyLibraryShouldBeInAvailabilityListShouldBePresent() { + $this->assertXPathContentContains($this->_html, '//div[@class="record_availability"]//div//ul//li', 'Boussy'); + } + + + protected function _unimarcFromFile($name) { + return file_get_contents(realpath(dirname(__FILE__)) . '/' . $name); + } } -class ZendAfi_View_Helper_Notice_MurForSiteTest extends ZendAfi_View_Helper_Notice_MurTestCase { +class ZendAfi_View_Helper_ListeNotices_MurForSiteTest extends ZendAfi_View_Helper_ListeNotices_MurTestCase { public function setUp() { parent::setUp(); $site = $this->fixture('Class_Sitotheque', ['id' => 4, @@ -113,7 +132,7 @@ class ZendAfi_View_Helper_Notice_MurForSiteTest extends ZendAfi_View_Helper_Noti 'type_doc' => Class_TypeDoc::SITE ]); - $this->_html = $this->_helper->notice_Mur($notice); + $this->_html = $this->_helper->listeNotices_Mur([$notice]); } public function tearDown() { @@ -131,7 +150,7 @@ class ZendAfi_View_Helper_Notice_MurForSiteTest extends ZendAfi_View_Helper_Noti -class ZendAfi_View_Helper_Notice_MurForArticleTest extends ZendAfi_View_Helper_Notice_MurTestCase { +class ZendAfi_View_Helper_ListeNotices_MurForArticleTest extends ZendAfi_View_Helper_ListeNotices_MurTestCase { public function setUp() { parent::setUp(); @@ -147,7 +166,7 @@ class ZendAfi_View_Helper_Notice_MurForArticleTest extends ZendAfi_View_Helper_N Class_Article::newInstanceWithId(5, ['titre' => 'Concert', 'description' => 'Ce soir <img src="concert.jpg">']); - $this->_html = $this->_helper->notice_Mur($concert); + $this->_html = $this->_helper->listeNotices_Mur([$concert]); } @@ -175,7 +194,7 @@ class ZendAfi_View_Helper_Notice_MurForArticleTest extends ZendAfi_View_Helper_N -class ZendAfi_View_Helper_Notice_Mur_BarreDeLienTest extends ZendAfi_View_Helper_Notice_MurTestCase { +class ZendAfi_View_Helper_ListeNotices_Mur_BarreDeLienTest extends ZendAfi_View_Helper_ListeNotices_MurTestCase { protected $_notice; public function setUp() { parent::setUp(); @@ -211,7 +230,7 @@ class ZendAfi_View_Helper_Notice_Mur_BarreDeLienTest extends ZendAfi_View_Helper ->whenCalled('countBy') ->answers(1); - $this->_html = $this->_helper->notice_Mur($this->_notice); + $this->_html = $this->_helper->listeNotices_Mur([$this->_notice]); } @@ -243,7 +262,7 @@ class ZendAfi_View_Helper_Notice_Mur_BarreDeLienTest extends ZendAfi_View_Helper ->setSigbExemplaire(Storm_Test_ObjectWrapper::mock() ->whenCalled('isReservable') ->answers(true))]); - $this->_html = $this->_helper->notice_Mur($this->_notice); + $this->_html = $this->_helper->listeNotices_Mur([$this->_notice]); $this->assertXPath($this->_html, '//a[contains(@onclick, "openDialogExemplaires")][contains(@onclick, "/noticeAjax/exemplaires/id_notice/34")]', $this->_html); @@ -266,7 +285,7 @@ class ZendAfi_View_Helper_Notice_Mur_BarreDeLienTest extends ZendAfi_View_Helper ->setSigbExemplaire(Storm_Test_ObjectWrapper::mock() ->whenCalled('isReservable') ->answers(false))]); - $this->_html = $this->_helper->notice_Mur($this->_notice); + $this->_html = $this->_helper->listeNotices_Mur([$this->_notice]); $this->assertNotXPath($this->_html, '//a[contains(@onclick, "openDialogExemplaires")]'); } } diff --git a/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php b/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php index fb2cfb491b19b4a34c34d21d436811db1e7235cd..bf63fa1058dd0cb1e44b3d8a9dcc8085b75dd465 100644 --- a/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php +++ b/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php @@ -20,21 +20,26 @@ */ -require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php'; - class VignettesRGAATest extends ViewHelperTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); - Storm_Model_Loader::defaultToVolatile(); + $this->fixture('Class_AdminVar', ['id'=>'AFFICHER_DISPONIBILITE_SUR_RECHERCHE', 'valeur'=>1] ); defineConstant('PATH_SKIN', './public/opac/skins/original/'); $helper = new ZendAfi_View_Helper_ListeNotices_Vignettes(); $helper->setView($this->view); + $this->fixture('Class_Bib', + ['id' => 2, + 'libelle' => 'Médiathèque de Pekin']); + $notice = $this ->fixture('Class_Notice', ['id' => 3455, - 'unimarc' => $this->_unimarcFromFile('beatrix_potter.txt')]); + 'unimarc' => $this->_unimarcFromFile('beatrix_potter.txt'), + 'facettes' => 'V2']); $this->_html = $helper->listeNotices_Vignettes([$notice]); } @@ -52,6 +57,18 @@ class VignettesRGAATest extends ViewHelperTestCase { } + /** @test */ + public function recordShouldBeAvailable() { + $this->assertXPath($this->_html, '//div[@class="vignette"][@data-availability="1"]', $this->_html); + } + + + /** @test */ + public function pekinLibrarySHouldBeInAvailabilityListShouldBePresent() { + $this->assertXPathContentContains($this->_html, '//div[@class="record_availability"]//div//ul//li', 'Pekin'); + } + + protected function _unimarcFromFile($name) { return file_get_contents(realpath(dirname(__FILE__)) . '/' . $name); } diff --git a/tests/library/ZendAfi/View/Helper/SuggestsTest.php b/tests/library/ZendAfi/View/Helper/SuggestsTest.php index 897e4c10b732e977d6d4737895087c71ad8b0197..df829a6a0d7b1b19d775f7cf2ba6657690f1a93a 100644 --- a/tests/library/ZendAfi/View/Helper/SuggestsTest.php +++ b/tests/library/ZendAfi/View/Helper/SuggestsTest.php @@ -22,11 +22,18 @@ class ZendAfi_View_Helper_SuggestsTest extends ViewHelperTestCase { protected $_html, - $_storm_default_to_volatile = true; + $_storm_default_to_volatile = true, + $_engine; public function setUp() { parent::setUp(); + $this->_engine = $this->mock() + ->whenCalled('getCriteresRecherche') + ->answers(new Class_CriteresRecherche()) + + ->whenCalled('getSettings') + ->answers([]); $this->_helper = new ZendAfi_View_Helper_Suggests(); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); @@ -35,21 +42,25 @@ class ZendAfi_View_Helper_SuggestsTest extends ViewHelperTestCase { /** @test */ public function withEmptySuggestsShouldReturnEmptyString() { + $this->_engine->whenCalled('fetchFacetsAndTags') + ->answers(['suggests' => []]); $this->assertSame('', - $this->_helper->suggests([], new Class_CriteresRecherche())); + $this->_helper->suggests($this->_engine)); } /** @test */ public function withSuggestResultPommesShouldH2WithSuggestions() { - $html = $this->_helper->suggests([ - ['id' => 'M87', - 'label' => 'Pomme (sujet)'], - - ['id' => 'A43', - 'label' => 'Pomme d\'API (auteur)'], - ], - new Class_CriteresRecherche()); + $this->_engine->whenCalled('fetchFacetsAndTags') + ->answers(['suggests' => [ + ['id' => 'M87', + 'label' => 'Pomme (sujet)'], + + ['id' => 'A43', + 'label' => 'Pomme d\'API (auteur)'], + ]]); + + $html = $this->_helper->suggests($this->_engine); $this->assertXPathContentContains($html, '//div[@class="suggests_outer facette_outer"]/h2', 'Suggestions'); return $html; }