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

(-)a/catalogue/search.pl (-58 / +10 lines)
Lines 631-696 for (my $i=0;$i<@servers;$i++) { Link Here
631
                    $line->{'incart'} = 1;
631
                    $line->{'incart'} = 1;
632
                }
632
                }
633
            }
633
            }
634
            $template->param(SEARCH_RESULTS => \@newresults);
634
            my( $page_numbers, $hits_to_paginate, $pages, $current_page_number, $previous_page_offset, $next_page_offset, $last_page_offset ) =
635
            ## FIXME: add a global function for this, it's better than the current global one
635
                Koha::SearchEngine::Search->pagination_bar({
636
            ## Build the page numbers on the bottom of the page
636
                    hits => $hits,
637
            my @page_numbers;
637
                    max_result_window => $searcher->max_result_window,
638
            my $max_result_window = $searcher->max_result_window;
638
                    results_per_page => $results_per_page,
639
            my $hits_to_paginate = ($max_result_window && $max_result_window < $hits) ? $max_result_window : $hits;
639
                    offset => $offset,
640
                    sort_by => \@sort_by
641
                 });
640
            $template->param( hits_to_paginate => $hits_to_paginate );
642
            $template->param( hits_to_paginate => $hits_to_paginate );
641
            # total number of pages there will be
643
            $template->param(SEARCH_RESULTS => \@newresults);
642
            my $pages = ceil($hits_to_paginate / $results_per_page);
643
            my $last_page_offset = ( $pages -1 ) * $results_per_page;
644
            # default page number
645
            my $current_page_number = 1;
646
            $current_page_number = ($offset / $results_per_page + 1) if $offset;
647
            my $previous_page_offset;
648
            if ( $offset >= $results_per_page ) {
649
                $previous_page_offset = $offset - $results_per_page;
650
            }
651
            my $next_page_offset = $offset + $results_per_page;
652
            # If we're within the first 10 pages, keep it simple
653
            #warn "current page:".$current_page_number;
654
            if ($current_page_number < 10) {
655
                # just show the first 10 pages
656
                # Loop through the pages
657
                my $pages_to_show = 10;
658
                $pages_to_show = $pages if $pages<10;
659
                for (my $i=1; $i<=$pages_to_show;$i++) {
660
                    # the offset for this page
661
                    my $this_offset = (($i*$results_per_page)-$results_per_page);
662
                    # the page number for this page
663
                    my $this_page_number = $i;
664
                    # put it in the array
665
                    push @page_numbers,
666
                      { offset    => $this_offset,
667
                        pg        => $this_page_number,
668
                        # it should only be highlighted if it's the current page
669
                        highlight => $this_page_number == $current_page_number,
670
                        sort_by   => join ' ', @sort_by
671
                      };
672
                                
673
                }
674
                        
675
            }
676
677
            # now, show twenty pages, with the current one smack in the middle
678
            else {
679
                for (my $i=$current_page_number; $i<=($current_page_number + 20 );$i++) {
680
                    my $this_offset = ((($i-9)*$results_per_page)-$results_per_page);
681
                    my $this_page_number = $i-9;
682
                    if ( $this_page_number <= $pages ) {
683
                        push @page_numbers,
684
                          { offset    => $this_offset,
685
                            pg        => $this_page_number,
686
                            highlight => $this_page_number == $current_page_number,
687
                            sort_by   => join ' ', @sort_by
688
                          };
689
                    }
690
                }
691
            }
692
            # FIXME: no previous_page_offset when pages < 2
644
            # FIXME: no previous_page_offset when pages < 2
693
            $template->param(   PAGE_NUMBERS => \@page_numbers,
645
            $template->param(   PAGE_NUMBERS => $page_numbers,
694
                                last_page_offset => $last_page_offset,
646
                                last_page_offset => $last_page_offset,
695
                                previous_page_offset => $previous_page_offset) unless $pages < 2;
647
                                previous_page_offset => $previous_page_offset) unless $pages < 2;
696
            $template->param(   next_page_offset => $next_page_offset) unless $pages eq $current_page_number;
648
            $template->param(   next_page_offset => $next_page_offset) unless $pages eq $current_page_number;
(-)a/opac/opac-search.pl (-61 / +13 lines)
Lines 865-932 for (my $i=0;$i<@servers;$i++) { Link Here
865
                OPACItemsResultsDisplay => (C4::Context->preference("OPACItemsResultsDisplay")),
865
                OPACItemsResultsDisplay => (C4::Context->preference("OPACItemsResultsDisplay")),
866
                suppress_result_number => $hide,
866
                suppress_result_number => $hide,
867
                            );
867
                            );
868
	    if (C4::Context->preference("OPACLocalCoverImages")){
868
            if (C4::Context->preference("OPACLocalCoverImages")){
869
		$template->param(OPACLocalCoverImages => 1);
869
            $template->param(OPACLocalCoverImages => 1);
870
		$template->param(OPACLocalCoverImagesPriority => C4::Context->preference("OPACLocalCoverImagesPriority"));
870
            $template->param(OPACLocalCoverImagesPriority => C4::Context->preference("OPACLocalCoverImagesPriority"));
871
	    }
871
            }
872
            ## Build the page numbers on the bottom of the page
872
            ## Build the page numbers on the bottom of the page
873
            my @page_numbers;
873
            my ( $page_numbers, $hits_to_paginate, $pages, $current_page_number, $previous_page_offset, $next_page_offset, $last_page_offset ) =
874
            my $max_result_window = $searcher->max_result_window;
874
                Koha::SearchEngine::Search->pagination_bar({
875
            my $hits_to_paginate = ($max_result_window && $max_result_window < $hits) ? $max_result_window : $hits;
875
                    hits => $hits,
876
                    max_result_window => $searcher->max_result_window,
877
                    results_per_page => $results_per_page,
878
                    offset => $offset,
879
                    sort_by => \@sort_by
880
                });
876
            $template->param( hits_to_paginate => $hits_to_paginate );
881
            $template->param( hits_to_paginate => $hits_to_paginate );
877
            # total number of pages there will be
882
            $template->param(   PAGE_NUMBERS => $page_numbers,
878
            my $pages = ceil($hits_to_paginate / $results_per_page);
879
            my $last_page_offset = ( $pages - 1 ) * $results_per_page;
880
            # default page number
881
            my $current_page_number = 1;
882
            if ($offset) {
883
                $current_page_number = ( $offset / $results_per_page + 1 );
884
            }
885
            my $previous_page_offset;
886
            if ( $offset >= $results_per_page ) {
887
                $previous_page_offset = $offset - $results_per_page;
888
            }
889
            my $next_page_offset = $offset + $results_per_page;
890
            # If we're within the first 10 pages, keep it simple
891
            #warn "current page:".$current_page_number;
892
            if ($current_page_number < 10) {
893
                # just show the first 10 pages
894
                # Loop through the pages
895
                my $pages_to_show = 10;
896
                $pages_to_show = $pages if $pages<10;
897
                for ($i=1; $i<=$pages_to_show;$i++) {
898
                    # the offset for this page
899
                    my $this_offset = (($i*$results_per_page)-$results_per_page);
900
                    # the page number for this page
901
                    my $this_page_number = $i;
902
                    # put it in the array
903
                    push @page_numbers,
904
                      { offset    => $this_offset,
905
                        pg        => $this_page_number,
906
                        highlight => $this_page_number == $current_page_number,
907
                        sort_by   => join ' ', @sort_by
908
                      };
909
910
                }
911
                        
912
            }
913
            # now, show twenty pages, with the current one smack in the middle
914
            else {
915
                for ($i=$current_page_number; $i<=($current_page_number + 20 );$i++) {
916
                    my $this_offset = ((($i-9)*$results_per_page)-$results_per_page);
917
                    my $this_page_number = $i-9;
918
                    if ( $this_page_number <= $pages ) {
919
                        push @page_numbers,
920
                          { offset    => $this_offset,
921
                            pg        => $this_page_number,
922
                            highlight => $this_page_number == $current_page_number,
923
                            sort_by => join ' ', @sort_by
924
                          };
925
                    }
926
                }
927
                        
928
            }
929
            $template->param(   PAGE_NUMBERS => \@page_numbers,
930
                                last_page_offset => $last_page_offset,
883
                                last_page_offset => $last_page_offset,
931
                                previous_page_offset => $previous_page_offset) unless $pages < 2;
884
                                previous_page_offset => $previous_page_offset) unless $pages < 2;
932
            $template->param(next_page_offset => $next_page_offset) unless $pages eq $current_page_number;
885
            $template->param(next_page_offset => $next_page_offset) unless $pages eq $current_page_number;
933
- 

Return to bug 23763