X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Felements%2Fpager.html;h=d360e647891647945c2af1877dd3eec4dffbf551;hp=0510d327d5b9f811f6366344caf142f839e219b3;hb=ff27c3f36240aee48ed50153dd5d8fe3ac3f2443;hpb=c0c6e3937fb2fa8f6b7cab217461515e837c444f diff --git a/httemplate/elements/pager.html b/httemplate/elements/pager.html index 0510d327d..d360e6478 100644 --- a/httemplate/elements/pager.html +++ b/httemplate/elements/pager.html @@ -1,42 +1,58 @@ -<% +% if ( $opt{'total'} != $opt{'num_rows'} && $opt{'maxrecords'} ) { +% +% unless ( $opt{'offset'} == 0 ) { +% $cgi->param('offset', $opt{'offset'} - $opt{'maxrecords'}); + Previous +% } +% +% 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 ) { + + <% $page %> + +% } else { +% $cgi->param('offset', $poff); +% +% if ( $page > $prevpage+1 ) { + ... +% } + + <% $page %> + +% } +% +% $prevpage = $page; +% +% } +% +% unless ( $opt{'offset'} + $opt{'maxrecords'} > $opt{'total'} ) { +% $cgi->param('offset', $opt{'offset'} + $opt{'maxrecords'}); + Next +% } +% +% $cgi->param('offset', $orig_offset); #so future $self_url invocations don't advance a page +% +% } +<%init> + +my %opt = @_; + +my $orig_offset = $opt{'offset'}; + + - my %opt = @_; - - my $pager = ''; - if ( $opt{'total'} != $opt{'num_rows'} && $opt{'maxrecords'} ) { - unless ( $opt{'offset'} == 0 ) { - $cgi->param('offset', $opt{'offset'} - $opt{'maxrecords'}); -%> - - Previous - -<% - } - my $page = 0; - for ( my $poff = 0; $poff < $opt{'total'}; $poff += $opt{'maxrecords'} ) { - $page++; - if ( $opt{'offset'} == $poff ) { -%> - - <%= $page %> - -<% - } else { - $cgi->param('offset', $poff); -%> - - <%= $page %> - -<% - } - } - unless ( $opt{'offset'} + $opt{'maxrecords'} > $opt{'total'} ) { - $cgi->param('offset', $opt{'offset'} + $opt{'maxrecords'}); -%> - - Next - -<% - } - } -%>