line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sledge::Request::Apache::I18N; |
2
|
1
|
|
|
1
|
|
23738
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
3
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
4
|
|
|
|
|
|
|
$VERSION = '0.02'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw(Class::Accessor); |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
943
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(req)); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use vars qw($AUTOLOAD); |
10
|
|
|
|
|
|
|
use Sledge::Request::Apache::I18N::Upload; |
11
|
|
|
|
|
|
|
use Apache::Request; |
12
|
|
|
|
|
|
|
use Encode; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
|
|
|
|
|
|
my($class, $r) = @_; |
16
|
|
|
|
|
|
|
bless { req => Apache::Request->new($r) }, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub upload { |
20
|
|
|
|
|
|
|
my $self = shift; |
21
|
|
|
|
|
|
|
Sledge::Request::Apache::I18N::Upload->new($self, @_); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub param { |
25
|
|
|
|
|
|
|
my $self = shift; |
26
|
|
|
|
|
|
|
if ( @_ == 0) { |
27
|
|
|
|
|
|
|
return map { $self->_decode_param($_) } $self->req->param; |
28
|
|
|
|
|
|
|
} elsif ( @_ == 1) { |
29
|
|
|
|
|
|
|
my @value = map { $self->_decode_param($_) } $self->req->param($_[0]); |
30
|
|
|
|
|
|
|
return wantarray ? @value : $value[0]; |
31
|
|
|
|
|
|
|
} else { |
32
|
|
|
|
|
|
|
my ($key, $param) = @_; |
33
|
|
|
|
|
|
|
if (ref $param eq 'ARRAY') { |
34
|
|
|
|
|
|
|
$param = [map { $self->_encode_param($_) } @$param]; |
35
|
|
|
|
|
|
|
return $self->req->param( $key, $param); |
36
|
|
|
|
|
|
|
} elsif ( ! ref $param ) { |
37
|
|
|
|
|
|
|
return $self->req->param($_[0], $self->_encode_param($_[1])); |
38
|
|
|
|
|
|
|
} else { |
39
|
|
|
|
|
|
|
return $self->req->param(@_); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _decode_param { |
45
|
|
|
|
|
|
|
my ($self, $val) = @_; |
46
|
|
|
|
|
|
|
return Encode::is_utf8($val) |
47
|
|
|
|
|
|
|
? $val |
48
|
|
|
|
|
|
|
: Encode::decode('utf-8', $val); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _encode_param { |
52
|
|
|
|
|
|
|
my ($self, $val) = @_; |
53
|
|
|
|
|
|
|
return Encode::is_utf8($val) |
54
|
|
|
|
|
|
|
? Encode::encode('utf-8', $val) |
55
|
|
|
|
|
|
|
: $val; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub DESTROY { } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub AUTOLOAD { |
61
|
|
|
|
|
|
|
my $self = shift; |
62
|
|
|
|
|
|
|
(my $meth = $AUTOLOAD) =~ s/.*:://; |
63
|
|
|
|
|
|
|
$self->req->$meth(@_); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |