Revision e4fb6339
Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt
SL/DB/Helper/Paginated.pm | ||
---|---|---|
9 | 9 |
use List::MoreUtils qw(any); |
10 | 10 |
|
11 | 11 |
sub paginate { |
12 |
my ($self, %params) = @_; |
|
13 |
my $page = $params{page} || 1; |
|
14 |
my %args = %{ $params{args} || {} }; |
|
15 |
|
|
16 |
my $ret = { }; |
|
17 |
|
|
18 |
$ret->{per_page} = per_page($self, %params); |
|
19 |
$ret->{max} = ceil($self->get_all_count(%args), $ret->{per_page}) || 1; |
|
20 |
$ret->{cur} = $page < 1 ? 1 |
|
21 |
: $page > $ret->{max} ? $ret->{max} |
|
22 |
: $page; |
|
23 |
$ret->{common} = make_common_pages($ret->{cur}, $ret->{max}); |
|
12 |
my ($self, %params) = @_;
|
|
13 |
my $page = $params{page} || 1;
|
|
14 |
my %args = %{ $params{args} || {} };
|
|
15 |
|
|
16 |
my $ret = { };
|
|
17 |
|
|
18 |
$ret->{per_page} = per_page($self, %params);
|
|
19 |
$ret->{max} = ceil($self->get_all_count(%args), $ret->{per_page}) || 1;
|
|
20 |
$ret->{cur} = $page < 1 ? 1
|
|
21 |
: $page > $ret->{max} ? $ret->{max}
|
|
22 |
: $page;
|
|
23 |
$ret->{common} = make_common_pages($ret->{cur}, $ret->{max});
|
|
24 | 24 |
|
25 | 25 |
$params{args}{page} = $ret->{cur}; |
26 | 26 |
$params{args}{per_page} = $ret->{per_page}; |
Auch abrufbar als: Unified diff
Kosmetik: Einrückung