Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0d3ea611

Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt

  • ID 0d3ea6111fe9f64330e5d75be32fe0612a896333
  • Vorgänger cdfebb50
  • Nachfolger c83d63ed

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.

Unterschiede anzeigen:

SL/Locale.pm
$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;
SL/ReportGenerator.pm
use IO::Wrap;
use List::Util qw(max);
use Text::CSV_XS;
use Text::Iconv;
use SL::Form;
......
$self->set_options(@_) if (@_);
$self->_init_escaped_strings_map();
return $self;
}
sub _init_escaped_strings_map {
my $self = shift;
$self->{escaped_strings_map} =
('ä' => '?',
'ö' => '?',
'ü' => '?',
'Ä' => '?',
'Ö' => '?',
'Ü' => '?',
'ß' => '?',
'>' => '>',
'&lt;' => '<',
'&quot;' => '"');
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 = @_;
......
}
}
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&amp;\E/&/g;
return $text;
}
sub generate_csv_content {
my $self = shift;
......
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} }) {
templates/webpages/report_generator/html_report_de.html
<table width="100%">
<tr>
[% FOREACH col = COLUMN_HEADERS %]
<th class="listheading">[% IF col.link %]<a href="[% col.link %]">[% END %][% HTML.escape(col.text) %][% IF col.link %][% IF col.show_sort_indicator %]<img border="0" src="image/[% IF col.sort_indicator_direction %]down[% ELSE %]up[% END %].png">[% END %]</a>[% ELSE %][% IF col.show_sort_indicator %]<img src="image/[% IF col.sort_indicator_direction %]down[% ELSE %]up[% END %].png">[% END %][% END %]</th>
<th class="listheading">[% IF col.link %]<a href="[% col.link %]">[% END %][% col.text %][% IF col.link %][% IF col.show_sort_indicator %]<img border="0" src="image/[% IF col.sort_indicator_direction %]down[% ELSE %]up[% END %].png">[% END %]</a>[% ELSE %][% IF col.show_sort_indicator %]<img src="image/[% IF col.sort_indicator_direction %]down[% ELSE %]up[% END %].png">[% END %][% END %]</th>
[% END %]
</tr>
templates/webpages/report_generator/html_report_master.html
<table width="100%">
<tr>
[% FOREACH col = COLUMN_HEADERS %]
<th class="listheading">[% IF col.link %]<a href="[% col.link %]">[% END %][% HTML.escape(col.text) %][% IF col.link %][% IF col.show_sort_indicator %]<img border="0" src="image/[% IF col.sort_indicator_direction %]down[% ELSE %]up[% END %].png">[% END %]</a>[% ELSE %][% IF col.show_sort_indicator %]<img src="image/[% IF col.sort_indicator_direction %]down[% ELSE %]up[% END %].png">[% END %][% END %]</th>
<th class="listheading">[% IF col.link %]<a href="[% col.link %]">[% END %][% col.text %][% IF col.link %][% IF col.show_sort_indicator %]<img border="0" src="image/[% IF col.sort_indicator_direction %]down[% ELSE %]up[% END %].png">[% END %]</a>[% ELSE %][% IF col.show_sort_indicator %]<img src="image/[% IF col.sort_indicator_direction %]down[% ELSE %]up[% END %].png">[% END %][% END %]</th>
[% END %]
</tr>
templates/webpages/report_generator/pdf_report_de.html
<table width="100%">
<tr>
[%- FOREACH col = COLUMN_HEADERS %]
<th>[% IF col.link %]<a href="[% col.link %]">[% END %][% HTML.escape(col.text) %][% IF col.link %]</a>[% END %]</th>
<th>[% IF col.link %]<a href="[% col.link %]">[% END %][% col.text %][% IF col.link %]</a>[% END %]</th>
[%- END %]
</tr>
templates/webpages/report_generator/pdf_report_master.html
<table width="100%">
<tr>
[%- FOREACH col = COLUMN_HEADERS %]
<th>[% IF col.link %]<a href="[% col.link %]">[% END %][% HTML.escape(col.text) %][% IF col.link %]</a>[% END %]</th>
<th>[% IF col.link %]<a href="[% col.link %]">[% END %][% col.text %][% IF col.link %]</a>[% END %]</th>
[%- END %]
</tr>

Auch abrufbar als: Unified diff