Revision 783342e0
Von Sven Schöling vor etwa 11 Jahren hinzugefügt
SL/Template/Plugin/L.pm | ||
---|---|---|
443 | 443 |
my ($self, $by, %params) = _hashify(2, @_); |
444 | 444 |
|
445 | 445 |
my $controller = $self->{CONTEXT}->stash->get('SELF'); |
446 |
my $sort_spec = $controller->get_sort_spec; |
|
446 |
my $models = $params{models} || $self->{CONTEXT}->stash->get('MODELS'); |
|
447 |
my $sort_spec = $models->get_sort_spec; |
|
447 | 448 |
my $by_spec = $sort_spec->{$by}; |
448 |
my %current_sort_params = $controller->get_current_sort_params;
|
|
449 |
my %current_sort_params = $models->get_current_sort_params;
|
|
449 | 450 |
my ($image, $new_dir) = ('', $current_sort_params{dir}); |
450 | 451 |
my $title = delete($params{title}) || $::locale->text($by_spec->{title}); |
451 | 452 |
|
452 |
if ($current_sort_params{by} eq $by) { |
|
453 |
my $current_dir = $current_sort_params{dir} ? 'up' : 'down'; |
|
453 |
if ($current_sort_params{sort_by} eq $by) {
|
|
454 |
my $current_dir = $current_sort_params{sort_dir} ? 'up' : 'down';
|
|
454 | 455 |
$image = '<img border="0" src="image/' . $current_dir . '.png">'; |
455 |
$new_dir = 1 - ($current_sort_params{dir} || 0); |
|
456 |
$new_dir = 1 - ($current_sort_params{sort_dir} || 0);
|
|
456 | 457 |
} |
457 | 458 |
|
458 |
$params{ $sort_spec->{FORM_PARAMS}->[0] } = $by;
|
|
459 |
$params{ $sort_spec->{FORM_PARAMS}->[1] } = ($new_dir ? '1' : '0');
|
|
459 |
$params{ $models->sorted->form_params->[0] } = $by;
|
|
460 |
$params{ $models->sorted->form_params->[1] } = ($new_dir ? '1' : '0');
|
|
460 | 461 |
|
461 |
return '<a href="' . $controller->get_callback(%params) . '">' . _H($title) . $image . '</a>';
|
|
462 |
return '<a href="' . $models->get_callback(%params) . '">' . _H($title) . $image . '</a>';
|
|
462 | 463 |
} |
463 | 464 |
|
464 | 465 |
sub paginate_controls { |
465 | 466 |
my ($self, %params) = _hashify(1, @_); |
466 | 467 |
|
467 | 468 |
my $controller = $self->{CONTEXT}->stash->get('SELF'); |
468 |
my $pager = $params{models}->paginated; |
|
469 |
my $models = $params{models} || $self->{CONTEXT}->stash->get('MODELS'); |
|
470 |
my $pager = $models->paginated; |
|
469 | 471 |
# my $paginate_spec = $controller->get_paginate_spec; |
470 | 472 |
|
471 |
my %paginate_params = $params{models}->get_paginate_args;
|
|
473 |
my %paginate_params = $models->get_paginate_args;
|
|
472 | 474 |
|
473 | 475 |
my %template_params = ( |
474 | 476 |
pages => \%paginate_params, |
Auch abrufbar als: Unified diff
BackgroundJob models