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 843-886 for (my $i=0;$i<@servers;$i++) { Link Here
843
                $previous_page_offset = $offset - $results_per_page;
843
                $previous_page_offset = $offset - $results_per_page;
844
            }
844
            }
845
            my $next_page_offset = $offset + $results_per_page;
845
            my $next_page_offset = $offset + $results_per_page;
846
            # If we're within the first 10 pages, keep it simple
846
            # Loop through the pages
847
            #warn "current page:".$current_page_number;
847
            for ($i=1; $i<=$pages;$i++) {
848
            if ($current_page_number < 10) {
848
                # the offset for this page
849
                # just show the first 10 pages
849
                my $this_offset = (($i*$results_per_page)-$results_per_page);
850
                # Loop through the pages
850
                # the page number for this page
851
                my $pages_to_show = 10;
851
                my $this_page_number = $i;
852
                $pages_to_show = $pages if $pages<10;
852
                # put it in the array
853
                for ($i=1; $i<=$pages_to_show;$i++) {
853
                push @page_numbers,
854
                    # the offset for this page
854
                    { offset    => $this_offset,
855
                    my $this_offset = (($i*$results_per_page)-$results_per_page);
855
                      pg        => $this_page_number,
856
                    # the page number for this page
856
                      highlight => $this_page_number == $current_page_number,
857
                    my $this_page_number = $i;
857
                      show => $current_page_number - $this_page_number == -5 ||
858
                    # put it in the array
858
                              $current_page_number - $this_page_number == -4 ||
859
                    push @page_numbers,
859
                              $current_page_number - $this_page_number == -3 ||
860
                      { offset    => $this_offset,
860
                              $current_page_number - $this_page_number == -2 ||
861
                        pg        => $this_page_number,
861
                              $current_page_number - $this_page_number == -1 ||
862
                        highlight => $this_page_number == $current_page_number,
862
                              $current_page_number - $this_page_number == 1 ||
863
                        sort_by   => join ' ', @sort_by
863
                              $current_page_number - $this_page_number == 2 ||
864
                      };
864
                              $current_page_number - $this_page_number == 3 ||
865
865
                              $current_page_number - $this_page_number == 4 ||
866
                }
866
                              $current_page_number - $this_page_number == 5,
867
                        
867
                      sort_by   => join ' ', @sort_by
868
            }
868
                    };
869
            # now, show twenty pages, with the current one smack in the middle
870
            else {
871
                for ($i=$current_page_number; $i<=($current_page_number + 20 );$i++) {
872
                    my $this_offset = ((($i-9)*$results_per_page)-$results_per_page);
873
                    my $this_page_number = $i-9;
874
                    if ( $this_page_number <= $pages ) {
875
                        push @page_numbers,
876
                          { offset    => $this_offset,
877
                            pg        => $this_page_number,
878
                            highlight => $this_page_number == $current_page_number,
879
                            sort_by => join ' ', @sort_by
880
                          };
881
                    }
882
                }
883
                        
884
            }
869
            }
885
            $template->param(   PAGE_NUMBERS => \@page_numbers,
870
            $template->param(   PAGE_NUMBERS => \@page_numbers,
886
                                last_page_offset => $last_page_offset,
871
                                last_page_offset => $last_page_offset,
887
- 

Return to bug 18128