Revision 7714d4d0
Von Sven Schöling vor fast 14 Jahren hinzugefügt
SL/Template/Plugin/L.pm | ||
---|---|---|
3 | 3 |
use base qw( Template::Plugin ); |
4 | 4 |
use Template::Plugin; |
5 | 5 |
use List::MoreUtils qw(apply); |
6 |
use List::Util qw(max); |
|
6 | 7 |
|
7 | 8 |
use strict; |
8 | 9 |
|
... | ... | |
84 | 85 |
} |
85 | 86 |
|
86 | 87 |
sub textarea_tag { |
87 |
my $self = shift; |
|
88 |
my $name = shift; |
|
89 |
my $content = shift; |
|
90 |
my %attributes = _hashify(@_); |
|
88 |
my ($self, $name, $content, @slurp) = @_; |
|
89 |
my %attributes = _hashify(@slurp); |
|
91 | 90 |
|
92 | 91 |
$attributes{id} ||= $self->name_to_id($name); |
93 | 92 |
$content = $content ? _H($content) : ''; |
... | ... | |
139 | 138 |
|
140 | 139 |
sub input_tag { |
141 | 140 |
my ($self, $name, $value, @slurp) = @_; |
142 |
my %attributes = _hashify(@slurp);
|
|
141 |
my %attributes = _hashify(@slurp); |
|
143 | 142 |
|
144 | 143 |
$attributes{id} ||= $self->name_to_id($name); |
145 | 144 |
$attributes{type} ||= 'text'; |
... | ... | |
176 | 175 |
} |
177 | 176 |
|
178 | 177 |
sub submit_tag { |
179 |
my $self = shift; |
|
180 |
my $name = shift; |
|
181 |
my $value = shift; |
|
182 |
my %attributes = _hashify(@_); |
|
178 |
my ($self, $name, $value, @slurp) = @_; |
|
179 |
my %attributes = _hashify(@slurp); |
|
183 | 180 |
|
184 | 181 |
$attributes{onclick} = "if (confirm('" . delete($attributes{confirm}) . "')) return true; else return false;" if $attributes{confirm}; |
185 | 182 |
|
186 | 183 |
return $self->input_tag($name, $value, %attributes, type => 'submit', class => 'submit'); |
187 | 184 |
} |
188 | 185 |
|
186 |
sub button_tag { |
|
187 |
my ($self, $onclick, $value, @slurp) = @_; |
|
188 |
my %attributes = _hashify(@slurp); |
|
189 |
|
|
190 |
return $self->input_tag(undef, $value, %attributes, type => 'button', onclick => $onclick); |
|
191 |
} |
|
192 |
|
|
189 | 193 |
sub options_for_select { |
190 | 194 |
my $self = shift; |
191 | 195 |
my $collection = shift; |
... | ... | |
339 | 343 |
return +{ name => $name, data => $data }; |
340 | 344 |
} |
341 | 345 |
|
346 |
sub areainput_tag { |
|
347 |
my ($self, $name, $value, @slurp) = @_; |
|
348 |
my %attributes = _hashify(@slurp); |
|
349 |
|
|
350 |
my $rows = delete $attributes{rows} || 1; |
|
351 |
my $min = delete $attributes{min_rows} || 1; |
|
352 |
|
|
353 |
return $rows > 1 |
|
354 |
? $self->textarea_tag($name, $value, %attributes, rows => max $rows, $min) |
|
355 |
: $self->input_tag($name, $value, %attributes); |
|
356 |
} |
|
357 |
|
|
342 | 358 |
1; |
343 | 359 |
|
344 | 360 |
__END__ |
... | ... | |
491 | 507 |
An optional attribute is C<selected>, which accepts the ordinal of a tab which |
492 | 508 |
should be selected by default. |
493 | 509 |
|
510 |
=item C<areainput_tag $name, $content, %PARAMS> |
|
511 |
|
|
512 |
Creates a generic input tag or textarea tag, depending on content size. The |
|
513 |
mount of desired rows must be given with C<rows> parameter, Accpeted parameters |
|
514 |
include C<min_rows> for rendering a minimum of rows if a textarea is displayed. |
|
515 |
|
|
516 |
You can force input by setting rows to 1, and you can force textarea by setting |
|
517 |
rows to anything >1. |
|
518 |
|
|
494 | 519 |
=back |
495 | 520 |
|
496 | 521 |
=head2 CONVERSION FUNCTIONS |
Auch abrufbar als: Unified diff
button tag und areainput tag in L.pm