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