Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5b22ebf0

Von Moritz Bunkus vor fast 12 Jahren hinzugefügt

  • ID 5b22ebf0e0e3cf62364dfb46a7f2de28f90289da
  • Vorgänger e831bee6
  • Nachfolger e3815e78

Refactoring: In Rückgabewert vom Paginated-DB-Helfer 'cur' in 'page' umbenennen

Dient Konsistenz der Eingangs- und Ausgangsparameter.

Dadurch entfällt auch das Hin- und Herbenennen im
Paginated-Controller-Helfer/im L-Plugin.

Unterschiede anzeigen:

SL/Controller/Helper/Paginated.pm
61 61
                        :     $spec->{PAGINATE_ARGS}            ? do { my $sub = $spec->{PAGINATE_ARGS}; %{ $self->$sub() } }
62 62
                        :                                         ();
63 63
  my $calculated_params = "SL::DB::Manager::$spec->{MODEL}"->paginate(%paginate_params, args => \%paginate_args);
64
  %paginate_params      = (
65
    page         => min($paginate_params{page}, $calculated_params->{max}),
66
    per_page     => $paginate_params{per_page},
67
    num_pages    => $calculated_params->{max},
68
    common_pages => $calculated_params->{common},
69
  );
70 64

  
71
  # $::lxdebug->dump(0, "get_current_paginate_params: ", \%paginate_params);
65
  # $::lxdebug->dump(0, "get_current_paginate_params: ", $calculated_params);
72 66

  
73
  return %paginate_params;
67
  return %{ $calculated_params };
74 68
}
75 69

  
76 70
sub disable_pagination {
SL/DB/Helper/Paginated.pm
17 17

  
18 18
  $ret->{per_page}        = per_page($self, %params);
19 19
  $ret->{max}             = ceil($self->get_all_count(%args), $ret->{per_page}) || 1;
20
  $ret->{cur}             = $page < 1 ? 1
20
  $ret->{page}            = $page < 1 ? 1
21 21
                          : $page > $ret->{max} ? $ret->{max}
22 22
                          : $page;
23
  $ret->{common}          = make_common_pages($ret->{cur}, $ret->{max});
23
  $ret->{common}          = make_common_pages($ret->{page}, $ret->{max});
24 24

  
25
  $params{args}{page}     = $ret->{cur};
25
  $params{args}{page}     = $ret->{page};
26 26
  $params{args}{per_page} = $ret->{per_page};
27 27
  delete $params{args}{limit};
28 28
  delete $params{args}{offset};
SL/Template/Plugin/L.pm
689 689
  my %paginate_params = $controller->get_current_paginate_params;
690 690

  
691 691
  my %template_params = (
692
    pages             => {
693
      cur             => $paginate_params{page},
694
      max             => $paginate_params{num_pages},
695
      common          => $paginate_params{common_pages},
696
    },
692
    pages             => \%paginate_params,
697 693
    url_maker         => sub {
698 694
      my %url_params                                    = _hashify(@_);
699 695
      $url_params{ $paginate_spec->{FORM_PARAMS}->[0] } = delete $url_params{page};
templates/webpages/common/paginate.html
8 8
[%- END %]
9 9
[%- IF pages.max > 1 %]
10 10
<div class='paginate'>
11
[%- IF pages.cur > 1 %]<a class='paginate-prev' href='[% build_url(page=pages.cur - 1) %]'>&laquo; [% 'prev' | $T8 %]</a> [% ELSE %]<b>&laquo;</b> [% END %]
11
[%- IF pages.page > 1 %]<a class='paginate-prev' href='[% build_url(page=pages.page - 1) %]'>&laquo; [% 'prev' | $T8 %]</a> [% ELSE %]<b>&laquo;</b> [% END %]
12 12
[%- FOR p = pages.common %]
13 13
  [%- NEXT UNLESS p.visible %]
14 14
  [%- IF p.active %]<a class='paginate-page' href="[% build_url(page=p.page) %]">[% p.page %]</a> [% ELSE %]<b>[% p.page %]</b> [%- END %]
15 15
[%- END %]
16
[%- IF pages.cur < pages.max %]<a class='paginate-next' href='[% build_url(page=pages.cur + 1) %]'>[% 'next' | $T8 %] &raquo;</a>[% ELSE %]<b>&raquo;</b>[%- END %]
16
[%- IF pages.page < pages.max %]<a class='paginate-next' href='[% build_url(page=pages.page + 1) %]'>[% 'next' | $T8 %] &raquo;</a>[% ELSE %]<b>&raquo;</b>[%- END %]
17 17
</div>
18 18
[%- END %]

Auch abrufbar als: Unified diff