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/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..ec5d66b41270a10e1440477635b627536b09ad55 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,11 +16,11 @@ * * 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) { @@ -45,12 +45,12 @@ 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() { + public function breadcrumb() { if ($this->_current->getId()==$this->_pref['root_domain_id']) return ''; $parents_html = ''; @@ -73,8 +73,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 +86,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 +105,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 +128,32 @@ 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 +166,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/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); }