View | Details | Raw Unified | Return to bug 18128
Collapse All | Expand All

(-)a/catalogue/search.pl (-39 / +25 lines)
Lines 626-670 for (my $i=0;$i<@servers;$i++) { Link Here
626
                $previous_page_offset = $offset - $results_per_page;
626
                $previous_page_offset = $offset - $results_per_page;
627
            }
627
            }
628
            my $next_page_offset = $offset + $results_per_page;
628
            my $next_page_offset = $offset + $results_per_page;
629
            # If we're within the first 10 pages, keep it simple
629
            # Loop through the pages
630
            #warn "current page:".$current_page_number;
630
            for (my $i=1; $i<=$pages;$i++) {
631
            if ($current_page_number < 10) {
631
                # the offset for this page
632
                # just show the first 10 pages
632
                my $this_offset = (($i*$results_per_page)-$results_per_page);
633
                # Loop through the pages
633
                # the page number for this page
634
                my $pages_to_show = 10;
634
                my $this_page_number = $i;
635
                $pages_to_show = $pages if $pages<10;
635
                # put it in the array
636
                for (my $i=1; $i<=$pages_to_show;$i++) {
636
                push @page_numbers,
637
                    # the offset for this page
637
                     { offset    => $this_offset,
638
                    my $this_offset = (($i*$results_per_page)-$results_per_page);
638
                       pg        => $this_page_number,
639
                    # the page number for this page
639
                       # it should only be highlighted if it's the current page
640
                    my $this_page_number = $i;
640
                       highlight => $this_page_number == $current_page_number,
641
                    # put it in the array
641
                       # it should only show if it is within 5 pages of the current page on either side
642
                    push @page_numbers,
642
                       show => $current_page_number - $this_page_number == -5 ||
643
                      { offset    => $this_offset,
643
                               $current_page_number - $this_page_number == -4 ||
644
                        pg        => $this_page_number,
644
                               $current_page_number - $this_page_number == -3 ||
645
                        # it should only be highlighted if it's the current page
645
                               $current_page_number - $this_page_number == -2 ||
646
                        highlight => $this_page_number == $current_page_number,
646
                               $current_page_number - $this_page_number == -1 ||
647
                        sort_by   => join ' ', @sort_by
647
                               $current_page_number - $this_page_number == 1 ||
648
                      };
648
                               $current_page_number - $this_page_number == 2 ||
649
                                
649
                               $current_page_number - $this_page_number == 3 ||
650
                }
650
                               $current_page_number - $this_page_number == 4 ||
651
                        
651
                               $current_page_number - $this_page_number == 5,
652
            }
652
                       sort_by   => join ' ', @sort_by
653
653
                    };
654
            # now, show twenty pages, with the current one smack in the middle
655
            else {
656
                for (my $i=$current_page_number; $i<=($current_page_number + 20 );$i++) {
657
                    my $this_offset = ((($i-9)*$results_per_page)-$results_per_page);
658
                    my $this_page_number = $i-9;
659
                    if ( $this_page_number <= $pages ) {
660
                        push @page_numbers,
661
                          { offset    => $this_offset,
662
                            pg        => $this_page_number,
663
                            highlight => $this_page_number == $current_page_number,
664
                            sort_by   => join ' ', @sort_by
665
                          };
666
                    }
667
                }
668
            }
654
            }
669
            # FIXME: no previous_page_offset when pages < 2
655
            # FIXME: no previous_page_offset when pages < 2
670
            $template->param(   PAGE_NUMBERS => \@page_numbers,
656
            $template->param(   PAGE_NUMBERS => \@page_numbers,
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc (-1 / +3 lines)
Lines 8-14 Link Here
8
        [% IF ( PAGE_NUMBER.highlight ) %]
8
        [% IF ( PAGE_NUMBER.highlight ) %]
9
            <li class="active"><span>[% PAGE_NUMBER.pg %]</span></li>
9
            <li class="active"><span>[% PAGE_NUMBER.pg %]</span></li>
10
        [% ELSE %]
10
        [% ELSE %]
11
            <li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% PAGE_NUMBER.offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">[% PAGE_NUMBER.pg %]</a></li>
11
            [% IF ( PAGE_NUMBER.show ) %]
12
                <li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% PAGE_NUMBER.offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |url %][% END %]">[% PAGE_NUMBER.pg %]</a></li>
13
            [% END %]
12
        [% END %]
14
        [% END %]
13
    [% END %]
15
    [% END %]
14
    [% IF ( next_page_offset ) %]
16
    [% IF ( next_page_offset ) %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/page-numbers.inc (-1 / +3 lines)
Lines 9-15 Link Here
9
                [% IF ( PAGE_NUMBER.highlight ) %]
9
                [% IF ( PAGE_NUMBER.highlight ) %]
10
                    <li class="active"><a href="#">[% PAGE_NUMBER.pg %]</a></li>
10
                    <li class="active"><a href="#">[% PAGE_NUMBER.pg %]</a></li>
11
                [% ELSE %]
11
                [% ELSE %]
12
                    <li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% PAGE_NUMBER.offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |html%][% END %]">[% PAGE_NUMBER.pg %]</a></li>
12
                    [% IF ( PAGE_NUMBER.show ) %]
13
                        <li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %]&amp;offset=[% PAGE_NUMBER.offset %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |html%][% END %]">[% PAGE_NUMBER.pg %]</a></li>
14
                    [% END %]
13
                [% END %]
15
                [% END %]
14
            [% END %]
16
            [% END %]
15
            [% IF ( next_page_offset ) %]
17
            [% IF ( next_page_offset ) %]
(-)a/opac/opac-search.pl (-39 / +23 lines)
Lines 850-893 for (my $i=0;$i<@servers;$i++) { Link Here
850
                $previous_page_offset = $offset - $results_per_page;
850
                $previous_page_offset = $offset - $results_per_page;
851
            }
851
            }
852
            my $next_page_offset = $offset + $results_per_page;
852
            my $next_page_offset = $offset + $results_per_page;
853
            # If we're within the first 10 pages, keep it simple
853
            # Loop through the pages
854
            #warn "current page:".$current_page_number;
854
            for ($i=1; $i<=$pages;$i++) {
855
            if ($current_page_number < 10) {
855
                # the offset for this page
856
                # just show the first 10 pages
856
                my $this_offset = (($i*$results_per_page)-$results_per_page);
857
                # Loop through the pages
857
                # the page number for this page
858
                my $pages_to_show = 10;
858
                my $this_page_number = $i;
859
                $pages_to_show = $pages if $pages<10;
859
                # put it in the array
860
                for ($i=1; $i<=$pages_to_show;$i++) {
860
                push @page_numbers,
861
                    # the offset for this page
861
                    { offset    => $this_offset,
862
                    my $this_offset = (($i*$results_per_page)-$results_per_page);
862
                      pg        => $this_page_number,
863
                    # the page number for this page
863
                      highlight => $this_page_number == $current_page_number,
864
                    my $this_page_number = $i;
864
                      show => $current_page_number - $this_page_number == -5 ||
865
                    # put it in the array
865
                              $current_page_number - $this_page_number == -4 ||
866
                    push @page_numbers,
866
                              $current_page_number - $this_page_number == -3 ||
867
                      { offset    => $this_offset,
867
                              $current_page_number - $this_page_number == -2 ||
868
                        pg        => $this_page_number,
868
                              $current_page_number - $this_page_number == -1 ||
869
                        highlight => $this_page_number == $current_page_number,
869
                              $current_page_number - $this_page_number == 1 ||
870
                        sort_by   => join ' ', @sort_by
870
                              $current_page_number - $this_page_number == 2 ||
871
                      };
871
                              $current_page_number - $this_page_number == 3 ||
872
872
                              $current_page_number - $this_page_number == 4 ||
873
                }
873
                              $current_page_number - $this_page_number == 5,
874
                        
874
                      sort_by   => join ' ', @sort_by
875
            }
875
                    };
876
            # now, show twenty pages, with the current one smack in the middle
877
            else {
878
                for ($i=$current_page_number; $i<=($current_page_number + 20 );$i++) {
879
                    my $this_offset = ((($i-9)*$results_per_page)-$results_per_page);
880
                    my $this_page_number = $i-9;
881
                    if ( $this_page_number <= $pages ) {
882
                        push @page_numbers,
883
                          { offset    => $this_offset,
884
                            pg        => $this_page_number,
885
                            highlight => $this_page_number == $current_page_number,
886
                            sort_by => join ' ', @sort_by
887
                          };
888
                    }
889
                }
890
                        
891
            }
876
            }
892
            $template->param(   PAGE_NUMBERS => \@page_numbers,
877
            $template->param(   PAGE_NUMBERS => \@page_numbers,
893
                                last_page_offset => $last_page_offset,
878
                                last_page_offset => $last_page_offset,
894
- 

Return to bug 18128