diff --git a/application/modules/admin/views/scripts/accueil/sitotheque.phtml b/application/modules/admin/views/scripts/accueil/sitotheque.phtml index 6f3e6e4b36ce42286b67e6be95d80d2b42fa3771..942e6213c49633901b3028299c77d414cb28b4ae 100644 --- a/application/modules/admin/views/scripts/accueil/sitotheque.phtml +++ b/application/modules/admin/views/scripts/accueil/sitotheque.phtml @@ -34,12 +34,13 @@ <td class="droite" width="90px">Type </td> <td class="gauche"> <?php - $onchange="$('.treeselect').treeselect('toggleVisibility', (this.value == '1'));"; + $onchange="$('.treeselect').treeselect('toggleVisibility', (this.value == '1' || this.value=='3'));"; echo $this->formSelect("type_aff", $this->preferences["type_aff"], - array("onchange" => $onchange), - array("1" => "Une sélection de catégories ou de sites", - "2" => "Les sites les plus récents")) + ["onchange" => $onchange], + ["1" => "Une sélection de catégories ou de sites", + "2" => "Les sites les plus récents", + "3" => "Affichage hiérarchique par catégorie"]) ?> </td> </tr> diff --git a/application/modules/opac/controllers/SitoController.php b/application/modules/opac/controllers/SitoController.php index 6700be3445c74b537831b58e3cb73316cc7be1c8..bac17cff4f58321deb4e7d95edc0a7475c015ae8 100644 --- a/application/modules/opac/controllers/SitoController.php +++ b/application/modules/opac/controllers/SitoController.php @@ -66,7 +66,7 @@ class SitoController extends Zend_Controller_Action { $preferences = Class_Profil::getCurrentProfil() ->getModuleAccueilPreferences($id_module, 'SITO'); - + xdebug_break(); $sites = Class_Sitotheque::getSitesFromIdsAndCategories( explode('-', $preferences['id_items']), explode('-', $preferences['id_categorie'])); diff --git a/library/ZendAfi/View/Helper/Menu/Profil.php b/library/ZendAfi/View/Helper/Menu/Profil.php index c759646e3562a785943f9234ee972309a32b14dc..40e14574e356e4155cd38844144a6bba8e77fc77 100644 --- a/library/ZendAfi/View/Helper/Menu/Profil.php +++ b/library/ZendAfi/View/Helper/Menu/Profil.php @@ -16,14 +16,15 @@ * * 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 ZendAfi_View_Helper_Menu_Profil extends ZendAfi_View_Helper_Menu_Entry { public function getBoite($li_class = '') { - return (Class_Profil::getCurrentProfil()->getId() == (int)$this->_preferences['clef_profil']) - ? parent::getBoite(trim($li_class.' selected_profil')) - : parent::getBoite($li_class); + if (isset($this->_preferences['clef_profil']) && + (Class_Profil::getCurrentProfil()->getId() == (int)$this->_preferences['clef_profil'])) + return parent::getBoite(trim($li_class.' selected_profil')); + return parent::getBoite($li_class); } } diff --git a/tests/application/modules/admin/controllers/AccueilControllerTest.php b/tests/application/modules/admin/controllers/AccueilControllerTest.php index f82c9f25adb18c56d9c720278b5d8d2b7fa6a58e..b9958afdbc6a0c7643d5b523fd8daf06f1d08adf 100644 --- a/tests/application/modules/admin/controllers/AccueilControllerTest.php +++ b/tests/application/modules/admin/controllers/AccueilControllerTest.php @@ -296,6 +296,11 @@ class AccueilControllerConfigSitothequeWithPreferencesTest extends Admin_Abstrac public function displayOrderSelectionShouldBeChecked() { $this->assertXPath('//input[@type="radio"][@name="display_order"][@checked="checked"][@value="Selection"]'); } + +/** @test */ + public function typeHierarchicCanBeSelected() { + $this->assertXPathContentContains('//select[@id="type_aff"]//option[@value=3]','Affichage hiérarchique par catégorie'); + } } diff --git a/tests/application/modules/opac/controllers/SitoControllerTest.php b/tests/application/modules/opac/controllers/SitoControllerTest.php index 0a18cc72cc260791aef4bf42e4744b803ad225c4..0b7904fdb5a95c9883c2043ec0765f203108559a 100644 --- a/tests/application/modules/opac/controllers/SitoControllerTest.php +++ b/tests/application/modules/opac/controllers/SitoControllerTest.php @@ -19,9 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ abstract class SitoControllerTestCase extends AbstractControllerTestCase { + protected $hackers; public function setUp() { parent::setUp(); - $this->fixture('Class_SitothequeCategorie', + $this->hackers=$this->fixture('Class_SitothequeCategorie', ['id' => 3, 'libelle' => 'Hackers']); @@ -57,7 +58,59 @@ abstract class SitoControllerTestCase extends AbstractControllerTestCase { } +class SitoControllerHierarchicViewTest extends SitoControllerTestCase { + public function setUp() { + parent::setUp(); + $this->fixture('Class_SitothequeCategorie', + ['id' => 12, + 'parent_categorie' => $this->hackers, + 'libelle' => 'Collectifs' ]); + + + $this->fixture('Class_Sitotheque', + ['id' => 280, + 'id_cat' => 12, + 'titre' => 'La quadrature du net', + 'description' => 'Internet et libertés', + 'url' => 'http://laquadrature.net']); + + $this->fixture('Class_Sitotheque', + ['id' => 281, + 'id_cat' => 12, + 'titre' => 'Framasoft', + 'description' => 'Degooglisons internet', + 'url' => 'http://framasoft.org']); + + Class_Profil::getCurrentProfil() + ->setCfgAccueil([ + 'modules' => [ + '1' => [ + 'division' => '2', + 'type_module' => 'SITO', + 'preferences' => [ + 'id_categorie' => '12', + "type_aff" => "3", + 'id_items' => '280-281'] + ] + ], + 'options' => []]); + + $this->dispatch('/sito/viewselection/id_module/1', true); + + } + /** @test */ + public function LinuxFrShouldNotBeShown() { + $this->assertNotXPath('//div[@class="contenu"]//div[@class="sitotheque"]//a[@href="http://linuxfr.org"]', + $this->_response->getBody()); + } + +/** @test */ + public function FramasoftShouldBeShown() { + $this->assertNotXPath('//div[@class="contenu"]//div[@class="sitotheque"]//a[@href="http://framasoft.org"]', + $this->_response->getBody()); + } +} class SitoControllerViewRecentTest extends SitoControllerTestCase { public function setUp() { parent::setUp(); @@ -79,7 +132,7 @@ class SitoControllerViewSelectionTest extends SitoControllerTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/sito/viewselection/id_module/1', true); + $this->dispatch('/sito/viewselection/id_module/1', true);; }