]> wagnertech.de Git - kivitendo-erp.git/blobdiff - SL/Form.pm
Parametername von "type" in "content_type" geändert.
[kivitendo-erp.git] / SL / Form.pm
index d7da58c160f312e8fbe35bd2d0bd3a47fbbb711b..8a12841e3b9443d4fcaa465011749f869f118b55 100644 (file)
@@ -376,53 +376,6 @@ sub unquote {
 
 }
 
-sub quote_html {
-  $main::lxdebug->enter_sub(2);
-
-  my ($self, $str) = @_;
-
-  my %replace =
-    ('order' => ['&', '"', '<', '>'],
-     '<'     => '&lt;',
-     '>'     => '&gt;',
-     '"'     => '&quot;',
-     '&'     => '&amp;',
-    );
-
-  map({ $str =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} });
-
-  $main::lxdebug->leave_sub(2);
-
-  return $str;
-}
-
-sub unquote_html {
-  $main::lxdebug->enter_sub(2);
-
-  my ($self, $str) = @_;
-
-  my %replace  =
-    ('&auml;'  => 'ä',
-     '&ouml;'  => 'ö',
-     '&uuml;'  => 'ü',
-     '&Auml;'  => 'Ä',
-     '&Ouml;'  => 'Ö',
-     '&Uuml;'  => 'Ü',
-     '&szlig;' => 'ß',
-     '&gt;'    => '>',
-     '&lt;'    => '<',
-     '&quot;'  => '"',
-    );
-
-  map { $str =~ s/\Q$_\E/$replace{$_}/g; } keys %replace;
-  $str =~ s/\&amp;/\&/g;
-
-  $main::lxdebug->leave_sub(2);
-
-  return $str;
-}
-
-
 sub hide_form {
   my $self = shift;
 
@@ -528,6 +481,48 @@ sub isblank {
   $main::lxdebug->leave_sub();
 }
 
+sub create_http_response {
+  $main::lxdebug->enter_sub();
+
+  my $self     = shift;
+  my %params   = @_;
+
+  my $cgi      = $main::cgi;
+  $cgi       ||= CGI->new('');
+
+  my $base_path;
+
+  if ($ENV{HTTP_X_FORWARDED_FOR}) {
+    $base_path =  $ENV{HTTP_REFERER};
+    $base_path =~ s|^.*?://.*?/|/|;
+  } else {
+    $base_path =  $ENV{REQUEST_URI};
+  }
+  $base_path =~ s|[^/]+$||;
+  $base_path =~ s|/$||;
+
+  my $session_cookie;
+  if (defined $main::auth) {
+    my $session_cookie_value   = $main::auth->get_session_id();
+    $session_cookie_value    ||= 'NO_SESSION';
+
+    $session_cookie = $cgi->cookie('-name'  => $main::auth->get_session_cookie_name(),
+                                   '-value' => $session_cookie_value,
+                                   '-path'  => $base_path);
+  }
+
+  my %cgi_params = ('-type' => $params{content_type});
+  $cgi_params{'-charset'} = $params{charset} if ($parmas{charset});
+
+  my $output = $cgi->header('-cookie' => $session_cookie,
+                            %cgi_params);
+
+  $main::lxdebug->leave_sub();
+
+  return $output;
+}
+
+
 sub header {
   $main::lxdebug->enter_sub();
 
@@ -538,9 +533,6 @@ sub header {
     return;
   }
 
-  my $cgi   = $main::cgi;
-  $cgi    ||= CGI->new('');
-
   my ($stylesheet, $favicon);
 
   if ($ENV{HTTP_USER_AGENT}) {
@@ -602,30 +594,8 @@ sub header {
       $ajax .= $item->show_javascript();
     }
 
-    my $base_path;
-
-    if ($ENV{HTTP_X_FORWARDED_FOR}) {
-      $base_path =  $ENV{HTTP_REFERER};
-      $base_path =~ s|^.*?://.*?/|/|;
-    } else {
-      $base_path =  $ENV{REQUEST_URI};
-    }
-    $base_path =~ s|[^/]+$||;
-    $base_path =~ s|/$||;
-
-    my $session_cookie;
-    if (defined $main::auth) {
-      my $session_cookie_value   = $main::auth->get_session_id();
-      $session_cookie_value    ||= 'NO_SESSION';
-
-      $session_cookie = $cgi->cookie('-name'  => $main::auth->get_session_cookie_name(),
-                                     '-value' => $session_cookie_value,
-                                     '-path'  => $base_path);
-    }
-
-    print $cgi->header('-type'    => 'text/html',
-                       '-charset' => $db_charset,
-                       '-cookie'  => $session_cookie);
+    print $self->create_http_response('content_type' => 'text/html',
+                                      'charset'      => $db_charset,);
     print qq|${doctype}<html>
 <head>
   <title>$self->{titlebar}</title>
@@ -1279,7 +1249,7 @@ sub get_formname_translation {
 sub generate_attachment_filename {
   my ($self) = @_;
 
-  my $attachment_filename = $self->unquote_html($self->get_formname_translation());
+  my $attachment_filename = $main::locale->unquote_special_chars('HTML', $self->get_formname_translation());
   my $prefix =
       (first { $self->{type} eq $_ } qw(invoice credit_note)) ? 'inv'
     : ($self->{type} =~ /_quotation$/)                        ? 'quo'
@@ -1293,10 +1263,8 @@ sub generate_attachment_filename {
                                : $self->{format} =~ /opendocument/i ? ".odt"
                                : $self->{format} =~ /html/i         ? ".html"
                                :                                      "");
+    $attachment_filename =  lc $main::locale->quote_special_chars('filenames', $attachment_filename);
     $attachment_filename =~ s/ /_/g;
-    my %umlaute = ( "ä" => "ae", "ö" => "oe", "ü" => "ue", 
-                    "Ä" => "Ae", "Ö" => "Oe", "Ü" => "Ue", "ß" => "ss");
-    map { $attachment_filename =~ s/$_/$umlaute{$_}/g } keys %umlaute;
   } else {
     $attachment_filename = "";
   }