Skip to content
Snippets Groups Projects
Commit 4285d6c3 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch 'hotline#59392_bug_facettes_nouveautes_sur_domaines_master' into 'hotline-master'

hotline #59392 : fix facets filtering with domain and profile filters

See merge request !2119
parents 716ceb62 98c2c5c4
Branches
Tags
4 merge requests!2334Master,!2124Master,!2123Hotline master,!2119hotline #59392 : fix facets filtering with domain and profile filters
Pipeline #1214 failed with stage
in 18 minutes and 11 seconds
- ticket #59392 : Résultat de recherche : Correction de la disparition des facettes lors de l'usage simultané des domaines et des filtres par profils
\ No newline at end of file
......@@ -253,31 +253,33 @@ class Class_CriteresRecherche {
public function getFiltres() {
$filtres = [ 'G' => $this->selectionToArray('G', $this->getGenre()),
];
if (!$this->isRecherchePanier() && !$this->isRechercheCatalogueEmpty() && $this->_profil) {
$filtres = array_merge($filtres, [
'T' => $this->selectionToArray('T', $this->_profil->getSelTypeDoc()),
'Y' => $this->selectionToArray('Y', $this->_profil->getSelAnnexe()),
'S' => $this->selectionToArray('S', $this->_profil->getSelSection()),
]);
$filtres = ['G' => $this->selectionToArray('G', $this->getGenre())];
if (!$this->isRecherchePanier()
&& !$this->isRechercheCatalogueEmpty()
&& $this->_profil) {
$filtres = array_merge($filtres,
['T' => $this->selectionToArray('T', $this->_profil->getSelTypeDoc()),
'Y' => $this->selectionToArray('Y', $this->_profil->getSelAnnexe()),
'S' => $this->selectionToArray('S', $this->_profil->getSelSection()),
]);
}
$filtres_array = array_filter(explode('-',$this->getParam('filtres',null)));
$filtres_array = array_filter(explode('-', $this->getParam('filtres', null)));
foreach ($filtres_array as $filtre_str) {
$filtres[]= array_filter(explode(';',$filtre_str),
[$this, 'validCodeOrNull']);
}
if (($codes = array_filter(explode(';',$filtre_str), [$this, 'validCodeOrNull']))
&& ($key = Class_Notice_Facette::extractCodeRubrique($codes[0])))
$filtres[$key] = $codes;
}
if ($bibs=$this->getBibs()) {
if ($bibs = $this->getBibs()) {
$bib_ids=[];
$bibs_array=explode(',',$bibs);
$bibs_array = explode(',',$bibs);
foreach ($bibs_array as $bib) {
$bib_ids[]= 'B'.$bib;
$bib_ids[] = 'B'.$bib;
}
$filtres['B']=$bib_ids;
$filtres['B'] = $bib_ids;
}
if ($geo_zone=$this->getGeoZone()) {
......@@ -294,7 +296,7 @@ class Class_CriteresRecherche {
$filtres['B'] = ['B'.$bib->getId()];
}
return array_filter($filtres);
return array_filter($filtres);
}
......@@ -786,6 +788,9 @@ class Class_CriteresRecherche {
public function getUrlRemoveMultiFacet($code) {
$multifacets = [];
foreach($this->getMultiFacets() as $facet) {
if (!$facet)
continue;
$model = new Class_Notice_Facette($facet);
if ($model->getRubrique()->getCode() != $code)
$multifacets[] = $facet;
......
......@@ -93,7 +93,6 @@ class SearchResultHeaderTest extends AbstractControllerTestCase {
class SearchResultFilterFromProfilTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$profil = Class_Profil::getCurrentProfil();
......@@ -116,4 +115,65 @@ class SearchResultFilterFromProfilTest extends AbstractControllerTestCase {
public function facetShouldNotContainsDocTypeBook() {
$this->assertNotXpath('//li[@class="facette"]//input[@name="multifacet_T1"]');
}
}
/**
* @see http://forge.afi-sa.fr/issues/59392
*/
class SearchResultFilterFromProfilOnDomainTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$profil = Class_Profil::getCurrentProfil();
$profil
->setSelTypeDoc(Class_TypeDoc::PERIODIQUE)
->setIdSite(1);
$this->fixture('Class_Bib',
['id' => 1, 'libelle' => 'testing lib']);
$this->fixture('Class_CodifEmplacement',
['id' => 36,
'libelle' => 'Third floor',
'regles' => '995$k=36']);
$this->fixture('Class_CodifAuteur',
['id' => 332,
'libelle' => 'leiji matsumoto']);
$this->fixture('Class_Notice', ['id' => 1]);
Class_CodifThesaurus::findLibraryNoveltyFor(1);
$this->fixture('Class_Catalogue',
['id' => 24,
'libelle' => 'Jeunesse',
'nouveaute' => 1,
'bibliotheque' => 1,
'emplacement' => '36;112']);
$sql = $this->mock()
->whenCalled('fetchAll')
->with("select id_notice, facettes from notices Where (date_creation >'2017-04-13' and MATCH(facettes) AGAINST('+(B1) +(E36 E112) +(HNNNN0001)' IN BOOLEAN MODE)) and MATCH(facettes) AGAINST('+B1 +(T2)' IN BOOLEAN MODE) order by annee desc", true, false)
->answers([ [1, 'T1 T2 B1 HNNNN0001 E36 A332'] ]);
Zend_Registry::set('sql', $sql);
$this->dispatch('/opac/recherche/simple/id_catalogue/24', true);
}
/** @test */
public function shouldDisplayNonFilteredAuthor() {
$this->assertXPath('//li[@class="facette"]//input[@name="multifacet_A332"]');
}
/** @test */
public function facetShouldNotDisplyFilteredDocTypeBook() {
$this->assertNotXpath('//li[@class="facette"]//input[@name="multifacet_T1"]');
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment