- ## Build the page numbers on the bottom of the page
- my @page_numbers;
- # total number of pages there will be
- my $pages = ceil($hits / $results_per_page);
- # default page number
- my $current_page_number = 1;
- $current_page_number = ($offset / $results_per_page + 1) if $offset;
- my $previous_page_offset = $offset - $results_per_page unless ($offset - $results_per_page <0);
- my $next_page_offset = $offset + $results_per_page;
- # If we're within the first 10 pages, keep it simple
- #warn "current page:".$current_page_number;
- if ($current_page_number < 10) {
- # just show the first 10 pages
- # Loop through the pages
- my $pages_to_show = 10;
- $pages_to_show = $pages if $pages<10;
- for ($i=1; $i<=$pages_to_show;$i++) {
- # the offset for this page
- my $this_offset = (($i*$results_per_page)-$results_per_page);
- # the page number for this page
- my $this_page_number = $i;
- # it should only be highlighted if it's the current page
- my $highlight = 1 if ($this_page_number == $current_page_number);
- # put it in the array
- push @page_numbers, { offset => $this_offset, pg => $this_page_number, highlight => $highlight, sort_by => join " ",@sort_by };
+
+ ## FIXME: add a global function for this, it's better than the current global one
+ ## Build the page numbers on the bottom of the page
+ my @page_numbers;
+ # total number of pages there will be
+ my $pages = ceil($hits / $results_per_page);
+ # default page number
+ my $current_page_number = 1;
+ $current_page_number = ($offset / $results_per_page + 1) if $offset;
+ my $previous_page_offset = $offset - $results_per_page unless ($offset - $results_per_page <0);
+ my $next_page_offset = $offset + $results_per_page;
+ # If we're within the first 10 pages, keep it simple
+ #warn "current page:".$current_page_number;
+ if ($current_page_number < 10) {
+ # just show the first 10 pages
+ # Loop through the pages
+ my $pages_to_show = 10;
+ $pages_to_show = $pages if $pages<10;
+ for (my $i=1; $i<=$pages_to_show;$i++) {
+ # the offset for this page
+ my $this_offset = (($i*$results_per_page)-$results_per_page);
+ # the page number for this page
+ my $this_page_number = $i;
+ # it should only be highlighted if it's the current page
+ my $highlight = 1 if ($this_page_number == $current_page_number);
+ # put it in the array
+ push @page_numbers, { offset => $this_offset, pg => $this_page_number, highlight => $highlight, sort_by => join " ",@sort_by };