line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# HTML::EP - A Perl based HTML extension. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright (C) 1998 Jochen Wiedmann |
7
|
|
|
|
|
|
|
# Am Eisteich 9 |
8
|
|
|
|
|
|
|
# 72555 Metzingen |
9
|
|
|
|
|
|
|
# Germany |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Phone: +49 7123 14887 |
12
|
|
|
|
|
|
|
# Email: joe@ispsoft.de |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# All rights reserved. |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# You may distribute this module under the terms of either |
17
|
|
|
|
|
|
|
# the GNU General Public License or the Artistic License, as |
18
|
|
|
|
|
|
|
# specified in the Perl README file. |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
############################################################################ |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
require 5.004; |
23
|
5
|
|
|
5
|
|
2885
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
214
|
|
24
|
|
|
|
|
|
|
|
25
|
5
|
|
|
5
|
|
783
|
use HTML::EP (); |
|
5
|
|
|
|
|
42
|
|
|
5
|
|
|
|
|
10433
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
package HTML::EP::Locale; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
@HTML::EP::Locale::ISA = qw(HTML::EP); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub init ($$) { |
34
|
15
|
|
|
15
|
0
|
39
|
my $self = shift; my $attr = shift; |
|
15
|
|
|
|
|
22
|
|
35
|
15
|
50
|
|
|
|
40
|
return $self->{'_ep_language'} if $self->{'_ep_language'}; |
36
|
15
|
|
|
|
|
62
|
$self->SUPER::init(); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Try to guess a language. First try to guess what languages are |
39
|
|
|
|
|
|
|
# offered. |
40
|
15
|
|
|
|
|
17
|
my @offered; |
41
|
15
|
100
|
|
|
|
41
|
if ($attr->{'accept-language'}) { |
42
|
11
|
|
|
|
|
49
|
@offered = split(/,/, $attr->{'accept-language'}); |
43
|
|
|
|
|
|
|
} |
44
|
15
|
100
|
|
|
|
53
|
@offered = ($self->{'_ep_config'}->{'default_language'}, "en") |
45
|
|
|
|
|
|
|
unless @offered; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Next, try to guess what the user wants. First let's see, if there |
48
|
|
|
|
|
|
|
# is a CGI variable 'language'. |
49
|
15
|
|
|
|
|
24
|
my $get; |
50
|
15
|
50
|
|
|
|
58
|
if (my $lang = $self->{'cgi'}->param('language')) { |
51
|
0
|
|
|
|
|
0
|
foreach my $l (@offered) { |
52
|
0
|
0
|
|
|
|
0
|
return ($self->{'_ep_language'} = $l) if $l eq $lang; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
# If there's no such CGI variable, look at the value of |
56
|
|
|
|
|
|
|
# $ENV{'HTTP_ACCEPT_LANGUAGE'}. |
57
|
15
|
50
|
|
|
|
290
|
if (exists($ENV{'HTTP_ACCEPT_LANGUAGE'})) { |
58
|
0
|
|
0
|
|
|
0
|
foreach my $lang (split(/\s*,\s*/, |
59
|
|
|
|
|
|
|
($ENV{'HTTP_ACCEPT_LANGUAGE'} || ''))) { |
60
|
0
|
|
|
|
|
0
|
foreach my $l (@offered) { |
61
|
0
|
0
|
|
|
|
0
|
return ($self->{'_ep_language'} = $l) if $l eq $lang; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
# If anything else fails, choose a default language |
66
|
15
|
|
|
|
|
66
|
return $self->{'_ep_language'} = $offered[0]; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _ep_language { |
71
|
12
|
|
|
12
|
|
19
|
my($self, $attr, $tokens) = @_; |
72
|
12
|
|
|
|
|
22
|
my $language = $self->{'_ep_language'}; |
73
|
12
|
|
|
|
|
16
|
my $debug = $self->{'debug'}; |
74
|
12
|
100
|
|
|
|
40
|
return exists $attr->{$language} ? $attr->{$language} : '' |
|
|
100
|
|
|
|
|
|
75
|
|
|
|
|
|
|
unless exists $attr->{'language'}; |
76
|
|
|
|
|
|
|
|
77
|
9
|
|
|
|
|
13
|
my $level = 0; |
78
|
9
|
|
|
|
|
15
|
my $state = $attr->{'language'} eq $language; |
79
|
9
|
|
|
|
|
13
|
my $state_done = $state; |
80
|
9
|
100
|
|
|
|
36
|
my $start = $tokens->First() if $state; |
81
|
9
|
|
|
|
|
10
|
my $last; |
82
|
9
|
|
|
|
|
23
|
while (defined(my $token = $tokens->Token())) { |
83
|
24
|
100
|
|
|
|
95
|
if ($token->{'type'} eq 'S') { |
|
|
100
|
|
|
|
|
|
84
|
3
|
50
|
|
|
|
9
|
if ($token->{'tag'} eq 'ep-language') { |
85
|
3
|
100
|
|
|
|
10
|
if ($state) { |
|
|
50
|
|
|
|
|
|
86
|
1
|
|
|
|
|
4
|
$last = $tokens->First()-1; |
87
|
1
|
|
|
|
|
5
|
$state = 0; |
88
|
|
|
|
|
|
|
} elsif (!$state_done) { |
89
|
2
|
|
|
|
|
10
|
my $at = $self->ParseAttr($token->{'attr'}); |
90
|
2
|
100
|
|
|
|
11
|
if ($state = ($at->{'language'} eq $language)) { |
91
|
1
|
|
|
|
|
33
|
$start = $tokens->First(); |
92
|
1
|
|
|
|
|
5
|
$state_done = 1; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} elsif ($token->{'type'} eq 'E') { |
97
|
9
|
50
|
|
|
|
21
|
if ($token->{'tag'} eq 'ep-language') { |
98
|
9
|
100
|
|
|
|
29
|
return '' unless $state_done; |
99
|
4
|
100
|
|
|
|
13
|
$last = $tokens->First()-1 if $state; |
100
|
4
|
|
|
|
|
15
|
return $self->TokenMarch($tokens->Clone($start, $last)); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
0
|
|
|
|
|
0
|
die "ep-language without /ep-language"; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _format_DM { |
109
|
4
|
|
|
4
|
|
7
|
my $self = shift; my $str = shift; |
|
4
|
|
|
|
|
5
|
|
110
|
4
|
|
|
|
|
54
|
$str = sprintf("%.2f DM", $str); |
111
|
4
|
|
|
|
|
57
|
while ($str =~ s/(\d)(\d\d\d[\.\s])/$1 $2/) { |
112
|
|
|
|
|
|
|
} |
113
|
4
|
|
|
|
|
15
|
$str =~ s/\./,/; |
114
|
4
|
|
|
|
|
13
|
$str; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub _format_Dollar { |
118
|
1
|
|
|
1
|
|
2
|
my $self = shift; my $str = shift; |
|
1
|
|
|
|
|
2
|
|
119
|
1
|
|
|
|
|
6
|
$str = sprintf("%.2f \$", $str); |
120
|
1
|
|
|
|
|
11
|
while ($str =~ s/(\d)(\d\d\d[,\s])/$1 $2/) { |
121
|
|
|
|
|
|
|
} |
122
|
1
|
|
|
|
|
4
|
$str; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub _format_TIME { |
127
|
2
|
|
|
2
|
|
3
|
my $self = shift; my $date = shift; |
|
2
|
|
|
|
|
5
|
|
128
|
2
|
100
|
|
|
|
8
|
if ($self->{'_ep_language'} eq 'de') { |
129
|
|
|
|
|
|
|
# Sun, 7 Feb 1999 18:17:57 +0100 |
130
|
1
|
50
|
|
|
|
10
|
if ($date =~ m{(\S+),\s+ |
131
|
|
|
|
|
|
|
(\d+)\s+ |
132
|
|
|
|
|
|
|
(\S+)\s+ |
133
|
|
|
|
|
|
|
(\d+)\s+ |
134
|
|
|
|
|
|
|
(\d+\:\d+\:\d+)\s+ |
135
|
|
|
|
|
|
|
(\+\d+)}x) { |
136
|
1
|
|
|
|
|
10
|
my %wdays = ('sun' => 0, 'mon' => 1, 'tue' => 2, |
137
|
|
|
|
|
|
|
'wed' => 3, 'thu' => 4, 'fri' => 5, |
138
|
|
|
|
|
|
|
'sat' => 6); |
139
|
1
|
|
|
|
|
8
|
my $wday = (('Sonntag', 'Montag', 'Dienstag', 'Mittwoch', |
140
|
|
|
|
|
|
|
'Donnerstag', 'Freitag', 'Samstag')[$wdays{lc $1}]); |
141
|
1
|
|
|
|
|
14
|
my %months = ('jan' => 0, 'feb' => 1, 'mar' => 2, |
142
|
|
|
|
|
|
|
'apr' => 3, 'may' => 4, 'jun' => 5, |
143
|
|
|
|
|
|
|
'jul' => 6, 'aug' => 7, 'sep' => 8, |
144
|
|
|
|
|
|
|
'oct' => 9, 'nov' => 10, 'dec' => 12 |
145
|
|
|
|
|
|
|
); |
146
|
1
|
|
|
|
|
5
|
my $mon = (('Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', |
147
|
|
|
|
|
|
|
'Juli', 'August', 'September', 'Oktober', 'November', |
148
|
|
|
|
|
|
|
'Dezember')[$months{lc $3}]); |
149
|
1
|
|
|
|
|
11
|
$date = "$wday, den $2. $mon $4, $5 Uhr ($6)"; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
} |
152
|
2
|
|
|
|
|
7
|
$date; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
1; |