diff --git a/.gitattributes b/.gitattributes index 3babbe9c389ac507484d25540089a408fc5ea0c3..82233aaf139b30f4e1325d89d2d296c417ba012e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6145,6 +6145,7 @@ tests/library/ZendAfi/View/Helper/TagUploadMultipleTest.php -text tests/library/ZendAfi/View/Helper/TagUploadTest.php -text tests/library/ZendAfi/View/Helper/TagVideoTest.php -text tests/library/ZendAfi/View/Helper/Telephone/KiosqueTest.php -text +tests/library/ZendAfi/View/Helper/Telephone/PagerTest.php -text tests/library/ZendAfi/View/Helper/TreeViewFixtures.php -text tests/library/ZendAfi/View/Helper/TreeViewTest.php -text tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php -text diff --git a/application/modules/telephone/views/scripts/recherche/simple.phtml b/application/modules/telephone/views/scripts/recherche/simple.phtml index 11102f1f7dcb2734b437a034605b363074ad237a..1827817cb42062020c613bc5dd8817011d92786c 100644 --- a/application/modules/telephone/views/scripts/recherche/simple.phtml +++ b/application/modules/telephone/views/scripts/recherche/simple.phtml @@ -11,7 +11,6 @@ echo $this->listeNotices($this->liste, echo $this->pager($this->resultat['nombre'], $this->preferences["liste_nb_par_page"], - $this->resultat['page_cours'], - $this->url_retour); + $this->resultat['page_cours']); ?> </ul> diff --git a/library/ZendAfi/View/Helper/Telephone/Pager.php b/library/ZendAfi/View/Helper/Telephone/Pager.php index d3cb2e3c3d9523b0df37375ff9aca8ce386e0fa6..7b1720a96a60bbf8da5ebbf80d73a323367ac3f6 100644 --- a/library/ZendAfi/View/Helper/Telephone/Pager.php +++ b/library/ZendAfi/View/Helper/Telephone/Pager.php @@ -26,7 +26,7 @@ class ZendAfi_View_Helper_Telephone_Pager extends ZendAfi_View_Helper_BaseHelper //--------------------------------------------------------------------- // Main routine //--------------------------------------------------------------------- - public function pager($nombre,$nb_par_page,$page,$url) + public function pager($nombre,$nb_par_page,$page) { if(!$nombre) return; if(!$nb_par_page) $nb_par_page = 10; @@ -36,22 +36,17 @@ class ZendAfi_View_Helper_Telephone_Pager extends ZendAfi_View_Helper_BaseHelper if($nombre % $nb_par_page) $nb_pages++; if($nb_pages == 1) return; - // Url - if(strPos($url,"?") === false) $url.="?"; else $url.="&"; - $pos=strPos($url,"page="); if($pos >0) $url=substr($url,0,$pos); - $url.="page="; - // Pager $html='<div class="ui-bar" data-theme="c" data-role="footer" data-id="pager" data-position="fixed">'; $html.='<div data-role="controlgroup" data-type="horizontal">'; $html.=sprintf('<a href="%s" data-role="button" data-icon="arrow-l" %s>%s</a>', - $url.($page-1), + $this->view->url(['page'=>$page-1]), $page > 1 ? '' : 'class="ui-disabled"', $this->translate()->_('Page précédente')); $html.=sprintf('<a href="%s" data-role="button" data-icon="arrow-r" data-iconpos="right" %s>%s</a>', - $url.($page+1), + $this->view->url(['page'=>$page+1]), ($page != $nb_pages) ? '' : 'class="ui-disabled"', $this->translate()->_('Page suivante')); diff --git a/tests/library/ZendAfi/View/Helper/Telephone/PagerTest.php b/tests/library/ZendAfi/View/Helper/Telephone/PagerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..482cbf55126cf7c0c457b85e22487726146b21eb --- /dev/null +++ b/tests/library/ZendAfi/View/Helper/Telephone/PagerTest.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 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). + * + * AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php'; + +class Telephone_PagerTest extends ViewHelperTestCase { + public function setUp() { + parent::setUp(); + + $this->helper = new ZendAfi_View_Helper_Telephone_Pager(); + $this->helper->setView(new ZendAfi_Controller_Action_Helper_View()); + $this->html = $this->helper->pager(50, 5, 2); + + } + + /** @test **/ + public function previousPageLinkShouldBePage1(){ + $this->assertXPath($this->html, '//a[contains(@href, "/page/1")]'); + } + + /** @test **/ + public function nextPageLinkShouldBePage3() { + $this->assertXPath($this->html, '//a[contains(@href, "/page/3")]'); + } +} \ No newline at end of file