Commit 05d0fa72 authored by Patrick Barroca's avatar Patrick Barroca 😁
Browse files

hotline #99776 : fix handling of authorities fields with custom / multifacets fields

parent 2f6e9fad
Pipeline #8625 passed with stage
in 44 minutes and 8 seconds
- ticket #99776 : Formulaires de recherche avancée : Correction de la prise en charge des formulaires contenant des champs sur facettes dynamiques et des champs sur autorités
\ No newline at end of file
......@@ -99,23 +99,23 @@ class RechercheController extends ZendAfi_Controller_Action {
$this->_saveParams($criteres_recherche);
if ($this->view->statut == 'guidee')
$criteres_recherche->updateRubrique('guidee');
$should_redirect = false;
if ($multifacets = array_merge($this->_extractDynamicFacets($params),
$this->_extractMultifacetsPost())) {
$url = $criteres_recherche->getUrlWithMultifacetsUpdate($multifacets);
isset($params ['titre']) ? ($url ['titre'] = $params ['titre']) : '';
return $this->_redirect($this->view->url($url, null, true),
['prependBase' => false]);
$criteres_recherche->multifacetsUpdate($multifacets);
$should_redirect = true;
}
if ($this->view->statut == 'guidee')
$criteres_recherche->updateRubrique('guidee');
if ($this->_request->isPost()) {
$should_redirect = true;
$criteres_recherche = (new Class_CriteresRecherche_AuthoritiesParam($params))
->injectInto($criteres_recherche);
}
if ($should_redirect) {
$criteria_params = $criteres_recherche->getUrlCriteresWithFacettes();
// preserve module as we may come from Telephone_RechercheController
$criteria_params['module'] = $this->_request->getModuleName();
......
......@@ -830,7 +830,7 @@ class Class_CriteresRecherche extends Class_CriteresRecherche_Abstract {
}
public function getUrlWithMultifacetsUpdate($update) {
public function multifacetsUpdate($update) {
$url = $this->getUrlRetourListe();
$multifacets = isset($url['multifacets']) ? explode('-', $url['multifacets']) : [];
......@@ -840,9 +840,14 @@ class Class_CriteresRecherche extends Class_CriteresRecherche_Abstract {
$multifacets = array_diff($multifacets, $remove);
$multifacets = array_unique(array_merge($multifacets, $add));
$url['multifacets'] = implode('-', $multifacets);
$this->setParam('multifacets', implode('-', $multifacets));
return array_filter($url);
return $this;
}
public function getUrlWithMultifacetsUpdate($update) {
return array_filter($this->multifacetsUpdate($update)->getUrlRetourListe());
}
......
......@@ -226,6 +226,9 @@ class ZendAfi_View_Helper_Facettes extends ZendAfi_View_Helper_BaseHelper {
if (0 !== strpos($k, 'custom_multifacets_'))
return $facets;
if ('' === $v)
return $facets;
if (!is_array($v)) {
$facets[$v] = 1;
return $facets;
......
......@@ -338,4 +338,28 @@ class SearchResultWithAuthorityRecordTest
'mode_authority_nothing' => '1']);
$this->assertRedirectTo('/recherche/simple/authorities/HDOCU_8898_0-HDOCU_8899_1');
}
/** @test */
public function withEmptyCustomFacetShouldRedirectToSearchWith8898NoHierarchyAnd8899AndItsHierarchy() {
$this->postDispatch('/opac/recherche/simple',
['authority_anything' => '8898',
'mode_authority_anything' => '0',
'authority_nothing' => '8899',
'mode_authority_nothing' => '1',
'custom_multifacets_subject' => '']);
$this->assertRedirectTo('/recherche/simple/authorities/HDOCU_8898_0-HDOCU_8899_1');
}
/** @test */
public function withCustomFacetShouldRedirectToSearchWith8898NoHierarchyAnd8899AndItsHierarchy() {
$this->postDispatch('/opac/recherche/simple',
['authority_anything' => '8898',
'mode_authority_anything' => '0',
'authority_nothing' => '8899',
'mode_authority_nothing' => '1',
'custom_multifacets_subject' => 'M608']);
$this->assertRedirectTo('/recherche/simple/multifacets/M608/authorities/HDOCU_8898_0-HDOCU_8899_1');
}
}
Markdown is supported
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