summaryrefslogtreecommitdiff
path: root/httemplate/elements/pager.html
blob: d360e647891647945c2af1877dd3eec4dffbf551 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
% if ( $opt{'total'} != $opt{'num_rows'} && $opt{'maxrecords'} ) {
%
%   unless ( $opt{'offset'} == 0 ) {
%     $cgi->param('offset', $opt{'offset'} - $opt{'maxrecords'});
      <A HREF="<% $cgi->self_url %>"><B><FONT SIZE="+1">Previous</FONT></B></A>
%   }
%
%   my $page = 0;
%   my $prevpage = 0;
%   my $over = 0;
%   my $step = $opt{total} / 10; # 10 evenly spaced
%   for ( my $poff = 0; $poff < $opt{total}; $poff += $opt{maxrecords} ) {
%     $page++;
%	
%     next unless
%          $page <= 4                                          #first four
%       || $page >= ( $opt{total} / $opt{maxrecords} ) - 3     #last four
%       || abs( ($opt{offset}-$poff) / $opt{maxrecords} ) <= 3 #w/i 3 of current
%       || $poff > $over                                       # evenly spaced
%     ;           
%
%     $over += $step if $poff > $over;
%
%     if ( $opt{'offset'} == $poff ) {

        <FONT SIZE="+2"><% $page %></FONT>

%     } else {
%       $cgi->param('offset', $poff);
%
%       if ( $page > $prevpage+1 ) {
          ...
%       }

        <A HREF="<% $cgi->self_url %>"><% $page %></A>

%     }
%
%     $prevpage = $page;
%
%   }
%
%   unless ( $opt{'offset'} + $opt{'maxrecords'} > $opt{'total'} ) {
%     $cgi->param('offset', $opt{'offset'} + $opt{'maxrecords'});
      <A HREF="<% $cgi->self_url %>"><B><FONT SIZE="+1">Next</FONT></B></A>
%   }
%
%   $cgi->param('offset', $orig_offset); #so future $self_url invocations don't advance a page
%
% }
<%init>

my %opt = @_;

my $orig_offset = $opt{'offset'};

</%init>