Revision da2fecb4
Von Moritz Bunkus vor fast 12 Jahren hinzugefügt
SL/Presenter/Tag.pm | ||
---|---|---|
sub input_tag {
|
||
my ($self, $name, $value, %attributes) = @_;
|
||
|
||
$attributes{id} ||= $self->name_to_id($name);
|
||
_set_id_attribute(\%attributes, $name);
|
||
$attributes{type} ||= 'text';
|
||
|
||
return $self->html_tag('input', undef, %attributes, name => $name, value => $value);
|
||
... | ... | |
sub select_tag {
|
||
my ($self, $name, $collection, %attributes) = @_;
|
||
|
||
$attributes{id} ||= $self->name_to_id($name);
|
||
_set_id_attribute(\%attributes, $name);
|
||
|
||
my $value_key = delete($attributes{value_key}) || 'id';
|
||
my $title_key = delete($attributes{title_key}) || $value_key;
|
||
... | ... | |
return $self->html_tag('select', $code, %attributes, name => $name);
|
||
}
|
||
|
||
sub _set_id_attribute {
|
||
my ($attributes, $name) = @_;
|
||
|
||
$attributes->{id} = name_to_id(undef, $name) if !delete($attributes->{no_id}) && !$attributes->{id};
|
||
|
||
return %{ $attributes };
|
||
}
|
||
|
||
1;
|
||
__END__
|
||
|
||
... | ... | |
A module modeled a bit after Rails' ActionView helpers. Several small
|
||
functions that create HTML tags from various kinds of data sources.
|
||
|
||
The C<id> attribute is usually calculated automatically. This can be
|
||
overridden by either specifying an C<id> attribute or by setting
|
||
C<no_id> to trueish.
|
||
|
||
=head1 FUNCTIONS
|
||
|
||
=head2 LOW-LEVEL FUNCTIONS
|
SL/Template/Plugin/L.pm | ||
---|---|---|
sub truncate { return _call_presenter('truncate', @_); }
|
||
sub simple_format { return _call_presenter('simple_format', @_); }
|
||
|
||
sub _set_id_attribute {
|
||
my ($attributes, $name) = @_;
|
||
SL::Presenter::Tag::_set_id_attribute($attributes, $name);
|
||
}
|
||
|
||
sub img_tag {
|
||
my ($self, @slurp) = @_;
|
||
my %options = _hashify(@slurp);
|
||
... | ... | |
my ($self, $name, $content, @slurp) = @_;
|
||
my %attributes = _hashify(@slurp);
|
||
|
||
$attributes{id} ||= $self->name_to_id($name);
|
||
_set_id_attribute(\%attributes, $name);
|
||
$attributes{rows} *= 1; # required by standard
|
||
$attributes{cols} *= 1; # required by standard
|
||
$content = $content ? _H($content) : '';
|
||
... | ... | |
my ($self, $name, @slurp) = @_;
|
||
my %attributes = _hashify(@slurp);
|
||
|
||
$attributes{id} ||= $self->name_to_id($name);
|
||
_set_id_attribute(\%attributes, $name);
|
||
$attributes{value} = 1 unless defined $attributes{value};
|
||
my $label = delete $attributes{label};
|
||
my $checkall = delete $attributes{checkall};
|
||
... | ... | |
my $name = shift;
|
||
my %attributes = _hashify(@_);
|
||
|
||
_set_id_attribute(\%attributes, $name);
|
||
$attributes{value} = 1 unless defined $attributes{value};
|
||
$attributes{id} ||= $self->name_to_id($name . "_" . $attributes{value});
|
||
my $label = delete $attributes{label};
|
||
|
||
if ($attributes{checked}) {
|
||
... | ... | |
my ($self, $onclick, $value, @slurp) = @_;
|
||
my %attributes = _hashify(@slurp);
|
||
|
||
$attributes{id} ||= $self->name_to_id($attributes{name}) if $attributes{name};
|
||
_set_id_attribute(\%attributes, $attributes{name}) if $attributes{name};
|
||
$attributes{type} ||= 'button';
|
||
|
||
$onclick = 'if (!confirm("'. _J(delete($attributes{confirm})) .'")) return false; ' . $onclick if $attributes{confirm};
|
||
... | ... | |
my ($self, $name, $value, @slurp) = @_;
|
||
|
||
my %params = _hashify(@slurp);
|
||
my $id = $self->name_to_id($name) . _tag_id();
|
||
_set_id_attribute(\%params, $name);
|
||
my @onchange = $params{onchange} ? (onChange => delete $params{onchange}) : ();
|
||
my @class = $params{no_cal} || $params{readonly} ? () : (class => 'datepicker');
|
||
|
||
return $self->input_tag(
|
||
$name, blessed($value) ? $value->to_lxoffice : $value,
|
||
id => $id,
|
||
size => 11,
|
||
onblur => "check_right_date_format(this);",
|
||
%params,
|
||
... | ... | |
A module modeled a bit after Rails' ActionView helpers. Several small
|
||
functions that create HTML tags from various kinds of data sources.
|
||
|
||
The C<id> attribute is usually calculated automatically. This can be
|
||
overridden by either specifying an C<id> attribute or by setting
|
||
C<no_id> to trueish.
|
||
|
||
=head1 FUNCTIONS
|
||
|
||
=head2 LOW-LEVEL FUNCTIONS
|
Auch abrufbar als: Unified diff
L-Plugin und Presenter: Erzeugung "ID"-Attribute mittels "no_id => 1" unterdrückbar