Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0d3ea611

Von Moritz Bunkus vor fast 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
70 70
      $self->{charset} = Common::DEFAULT_CHARSET;
71 71
    }
72 72

  
73
    my $db_charset = $main::dbcharset;
74
    $db_charset ||= Common::DEFAULT_CHARSET;
75
    $self->{iconv} = Text::Iconv->new($self->{charset}, $db_charset);
76
    $self->{iconv_english} = Text::Iconv->new("ASCII", $db_charset);
73
    my $db_charset         = $main::dbcharset || Common::DEFAULT_CHARSET;
74

  
75
    $self->{iconv}         = Text::Iconv->new($self->{charset}, $db_charset);
76
    $self->{iconv_english} = Text::Iconv->new('ASCII',          $db_charset);
77
    $self->{iconv_iso8859} = Text::Iconv->new('ISO-8859-15',    $db_charset);
77 78
  }
78 79

  
79 80
  $self->{NLS_file} = $NLS_file;
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
     '&lt;'    => '<',
74
     '&quot;'  => '"');
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&amp;\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} }) {
templates/webpages/report_generator/html_report_de.html
40 40
  <table width="100%">
41 41
   <tr>
42 42
    [% FOREACH col = COLUMN_HEADERS %]
43
     <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>
43
     <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>
44 44
    [% END %]
45 45
   </tr>
46 46

  
templates/webpages/report_generator/html_report_master.html
40 40
  <table width="100%">
41 41
   <tr>
42 42
    [% FOREACH col = COLUMN_HEADERS %]
43
     <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>
43
     <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>
44 44
    [% END %]
45 45
   </tr>
46 46

  
templates/webpages/report_generator/pdf_report_de.html
11 11
   <table width="100%">
12 12
    <tr>
13 13
     [%- FOREACH col = COLUMN_HEADERS %]
14
     <th>[% IF col.link %]<a href="[% col.link %]">[% END %][% HTML.escape(col.text) %][% IF col.link %]</a>[% END %]</th>
14
     <th>[% IF col.link %]<a href="[% col.link %]">[% END %][% col.text %][% IF col.link %]</a>[% END %]</th>
15 15
     [%- END %]
16 16
    </tr>
17 17

  
templates/webpages/report_generator/pdf_report_master.html
11 11
   <table width="100%">
12 12
    <tr>
13 13
     [%- FOREACH col = COLUMN_HEADERS %]
14
     <th>[% IF col.link %]<a href="[% col.link %]">[% END %][% HTML.escape(col.text) %][% IF col.link %]</a>[% END %]</th>
14
     <th>[% IF col.link %]<a href="[% col.link %]">[% END %][% col.text %][% IF col.link %]</a>[% END %]</th>
15 15
     [%- END %]
16 16
    </tr>
17 17

  

Auch abrufbar als: Unified diff