From 8d74f62fb503d3ae9a9693a594ce42b6b2ac96c9 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Wed, 1 Feb 2017 09:42:20 +0000 Subject: [PATCH] Bug 18008: Make pagination generated in templates It generates pagination in bootstrap style (as bug 18005 also do) Modified pages: acqui/neworderbiblio.pl authorities/authorities-home.pl cataloguing/addbooks.pl cataloguing/value_builder/marc21_linking_section.pl cataloguing/value_builder/unimarc_field_210c.pl cataloguing/value_builder/unimarc_field_4XX.pl reports/guided_reports.pl reviews/reviewswaiting.pl tags/review.pl virtualshelves/shelves.pl Test plan: 0) Apply the patch 1) go through pages from the list above/use cataloguing plugins, and make the data to be big enough for pagination 2) confirm that pagination looks nice and behave correctly 3) git grep pagination_bar should return just C4/Output.pm and opac templates (I'll deal with it on another bugs) --- acqui/neworderbiblio.pl | 8 ++- authorities/authorities-home.pl | 11 ++-- cataloguing/addbooks.pl | 9 +++- .../value_builder/marc21_linking_section.pl | 8 --- cataloguing/value_builder/unimarc_field_210c.pl | 13 ++--- cataloguing/value_builder/unimarc_field_4XX.pl | 8 --- .../intranet-tmpl/prog/en/includes/pagination.inc | 62 ++++++++++++++++++++++ .../prog/en/modules/acqui/neworderbiblio.tt | 4 +- .../prog/en/modules/admin/matching-rules.tt | 2 - .../prog/en/modules/admin/patron-attr-types.tt | 2 - .../en/modules/authorities/searchresultlist.tt | 4 +- .../prog/en/modules/cataloguing/addbooks.tt | 2 +- .../value_builder/unimarc_field_210c.tt | 10 ++-- .../en/modules/reports/guided_reports_start.tt | 3 +- .../prog/en/modules/reviews/reviewswaiting.tt | 4 +- .../intranet-tmpl/prog/en/modules/tags/review.tt | 8 ++- .../prog/en/modules/virtualshelves/shelves.tt | 5 +- reports/guided_reports.pl | 10 +++- reviews/reviewswaiting.pl | 9 +++- tags/review.pl | 15 ++++-- virtualshelves/shelves.pl | 12 +++-- 21 files changed, 145 insertions(+), 64 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/pagination.inc diff --git a/acqui/neworderbiblio.pl b/acqui/neworderbiblio.pl index 2e65569..a13c11d 100755 --- a/acqui/neworderbiblio.pl +++ b/acqui/neworderbiblio.pl @@ -144,6 +144,12 @@ foreach my $r (@{$budgets}) { last; } +my $pagination = { + base_url => "/cgi-bin/koha/acqui/neworderbiblio.pl?q=$query&booksellerid=$booksellerid&basketno=$basketno&page=", + pages => getnbpages( $total_hits, $results_per_page ), + current_page => $page, +}; + $template->param( has_budgets => $has_budgets, basketno => $basketno, @@ -152,7 +158,7 @@ $template->param( resultsloop => \@results, total => $total_hits, query => $query, - pagination_bar => pagination_bar( "/cgi-bin/koha/acqui/neworderbiblio.pl?q=$query&booksellerid=$booksellerid&basketno=$basketno&", getnbpages( $total_hits, $results_per_page ), $page, 'page' ), + pagination => $pagination, ); # BUILD THE TEMPLATE diff --git a/authorities/authorities-home.pl b/authorities/authorities-home.pl index d9c5ac8..01ec38e 100755 --- a/authorities/authorities-home.pl +++ b/authorities/authorities-home.pl @@ -188,11 +188,14 @@ if ( $op eq "do_search" ) { $template->param( result => $results ) if $results; + my $pagination = { + base_url => "$base_url&startfrom=", + pages => getnbpages( $total, $resultsperpage ), + current_page => $startfrom, + }; + $template->param( - pagination_bar => pagination_bar( - $base_url, int( $total / $resultsperpage ) + 1, - $startfrom, 'startfrom' - ), + pagination => $pagination, total => $total, from => $from, to => $to, diff --git a/cataloguing/addbooks.pl b/cataloguing/addbooks.pl index 1d52bb8..3ab48c68 100755 --- a/cataloguing/addbooks.pl +++ b/cataloguing/addbooks.pl @@ -90,11 +90,18 @@ if ($query) { # SimpleSearch() give the results per page we want, so 0 offet here my $total = @{$marcresults}; my @newresults = searchResults( 'intranet', $query, $total, $results_per_page, 0, 0, $marcresults ); + + my $pagination = { + base_url => "/cgi-bin/koha/cataloguing/addbooks.pl?q=$query&page=", + pages => getnbpages( $total_hits, $results_per_page ), + current_page => $page, + }; + $template->param( total => $total_hits, query => $query, resultsloop => \@newresults, - pagination_bar => pagination_bar( "/cgi-bin/koha/cataloguing/addbooks.pl?q=$query&", getnbpages( $total_hits, $results_per_page ), $page, 'page' ), + pagination => $pagination, ); } diff --git a/cataloguing/value_builder/marc21_linking_section.pl b/cataloguing/value_builder/marc21_linking_section.pl index 0fb9b7b..c4aca0d 100755 --- a/cataloguing/value_builder/marc21_linking_section.pl +++ b/cataloguing/value_builder/marc21_linking_section.pl @@ -274,14 +274,6 @@ my $launcher = sub { # foreach my $sort (@sort_by){ # $link.="&sort_by=".$sort."&"; # } - # $template->param( - # pagination_bar => pagination_bar( - # $link, - # getnbpages($hits, $results_per_page), - # $page, - # 'page' - # ), - # ); $template->param( result => \@arrayresults, index => scalar $query->param('index') . "", diff --git a/cataloguing/value_builder/unimarc_field_210c.pl b/cataloguing/value_builder/unimarc_field_210c.pl index fe9f19a..82c22c1 100755 --- a/cataloguing/value_builder/unimarc_field_210c.pl +++ b/cataloguing/value_builder/unimarc_field_210c.pl @@ -137,6 +137,12 @@ my ($input) = @_; $template->param(result => $results) if $results; $template->param('index' => scalar $query->param('index')); + + my $pagination = { + base_url => "$link&startfrom=", + pages => getnbpages($total, $resultsperpage), + current_page => $startfrom, + }; $template->param(startfrom=> $startfrom, displaynext=> $displaynext, displayprev=> $displayprev, @@ -149,12 +155,7 @@ my ($input) = @_; numbers=>\@numbers, authtypecode =>$authtypecode, resultstring =>$value[0], - pagination_bar => pagination_bar( - $link, - getnbpages($total, $resultsperpage), - $startfrom, - 'startfrom' - ), + pagination => $pagination, ); } else { ($template, $loggedinuser, $cookie) diff --git a/cataloguing/value_builder/unimarc_field_4XX.pl b/cataloguing/value_builder/unimarc_field_4XX.pl index c514349..a6cbd44 100755 --- a/cataloguing/value_builder/unimarc_field_4XX.pl +++ b/cataloguing/value_builder/unimarc_field_4XX.pl @@ -476,14 +476,6 @@ sub plugin { # foreach my $sort (@sort_by){ # $link.="&sort_by=".$sort."&"; # } -# $template->param( -# pagination_bar => pagination_bar( -# $link, -# getnbpages($hits, $results_per_page), -# $page, -# 'page' -# ), -# ); $template->param( result => \@arrayresults, index => scalar $query->param('index') . "", diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/pagination.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/pagination.inc new file mode 100644 index 0000000..7b0e0cf --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/pagination.inc @@ -0,0 +1,62 @@ +[% +# this is template for generating pagination +# it needed an array named "pagination" with this structure: +# pagination.pages => total number of pages +# pagination.base_url => url with all needed parameters and with parameter specifiyng page at the end +# pagination.current_page => number of current active page +%] + +[% IF pagination && ( pagination.pages > 1 ) %] + + + +[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderbiblio.tt index 3796d18..90e67d9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderbiblio.tt @@ -45,8 +45,8 @@ [% IF ( total ) %] -[% total %] results found -
[% pagination_bar %]
+ [% total %] results found + [% INCLUDE 'pagination.inc' %] [% ELSE %]

No results found

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt index 6c15b2b..d9c21f1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt @@ -611,8 +611,6 @@ function CheckRuleForm(f) { [% END %] [% ELSE %]

There are no saved matching rules.

[% END %] -
[% pagination_bar %]
- [% END %] [% IF ( matching_rule_form ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt index 76e4589..fed37e5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt @@ -58,7 +58,7 @@ function searchauthority() {
[% IF ( total ) %] -
[% pagination_bar %]
+[% INCLUDE 'pagination.inc' %]

Results [% from %] to [% to %] of [% total %] @@ -108,7 +108,7 @@ function searchauthority() { -

[% pagination_bar %]
+[% INCLUDE 'pagination.inc' %] [% ELSE %] No results found diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt index d6d39d8..f2bced1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt @@ -134,7 +134,7 @@ [% total %] result(s) found in catalog, [% breeding_count %] result(s) found in reservoir -
[% pagination_bar %]
+[% INCLUDE 'pagination.inc' %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_210c.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_210c.tt index 043e700..729491e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_210c.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_210c.tt @@ -40,9 +40,8 @@ [% IF ( total ) %]

Authority search results

-
- [% pagination_bar %] -
[% END %] + [% INCLUDE 'pagination.inc' %] + [% END %]

[% IF ( total ) %]  Results [% from %] to [% to %] of [% total %]

@@ -73,9 +72,8 @@ [% END %] - [% IF ( total ) %]

- [% pagination_bar %] -
+ [% IF ( total ) %] + [% INCLUDE 'pagination.inc' %] [% END %]