From 3096d756771d6f6c99cd75a16bf38bb1d7dc7cf0 Mon Sep 17 00:00:00 2001 From: plg Date: Fri, 7 Apr 2006 08:24:36 +0000 Subject: [PATCH] bug fixed: on admin/stopwords, the calculation of the number of pages to display in the pagination bar was wrong on extreme case (when number of items equals the pagesize). Calculation replaced by a generic function getnbpages in C4::Koha. This function could be useful elsewhere than in stpwords management screen and avoid calculation bugs as I did. --- C4/Koha.pm | 13 +++++++++++++ admin/stopwords.pl | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index abd65126ae..48f4d67ae5 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -62,6 +62,7 @@ Koha.pm provides many functions for Koha scripts. &getauthtypes &getauthtype &getallthemes &getalllanguages &getallbranches &getletters + getnbpages $DEBUG); use vars qw(); @@ -732,6 +733,18 @@ sub getallthemes { return @themes; } +=item getnbpages + +Returns the number of pages to display in a pagination bar, given the number +of items and the number of items per page. + +=cut + +sub getnbpages { + my ($nb_items, $nb_items_per_page) = @_; + + return int(($nb_items - 1) / $nb_items_per_page) + 1; +} 1; __END__ diff --git a/admin/stopwords.pl b/admin/stopwords.pl index 8d26716f5a..da465c8a92 100755 --- a/admin/stopwords.pl +++ b/admin/stopwords.pl @@ -29,6 +29,7 @@ use strict; use CGI; use List::Util qw/min/; +use C4::Koha; use C4::Context; use C4::Output; use C4::Search; @@ -161,7 +162,7 @@ $template->param( loop => \@loop, pagination_bar => pagination_bar( $script_name, - int(scalar(@results) / $pagesize) + 1, + getnbpages(scalar @results, $pagesize), $page, 'page' ) -- 2.20.1