Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b5f4fac1

Von Moritz Bunkus vor etwa 8 Jahren hinzugefügt

  • ID b5f4fac196509681df791bc5e4ee3d8c7d2a4a41
  • Vorgänger c44615e9
  • Nachfolger d6838f77

Presenter: hidden_tag, javascript, checkbox_tag von L → Presenter::Tag verschoben

Damit sind diese Funktionen auch direkt aus Perl-Code verfügbar, und man
muss nicht mehr das unsägliche CGI benutzen, um Checkboxen zu rendern.

Unterschiede anzeigen:

SL/Template/Plugin/L.pm
62 62

  
63 63
sub name_to_id    { return _call_presenter('name_to_id',    @_); }
64 64
sub html_tag      { return _call_presenter('html_tag',      @_); }
65
sub hidden_tag    { return _call_presenter('hidden_tag',    @_); }
65 66
sub select_tag    { return _call_presenter('select_tag',    @_); }
67
sub checkbox_tag  { return _call_presenter('checkbox_tag',  @_); }
66 68
sub input_tag     { return _call_presenter('input_tag',     @_); }
69
sub javascript    { return _call_presenter('javascript',    @_); }
67 70
sub truncate      { return _call_presenter('truncate',      @_); }
68 71
sub simple_format { return _call_presenter('simple_format', @_); }
69 72
sub part_picker   { return _call_presenter('part_picker',   @_); }
......
95 98
  return $self->html_tag('textarea', $content, %attributes, name => $name);
96 99
}
97 100

  
98
sub checkbox_tag {
99
  my ($self, $name, %attributes) = _hashify(2, @_);
100

  
101
  _set_id_attribute(\%attributes, $name);
102
  $attributes{value}   = 1 unless defined $attributes{value};
103
  my $label            = delete $attributes{label};
104
  my $checkall         = delete $attributes{checkall};
105
  my $for_submit       = delete $attributes{for_submit};
106

  
107
  if ($attributes{checked}) {
108
    $attributes{checked} = 'checked';
109
  } else {
110
    delete $attributes{checked};
111
  }
112

  
113
  my $code  = '';
114
  $code    .= $self->hidden_tag($name, 0, %attributes, id => $attributes{id} . '_hidden') if $for_submit;
115
  $code    .= $self->html_tag('input', undef,  %attributes, name => $name, type => 'checkbox');
116
  $code    .= $self->html_tag('label', $label, for => $attributes{id}) if $label;
117
  $code    .= $self->javascript(qq|\$('#$attributes{id}').checkall('$checkall');|) if $checkall;
118

  
119
  return $code;
120
}
121

  
122 101
sub radio_button_tag {
123 102
  my ($self, $name, %attributes) = _hashify(2, @_);
124 103

  
......
141 120
  return $code;
142 121
}
143 122

  
144
sub hidden_tag {
145
  my ($self, $name, $value, %attributes) = _hashify(3, @_);
146
  return $self->input_tag($name, $value, %attributes, type => 'hidden');
147
}
148

  
149 123
sub div_tag {
150 124
  my ($self, $content, @slurp) = @_;
151 125
  return $self->html_tag('div', $content, @slurp);
......
206 180
  return $self->select_tag($name, [ [ 1 => $::locale->text('Yes') ], [ 0 => $::locale->text('No') ] ], default => $value ? 1 : 0, %attributes);
207 181
}
208 182

  
209
sub javascript {
210
  my ($self, $data) = @_;
211
  return $self->html_tag('script', $data, type => 'text/javascript');
212
}
213

  
214 183
sub stylesheet_tag {
215 184
  my $self = shift;
216 185
  my $code = '';

Auch abrufbar als: Unified diff