Commit c02e7e37 authored by Ghislain Loas's avatar Ghislain Loas

dev #75068 explo

parent ed10f348
'75068' =>
['Label' => $this->_('[MINSOC] XSLT - étape 4 : gestion des rebonds '),
'Desc' => '',
'Image' => '',
'Video' => '',
'Category' => '',
'Right' => function($feature_description, $user) {return true;},
'Wiki' => '',
'Test' => '',
'Date' => '2018-05-29'],
\ No newline at end of file
- ticket #75068 : [MINSOC] XSLT - étape 4 : gestion des rebonds
\ No newline at end of file
......@@ -413,6 +413,30 @@ class CodifThesaurusLoader extends Storm_Model_Loader {
protected function _like($field, $clause) {
return $field . ' like \''. $clause . '\'';
}
public function getSearchParams() {
$params = [];
foreach(static::getDynamicCodes() as $thesaurus) {
$params [] = 'rech_' . Class_CodifThesaurus::CODE_FACETTE. $thesaurus;
}
return $params;
}
public function getDynamicCodes() {
xdebug_break();
$dynamic_facets = Class_CodifThesaurus::findAllBy(['rules not' => null,
'code not' => null,
'id_thesaurus not' => null]);
$params = [];
foreach($dynamic_facets as $facet)
$params [] = $facet->getCode();
return array_unique($params);
}
}
......
......@@ -128,7 +128,8 @@ class Class_CriteresRecherche {
'fil',
'bib_select',
'serie',
'from']);
'from'],
Class_CodifThesaurus::getSearchParams());
}
......@@ -225,6 +226,8 @@ class Class_CriteresRecherche {
$facettes = explode('-', $this->getParam('facettes', ''));
$facettes[] = $this->getParam('facette', '');
$facettes = $this->_getFacetsForDynamicParams($facettes);
return array_unique(array_filter($facettes,
[$this->getValidateFacette(),
'isValid']
......@@ -232,6 +235,20 @@ class Class_CriteresRecherche {
}
protected function _getFacetsForDynamicParams($facets) {
foreach(Class_CodifThesaurus::getDynamicCodes() as $code) {
if (!$value = $this->getParam('rech_'.Class_CodifThesaurus::CODE_FACETTE.$code))
continue;
$instance = Class_CodifThesaurus::findFirstBy(['code' => $code,
'libelle' => $value]);
$facets[] = $instance ? Class_CodifThesaurus::CODE_FACETTE.$instance->getIdThesaurus() : '';
}
return array_filter($facets);
}
public function getMultiFacets() {
return array_filter(array_merge(explode('-', $this->getParam('multifacets','')),
$this->selectionToArray(Class_CodifGenre::CODE_FACETTE,
......@@ -519,10 +536,16 @@ class Class_CriteresRecherche {
$visitor->visitExpression($expression,$this->getPertinence(),$this->getTri());
$type_recherche = $this->getTypeRecherche();
$text_inputs = ['titres', 'auteurs', 'matieres', 'dewey', 'collection'];
$text_inputs = array_merge(['titres',
'auteurs',
'matieres',
'dewey',
'collection']);
foreach($text_inputs as $name) {
$operateur = $this->getParam('operateur_'.$name);
if ($value = $this->getParam('rech_'.$name))
$operateur = $this->getParam('operateur_' . $name);
if ($value = $this->getParam('rech_' . $name))
$visitor->visitTextInput($name, $operateur, $type_recherche, $value,$this->getPertinence());
}
......@@ -567,7 +590,7 @@ class Class_CriteresRecherche {
$visitor->visitSearchUrl($this->getUrlCriteresWithFacettes());
$this->visitByRechercheType($visitor);
xdebug_break();
$facettes = $this->getFacettes();
foreach($facettes as $facette)
$visitor->visitFacette($facette);
......
......@@ -88,6 +88,8 @@ class SearchResultHeaderTest extends AbstractControllerTestCase {
}
class SearhResultFilterDomainsFromProfilTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
......@@ -137,7 +139,6 @@ class SearhResultFilterDomainsFromProfilTest extends AbstractControllerTestCase
public function linkToDomainYouthsOrAdultsShouldBeDisplayInFacet() {
$this->assertXPathContentContains('//div[@class="criteres_recherche"]', 'Domaine: Youths OU Adults', $this->_response->getBody());
}
}
......@@ -232,4 +233,51 @@ class SearchResultFilterFromProfilOnDomainTest extends AbstractControllerTestCas
public function facetShouldNotDisplyFilteredDocTypeBook() {
$this->assertNotXpath('//li[@class="facette"]//input[@name="multifacet_T1"]');
}
}
class SearchResultWithDynamicFacetTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->fixture('Class_CodifThesaurus',
['id' => 3,
'libelle' => 'Document',
'libelle_facette' => 'Document',
'id_thesaurus' => 'DOCU',
'id_origine' => null,
'code' => 'DOCU',
'rules' => '{"label":" 99$t "}']);
$this->fixture('Class_CodifThesaurus',
['id' => 4,
'libelle' => 'SIFI',
'libelle_facette' => 'Science fiction',
'id_thesaurus' => 'DOCU0001',
'id_origine' => null,
'code' => 'DOCU',
'rules' => '{"label":" 99$t "}']);
$sql = $this->mock()
->whenCalled('fetchAll')
->with("select id_notice, facettes from notices Where MATCH(facettes) AGAINST('+HDOCU0001' IN BOOLEAN MODE)", true, false)
->answers([
[1, 'HDOCU0001']
])
->beStrict();
Zend_Registry::set('sql', $sql);
$this->dispatch('/opac/recherche/simple/rech_HDOCU/SIFI', true);
}
/** @test */
public function shouldReturnSearchResult() {
$this->assertXPath('//div');
}
}
\ No newline at end of file
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