Dient Konsistenz der Eingangs- und Ausgangsparameter.
Dadurch entfällt auch das Hin- und Herbenennen im
Paginated-Controller-Helfer/im L-Plugin.
: $spec->{PAGINATE_ARGS} ? do { my $sub = $spec->{PAGINATE_ARGS}; %{ $self->$sub() } }
: ();
my $calculated_params = "SL::DB::Manager::$spec->{MODEL}"->paginate(%paginate_params, args => \%paginate_args);
- %paginate_params = (
- page => min($paginate_params{page}, $calculated_params->{max}),
- per_page => $paginate_params{per_page},
- num_pages => $calculated_params->{max},
- common_pages => $calculated_params->{common},
- );
- # $::lxdebug->dump(0, "get_current_paginate_params: ", \%paginate_params);
+ # $::lxdebug->dump(0, "get_current_paginate_params: ", $calculated_params);
- return %paginate_params;
+ return %{ $calculated_params };
}
sub disable_pagination {
$ret->{per_page} = per_page($self, %params);
$ret->{max} = ceil($self->get_all_count(%args), $ret->{per_page}) || 1;
- $ret->{cur} = $page < 1 ? 1
+ $ret->{page} = $page < 1 ? 1
: $page > $ret->{max} ? $ret->{max}
: $page;
- $ret->{common} = make_common_pages($ret->{cur}, $ret->{max});
+ $ret->{common} = make_common_pages($ret->{page}, $ret->{max});
- $params{args}{page} = $ret->{cur};
+ $params{args}{page} = $ret->{page};
$params{args}{per_page} = $ret->{per_page};
delete $params{args}{limit};
delete $params{args}{offset};
my %paginate_params = $controller->get_current_paginate_params;
my %template_params = (
- pages => {
- cur => $paginate_params{page},
- max => $paginate_params{num_pages},
- common => $paginate_params{common_pages},
- },
+ pages => \%paginate_params,
url_maker => sub {
my %url_params = _hashify(@_);
$url_params{ $paginate_spec->{FORM_PARAMS}->[0] } = delete $url_params{page};
[%- END %]
[%- IF pages.max > 1 %]
<div class='paginate'>
-[%- IF pages.cur > 1 %]<a class='paginate-prev' href='[% build_url(page=pages.cur - 1) %]'>« [% 'prev' | $T8 %]</a> [% ELSE %]<b>«</b> [% END %]
+[%- IF pages.page > 1 %]<a class='paginate-prev' href='[% build_url(page=pages.page - 1) %]'>« [% 'prev' | $T8 %]</a> [% ELSE %]<b>«</b> [% END %]
[%- FOR p = pages.common %]
[%- NEXT UNLESS p.visible %]
[%- IF p.active %]<a class='paginate-page' href="[% build_url(page=p.page) %]">[% p.page %]</a> [% ELSE %]<b>[% p.page %]</b> [%- END %]
[%- END %]
-[%- IF pages.cur < pages.max %]<a class='paginate-next' href='[% build_url(page=pages.cur + 1) %]'>[% 'next' | $T8 %] »</a>[% ELSE %]<b>»</b>[%- END %]
+[%- IF pages.page < pages.max %]<a class='paginate-next' href='[% build_url(page=pages.page + 1) %]'>[% 'next' | $T8 %] »</a>[% ELSE %]<b>»</b>[%- END %]
</div>
[%- END %]