Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9deadd1d

Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt

  • ID 9deadd1d1a37ce24b807132c00f4890785400683
  • Vorgänger cf32b30b
  • Nachfolger 35f3e56a

Controller-Helfer für das halbautomatische Sortieren von Listenansichten

Unterschiede anzeigen:

SL/Template/Plugin/L.pm
582 582
  return substr($text, 0, $params{at}) . '...';
583 583
}
584 584

  
585
sub sortable_table_header {
586
  my ($self, $by, @slurp) = @_;
587
  my %params              = _hashify(@slurp);
588

  
589
  my $controller          = $self->{CONTEXT}->stash->get('SELF');
590
  my $sort_spec           = $controller->get_sort_spec;
591
  my $by_spec             = $sort_spec->{$by};
592
  my %current_sort_params = $controller->get_current_sort_params;
593
  my ($image, $new_dir)   = ('', $current_sort_params{dir});
594
  my $title               = delete($params{title}) || $by_spec->{title};
595

  
596
  if ($current_sort_params{by} eq $by) {
597
    my $current_dir = $current_sort_params{dir} ? 'up' : 'down';
598
    $image          = '<img border="0" src="image/' . $current_dir . '.png">';
599
    $new_dir        = 1 - ($current_sort_params{dir} || 0);
600
  }
601

  
602
  $params{ $sort_spec->{FORM_PARAMS}->[0] } = $by;
603
  $params{ $sort_spec->{FORM_PARAMS}->[1] } = ($new_dir ? '1' : '0');
604

  
605
  return '<a href="' . $controller->get_callback(%params) . '">' . _H($title) . $image . '</a>';
606
}
607

  
585 608
1;
586 609

  
587 610
__END__
......
864 887

  
865 888
Dumps the Argument using L<Data::Dumper> into a E<lt>preE<gt> block.
866 889

  
890
=item C<sortable_table_header $by, %params>
891

  
892
Create a link and image suitable for placement in a table
893
header. C<$by> must be an index set up by the controller with
894
L<SL::Controller::Helper::make_sorted>.
895

  
896
The optional parameter C<$params{title}> can override the column title
897
displayed to the user. Otherwise the column title from the
898
controller's sort spec is used.
899

  
900
The other parameters in C<%params> are passed unmodified to the
901
underlying call to L<SL::Controller::Base::url_for>.
902

  
903
See the documentation of L<SL::Controller::Helper::Sorted> for an
904
overview and further usage instructions.
905

  
867 906
=back
868 907

  
869 908
=head2 CONVERSION FUNCTIONS

Auch abrufbar als: Unified diff