Revision 0d3ea611
Von Moritz Bunkus vor etwa 17 Jahren hinzugefügt
SL/ReportGenerator.pm | ||
---|---|---|
3 | 3 |
use IO::Wrap; |
4 | 4 |
use List::Util qw(max); |
5 | 5 |
use Text::CSV_XS; |
6 |
use Text::Iconv; |
|
6 | 7 |
|
7 | 8 |
use SL::Form; |
8 | 9 |
|
... | ... | |
52 | 53 |
|
53 | 54 |
$self->set_options(@_) if (@_); |
54 | 55 |
|
56 |
$self->_init_escaped_strings_map(); |
|
57 |
|
|
55 | 58 |
return $self; |
56 | 59 |
} |
57 | 60 |
|
61 |
sub _init_escaped_strings_map { |
|
62 |
my $self = shift; |
|
63 |
|
|
64 |
$self->{escaped_strings_map} = |
|
65 |
('ä' => '?', |
|
66 |
'ö' => '?', |
|
67 |
'ü' => '?', |
|
68 |
'Ä' => '?', |
|
69 |
'Ö' => '?', |
|
70 |
'Ü' => '?', |
|
71 |
'ß' => '?', |
|
72 |
'>' => '>', |
|
73 |
'<' => '<', |
|
74 |
'"' => '"'); |
|
75 |
|
|
76 |
my $iconv = $main::locale->{iconv_iso8859}; |
|
77 |
|
|
78 |
if ($iconv) { |
|
79 |
map { $self->{escaped_strings_map}->{$_} = $iconv->convert($self->{escaped_strings_map}->{$_}) } keys %{ $self->{escaped_strings_map} }; |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
58 | 83 |
sub set_columns { |
59 | 84 |
my $self = shift; |
60 | 85 |
my %columns = @_; |
... | ... | |
492 | 517 |
} |
493 | 518 |
} |
494 | 519 |
|
520 |
sub unescape_string { |
|
521 |
my $self = shift; |
|
522 |
my $text = shift; |
|
523 |
|
|
524 |
foreach my $key (keys %{ $self->{escaped_strigns_map} }) { |
|
525 |
$text =~ s/\Q$key\E/$self->{escaped_strings_map}->{$key}/g; |
|
526 |
} |
|
527 |
|
|
528 |
$text =~ s/\Q&\E/&/g; |
|
529 |
|
|
530 |
return $text; |
|
531 |
} |
|
532 |
|
|
495 | 533 |
sub generate_csv_content { |
496 | 534 |
my $self = shift; |
497 | 535 |
|
... | ... | |
517 | 555 |
my @visible_columns = $self->get_visible_columns('CSV'); |
518 | 556 |
|
519 | 557 |
if ($opts->{headers}) { |
520 |
$csv->print($stdout, [ map { $self->{columns}->{$_}->{text} } @visible_columns ]);
|
|
558 |
$csv->print($stdout, [ map { $self->unescape_for_csv($self->{columns}->{$_}->{text}) } @visible_columns ]);
|
|
521 | 559 |
} |
522 | 560 |
|
523 | 561 |
foreach my $row_set (@{ $self->{data} }) { |
Auch abrufbar als: Unified diff
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.