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.
&getauthtypes &getauthtype
&getallthemes &getalllanguages
&getallbranches &getletters
+ getnbpages
$DEBUG);
use vars qw();
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__
use CGI;
use List::Util qw/min/;
+use C4::Koha;
use C4::Context;
use C4::Output;
use C4::Search;
loop => \@loop,
pagination_bar => pagination_bar(
$script_name,
- int(scalar(@results) / $pagesize) + 1,
+ getnbpages(scalar @results, $pagesize),
$page,
'page'
)