diff --git a/VERSIONS_WIP/30038 b/VERSIONS_WIP/30038 new file mode 100644 index 0000000000000000000000000000000000000000..ca9bb85d08eb7a0ea0167093d0cad3889217779b --- /dev/null +++ b/VERSIONS_WIP/30038 @@ -0,0 +1,2 @@ + - ticket #30038 : Boite domaine : ajout du paramètre "tri du résultat de recherche" dans la configuration de la boite. + \ No newline at end of file diff --git a/application/modules/opac/controllers/DomainsController.php b/application/modules/opac/controllers/DomainsController.php index 4933589e3c6fc5be71e004b68d3b774d980cc100..9128b2948bcd0af697da78e07bb65412da2ade54 100644 --- a/application/modules/opac/controllers/DomainsController.php +++ b/application/modules/opac/controllers/DomainsController.php @@ -21,20 +21,16 @@ class DomainsController extends ZendAfi_Controller_Action { public function browseAction() { - if (!$catalog = Class_Catalogue::find($this->_getParam('id'))) { - $this->_redirect(); - return; - } + if (!$catalog = Class_Catalogue::find($this->_getParam('id'))) + return $this->_redirect(); $id_module = $this->_getParam('id_module'); - if (!$catalog->hasSousDomaines()) { - $this->_redirect($this->view->url(array_filter(['controller' => 'recherche', + if (!$catalog->hasSousDomaines()) + return $this->_redirect($this->view->url(array_filter(['controller' => 'recherche', 'action' => 'simple', 'id_catalogue' => $catalog->getId(), 'id_module' => $id_module]), null, true)); - return; - } $this->view->module_preferences = Class_Profil::getCurrentProfil() ->getModuleAccueilPreferences($id_module, 'DOMAIN_BROWSER'); @@ -42,5 +38,4 @@ class DomainsController extends ZendAfi_Controller_Action { $this->view->current_domain = $catalog; $this->view->id_module = $id_module; } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/application/modules/opac/views/scripts/domains/browse.phtml b/application/modules/opac/views/scripts/domains/browse.phtml index 47e36d12e751cae65111b7cbfc511b3728aa5746..2f498de89eb09906d75bd254aa94e98d8611781d 100644 --- a/application/modules/opac/views/scripts/domains/browse.phtml +++ b/application/modules/opac/views/scripts/domains/browse.phtml @@ -1,7 +1,6 @@ <?php $this->openBoite(''); echo $this->renderDomainBrowser($this->current_domain, - $this->id_module, + $this->id_module, $this->module_preferences); $this->closeBoite(); -?> diff --git a/library/Class/Systeme/ModulesAccueil/DomainBrowser.php b/library/Class/Systeme/ModulesAccueil/DomainBrowser.php index de574c668c5433bba50e47f9589ae9144baa4907..fd1f64e2fc583946b5efeda1219869b541ef6e54 100644 --- a/library/Class/Systeme/ModulesAccueil/DomainBrowser.php +++ b/library/Class/Systeme/ModulesAccueil/DomainBrowser.php @@ -35,6 +35,7 @@ class Class_Systeme_ModulesAccueil_DomainBrowser extends Class_Systeme_ModulesAc $this->_defaultValues = ['titre' => $this->_libelle, 'allow_breadcrumb' => 0, 'root_domain_id' => 0, + 'tri' => Class_CriteresRecherche::SORT_PUBLICATION, 'display_mode' => Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR]; } } \ No newline at end of file diff --git a/library/ZendAfi/Form/Configuration/Widget/Domains.php b/library/ZendAfi/Form/Configuration/Widget/Domains.php index 15cca0e2584ee1e0343183954ad846c81e638221..41102880d45a787efc6d33d4dab377781b349d5d 100644 --- a/library/ZendAfi/Form/Configuration/Widget/Domains.php +++ b/library/ZendAfi/Form/Configuration/Widget/Domains.php @@ -37,8 +37,14 @@ class ZendAfi_Form_Configuration_Widget_Domains extends ZendAfi_Form_Configurati ['label' => $this->_('Format'), 'multiOptions' => Class_Systeme_ModulesAppli::getAvailableListeDomainsFormat()]) + ->addElement('select', + 'tri', + ['label' => $this->_('Tri du résultat de recherche'), + 'multiOptions' => (new Class_CriteresRecherche())->getListeTris()]) + ->addToSelectionGroup(['root_domain_id']) - ->addToDisplaySettingsGroup(['display_mode']); + ->addToDisplaySettingsGroup(['display_mode', + 'tri']); } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/RenderDomainBrowser.php b/library/ZendAfi/View/Helper/RenderDomainBrowser.php index ee4e7172fc5883a95c10d994e5d28da3c96ddd06..3e9bb4a0636b99f4fe786ab6323b7ceab4cfe89f 100644 --- a/library/ZendAfi/View/Helper/RenderDomainBrowser.php +++ b/library/ZendAfi/View/Helper/RenderDomainBrowser.php @@ -1,4 +1,4 @@ -<?php +<?php /** * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. * @@ -16,17 +16,18 @@ * * 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_RenderDomainBrowser extends ZendAfi_View_Helper_BaseHelper { - + protected $_current, $_pref, $_id_module,$renderer; public function renderDomainBrowser($current, $id_module, $preferences) { if (null == $current) $current = Class_Catalogue::getRoot(); - $this->_id_module=$id_module; + + $this->_id_module = $id_module; $this->_current = $current; $this->_pref = $preferences; @@ -45,14 +46,15 @@ class ZendAfi_View_Helper_RenderDomainBrowser extends ZendAfi_View_Helper_BaseHe foreach($this->_current->getChildren() as $child) $html .= $this->display($child); - + return $html; } - public function breadcrumb() { - if ($this->_current->getId()==$this->_pref['root_domain_id']) + public function breadcrumb() { + if ($this->_current->getId() == $this->_pref['root_domain_id']) return ''; + $parents_html = ''; $parents = $this->_current->getParentsUntil($this->_pref['root_domain_id']); $new_root = ''; @@ -73,8 +75,8 @@ class ZendAfi_View_Helper_RenderDomainBrowser extends ZendAfi_View_Helper_BaseHe protected function display($domain) { $view = $this->view; $url_img = $domain->getUrlImg(); - $img = $view->tagImg($url_img ? $url_img : $view->skinImageUrl('filetypes.png'), - ['alt' => $domain->getLibelle(), + $img = $view->tagImg($url_img ? $url_img : $view->skinImageUrl('filetypes.png'), + ['alt' => $domain->getLibelle(), 'title' => $domain->getLibelle()]); $url = $this->getBrowsingUrl($domain); @@ -86,17 +88,16 @@ class ZendAfi_View_Helper_RenderDomainBrowser extends ZendAfi_View_Helper_BaseHe if (($domain->getId()==$this->_pref['root_domain_id']) || !$domain->hasDomaineParent()) return $this->view->url([], null, true); - $params = $domain->hasSousDomaines() + $params = $domain->hasSousDomaines() ? ['controller' =>'domains', - 'action' => 'browse', - 'id'=> $domain->getId(), - 'id_module' => $this->_id_module - ] + 'action' => 'browse', + 'id'=> $domain->getId(), + 'id_module' => $this->_id_module] : ['controller' =>'recherche', - 'action' => 'simple', - 'id_catalogue'=> $domain->getId(), - 'id_module' => $this->_id_module - ]; + 'action' => 'simple', + 'id_catalogue'=> $domain->getId(), + 'id_module' => $this->_id_module, + 'tri' => (isset($this->_pref['tri']) ? $this->_pref['tri'] : null)]; return $this->view->url($params, null, true); } @@ -106,7 +107,7 @@ class ZendAfi_View_Helper_RenderDomainBrowser extends ZendAfi_View_Helper_BaseHe abstract class ZendAfi_View_Helper_RenderDomainBrowser_Abstract { - protected + protected $_view, $_helper, $_container_tag = '', @@ -129,32 +130,34 @@ abstract class ZendAfi_View_Helper_RenderDomainBrowser_Abstract { public function children($html) { if (!$html) return ''; - return $this->_view->tag($this->_container_tag, + return $this->_view->tag($this->_container_tag, $html, ['class' => 'children']); } - + public function breadcrumb($html) { if (!$html) return ''; - return $this->_view->tag($this->_container_tag, + return $this->_view->tag($this->_container_tag, $html, - ['class' => 'breadcrumb']); + ['class' => 'breadcrumb']); } } class ZendAfi_View_Helper_RenderDomainBrowser_Wall extends ZendAfi_View_Helper_RenderDomainBrowser_Abstract { - protected + + protected $_container_tag = 'div', $_helper_class = 'liste_mur'; - + + public function display($url, $img, $title){ return $this->_view->tag('div', - $this->_view->tagAnchor($url, - $img . $this->_view->tag('div', + $this->_view->tagAnchor($url, + $img . $this->_view->tag('div', $title, ['class' => 'titre_auteur']))); } @@ -167,12 +170,12 @@ class ZendAfi_View_Helper_RenderDomainBrowser_Wall extends ZendAfi_View_Helper_R class ZendAfi_View_Helper_RenderDomainBrowser_List extends ZendAfi_View_Helper_RenderDomainBrowser_Abstract { - protected + protected $_container_tag = 'ul'; public function display($url, $img, $title){ $view = $this->_view; - return $view->tag('li',$view->tagAnchor($url, + return $view->tag('li',$view->tagAnchor($url, $img . $view->tag('span', $title))); } diff --git a/tests/application/modules/admin/controllers/WidgetControllerTest.php b/tests/application/modules/admin/controllers/WidgetControllerTest.php index 9538948d90ec7afb95ad31073ae22ba40b4b4c92..828c86fd56aff59f11b362893ddb0a7fd6ef97aa 100644 --- a/tests/application/modules/admin/controllers/WidgetControllerTest.php +++ b/tests/application/modules/admin/controllers/WidgetControllerTest.php @@ -1822,6 +1822,12 @@ class WidgetControllerDomainBrowserDispatchTest extends WidgetControllerDispatch } + /** @test **/ + public function inputTriShouldBeDisplay() { + $this->assertXpath('//select[@name="tri"]/option[@selected="selected"][@value="annee desc"]'); + } + + /** @test */ public function submitButtonShouldBeDisplayed() { $this->assertXPath('//button[@type="submit"]'); @@ -1868,8 +1874,10 @@ class WidgetControllerDomainBrowserPostDispatchTest extends WidgetControllerPost 'boite' => '', 'division' => '3', 'id_module' => '6', - 'type_module' => 'DOMAIN_BROWSER'], - 'profile_id' => '5']), + 'type_module' => 'DOMAIN_BROWSER', + 'tri' => 'annee desc'], + 'profile_id' => '5', + 'tri' => 'annee desc']), $this->_saved_settings); } } diff --git a/tests/application/modules/opac/controllers/DomainsControllerTest.php b/tests/application/modules/opac/controllers/DomainsControllerTest.php index 19d9aed65c4c2b83e0a53b838333685b8b95f8f5..d93459c6cc76ff2f568d6f0fcd811237386c76b4 100644 --- a/tests/application/modules/opac/controllers/DomainsControllerTest.php +++ b/tests/application/modules/opac/controllers/DomainsControllerTest.php @@ -16,16 +16,18 @@ * * 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 */ -require_once 'AbstractControllerTestCase.php'; abstract class DomainsControllerBrowseTestCase extends AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + + public function setUp() { parent::setUp(); - Class_CodifThesaurus::beVolatile(); Class_Profil::getCurrentProfil()-> updateModuleConfigAccueil(9, ['type_module' => 'DOMAIN_BROWSER', @@ -33,32 +35,31 @@ abstract class DomainsControllerBrowseTestCase extends AbstractControllerTestCas 'id_module' => 9, 'preferences' => ['display_mode' => 'list', 'root_domain_id' => 3 - ]]); + ]]); - - Class_AlbumCategorie::beVolatile(); $this->fixture( - 'Class_Catalogue', - ['id' => 3, 'libelle' => 'Youth', 'url_img' => 'http://imgs/youth.png', - 'sous_domaines' => [ - $this->fixture('Class_Catalogue', - ['id' => 4, 'libelle' => 'A', - 'sous_domaines' => [ - $this->fixture('Class_Catalogue', - ['id' => 10, 'libelle' => 'Animals'])]]), - - $this->fixture('Class_Catalogue', - ['id' => 6, 'libelle' => 'C', - 'sous_domaines' => [ - $this->fixture('Class_Catalogue', - ['id' => 15, 'libelle' => 'Car']), - $this->fixture('Class_Catalogue', - ['id' => 25, 'libelle' => 'Cinema'])]])]]); + 'Class_Catalogue', + ['id' => 3, 'libelle' => 'Youth', 'url_img' => 'http://imgs/youth.png', + 'sous_domaines' => [ + $this->fixture('Class_Catalogue', + ['id' => 4, 'libelle' => 'A', + 'sous_domaines' => [ + $this->fixture('Class_Catalogue', + ['id' => 10, 'libelle' => 'Animals'])]]), + + $this->fixture('Class_Catalogue', + ['id' => 6, 'libelle' => 'C', + 'sous_domaines' => [ + $this->fixture('Class_Catalogue', + ['id' => 15, 'libelle' => 'Car']), + $this->fixture('Class_Catalogue', + ['id' => 25, 'libelle' => 'Cinema'])]])]]); } } + class DomainsControllerBrowseDomainCWithDisplayModeWall extends DomainsControllerBrowseTestCase { public function setUp() { parent::setUp(); @@ -70,8 +71,7 @@ class DomainsControllerBrowseDomainCWithDisplayModeWall extends DomainsControlle 'id_module' => 10, 'preferences' => ['display_mode' => Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR, 'root_domain_id' => 3 - ]]); - + ]]); $this->dispatch('/domains/browse/id/6/id_module/10', true); } @@ -79,11 +79,10 @@ class DomainsControllerBrowseDomainCWithDisplayModeWall extends DomainsControlle /** @test */ public function breadcrumbLinkToDomainCShouldBeInADiv() { - $this->assertXPath('//div[@class="domains liste_mur"]//div[@class="breadcrumb"]/div/a/img[@alt="C"]', - $this->_response->getBody()); + $this->assertXPath('//div[@class="domains liste_mur"]//div[@class="breadcrumb"]/div/a/img[@alt="C"]', $this->_response->getBody()); } - + /** @test */ public function breadcrumbShouldContainsOneDivBetweenDomainsLinkToDisplaySeparator() { $this->assertXPath('//div[@class="breadcrumb"]/div[following-sibling::div[@class="separator"]]'); @@ -94,36 +93,39 @@ class DomainsControllerBrowseDomainCWithDisplayModeWall extends DomainsControlle class DomainsControllerYouthBrowseTest extends DomainsControllerBrowseTestCase { + public function setUp() { parent::setUp(); - $this->dispatch('/domains/browse/id/3/id_module/9', true); } + /** @test */ public function shouldDisplayLinkToLetterADomain() { $this->assertXPath('//div[@class="domains"]/ul[@class="children"]/li/a[@href="/domains/browse/id/4/id_module/9"]'); } - + /** @test */ public function shouldDisplayLinkToLetterCDomain() { $this->assertXPath('//div[@class="domains"]/ul[@class="children"]/li/a[@href="/domains/browse/id/6/id_module/9"]'); } - } + class DomainsControllerBrowseALetterDomainTest extends DomainsControllerBrowseTestCase { + public function setUp() { parent::setUp(); $this->dispatch('/domains/browse/id/4/id_module/9', true); } + /** @test */ public function shouldDisplayLinkAnimalsDomainAsRechercheSimple() { - $this->assertXPath('//div[@class="domains"]/ul[@class="children"]/li/a[@href="/recherche/simple/id_catalogue/10/id_module/9"]'); + $this->assertXPath('//div[@class="domains"]/ul[@class="children"]/li/a[@href="/recherche/simple/id_catalogue/10/id_module/9/tri/annee+desc"]'); } @@ -135,13 +137,15 @@ class DomainsControllerBrowseALetterDomainTest extends DomainsControllerBrowseTe /** @test */ public function youthDomainshouldLinkToHomepage() { - $this->assertXPath('//div[@class="domains"]/ul[@class="breadcrumb"]/li/' + $this->assertXPath('//div[@class="domains"]/ul[@class="breadcrumb"]/li/' . 'a[@href="/"]/img[@src="http://imgs/youth.png"]' . '[following-sibling::span]',$this->_response->getBody()); } } + + class DomainsControllerBrowseCLetterDomainTest extends DomainsControllerBrowseTestCase { public function setUp() { parent::setUp(); @@ -179,6 +183,7 @@ class DomainsControllerBrowseCarDomainTest extends DomainsControllerBrowseTestCa + class DomainsControllerBrowseYouthDomainWithoutRootDomainIdInWidgetConfigurationTest extends DomainsControllerBrowseTestCase { public function setUp() { parent::setUp(); @@ -190,18 +195,16 @@ class DomainsControllerBrowseYouthDomainWithoutRootDomainIdInWidgetConfiguration 'id_module' => 9, 'preferences' => ['display_mode' => 'list', 'root_domain_id' => '' - ]]); + ]]); $this->dispatch('/domains/browse/id/4/id_module/9', true); - } /** @test */ public function youthDomainshouldLinkToHomepage() { - $this->assertXPath('//div[@class="domains"]/ul[@class="breadcrumb"]/li/' + $this->assertXPath('//div[@class="domains"]/ul[@class="breadcrumb"]/li/' . 'a[@href="/"]/img[@src="http://imgs/youth.png"]' . '[following-sibling::span]',$this->_response->getBody()); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php b/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php index 794e2059abbbc517d67a767272b404512a953bf1..8188ca48a247ea6236b9d0dc93516c6b2e861888 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/DomainBrowserTest.php @@ -129,7 +129,7 @@ abstract class ZendAfi_View_Helper_Accueil_DomainBrowserViewAccordionTestCase ex class ZendAfi_View_Helper_Accueil_DomainBrowserViewAccordionTest extends ZendAfi_View_Helper_Accueil_DomainBrowserViewAccordionTestCase { /** @test */ public function linkForDomainMetalShouldBePresent() { - $this->assertXPath($this->_html, '//div[contains(@class,"domains")]//ul[@class="children"]//li//a[contains(@href, "/recherche/simple/id_catalogue/1/id_module/9")]', $this->_html); + $this->assertXPath($this->_html, '//div[contains(@class,"domains")]//ul[@class="children"]//li//a[contains(@href, "/recherche/simple/id_catalogue/1/id_module/9/tri/annee+desc")]', $this->_html); }