Revision 9c63c160
Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt
SL/Template.pm | ||
---|---|---|
79 | 79 |
return 0; |
80 | 80 |
} |
81 | 81 |
|
82 |
sub _get_loop_variable_value { |
|
83 |
my $self = shift; |
|
84 |
my $var = shift; |
|
85 |
my @indices = @_; |
|
82 |
sub _get_loop_variable { |
|
83 |
my $self = shift; |
|
84 |
my $var = shift; |
|
85 |
my $get_array = shift; |
|
86 |
my @indices = @_; |
|
86 | 87 |
|
87 |
my $form = $self->{form}; |
|
88 |
my $value = $form->{$var}; |
|
88 |
my $form = $self->{form}; |
|
89 |
my $value; |
|
90 |
|
|
91 |
if (($get_array || @indices) && (ref $form->{TEMPLATE_ARRAYS} eq 'HASH') && (ref $form->{TEMPLATE_ARRAYS}->{$var} eq 'ARRAY')) { |
|
92 |
$value = $form->{TEMPLATE_ARRAYS}->{$var}; |
|
93 |
} else { |
|
94 |
$value = $form->{$var}; |
|
95 |
} |
|
89 | 96 |
|
90 | 97 |
for (my $i = 0; $i < scalar(@indices); $i++) { |
91 | 98 |
last unless (ref($value) eq "ARRAY"); |
... | ... | |
104 | 111 |
my ($tag_pos, $tag_len) = ($-[0], $+[0] - $-[0]); |
105 | 112 |
my ($var, @options) = split(/\s+/, $1); |
106 | 113 |
|
107 |
my $value = $self->_get_loop_variable_value($var, @indices);
|
|
114 |
my $value = $self->_get_loop_variable($var, 0, @indices);
|
|
108 | 115 |
$value = $self->format_string($value) unless (grep(/^NOESCAPE$/, @options)); |
109 | 116 |
|
110 | 117 |
substr($text, $tag_pos, $tag_len, $value); |
... | ... | |
160 | 167 |
|
161 | 168 |
my ($form, $new_contents) = ($self->{"form"}, ""); |
162 | 169 |
|
163 |
my $ary = $form->{$var}; |
|
164 |
for (my $i = 0; $i < scalar(@indices); $i++) { |
|
165 |
last unless (ref($ary) eq "ARRAY"); |
|
166 |
$ary = $ary->[$indices[$i]]; |
|
167 |
} |
|
170 |
my $ary = $self->_get_loop_variable($var, 1, @indices); |
|
168 | 171 |
|
169 | 172 |
my $sum = 0; |
170 | 173 |
my $current_page = 1; |
... | ... | |
786 | 789 |
|
787 | 790 |
my ($form, $new_contents) = ($self->{"form"}, ""); |
788 | 791 |
|
789 |
my $ary = $form->{$var}; |
|
790 |
for (my $i = 0; $i < scalar(@indices); $i++) { |
|
791 |
last unless (ref($ary) eq "ARRAY"); |
|
792 |
$ary = $ary->[$indices[$i]]; |
|
793 |
} |
|
792 |
my $ary = $self->_get_loop_variable($var, 1, @indices); |
|
794 | 793 |
|
795 | 794 |
for (my $i = 0; $i < scalar(@{$ary}); $i++) { |
796 | 795 |
$form->{"__first__"} = $i == 0; |
Auch abrufbar als: Unified diff
Die Funktionen in Template.pm zum Ersetzen von Schleifenvariablen so erweitert, dass die Schleifenarrays auch in $form->{TEMPLATE_ARRAYS} gesucht werden. Weiterhin die Druckmechanismen in IS.pm, OE.pm und DN.pm so angepasst, dass sie diese Unterebene benutzen, um die Positionswerte zu speichern. Dadurch wird verhindert, dass Elemente direkt in $form sowohl als Skalar als auch als Array benutzt werden (z.B. $form->{reqdate} = ... und push @{ $form->{reqdate} }, ...).