"alle" E-Mail-Adressen per Anhaken als Empfänger hinzufügen können
[kivitendo-erp.git] / SL / Template / ShellCommand.pm
1 package SL::Template::ShellCommand;
2
3 use parent qw(SL::Template::LaTeX);
4
5 use strict;
6
7 use String::ShellQuote;
8
9 sub new {
10   my $type = shift;
11
12   return $type->SUPER::new(@_);
13 }
14
15 sub substitute_vars {
16   my ($self, $text, @indices) = @_;
17
18   my $form = $self->{"form"};
19
20   while ($text =~ /$self->{substitute_vars_re}/) {
21     my ($tag_pos, $tag_len) = ($-[0], $+[0] - $-[0]);
22     my ($var, @option_list) = split(/\s+/, $1);
23     my %options             = map { ($_ => 1) } @option_list;
24
25     my $value               = $self->_get_loop_variable($var, 0, @indices);
26     $value                  = $form->parse_amount({ numberformat => $::myconfig{output_numberformat} || $::myconfig{numberformat} }, $value) if $options{NOFORMAT};
27     $value                  = $self->format_string($value); # Don't allow NOESCAPE for arguments passed to shell commands.
28
29     substr($text, $tag_pos, $tag_len, $value);
30   }
31
32   return $text;
33 }
34
35 sub format_string {
36   my ($self, $variable) = @_;
37
38   return shell_quote($variable);
39 }
40
41 sub get_mime_type {
42   return "text/plain";
43 }
44
45 sub parse {
46   my ($self, $text) = @_;
47
48   return $self->parse_block($text);
49 }
50
51 1;