Revision 16fc2b20
Von Sven Schöling vor etwa 15 Jahren hinzugefügt
SL/Template.pm | ||
---|---|---|
269 | 269 |
my $sum = 0; |
270 | 270 |
my $current_page = 1; |
271 | 271 |
my ($current_line, $corrent_row) = (0, 1); |
272 |
my $description_array = $self->_get_loop_variable("description", 1) || [];
|
|
273 |
my $longdescription_array = $self->_get_loop_variable("longdescription", 1) || [];
|
|
274 |
my $linetotal_array = $self->_get_loop_variable("linetotal", 1) || [];
|
|
272 |
my $description_array = $self->_get_loop_variable("description", 1); |
|
273 |
my $longdescription_array = $self->_get_loop_variable("longdescription", 1); |
|
274 |
my $linetotal_array = $self->_get_loop_variable("linetotal", 1); |
|
275 | 275 |
|
276 | 276 |
$form->{TEMPLATE_ARRAYS}->{cumulatelinetotal} = []; |
277 | 277 |
|
278 |
# forech block hasn't given us an array. ignore |
|
279 |
return $new_contents unless ref $ary eq 'ARRAY'; |
|
280 |
|
|
278 | 281 |
for (my $i = 0; $i < scalar(@{$ary}); $i++) { |
282 |
# do magic markers |
|
279 | 283 |
$form->{"__first__"} = $i == 1; |
280 | 284 |
$form->{"__last__"} = ($i + 1) == scalar(@{$ary}); |
281 | 285 |
$form->{"__odd__"} = (($i + 1) % 2) == 1; |
282 | 286 |
$form->{"__counter__"} = $i + 1; |
283 | 287 |
|
284 |
if (scalar @{$description_array} == scalar @{$ary} && $self->{"chars_per_line"} != 0) { |
|
288 |
if ( ref $description_array eq 'ARRAY' |
|
289 |
&& scalar @{$description_array} == scalar @{$ary} |
|
290 |
&& $self->{"chars_per_line"} != 0) |
|
291 |
{ |
|
285 | 292 |
my $lines = int(length($description_array->[$i]) / $self->{"chars_per_line"}); |
286 | 293 |
my $lpp; |
287 | 294 |
|
288 | 295 |
$description_array->[$i] =~ s/(\\newline\s?)*$//; |
289 |
my $_description = $description_array->[$i]; |
|
290 |
while ($_description =~ /\\newline/) { |
|
291 |
$lines++; |
|
292 |
$_description =~ s/\\newline//; |
|
293 |
} |
|
296 |
$lines++ while ($description_array->[$i] =~ m/\\newline/g); |
|
294 | 297 |
$lines++; |
295 | 298 |
|
296 | 299 |
if ($current_page == 1) { |
... | ... | |
300 | 303 |
} |
301 | 304 |
|
302 | 305 |
# Yes we need a manual page break -- or the user has forced one |
303 |
if ((($current_line + $lines) > $lpp) || ($description_array->[$i] =~ /<pagebreak>/) || ($longdescription_array->[$i] =~ /<pagebreak>/)) { |
|
306 |
if ( (($current_line + $lines) > $lpp) |
|
307 |
|| ($description_array->[$i] =~ /<pagebreak>/) |
|
308 |
|| ( ref $longdescription_array eq 'ARRAY' |
|
309 |
&& $longdescription_array->[$i] =~ /<pagebreak>/)) { |
|
304 | 310 |
my $pb = $self->{"pagebreak_block"}; |
305 | 311 |
|
306 | 312 |
# replace the special variables <%sumcarriedforward%> |
... | ... | |
320 | 326 |
$current_line += $lines; |
321 | 327 |
} |
322 | 328 |
|
323 |
if ($i < scalar(@{$linetotal_array})) { |
|
329 |
if ( ref $linetotal_array eq 'ARRAY' |
|
330 |
&& $i < scalar(@{$linetotal_array})) { |
|
324 | 331 |
$sum += $form->parse_amount($self->{"myconfig"}, $linetotal_array->[$i]); |
325 | 332 |
} |
326 | 333 |
|
Auch abrufbar als: Unified diff
Pagebreak Algorithmus in Template sicherer gegen seltsame Eingaben gemacht.