diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index e25078334ef894aad10e892c1b24daaadaca5fa2..8adad5c85f222bc0db7180a128ef96e2b8153758 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -151,6 +151,7 @@ class Class_AdminVarLoader extends Storm_Model_Loader { 'FACETTE_INTERET_LIBELLE' => Class_AdminVar_Meta::newDefault('Libellé de la facette centres d\'intérêt'), 'FACETTE_MATIERE_LIBELLE' => Class_AdminVar_Meta::newDefault('Libellé de la facette matière'), 'FACETTE_TAG_LIBELLE' => Class_AdminVar_Meta::newDefault('Libellé de la facette tag'), + 'UNLEASHED_FACETS' => Class_AdminVar_Meta::newMultiInput($this->_('Liste des codes des facettes qui ne sont pas limitées à l\'affichage dans le résultat de recherche<br/>Exemple : T => Type de doc, Y => Annexe, B => Bibliothèque, ... (Voir <a href="http://git.afi-sa.fr/afi/opacce/blob/master/library/Class/Codification.php#L24">la liste complète</a>)')), 'AFFICHER_DISPONIBILITE_SUR_RECHERCHE' => Class_AdminVar_Meta::newOnOff($this->_('Activation de la disponibilite dans le resultat de recherche.')), 'NOM_DOMAINE' => Class_AdminVar_Meta::newDefault($this->_('Nom de domaine principal de l\'OPAC, ex: monopac.macommune.fr')), 'DATE_LAST_FULL_INTEGRATION_USERS' => Class_AdminVar_Meta::newDefault($this->_('Date du dernier import total des abonnés (modifié par cosmogramme)')), diff --git a/library/Class/MoteurRecherche/Facettes.php b/library/Class/MoteurRecherche/Facettes.php index e37b022ae0eb26adab71d824a4cb06a059acb787..00caa9204bcc6abb4c583f0c73dbbb57c511cc72 100644 --- a/library/Class/MoteurRecherche/Facettes.php +++ b/library/Class/MoteurRecherche/Facettes.php @@ -112,7 +112,9 @@ class Class_MoteurRecherche_Facettes { $nb=0; foreach($this->_facettes_par_code_rubrique[$code_rubrique] as $facette) { $nb++; - if($nb > $nb_facettes) break; + if ($nb > $nb_facettes + && (new Class_AdminVar_UnleashedFacets)->isNotUnleashed($code_rubrique)) + break; $table["facettes"][$code_rubrique][$nb]["id"] = $cle=$facette->getCle(); $table["facettes"][$code_rubrique][$nb]["libelle"]= $facette->getLibelleFacette(); diff --git a/library/ZendAfi/View/Helper/Facettes.php b/library/ZendAfi/View/Helper/Facettes.php index df4956723e67e04c9a7399a2a71261dac5aa2aa9..6e46eb327af353073e1625d4241a9cdb6aa218a4 100644 --- a/library/ZendAfi/View/Helper/Facettes.php +++ b/library/ZendAfi/View/Helper/Facettes.php @@ -73,7 +73,9 @@ class ZendAfi_View_Helper_Facettes extends ZendAfi_View_Helper_BaseHelper { public function listeFacettesElementHTML($type, $values, $url) { - $count = $this->_preferences['facettes_nombre']; + $count = (new Class_AdminVar_UnleashedFacets())->isUnleashed($type) + ? count($values) + : $this->_preferences['facettes_nombre']; $first_facets = array_splice($values, 0, $count); $following_facets = array_splice($values, 0, $count); diff --git a/tests/library/Class/MoteurRecherche/MoteurRechercheFacettesTest.php b/tests/library/Class/MoteurRecherche/MoteurRechercheFacettesTest.php index b0a41ecf88ebe092dd9c97a0aba2a88ecbdbeb4c..298fdadb4f60aa5bdc7b55400ca5a0ec4cb4428d 100644 --- a/tests/library/Class/MoteurRecherche/MoteurRechercheFacettesTest.php +++ b/tests/library/Class/MoteurRecherche/MoteurRechercheFacettesTest.php @@ -19,11 +19,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class MoteurRechercheFacettesTest extends Storm_Test_ModelTestCase { - protected $_requete; +class MoteurRechercheFacettesTest extends ModelTestCase { + protected + $_requete, + $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); + $this->fixture('Class_CodifLangue', + ['id' => 'fre', + 'libelle' => 'français']); + Class_CosmoVar::newInstanceWithId('types_docs', ['liste' => '0:non identifié\r\n1:livres\r\n2:périodiques']); @@ -165,7 +172,7 @@ class MoteurRechercheFacettesTest extends Storm_Test_ModelTestCase { /** @test */ - public function numberOfFacettesAutorShouldBeFivePlusFive() { + public function numberOfFacettesAuthorShouldBeFivePlusFive() { // title + facets + show more facets $this->assertEquals(1 + 5 + 5, count($this->facettes['facettes']['A'])); } @@ -210,6 +217,22 @@ class MoteurRechercheFacettesTest extends Storm_Test_ModelTestCase { 'facettes_actif' => 1 ])); } + + + /** @test */ + public function whenAuthorsUnleashedNumberOfFacetsShouldBe813() { + Class_AdminVar::set('UNLEASHED_FACETS', 'A'); + $this->facettes = $this->moteur_recherche->getFacettes($this->_requete, + ['facettes_nombre' => 5, + 'tags_actif' => 1, + 'tags_codes'=> 'MDPZAHTES1', + 'tags_nombre' => 30, + 'facettes_codes'=>'MFSABZLYHTHEMHTES1V', + 'facettes_actif' => 1 + ]); + $this->assertEquals(1 + 813, count($this->facettes['facettes']['A'])); + + } } diff --git a/tests/library/ZendAfi/View/Helper/FacettesTest.php b/tests/library/ZendAfi/View/Helper/FacettesTest.php index a25239c6fb73386b50ce3ba01dd23927be3cd2fc..e2269d352c03f5debf60562a1395cba23b92822d 100644 --- a/tests/library/ZendAfi/View/Helper/FacettesTest.php +++ b/tests/library/ZendAfi/View/Helper/FacettesTest.php @@ -19,57 +19,77 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class ZendAfi_View_Helper_FacettesTest extends ViewHelperTestCase { - protected $_html; +abstract class ZendAfi_View_Helper_FacettesTestCase extends ViewHelperTestCase { + protected + $_html, + $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); + $this->_helper = new ZendAfi_View_Helper_Facettes(); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); - $this->_html = $this->_helper->facettes(['M' => [ 'titre' => 'Matière', - 1 => ['id' => 'M6567', - 'libelle' => 'Pommes : albums', - 'nombre' => 22]], - 'HGENR' => [ 'titre' => 'Genre', - 1 => ['id' => 'HGENR0001', - 'libelle' => 'Electron libre', - 'nombre' => 1]], - 'Y' => [ 'titre' => 'Annexe', - 1 => ['id' => 'YMDE', - 'libelle' => 'Maison environnement', - 'nombre' => 1]], - 'A' => ['titre' => 'Author', - 1 => ['id' => 'A4656', - 'libelle' => 'Caradog Prichard', - 'nombre' => 58], - 2 => ['id' => 'A4657', - 'libelle' => 'Louis-Jean Calvet', - 'nombre' => 40], - 3 => ['id' => 'A6752', - 'libelle' => 'Maurice Henry', - 'nombre' => 21], - 4 => ['id' => 'A63246', - 'libelle' => 'François Chattot', - 'nombre' => 12], - 5 => ['id' => 'A12309', - 'libelle' => 'Olivier Richard', - 'nombre' => 10], - 6 => ['id' => 'A446', - 'libelle' => 'Clare Brown', - 'nombre' => 7], - 7 => ['id' => 'A800', - 'libelle' => 'Karine Delobbe', - 'nombre' => 7], - 8 => ['id' => 'A12168', - 'libelle' => 'Mehdi Lallaoui', - 'nombre' => 6], - 9 => ['id' => 'A9875', - 'libelle' => 'Régine Azria', - 'nombre' => 5] ]], - - ['facettes_codes' => 'YMHGENRA', - 'facettes_nombre' => 2], - new Class_CriteresRecherche(['expressionRecherche' => '*'])); + $this->_prepareFixtures(); + + $this->_html = $this->_helper + ->facettes(['M' => [ 'titre' => 'Matière', + 1 => ['id' => 'M6567', + 'libelle' => 'Pommes : albums', + 'nombre' => 22]], + 'HGENR' => [ 'titre' => 'Genre', + 1 => ['id' => 'HGENR0001', + 'libelle' => 'Electron libre', + 'nombre' => 1]], + 'Y' => [ 'titre' => 'Annexe', + 1 => ['id' => 'YMDE', + 'libelle' => 'Maison environnement', + 'nombre' => 1]], + 'A' => ['titre' => 'Author', + 1 => ['id' => 'A4656', + 'libelle' => 'Caradog Prichard', + 'nombre' => 58], + 2 => ['id' => 'A4657', + 'libelle' => 'Louis-Jean Calvet', + 'nombre' => 40], + 3 => ['id' => 'A6752', + 'libelle' => 'Maurice Henry', + 'nombre' => 21], + 4 => ['id' => 'A63246', + 'libelle' => 'François Chattot', + 'nombre' => 12], + 5 => ['id' => 'A12309', + 'libelle' => 'Olivier Richard', + 'nombre' => 10], + 6 => ['id' => 'A446', + 'libelle' => 'Clare Brown', + 'nombre' => 7], + 7 => ['id' => 'A800', + 'libelle' => 'Karine Delobbe', + 'nombre' => 7], + 8 => ['id' => 'A12168', + 'libelle' => 'Mehdi Lallaoui', + 'nombre' => 6], + 9 => ['id' => 'A9875', + 'libelle' => 'Régine Azria', + 'nombre' => 5]]], + + ['facettes_codes' => 'YMHGENRA', + 'facettes_nombre' => 2], + + new Class_CriteresRecherche(['expressionRecherche' => '*'])); + } + + + protected function _prepareFixtures() { + } +} + + + +class ZendAfi_View_Helper_FacettesRestrainedTest extends ZendAfi_View_Helper_FacettesTestCase { + + protected function _prepareFixtures() { + $this->fixture('Class_AdminVar', ['id' => 'UNLEASHED_FACETS', 'valeur' => '']); } @@ -120,14 +140,27 @@ class ZendAfi_View_Helper_FacettesTest extends ViewHelperTestCase { } -/** @test */ + /** @test */ public function linkForFacetElectroLibreShouldBePresent() { $this->assertXPathContentContains($this->_html, '//a[@class="facette"][contains(@href, "/recherche/simple/facette/HGENR0001")]', 'Electron libre'); } +} -} -?> \ No newline at end of file +class ZendAfi_View_Helper_FacettesUnleashedTest + extends ZendAfi_View_Helper_FacettesTestCase { + + protected function _prepareFixtures() { + Class_AdminVar::set('UNLEASHED_FACETS', 'A'); + } + + + /** @test */ + public function linkForFacetOlivierRichardShouldNotBePresent() { + $this->assertXPath($this->_html, + '//a[@class="facette"][contains(@href, "/recherche/simple/facette/A12309")]'); + } +} \ No newline at end of file