From 4b7b4e7cc0575ac3e1eda4b744a0a083cb8528c0 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Fri, 20 Oct 2017 01:48:32 +0000 Subject: [PATCH] Bug 18128: [FOLLOW-UP] Some display fixes This patch addresses some of the display issues brought up in Comment 6. The dropdown list should now include every page number. The bar will only show up to 5 page numbers on each side of the current active page. --- catalogue/search.pl | 64 +++++++++------------- .../prog/en/includes/page-numbers.inc | 4 +- .../bootstrap/en/includes/page-numbers.inc | 4 +- opac/opac-search.pl | 61 ++++++++------------- 4 files changed, 54 insertions(+), 79 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index 05d064b..543169d 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -626,45 +626,31 @@ for (my $i=0;$i<@servers;$i++) { $previous_page_offset = $offset - $results_per_page; } my $next_page_offset = $offset + $results_per_page; - # If we're within the first 10 pages, keep it simple - #warn "current page:".$current_page_number; - if ($current_page_number < 10) { - # just show the first 10 pages - # Loop through the pages - my $pages_to_show = 10; - $pages_to_show = $pages if $pages<10; - for (my $i=1; $i<=$pages_to_show;$i++) { - # the offset for this page - my $this_offset = (($i*$results_per_page)-$results_per_page); - # the page number for this page - my $this_page_number = $i; - # put it in the array - push @page_numbers, - { offset => $this_offset, - pg => $this_page_number, - # it should only be highlighted if it's the current page - highlight => $this_page_number == $current_page_number, - sort_by => join ' ', @sort_by - }; - - } - - } - - # now, show twenty pages, with the current one smack in the middle - else { - for (my $i=$current_page_number; $i<=($current_page_number + 20 );$i++) { - my $this_offset = ((($i-9)*$results_per_page)-$results_per_page); - my $this_page_number = $i-9; - if ( $this_page_number <= $pages ) { - push @page_numbers, - { offset => $this_offset, - pg => $this_page_number, - highlight => $this_page_number == $current_page_number, - sort_by => join ' ', @sort_by - }; - } - } + # Loop through the pages + for (my $i=1; $i<=$pages;$i++) { + # the offset for this page + my $this_offset = (($i*$results_per_page)-$results_per_page); + # the page number for this page + my $this_page_number = $i; + # put it in the array + push @page_numbers, + { offset => $this_offset, + pg => $this_page_number, + # it should only be highlighted if it's the current page + highlight => $this_page_number == $current_page_number, + # it should only show if it is within 5 pages of the current page on either side + show => $current_page_number - $this_page_number == -5 || + $current_page_number - $this_page_number == -4 || + $current_page_number - $this_page_number == -3 || + $current_page_number - $this_page_number == -2 || + $current_page_number - $this_page_number == -1 || + $current_page_number - $this_page_number == 1 || + $current_page_number - $this_page_number == 2 || + $current_page_number - $this_page_number == 3 || + $current_page_number - $this_page_number == 4 || + $current_page_number - $this_page_number == 5, + sort_by => join ' ', @sort_by + }; } # FIXME: no previous_page_offset when pages < 2 $template->param( PAGE_NUMBERS => \@page_numbers, diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc index f19f26d..f3198fa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc @@ -8,7 +8,9 @@ [% IF ( PAGE_NUMBER.highlight ) %]
  • [% PAGE_NUMBER.pg %]
  • [% ELSE %] -
  • [% PAGE_NUMBER.pg %]
  • + [% IF ( PAGE_NUMBER.show ) %] +
  • [% PAGE_NUMBER.pg %]
  • + [% END %] [% END %] [% END %] [% IF ( next_page_offset ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/page-numbers.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/page-numbers.inc index d0f02cd..e7d91ff 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/page-numbers.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/page-numbers.inc @@ -9,7 +9,9 @@ [% IF ( PAGE_NUMBER.highlight ) %]
  • [% PAGE_NUMBER.pg %]
  • [% ELSE %] -
  • [% PAGE_NUMBER.pg %]
  • + [% IF ( PAGE_NUMBER.show ) %] +
  • [% PAGE_NUMBER.pg %]
  • + [% END %] [% END %] [% END %] [% IF ( next_page_offset ) %] diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 133b671..d242bf1 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -850,44 +850,29 @@ for (my $i=0;$i<@servers;$i++) { $previous_page_offset = $offset - $results_per_page; } my $next_page_offset = $offset + $results_per_page; - # If we're within the first 10 pages, keep it simple - #warn "current page:".$current_page_number; - if ($current_page_number < 10) { - # just show the first 10 pages - # Loop through the pages - my $pages_to_show = 10; - $pages_to_show = $pages if $pages<10; - for ($i=1; $i<=$pages_to_show;$i++) { - # the offset for this page - my $this_offset = (($i*$results_per_page)-$results_per_page); - # the page number for this page - my $this_page_number = $i; - # put it in the array - push @page_numbers, - { offset => $this_offset, - pg => $this_page_number, - highlight => $this_page_number == $current_page_number, - sort_by => join ' ', @sort_by - }; - - } - - } - # now, show twenty pages, with the current one smack in the middle - else { - for ($i=$current_page_number; $i<=($current_page_number + 20 );$i++) { - my $this_offset = ((($i-9)*$results_per_page)-$results_per_page); - my $this_page_number = $i-9; - if ( $this_page_number <= $pages ) { - push @page_numbers, - { offset => $this_offset, - pg => $this_page_number, - highlight => $this_page_number == $current_page_number, - sort_by => join ' ', @sort_by - }; - } - } - + # Loop through the pages + for ($i=1; $i<=$pages;$i++) { + # the offset for this page + my $this_offset = (($i*$results_per_page)-$results_per_page); + # the page number for this page + my $this_page_number = $i; + # put it in the array + push @page_numbers, + { offset => $this_offset, + pg => $this_page_number, + highlight => $this_page_number == $current_page_number, + show => $current_page_number - $this_page_number == -5 || + $current_page_number - $this_page_number == -4 || + $current_page_number - $this_page_number == -3 || + $current_page_number - $this_page_number == -2 || + $current_page_number - $this_page_number == -1 || + $current_page_number - $this_page_number == 1 || + $current_page_number - $this_page_number == 2 || + $current_page_number - $this_page_number == 3 || + $current_page_number - $this_page_number == 4 || + $current_page_number - $this_page_number == 5, + sort_by => join ' ', @sort_by + }; } $template->param( PAGE_NUMBERS => \@page_numbers, last_page_offset => $last_page_offset, -- 2.1.4