diff --git a/application/modules/admin/views/scripts/accueil/critiques.phtml b/application/modules/admin/views/scripts/accueil/critiques.phtml index d4b3afb519f04455c09f11db5abb076a14115b30..8f521eae574c203de42c333f74e204c4a8e45638 100644 --- a/application/modules/admin/views/scripts/accueil/critiques.phtml +++ b/application/modules/admin/views/scripts/accueil/critiques.phtml @@ -1,74 +1,109 @@ +<?php +Class_ScriptLoader::getInstance() +->addJQueryReady(' +function toggleHierarchical() { + if ($("#hierarchical").is(":checked")) { + $(".non-hierarchical").hide(); + $("#only_img").parents("tr").hide(); + $("#id_panier").parents("tr").hide(); + return; + } + + $(".non-hierarchical").show(); + $("#only_img").parents("tr").show(); + $("#id_panier").parents("tr").show(); +} + + +$("#hierarchical").change(toggleHierarchical); +toggleHierarchical(); +'); +?> <center> - <h1>Propriétés du module : Dernières critiques</h1><br> + <h1>Propriétés du module : Critiques</h1><br> <div class="formTable"> - <form method="post" action="<?php echo $this->url ?>"> - + <form method="post" action="<?php echo $this->url; ?>"> + <fieldset> - <legend>Affichage</legend> - <table cellspacing="2"> - <tr> - <td class="droite">Titre du bloc </td> - <td class="gauche"><input type="text" name="titre" size="50" maxlength="60" value="<?php print($this->preferences["titre"]); ?>"></td> - </tr> - - <tr> - <td class="droite">Style de boite </td> - <td class="gauche"><?php echo $this->combo_templates ?></td> - </tr> - - </table> + <legend>Affichage</legend> + <table cellspacing="2"> + <tr> + <td class="droite">Titre du bloc </td> + <td class="gauche"><input type="text" name="titre" size="50" maxlength="60" value="<?php print($this->preferences['titre']); ?>"></td> + </tr> + + <tr> + <td class="droite">Style de boite </td> + <td class="gauche"><?php echo $this->combo_templates; ?></td> + </tr> + <tr> + <td class="droite">Proposer un fil Rss </td> + <td class="gauche"> + <?php echo $this->formCheckbox('rss_avis', + $this->preferences['rss_avis'], + null, + ['1', '0']); ?> + </td> + </tr> + </table> </fieldset> <br> - + <fieldset> - <legend>Critiques</legend> - <table cellspacing="2"> - <tr> - <td class="droite">Origine des critiques </td> - <td class="gauche"> - <?php echo $this->formSelect("abon_ou_bib",$this->preferences["abon_ou_bib"],"",array("1" => "Bibliothécaire","0"=>"Abonné ou utilisateur du site","all" => "Tout le monde")) ?> - </td> - </tr> - <tr> - <td class="droite">Nombre à afficher </td> - <td class="gauche"><input type="text" name="nb_aff_avis" size="2" maxlength="2" value="<?php print($this->preferences["nb_aff_avis"]); ?>"></td> - </tr> - <tr> - <td class="droite">Ordre d'affichage </td> - <td class="gauche"> - <?php - echo $this->formRadioButtons("display_order", - $this->preferences["display_order"], - array( - "CreationDesc" => "Par date de création (plus récent en premier)", - "Random" => "Aléatoire")); - ?> - </td> - </tr> + <legend>Critiques</legend> + <table cellspacing="2"> + <tr> + <td class="droite">Origine des critiques </td> + <td class="gauche"> + <?php echo $this->formSelect('abon_ou_bib', + $this->preferences['abon_ou_bib'], + '', + ['1' => 'Bibliothécaire', + '0' => 'Abonné ou utilisateur du site', + 'all' => 'Tout le monde']); ?> + </td> + </tr> - <tr> - <td class="droite">Couper les critiques à </td> - <td class="gauche"><input type="text" name="nb_words" size="3" maxlength="3" value="<?php print($this->preferences["nb_words"]); ?>">mots</td> - </tr> - <tr> - <td class="droite">Proposer un fil Rss </td> - <td class="gauche"> - <?php echo $this->formCheckbox('rss_avis', - $this->preferences['rss_avis'], - null, - array('1', '0')) ?> - </td> - </tr> - </table> + <tr> + <td class="droite">Navigation hiérarchique </td> + <td class="gauche"> + <?php echo $this->formCheckbox('hierarchical', + $this->preferences['hierarchical'], + null, + ['1', '0']); ?> + </td> + </tr> + + <tr class="non-hierarchical"> + <td class="droite">Nombre à afficher </td> + <td class="gauche"><input type="text" name="nb_aff_avis" size="2" maxlength="2" value="<?php print($this->preferences['nb_aff_avis']); ?>"></td> + </tr> + <tr class="non-hierarchical"> + <td class="droite">Ordre d'affichage </td> + <td class="gauche"> + <?php + echo $this->formRadioButtons('display_order', + $this->preferences['display_order'], + ['CreationDesc' => 'Par date de création (plus récent en premier)', + 'Random' => 'Aléatoire']); + ?> + </td> + </tr> + <tr class="non-hierarchical"> + <td class="droite">Couper les critiques à </td> + <td class="gauche"><input type="text" name="nb_words" size="3" maxlength="3" value="<?php print($this->preferences['nb_words']); ?>">mots</td> + </tr> + </table> </fieldset> - <?php - echo $this->partial("accueil/_options_catalogue_panier.phtml", - array('preferences' => $this->preferences, - 'catalogues' => $this->catalogues, - 'paniers' => $this->paniers)); + <?php + echo $this->partial('accueil/_options_catalogue_panier.phtml', + ['preferences' => $this->preferences, + 'catalogues' => $this->catalogues, + 'paniers' => $this->paniers]); ?> - - <?php echo $this->formSubmit("Valider","Valider",array("class" => "bouton")) ?> - </form> - </div> + + <?php echo $this->formSubmit('Valider', 'Valider', ['class' => 'bouton']); ?> + </form> + </div> +</center> diff --git a/library/Class/Systeme/ModulesAccueil/Critiques.php b/library/Class/Systeme/ModulesAccueil/Critiques.php index 8c9d1a8909517814d0a07159594c804d61f2b746..fbb1f5a8a1d798e5b86e4d5d7dac200f18f6f5fe 100644 --- a/library/Class/Systeme/ModulesAccueil/Critiques.php +++ b/library/Class/Systeme/ModulesAccueil/Critiques.php @@ -16,12 +16,12 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_Systeme_ModulesAccueil_Critiques extends Class_Systeme_ModulesAccueil_Null{ /** @var string */ protected $_group = Class_Systeme_ModulesAccueil::GROUP_INFO; - + /** @var string */ protected $_libelle = 'Critiques'; @@ -38,17 +38,17 @@ class Class_Systeme_ModulesAccueil_Critiques extends Class_Systeme_ModulesAccuei protected $_isPhone = true; /** @var array */ - protected $_defaultValues = array( - 'titre' => "Dernières critiques", // Titre du bloc critiques - 'nb_aff_avis' => 2, // Nombre de critiques à afficher - 'nb_words' => 30, // Couper les critiques à X mots - 'display_order' => "Random", // Affichage par ordre aléatoire - 'rss_avis' => "1", // Proposer le flux RSS - 'only_img' => '1', - 'id_panier' => 0, - 'id_catalogue' => 0, - 'abon_ou_bib' => 0, - 'tri' => 0 //tri par titre - ); + protected $_defaultValues = ['titre' => "Dernières critiques", // Titre du bloc critiques + 'nb_aff_avis' => 2, // Nombre de critiques à afficher + 'nb_words' => 30, // Couper les critiques à X mots + 'display_order' => "Random", // Affichage par ordre aléatoire + 'rss_avis' => "1", // Proposer le flux RSS + 'only_img' => '1', + 'id_panier' => 0, + 'id_catalogue' => 0, + 'abon_ou_bib' => 0, + 'tri' => 0, //tri par titre + 'hierarchical' => 0, + ]; } ?> \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/AccueilControllerCritiquesTest.php b/tests/application/modules/admin/controllers/AccueilControllerCritiquesTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d2e16effd6df2b4cc56fa879f0d946a67bd9e0e7 --- /dev/null +++ b/tests/application/modules/admin/controllers/AccueilControllerCritiquesTest.php @@ -0,0 +1,114 @@ +<?php +/** + * Copyright (c) 2012-2014, 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 Admin_AccueilControllerCritiquesTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + $this->onLoaderOfModel('Class_PanierNotice') + ->whenCalled('findAllBelongsToAdmin') + ->answers([]); + + $this->dispatch('admin/accueil/critiques?config=accueil&id_profil=1&id_module=1&type_module=CRITIQUES', + true); + } + + + /** @test */ + public function titleShouldBePresent() { + $this->assertXPathContentContains('//h1', 'Critiques'); + } + + + /** @test */ + public function boxTitleShouldBePresent() { + $this->assertXPath('//input[@name="titre"]'); + } + + + /** @test */ + public function styleShouldBePresent() { + $this->assertXPath('//select[@name="boite"]'); + } + + + /** @test */ + public function rssChoiceShouldBePresent() { + $this->assertXPath('//input[@type="checkbox"][@name="rss_avis"]'); + } + + + /** @test */ + public function originShouldBePresent() { + $this->assertXPath('//select[@name="abon_ou_bib"]'); + } + + + /** @test */ + public function hierarchicalChoiceShouldBePresent() { + $this->assertXPath('//input[@type="checkbox"][@name="hierarchical"]'); + } + + + /** @test */ + public function displayCountShouldBePresent() { + $this->assertXPath('//input[@name="nb_aff_avis"]'); + } + + + /** @test */ + public function displayOrderShouldBePresent() { + $this->assertXPath('//input[@type="radio"][@name="display_order"]'); + } + + + /** @test */ + public function contentCutShouldBePresent() { + $this->assertXPath('//input[@name="nb_words"]'); + } + + + /** @test */ + public function thumbsChoiceShouldBePresent() { + $this->assertXPath('//select[@name="only_img"]'); + } + + + /** @test */ + public function domainsShouldBePresent() { + $this->assertXPath('//select[@name="id_catalogue"]'); + } + + + /** @test */ + public function basketsShouldBePresent() { + $this->assertXPath('//select[@name="id_panier"]'); + } + + + /** @test */ + public function submitShouldBePresent() { + $this->assertXPath('//input[@type="submit"][@name="Valider"]'); + } +} \ No newline at end of file