diff --git a/VERSIONS_HOTLINE/132900 b/VERSIONS_HOTLINE/132900 new file mode 100644 index 0000000000000000000000000000000000000000..48599e47db8747139751c9b0d67adfc89a956f45 --- /dev/null +++ b/VERSIONS_HOTLINE/132900 @@ -0,0 +1 @@ + - ticket #132900 : Magasin de thèmes : Le bouton réinitialiser dans le résultat de recherche supprime maintenant le domaine. \ No newline at end of file diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index b3cd5e7ea089e963ef946b12a5d7171d07f50aae..17113b56781343507dc09242d6fd797b3a4f5ccf 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -183,7 +183,9 @@ class RechercheController extends ZendAfi_Controller_Action { $this->preferences['display_select_record'] = true; } - $this->view->titre = $this->getTitreRechercheSimple($criteres_recherche); + $this->view->titre = ($title = $this->view->search_Title($criteres_recherche, $this->_request, $this)) + ? $title + : $this->view->_('Résultat de la recherche'); if($criteres_recherche->getPertinence()) $this->view->titre .= $this->_(' (recherche élargie triée par pertinence)'); @@ -241,65 +243,12 @@ class RechercheController extends ZendAfi_Controller_Action { } - protected function getTitreRechercheSimple($criteres_recherche) { - if($title = $this->getTitleForPage($criteres_recherche)) - return $title; - - return $this->view->_('Résultat de la recherche'); - } - - - protected function getTitreRechercheViewNotice($criteres_recherche) { - if($title = $this->getTitleForPage($criteres_recherche)) + protected function _getTitreRechercheViewNotice($criteres_recherche) { + if($title = $this->view->search_Title($criteres_recherche, $this->_request, $this)) return $this->view->titreAdd($title); } - protected function getTitleForPage($criteres_recherche) { - if ($titre = $this->_request->getParam('titre')) - return $this->view->escape($titre); - - if ($this->_request->getParam('rubrique')) - return $this->_('Recherche guidée'); - - if ($titre_from_profil = $this->_getTitreFromProfil()) - return $titre_from_profil; - - if ($titre_from_module = $this->getTitreFromModule()) - return $titre_from_module; - - if ($criteres_recherche->isBookmarked()) - return $criteres_recherche->getBookmarkedLabel(); - - if ($panier = $criteres_recherche->getPanier()) - return $panier->getLibelle(); - - if ($catalogue = $criteres_recherche->getCatalogue()) - return $catalogue->getLibelle(); - - return null; - } - - - protected function getTitreFromModule() { - if(!$id_module = $this->extractIdModuleFromUrl()) - return null; - - if(!$profil = $this->extractProfilFromUrl()) - return null; - - return $profil->getModuleTitle($id_module); - } - - - protected function _getTitreFromProfil() { - $params = Class_Profil::getCurrentProfil()->getSearchResultSettings(); - return isset($params['titre']) - ? $params['titre'] - : ''; - } - - public function appelmenuAction() { $this->_forward('simple'); } @@ -389,7 +338,7 @@ class RechercheController extends ZendAfi_Controller_Action { $this->view->show_reset_thumbnail_link = Class_Users::isCurrentUserCanAccesBackend(); - $this->getTitreRechercheViewNotice($criteres_recherche); + $this->_getTitreRechercheViewNotice($criteres_recherche); $this->view->title = strip_tags($this->view->notice->getTitrePrincipal(' ')); if ($auteur = $this->view->notice->getAuteurPrincipal()) diff --git a/library/Class/CriteresRecherche.php b/library/Class/CriteresRecherche.php index 3eb3228168a9e3bbb5561f21fe8a933696e935d3..642e5bae920ca1dc6b91d8266eb9ea95f6129ff2 100644 --- a/library/Class/CriteresRecherche.php +++ b/library/Class/CriteresRecherche.php @@ -1045,4 +1045,14 @@ class Class_CriteresRecherche extends Class_CriteresRecherche_Abstract { return $this->_order_helper = new Class_CriteresRecherche_Order($this); } + + + public function isDomainOrSelectionWithoutFacets() { + if ( ! ($this->isRecherchePanier() || $this->isRechercheCatalogue())) + return false; + + return $this->getFacettes() || $this->getMultiFacets() + ? false + : true; + } } diff --git a/library/ZendAfi/Controller/Action.php b/library/ZendAfi/Controller/Action.php index 8c0ab81d1f211c1b77cc2a2e6e953005f5f0b9bb..8f7c78c2da415b63362907f9e15342c46a8c8dbc 100644 --- a/library/ZendAfi/Controller/Action.php +++ b/library/ZendAfi/Controller/Action.php @@ -260,7 +260,7 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { } - protected function extractProfilFromUrl() { + public function extractProfilFromUrl() { $id_module = $this->_getParam('id_module'); if (!($id_module) || 1 == count($parts = explode('-', $id_module))) return Class_Profil::getCurrentProfil(); @@ -270,7 +270,7 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { } - protected function extractIdModuleFromUrl() { + public function extractIdModuleFromUrl() { $id_module = $this->_getParam('id_module'); if (!$id_module || 1 ==count($parts = explode('-', $id_module))) return $id_module; diff --git a/library/ZendAfi/View/Helper/Search/Title.php b/library/ZendAfi/View/Helper/Search/Title.php new file mode 100644 index 0000000000000000000000000000000000000000..8d4ca3bb862f8eeef6736fcb9fa7ed520a92425a --- /dev/null +++ b/library/ZendAfi/View/Helper/Search/Title.php @@ -0,0 +1,67 @@ +<?php +/** + * Copyright (c) 2012-2021, 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_Title extends ZendAfi_View_Helper_BaseHelper { + public function search_Title($criteria, $request, $controller) { + if ($titre = $request->getParam('titre')) + return $this->view->escape($titre); + + if ($request->getParam('rubrique')) + return $this->_('Recherche guidée'); + + if ($titre_from_profil = $this->_getTitreFromProfil()) + return $titre_from_profil; + + if ($titre_from_module = $this->_getTitreFromModule($controller)) + return $titre_from_module; + + if ($criteria->isBookmarked()) + return $criteria->getBookmarkedLabel(); + + if ($panier = $criteria->getPanier()) + return $panier->getLibelle(); + + if ($catalogue = $criteria->getCatalogue()) + return $catalogue->getLibelle(); + + return ''; + } + + + protected function _getTitreFromProfil() { + $params = Class_Profil::getCurrentProfil()->getSearchResultSettings(); + + return (isset($params['titre']) && ($titre = $params['titre'])) + ? $titre + : ''; + } + + + protected function _getTitreFromModule($controller) { + if(!$id_module = $controller->extractIdModuleFromUrl()) + return null; + + return ($profil = $controller->extractProfilFromUrl()) + ? $profil->getModuleTitle($id_module) + : ''; + } +} diff --git a/library/templates/Chili/View/Search/Result.php b/library/templates/Chili/View/Search/Result.php index dd4caf171861bc079462b2246131b18c2afc8063..d1eb5dc2e7fa55e76fdba8025ae5f457d82ac3d4 100644 --- a/library/templates/Chili/View/Search/Result.php +++ b/library/templates/Chili/View/Search/Result.php @@ -177,7 +177,7 @@ $(id).on('hide.bs.dropdown', function () { $('body').removeClass('overflow_hidde 'Aucun résultat pour la recherche : %s', 'Résultat pour la recherche : %s', 'Résultats pour la recherche : %s', - $this->_tag('span', sprintf('"%s"',$title))); + $this->_tag('span', sprintf('"%s"',$title), ['class' => 'searched_word'])); } diff --git a/library/templates/Intonation/View/Search/HtmlCriteria.php b/library/templates/Intonation/View/Search/HtmlCriteria.php index f9541c7dc8f329dc85a886f6d87a139877ec14d8..0a70931395531c1e7ef802f71bb24fae7d5a4be9 100644 --- a/library/templates/Intonation/View/Search/HtmlCriteria.php +++ b/library/templates/Intonation/View/Search/HtmlCriteria.php @@ -59,6 +59,9 @@ class Intonation_View_Search_HtmlCriteria extends ZendAfi_View_Helper_TagCritere if ( ! $this->_html) return $this; + if ($this->_criteres_recherche->isDomainOrSelectionWithoutFacets()) + return $this; + $url = $this->view->url($this->_criteres_recherche->getUrlCriteresWithoutFacettes(), null, diff --git a/library/templates/Intonation/View/Search/Result.php b/library/templates/Intonation/View/Search/Result.php index aa496659905f6f087aad7503920d30342315593e..ae424470d41f9bf5b2e5f5d19fe66b44454cb2b9 100644 --- a/library/templates/Intonation/View/Search/Result.php +++ b/library/templates/Intonation/View/Search/Result.php @@ -114,11 +114,13 @@ class Intonation_View_Search_Result extends ZendAfi_View_Helper_BaseHelper { protected function _getTitle($title_from_url, $text_criteria) { - return $this->_('Résultat pour %s %s', - strtolower(($this->_criteria->getExpressionRecherche() - ? $this->_criteria->getExpressionRecherche() - : $title_from_url)), - strtolower($text_criteria)); + if ($this->_criteria->hasExpressionRecherche()) + return $this->_('Résultat pour %s %s', + strtolower($this->_criteria->getExpressionRecherche()), + strtolower($text_criteria)); + + return $this->_('Résultat %s', + ltrim(strtolower($text_criteria), ' ,')); } diff --git a/library/templates/Intonation/View/Search/Title.php b/library/templates/Intonation/View/Search/Title.php new file mode 100644 index 0000000000000000000000000000000000000000..76ab5b4f1c9411b9ad347f7d058c03610eb99582 --- /dev/null +++ b/library/templates/Intonation/View/Search/Title.php @@ -0,0 +1,32 @@ +<?php +/** + * Copyright (c) 2012-2021, 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_Search_Title extends ZendAfi_View_Helper_Search_Title { + protected function _getTitreFromProfil() { + return ''; + } + + + protected function _getTitreFromModule($controller) { + return ''; + } +} diff --git a/tests/scenarios/Templates/ChiliTest.php b/tests/scenarios/Templates/ChiliTest.php index 504fce0f6c8cbd3fc06e5cb2531e6309f48391f4..f22d606ada56bf80b9d03403c4d3f24266a5a100 100644 --- a/tests/scenarios/Templates/ChiliTest.php +++ b/tests/scenarios/Templates/ChiliTest.php @@ -400,7 +400,7 @@ class ChiliTemplateNewPageEditDispatchTest extends ChiliTemplateTestCase { -class ChiliTemplateSearchResultWithDomainBrowserTest extends ChiliTemplateTestCase { +abstract class ChiliTemplateSearchResultWithDomainBrowserTestCase extends ChiliTemplateTestCase { public function setUp() { parent::setUp(); @@ -417,13 +417,8 @@ class ChiliTemplateSearchResultWithDomainBrowserTest extends ChiliTemplateTestCa $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where type=1 order by annee desc", - true, - false) - ->answers([[89, ''], [99, '']]) - ; + ->answers([[89, 'A43'], [99, 'A43']]); - Zend_Registry::set('sql', $sql); $this->fixture('Class_Catalogue', ['id' => 1, @@ -437,6 +432,7 @@ class ChiliTemplateSearchResultWithDomainBrowserTest extends ChiliTemplateTestCa $this->fixture('Class_Catalogue', ['id' => 3, 'libelle' => 'Romans', + 'auteur' => '1', 'parent_id' => 1]); $preferences = array_merge(Class_Systeme_ModulesAccueil::getInstance() @@ -452,6 +448,18 @@ class ChiliTemplateSearchResultWithDomainBrowserTest extends ChiliTemplateTestCa $profile->save(); + Zend_Registry::set('sql', $sql); + } +} + + + + +class ChiliTemplateSearchResultWithDomainTest extends ChiliTemplateSearchResultWithDomainBrowserTestCase { + + + public function setUp() { + parent::setUp(); $this->dispatch('/recherche/simple/id_module/78/id_catalogue/3'); } @@ -466,6 +474,44 @@ class ChiliTemplateSearchResultWithDomainBrowserTest extends ChiliTemplateTestCa public function domainBrowserShouldContainsRomans() { $this->assertXPathContentContains('//div[contains(@class, "tree_view_current")]', 'Romans'); } + + + /** @test */ + public function buttonResetShouldNotBePresent() { + $this->assertNotXPathContentContains('//a[@href="/recherche/simple/id_module/78/id_catalogue/3"]', 'Réinitialiser'); + } + + + /** @test */ + public function pageTitleShouldBeResultForRomans() { + $this->assertXPathContentContains('//h1', 'Résultats pour la recherche : <span class="searched_word">"romans"'); + } +} + + + + +class ChiliTemplateSearchResultWithDomainAndFacetsTest extends ChiliTemplateSearchResultWithDomainBrowserTestCase { + + + public function setUp() { + parent::setUp(); + + (new Class_Profil_Preferences()) + ->setModulePref(Class_Profil::getCurrentProfil(), + (new Class_Profil_ModuleDefinition('recherche', + 'resultat', + 'simple')), + [ 'facettes_codes' => 'T;B']); + + $this->dispatch('/recherche/simple/id_module/78/id_catalogue/3/facette/T1'); + } + + + /** @test */ + public function buttonResetShouldBePresent() { + $this->assertXPathContentContains('//a[@href="/recherche/simple/id_module/78/id_catalogue/3"]', 'Réinitialiser'); + } } diff --git a/tests/scenarios/Templates/MuscleTemplateTest.php b/tests/scenarios/Templates/MuscleTemplateTest.php index 3a436b24c8471e81519cd9acc1af21fefaaa7cf6..b3e3dbb8afe5ddc7b56c1e2dd2c4b0fae1125220 100644 --- a/tests/scenarios/Templates/MuscleTemplateTest.php +++ b/tests/scenarios/Templates/MuscleTemplateTest.php @@ -500,11 +500,7 @@ class MuscleTemplateSearchResultWithDomainBrowserTest extends MuscleTemplateTest $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where type=1 order by annee desc", - true, - false) - ->answers([[89, ''], [99, '']]) - ; + ->answers([[89, ''], [99, '']]); Zend_Registry::set('sql', $sql); @@ -520,6 +516,7 @@ class MuscleTemplateSearchResultWithDomainBrowserTest extends MuscleTemplateTest $this->fixture('Class_Catalogue', ['id' => 3, 'libelle' => 'Romans', + 'auteur' => 1, 'parent_id' => 1]); $preferences = array_merge(Class_Systeme_ModulesAccueil::getInstance() @@ -549,6 +546,12 @@ class MuscleTemplateSearchResultWithDomainBrowserTest extends MuscleTemplateTest public function domainBrowserShouldContainsRomans() { $this->assertXPathContentContains('//div[contains(@class, "tree_view_current")]', 'Romans'); } + + + /** @test */ + public function pageTitleShouldBeResultInRomans() { + $this->assertXPathContentContains('//h1', 'Résultat dans romans'); + } } diff --git a/tests/scenarios/Templates/TemplatesSearchTest.php b/tests/scenarios/Templates/TemplatesSearchTest.php index 4d8b2570da7192984e9c52d0e660bc67b806623a..2d5d797c35e122fd94a3c2d9b427c4906bc7e19b 100644 --- a/tests/scenarios/Templates/TemplatesSearchTest.php +++ b/tests/scenarios/Templates/TemplatesSearchTest.php @@ -87,7 +87,7 @@ class TemplatesDispatchIntonationSearchTest extends TemplatesIntonationTestCase public function setUp() { parent::setUp(); - $this->dispatch('/opac/recherche/simple/expressionRecherche/pomme/id_profil/72/multifacets/T1-Y1/facette/Y1/section/1', true); + $this->dispatch('/opac/recherche/simple/expressionRecherche/pomme/id_profil/72/multifacets/T1-Y1/facette/Y1/section/1'); } @@ -142,6 +142,12 @@ class TemplatesDispatchIntonationSearchTest extends TemplatesIntonationTestCase public function facetsSlideToggleScriptShouldBePresent() { $this->assertXPathContentContains('//script', '$(function(){$(".facets .msg > a").click(function(e){ e.preventDefault();var anchor = $(this);anchor.next("ul").find("li").hide().appendTo(anchor.parent().closest("ul")).slideToggle();anchor.parent().remove();})});'); } + + + /** @test */ + public function buttonResetShouldContainsExpressionRechercheOnly() { + $this->assertXPathContentContains('//a[@href="/recherche/simple/expressionRecherche/pomme"]', 'Réinitialiser'); + } }