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 |
- |
|
|