Sonderzeichen in LaTeX ersetzen.
[kivitendo-erp.git] / SL / Template.pm
index d30b928..18b44d0 100644 (file)
@@ -91,7 +91,7 @@ sub format_string {
                  '<pagebreak>',
                  '&', quotemeta("\n"),
                  '"', '\$', '%', '_', '#', quotemeta('^'),
-                 '{', '}',  '<', '>', '£', "\r"
+                 '{', '}',  '<', '>', '£', "\r", '±',
                  ],
      quotemeta("\\") => '\\textbackslash ',
      '<pagebreak>'   => '',
@@ -107,6 +107,7 @@ sub format_string {
      '>'             => '$>$',
      '£'             => '\pounds ',
      "\r"            => "",
+     '±'             => '$\pm$',
      quotemeta('^')  => '\^\\',
      quotemeta("\n") => '\newline '
      );
@@ -196,7 +197,7 @@ sub parse_foreach {
         # replace the special variables <%sumcarriedforward%>
         # and <%lastpage%>
 
-        my $psum = $form->format_amount($myconfig, $sum, 2);
+        my $psum = $form->format_amount($self->{"myconfig"}, $sum, 2);
         $pb =~ s/<%sumcarriedforward%>/$psum/g;
         $pb =~ s/<%lastpage%>/$current_page/g;
 
@@ -210,9 +211,12 @@ sub parse_foreach {
       $current_line += $lines;
     }
     if ($i < scalar(@{$form->{"linetotal"}})) {
-      $sum += $form->parse_amount($myconfig, $form->{"linetotal"}->[$i]);
+      $sum += $form->parse_amount($self->{"myconfig"},
+                                  $form->{"linetotal"}->[$i]);
     }
-
+    
+    $form->{"cumulatelinetotal"}[$i] = $form->format_amount($self->{"myconfig"}, $sum, 2);
+    
     my $new_text = $self->parse_block($text, (@indices, $i));
     return undef unless (defined($new_text));
     $new_contents .= $start_tag . $new_text . $end_tag;
@@ -1258,4 +1262,64 @@ sub uses_temp_file {
   return 1;
 }
 
+
+##########################################################
+####
+#### XMLTemplate
+####
+##########################################################
+
+package XMLTemplate; 
+
+use vars qw(@ISA);
+
+@ISA = qw(HTMLTemplate);
+
+sub new {
+  #evtl auskommentieren
+  my $type = shift;
+
+  return $type->SUPER::new(@_);
+}
+
+sub format_string {
+  my ($self, $variable) = @_;
+  my $form = $self->{"form"};
+
+  my %replace =
+    ('order' => ['<', '>', quotemeta("\n")],
+     '<'             => '&lt;',
+     '>'             => '&gt;',
+     quotemeta("\n") => '<br>',
+     );
+
+  map({ $variable =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} });
+
+  # Allow no markup to be converted into the output format
+  my @markup_replace = ('b', 'i', 's', 'u', 'sub', 'sup');
+
+  foreach my $key (@markup_replace) {
+    $variable =~ s/\&lt;(\/?)${key}\&gt;//g;
+  }
+
+  return $variable;
+}
+
+sub get_mime_type() {
+  my ($self) = @_;
+
+  if ($self->{"form"}->{"format"} =~ /elsterwinston/i) {
+    return "application/xml ";
+  } elsif ($self->{"form"}->{"format"} =~ /elstertaxbird/i) {
+    return "application/x-taxbird";
+  } else {
+    return "text";
+  }
+}
+
+sub uses_temp_file {
+  # tempfile needet for XML Output
+  return 1;
+}
+
 1;