Lines 875-942
for (my $i=0;$i<@servers;$i++) {
Link Here
|
875 |
OPACItemsResultsDisplay => (C4::Context->preference("OPACItemsResultsDisplay")), |
875 |
OPACItemsResultsDisplay => (C4::Context->preference("OPACItemsResultsDisplay")), |
876 |
suppress_result_number => $hide, |
876 |
suppress_result_number => $hide, |
877 |
); |
877 |
); |
878 |
if (C4::Context->preference("OPACLocalCoverImages")){ |
878 |
if (C4::Context->preference("OPACLocalCoverImages")){ |
879 |
$template->param(OPACLocalCoverImages => 1); |
879 |
$template->param(OPACLocalCoverImages => 1); |
880 |
$template->param(OPACLocalCoverImagesPriority => C4::Context->preference("OPACLocalCoverImagesPriority")); |
880 |
$template->param(OPACLocalCoverImagesPriority => C4::Context->preference("OPACLocalCoverImagesPriority")); |
881 |
} |
881 |
} |
882 |
## Build the page numbers on the bottom of the page |
882 |
## Build the page numbers on the bottom of the page |
883 |
my @page_numbers; |
883 |
my ( $page_numbers, $hits_to_paginate, $pages, $current_page_number, $previous_page_offset, $next_page_offset, $last_page_offset ) = |
884 |
my $max_result_window = $searcher->max_result_window; |
884 |
Koha::SearchEngine::Search->pagination_bar({ |
885 |
my $hits_to_paginate = ($max_result_window && $max_result_window < $hits) ? $max_result_window : $hits; |
885 |
hits => $hits, |
|
|
886 |
max_result_window => $searcher->max_result_window, |
887 |
results_per_page => $results_per_page, |
888 |
offset => $offset, |
889 |
sort_by => \@sort_by |
890 |
}); |
886 |
$template->param( hits_to_paginate => $hits_to_paginate ); |
891 |
$template->param( hits_to_paginate => $hits_to_paginate ); |
887 |
# total number of pages there will be |
892 |
$template->param( PAGE_NUMBERS => $page_numbers, |
888 |
my $pages = ceil($hits_to_paginate / $results_per_page); |
|
|
889 |
my $last_page_offset = ( $pages - 1 ) * $results_per_page; |
890 |
# default page number |
891 |
my $current_page_number = 1; |
892 |
if ($offset) { |
893 |
$current_page_number = ( $offset / $results_per_page + 1 ); |
894 |
} |
895 |
my $previous_page_offset; |
896 |
if ( $offset >= $results_per_page ) { |
897 |
$previous_page_offset = $offset - $results_per_page; |
898 |
} |
899 |
my $next_page_offset = $offset + $results_per_page; |
900 |
# If we're within the first 10 pages, keep it simple |
901 |
#warn "current page:".$current_page_number; |
902 |
if ($current_page_number < 10) { |
903 |
# just show the first 10 pages |
904 |
# Loop through the pages |
905 |
my $pages_to_show = 10; |
906 |
$pages_to_show = $pages if $pages<10; |
907 |
for ($i=1; $i<=$pages_to_show;$i++) { |
908 |
# the offset for this page |
909 |
my $this_offset = (($i*$results_per_page)-$results_per_page); |
910 |
# the page number for this page |
911 |
my $this_page_number = $i; |
912 |
# put it in the array |
913 |
push @page_numbers, |
914 |
{ offset => $this_offset, |
915 |
pg => $this_page_number, |
916 |
highlight => $this_page_number == $current_page_number, |
917 |
sort_by => join ' ', @sort_by |
918 |
}; |
919 |
|
920 |
} |
921 |
|
922 |
} |
923 |
# now, show twenty pages, with the current one smack in the middle |
924 |
else { |
925 |
for ($i=$current_page_number; $i<=($current_page_number + 20 );$i++) { |
926 |
my $this_offset = ((($i-9)*$results_per_page)-$results_per_page); |
927 |
my $this_page_number = $i-9; |
928 |
if ( $this_page_number <= $pages ) { |
929 |
push @page_numbers, |
930 |
{ offset => $this_offset, |
931 |
pg => $this_page_number, |
932 |
highlight => $this_page_number == $current_page_number, |
933 |
sort_by => join ' ', @sort_by |
934 |
}; |
935 |
} |
936 |
} |
937 |
|
938 |
} |
939 |
$template->param( PAGE_NUMBERS => \@page_numbers, |
940 |
last_page_offset => $last_page_offset, |
893 |
last_page_offset => $last_page_offset, |
941 |
previous_page_offset => $previous_page_offset) unless $pages < 2; |
894 |
previous_page_offset => $previous_page_offset) unless $pages < 2; |
942 |
$template->param(next_page_offset => $next_page_offset) unless $pages eq $current_page_number; |
895 |
$template->param(next_page_offset => $next_page_offset) unless $pages eq $current_page_number; |