projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Spool-Dateien: Handling vom wiederholten Spoolen desselben Beleges gefixt
[kivitendo-erp.git]
/
SL
/
Template
/
Simple.pm
diff --git
a/SL/Template/Simple.pm
b/SL/Template/Simple.pm
index
d7a7c35
..
d29ec8f
100644
(file)
--- a/
SL/Template/Simple.pm
+++ b/
SL/Template/Simple.pm
@@
-10,6
+10,8
@@
package SL::Template::Simple;
use strict;
use strict;
+use Scalar::Util qw(blessed);
+
# Parameters:
# 1. The template's file name
# 2. A reference to the Form object
# Parameters:
# 1. The template's file name
# 2. A reference to the Form object
@@
-83,13
+85,13
@@
sub uses_temp_file {
}
sub _get_loop_variable {
}
sub _get_loop_variable {
- my $self = shift;
- my $var = shift;
- my $get_array = shift;
- my @indices = @_;
-
+ my ($self, $var, $get_array, @indices) = @_;
my $form = $self->{form};
my $form = $self->{form};
- my $value;
+ my ($value, @methods);
+
+ if ($var =~ m/\./) {
+ ($var, @methods) = split m/\./, $var;
+ }
if (($get_array || @indices) && (ref $form->{TEMPLATE_ARRAYS} eq 'HASH') && (ref $form->{TEMPLATE_ARRAYS}->{$var} eq 'ARRAY')) {
$value = $form->{TEMPLATE_ARRAYS}->{$var};
if (($get_array || @indices) && (ref $form->{TEMPLATE_ARRAYS} eq 'HASH') && (ref $form->{TEMPLATE_ARRAYS}->{$var} eq 'ARRAY')) {
$value = $form->{TEMPLATE_ARRAYS}->{$var};
@@
-102,6
+104,17
@@
sub _get_loop_variable {
$value = $value->[$indices[$i]];
}
$value = $value->[$indices[$i]];
}
+ for my $part (@methods) {
+ if (ref($value) =~ m/^(?:Form|HASH)$/) {
+ $value = $value->{$part};
+ } elsif (blessed($value) && $value->can($part)) {
+ $value = $value->$part;
+ } else {
+ $value = '';
+ last;
+ }
+ }
+
return $value;
}
return $value;
}
@@
-112,10
+125,12
@@
sub substitute_vars {
while ($text =~ /$self->{substitute_vars_re}/) {
my ($tag_pos, $tag_len) = ($-[0], $+[0] - $-[0]);
while ($text =~ /$self->{substitute_vars_re}/) {
my ($tag_pos, $tag_len) = ($-[0], $+[0] - $-[0]);
- my ($var, @options) = split(/\s+/, $1);
+ my ($var, @option_list) = split(/\s+/, $1);
+ my %options = map { ($_ => 1) } @option_list;
my $value = $self->_get_loop_variable($var, 0, @indices);
my $value = $self->_get_loop_variable($var, 0, @indices);
- $value = $self->format_string($value) unless (grep(/^NOESCAPE$/, @options));
+ $value = $form->parse_amount({ numberformat => $::myconfig{output_numberformat} || $::myconfig{numberformat} }, $value) if $options{NOFORMAT};
+ $value = $self->format_string($value) unless $options{NOESCAPE};
substr($text, $tag_pos, $tag_len, $value);
}
substr($text, $tag_pos, $tag_len, $value);
}