projects
/
kivitendo-erp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
134120b
)
Pagebreak Algorithmus in Template sicherer gegen seltsame Eingaben gemacht.
author
Sven Schöling
<s.schoeling@linet-services.de>
Wed, 28 Oct 2009 16:44:19 +0000
(17:44 +0100)
committer
Sven Schöling
<s.schoeling@linet-services.de>
Wed, 28 Oct 2009 16:44:19 +0000
(17:44 +0100)
SL/Template.pm
patch
|
blob
|
history
diff --git
a/SL/Template.pm
b/SL/Template.pm
index
5831270
..
3556dc4
100644
(file)
--- a/
SL/Template.pm
+++ b/
SL/Template.pm
@@
-269,28
+269,31
@@
sub parse_foreach {
my $sum = 0;
my $current_page = 1;
my ($current_line, $corrent_row) = (0, 1);
my $sum = 0;
my $current_page = 1;
my ($current_line, $corrent_row) = (0, 1);
- my $description_array = $self->_get_loop_variable("description", 1)
|| []
;
- my $longdescription_array = $self->_get_loop_variable("longdescription", 1)
|| []
;
- my $linetotal_array = $self->_get_loop_variable("linetotal", 1)
|| []
;
+ my $description_array = $self->_get_loop_variable("description", 1);
+ my $longdescription_array = $self->_get_loop_variable("longdescription", 1);
+ my $linetotal_array = $self->_get_loop_variable("linetotal", 1);
$form->{TEMPLATE_ARRAYS}->{cumulatelinetotal} = [];
$form->{TEMPLATE_ARRAYS}->{cumulatelinetotal} = [];
+ # forech block hasn't given us an array. ignore
+ return $new_contents unless ref $ary eq 'ARRAY';
+
for (my $i = 0; $i < scalar(@{$ary}); $i++) {
for (my $i = 0; $i < scalar(@{$ary}); $i++) {
+ # do magic markers
$form->{"__first__"} = $i == 1;
$form->{"__last__"} = ($i + 1) == scalar(@{$ary});
$form->{"__odd__"} = (($i + 1) % 2) == 1;
$form->{"__counter__"} = $i + 1;
$form->{"__first__"} = $i == 1;
$form->{"__last__"} = ($i + 1) == scalar(@{$ary});
$form->{"__odd__"} = (($i + 1) % 2) == 1;
$form->{"__counter__"} = $i + 1;
- if (scalar @{$description_array} == scalar @{$ary} && $self->{"chars_per_line"} != 0) {
+ if ( ref $description_array eq 'ARRAY'
+ && scalar @{$description_array} == scalar @{$ary}
+ && $self->{"chars_per_line"} != 0)
+ {
my $lines = int(length($description_array->[$i]) / $self->{"chars_per_line"});
my $lpp;
$description_array->[$i] =~ s/(\\newline\s?)*$//;
my $lines = int(length($description_array->[$i]) / $self->{"chars_per_line"});
my $lpp;
$description_array->[$i] =~ s/(\\newline\s?)*$//;
- my $_description = $description_array->[$i];
- while ($_description =~ /\\newline/) {
- $lines++;
- $_description =~ s/\\newline//;
- }
+ $lines++ while ($description_array->[$i] =~ m/\\newline/g);
$lines++;
if ($current_page == 1) {
$lines++;
if ($current_page == 1) {
@@
-300,7
+303,10
@@
sub parse_foreach {
}
# Yes we need a manual page break -- or the user has forced one
}
# Yes we need a manual page break -- or the user has forced one
- if ((($current_line + $lines) > $lpp) || ($description_array->[$i] =~ /<pagebreak>/) || ($longdescription_array->[$i] =~ /<pagebreak>/)) {
+ if ( (($current_line + $lines) > $lpp)
+ || ($description_array->[$i] =~ /<pagebreak>/)
+ || ( ref $longdescription_array eq 'ARRAY'
+ && $longdescription_array->[$i] =~ /<pagebreak>/)) {
my $pb = $self->{"pagebreak_block"};
# replace the special variables <%sumcarriedforward%>
my $pb = $self->{"pagebreak_block"};
# replace the special variables <%sumcarriedforward%>
@@
-320,7
+326,8
@@
sub parse_foreach {
$current_line += $lines;
}
$current_line += $lines;
}
- if ($i < scalar(@{$linetotal_array})) {
+ if ( ref $linetotal_array eq 'ARRAY'
+ && $i < scalar(@{$linetotal_array})) {
$sum += $form->parse_amount($self->{"myconfig"}, $linetotal_array->[$i]);
}
$sum += $form->parse_amount($self->{"myconfig"}, $linetotal_array->[$i]);
}