| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Sledge::Template::ClearSilver::I18N; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
29615
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
47
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use base qw(Sledge::Template::ClearSilver); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
598
|
|
|
5
|
1
|
|
|
1
|
|
1311
|
use Encode; |
|
|
1
|
|
|
|
|
17766
|
|
|
|
1
|
|
|
|
|
125
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
11
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1336
|
|
|
8
|
|
|
|
|
|
|
$VERSION = '0.01'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub output { |
|
11
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
12
|
0
|
|
|
|
|
|
my $input = $self->{_options}->{filename}; |
|
13
|
0
|
0
|
|
|
|
|
unless (-e $input) { |
|
14
|
0
|
|
|
|
|
|
Sledge::Exception::TemplateNotFound->throw( |
|
15
|
|
|
|
|
|
|
"$input: No template file detected. Check your template path.", |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
} |
|
18
|
0
|
|
|
|
|
|
my $hdf = $self->_create_hdf; |
|
19
|
0
|
|
|
|
|
|
my $cs = ClearSilver::CS->new($hdf); |
|
20
|
0
|
0
|
|
|
|
|
unless ($cs->parseFile($input)) { |
|
21
|
0
|
|
|
|
|
|
Sledge::Exception::TemplateParseError->throw( |
|
22
|
|
|
|
|
|
|
$input.': Parse Error.' |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
0
|
|
|
|
|
|
my $output = $cs->render(); |
|
26
|
0
|
|
|
|
|
|
return Encode::decode('utf-8',$output); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _create_hdf { |
|
30
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
31
|
0
|
|
|
|
|
|
local $Sledge::Template::NSSepChar = '.'; |
|
32
|
0
|
|
|
|
|
|
$self->_associate_dump; |
|
33
|
0
|
|
|
|
|
|
my $hdf = ClearSilver::HDF->new; |
|
34
|
|
|
|
|
|
|
# set loadpath |
|
35
|
0
|
|
|
|
|
|
_hdf_setValue($hdf, 'hdf.loadpaths', $self->{_options}->{loadpaths}); |
|
36
|
|
|
|
|
|
|
# read HDF Dataset files |
|
37
|
0
|
|
|
|
|
|
for my $path (@{$self->{_options}->{hdfpaths}}) { |
|
|
0
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $ret = $hdf->readFile($path); |
|
39
|
0
|
0
|
|
|
|
|
unless ($ret) { |
|
40
|
0
|
|
|
|
|
|
Sledge::Exception::TemplateParseError->throw( |
|
41
|
|
|
|
|
|
|
"$path: Parse Error. Couldn't create HDF Dataset." |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
# set params |
|
46
|
0
|
|
|
|
|
|
while (my ($key, $val) = each %{$self->{_params}}) { |
|
|
0
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
_hdf_setValue($hdf, $key, $val); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
# set associate |
|
50
|
0
|
|
|
|
|
|
for my $assoc (@{$self->{_options}->{associate}}) { |
|
|
0
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
_hdf_setValue($hdf, $_, $assoc->param($_)) for $assoc->param; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
0
|
|
|
|
|
|
$hdf; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _hdf_setValue { |
|
57
|
0
|
|
|
0
|
|
|
my ($hdf, $key, $val) = @_; |
|
58
|
0
|
0
|
0
|
|
|
|
if (ref $val eq 'ARRAY') { |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $index = 0; |
|
60
|
0
|
|
|
|
|
|
for my $v (@$val) { |
|
61
|
0
|
|
|
|
|
|
_hdf_setValue($hdf, $key.'.'.$index, $v); |
|
62
|
0
|
|
|
|
|
|
$index++; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
} elsif (ref $val eq 'HASH') { |
|
65
|
0
|
|
|
|
|
|
while (my ($k, $v) = each %$val) { |
|
66
|
0
|
|
|
|
|
|
_hdf_setValue($hdf, $key.'.'.$k, $v); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
} elsif (ref $val eq 'SCALAR') { |
|
69
|
0
|
|
|
|
|
|
_hdf_setValue($hdf, $key, $$val); |
|
70
|
|
|
|
|
|
|
} elsif (ref $val eq '' && $key && $val) { |
|
71
|
0
|
0
|
|
|
|
|
Encode::_utf8_on($key) unless Encode::is_utf8($key); |
|
72
|
0
|
0
|
|
|
|
|
Encode::_utf8_on($val) unless Encode::is_utf8($val); |
|
73
|
0
|
|
|
|
|
|
$hdf->setValue($key, $val); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
|
78
|
|
|
|
|
|
|
__END__ |