From: Moritz Bunkus Date: Thu, 15 Nov 2007 13:32:48 +0000 (+0000) Subject: Report-Generator: Spaltenüberschriften in HTML- und PDF-Ausgaben nicht erneut HTML... X-Git-Tag: release-2.6.0beta1~408 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=0d3ea6111fe9f64330e5d75be32fe0612a896333;p=kivitendo-erp.git Report-Generator: Spaltenüberschriften in HTML- und PDF-Ausgaben nicht erneut HTML-Escapen, weil die Übersetzungen meist bereits HTML-encodet sind. Dafür aber die HTML-encodierten Zeichen zurückkonvertieren. --- diff --git a/SL/Locale.pm b/SL/Locale.pm index 5454e74c5..f797ed6e6 100644 --- a/SL/Locale.pm +++ b/SL/Locale.pm @@ -70,10 +70,11 @@ sub new { $self->{charset} = Common::DEFAULT_CHARSET; } - my $db_charset = $main::dbcharset; - $db_charset ||= Common::DEFAULT_CHARSET; - $self->{iconv} = Text::Iconv->new($self->{charset}, $db_charset); - $self->{iconv_english} = Text::Iconv->new("ASCII", $db_charset); + my $db_charset = $main::dbcharset || Common::DEFAULT_CHARSET; + + $self->{iconv} = Text::Iconv->new($self->{charset}, $db_charset); + $self->{iconv_english} = Text::Iconv->new('ASCII', $db_charset); + $self->{iconv_iso8859} = Text::Iconv->new('ISO-8859-15', $db_charset); } $self->{NLS_file} = $NLS_file; diff --git a/SL/ReportGenerator.pm b/SL/ReportGenerator.pm index 67d69a9be..7421a78c1 100644 --- a/SL/ReportGenerator.pm +++ b/SL/ReportGenerator.pm @@ -3,6 +3,7 @@ package SL::ReportGenerator; use IO::Wrap; use List::Util qw(max); use Text::CSV_XS; +use Text::Iconv; use SL::Form; @@ -52,9 +53,33 @@ sub new { $self->set_options(@_) if (@_); + $self->_init_escaped_strings_map(); + return $self; } +sub _init_escaped_strings_map { + my $self = shift; + + $self->{escaped_strings_map} = + ('ä' => 'ä', + 'ö' => 'ö', + 'ü' => 'ü', + 'Ä' => 'Ä', + 'Ö' => 'Ö', + 'Ü' => 'Ü', + 'ß' => 'ß', + '>' => '>', + '<' => '<', + '"' => '"'); + + my $iconv = $main::locale->{iconv_iso8859}; + + if ($iconv) { + map { $self->{escaped_strings_map}->{$_} = $iconv->convert($self->{escaped_strings_map}->{$_}) } keys %{ $self->{escaped_strings_map} }; + } +} + sub set_columns { my $self = shift; my %columns = @_; @@ -492,6 +517,19 @@ END } } +sub unescape_string { + my $self = shift; + my $text = shift; + + foreach my $key (keys %{ $self->{escaped_strigns_map} }) { + $text =~ s/\Q$key\E/$self->{escaped_strings_map}->{$key}/g; + } + + $text =~ s/\Q&\E/&/g; + + return $text; +} + sub generate_csv_content { my $self = shift; @@ -517,7 +555,7 @@ sub generate_csv_content { my @visible_columns = $self->get_visible_columns('CSV'); if ($opts->{headers}) { - $csv->print($stdout, [ map { $self->{columns}->{$_}->{text} } @visible_columns ]); + $csv->print($stdout, [ map { $self->unescape_for_csv($self->{columns}->{$_}->{text}) } @visible_columns ]); } foreach my $row_set (@{ $self->{data} }) { diff --git a/templates/webpages/report_generator/html_report_de.html b/templates/webpages/report_generator/html_report_de.html index de330cfc4..6e1601ef8 100644 --- a/templates/webpages/report_generator/html_report_de.html +++ b/templates/webpages/report_generator/html_report_de.html @@ -40,7 +40,7 @@ [% FOREACH col = COLUMN_HEADERS %] - + [% END %] diff --git a/templates/webpages/report_generator/html_report_master.html b/templates/webpages/report_generator/html_report_master.html index d76788bbb..f414eb913 100644 --- a/templates/webpages/report_generator/html_report_master.html +++ b/templates/webpages/report_generator/html_report_master.html @@ -40,7 +40,7 @@
[% IF col.link %][% END %][% HTML.escape(col.text) %][% IF col.link %][% IF col.show_sort_indicator %][% END %][% ELSE %][% IF col.show_sort_indicator %][% END %][% END %][% IF col.link %][% END %][% col.text %][% IF col.link %][% IF col.show_sort_indicator %][% END %][% ELSE %][% IF col.show_sort_indicator %][% END %][% END %]
[% FOREACH col = COLUMN_HEADERS %] - + [% END %] diff --git a/templates/webpages/report_generator/pdf_report_de.html b/templates/webpages/report_generator/pdf_report_de.html index dac6aa3f9..d9843bf91 100644 --- a/templates/webpages/report_generator/pdf_report_de.html +++ b/templates/webpages/report_generator/pdf_report_de.html @@ -11,7 +11,7 @@
[% IF col.link %][% END %][% HTML.escape(col.text) %][% IF col.link %][% IF col.show_sort_indicator %][% END %][% ELSE %][% IF col.show_sort_indicator %][% END %][% END %][% IF col.link %][% END %][% col.text %][% IF col.link %][% IF col.show_sort_indicator %][% END %][% ELSE %][% IF col.show_sort_indicator %][% END %][% END %]
[%- FOREACH col = COLUMN_HEADERS %] - + [%- END %] diff --git a/templates/webpages/report_generator/pdf_report_master.html b/templates/webpages/report_generator/pdf_report_master.html index dac6aa3f9..d9843bf91 100644 --- a/templates/webpages/report_generator/pdf_report_master.html +++ b/templates/webpages/report_generator/pdf_report_master.html @@ -11,7 +11,7 @@
[% IF col.link %][% END %][% HTML.escape(col.text) %][% IF col.link %][% END %][% IF col.link %][% END %][% col.text %][% IF col.link %][% END %]
[%- FOREACH col = COLUMN_HEADERS %] - + [%- END %]
[% IF col.link %][% END %][% HTML.escape(col.text) %][% IF col.link %][% END %][% IF col.link %][% END %][% col.text %][% IF col.link %][% END %]