X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/2ee3300bca9cd8900047545bffa53c2d5d856336..6c0aa04610dde7e6bdc69394da0f0c8133b10280:/SL/DB/Helper/Paginated.pm diff --git a/SL/DB/Helper/Paginated.pm b/SL/DB/Helper/Paginated.pm index a5a07d067..df5a6e3d9 100644 --- a/SL/DB/Helper/Paginated.pm +++ b/SL/DB/Helper/Paginated.pm @@ -6,6 +6,8 @@ require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(paginate); +use List::MoreUtils qw(any); + sub paginate { my ($self, %params) = @_; my $page = $params{page} || 1; @@ -47,12 +49,21 @@ sub make_common_pages { my ($cur, $max) = @_; return [ map { - active => $_ != $cur, - page => $_, + active => $_ != $cur, + page => $_, + visible => }, 1 .. $max ]; } +sub calc_visibility { + my ($cur, $max, $this) = @_; + any { $_ } abs($cur - $this) < 5, + $cur <= 3, + $cur == $max, + any { ! abs ($cur - $this) % $_ } 10, 50, 100, 500, 1000, 5000; +} + 1; __END__