line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::View::Excel::Template::Plus; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20194
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
857
|
use MRO::Compat; |
|
1
|
|
|
|
|
2966
|
|
|
1
|
|
|
|
|
22
|
|
7
|
1
|
|
|
1
|
|
476
|
use Excel::Template::Plus; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Scalar::Util 'blessed'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Catalyst::Exception; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
13
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use base 'Catalyst::View'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw[ |
18
|
|
|
|
|
|
|
etp_engine |
19
|
|
|
|
|
|
|
etp_config |
20
|
|
|
|
|
|
|
etp_params |
21
|
|
|
|
|
|
|
]); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
|
|
|
|
|
|
my($class, $c, $args) = @_; |
25
|
|
|
|
|
|
|
my $self = $class->next::method($c, $args); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $config = $c->config->{'View::Excel::Template::Plus'}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$args->{etp_engine} ||= $config->{etp_engine} || 'TT'; |
30
|
|
|
|
|
|
|
$args->{etp_config} ||= $config->{etp_config} || {}; |
31
|
|
|
|
|
|
|
$args->{etp_params} ||= $config->{etp_params} || {}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$self->etp_engine($args->{etp_engine}); |
34
|
|
|
|
|
|
|
$self->etp_config($args->{etp_config}); |
35
|
|
|
|
|
|
|
$self->etp_params($args->{etp_params}); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
if ( defined $self->config->{TEMPLATE_EXTENSION} && $self->config->{TEMPLATE_EXTENSION} !~ /\./ ){ |
38
|
|
|
|
|
|
|
$c->log->warn(qq/Missing . (dot) in TEMPLATE_EXTENSION ( $class ), the attitude has changed with version 0.02./); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub process { |
45
|
|
|
|
|
|
|
my $self = shift; |
46
|
|
|
|
|
|
|
my $c = shift; |
47
|
|
|
|
|
|
|
my @args = @_; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $template = $self->get_template_filename($c); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
(defined $template) |
52
|
|
|
|
|
|
|
|| die 'No template specified for rendering'; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $etp_engine = $c->stash->{etp_engine} || $self->etp_engine; |
55
|
|
|
|
|
|
|
my $etp_config = $c->stash->{etp_config} || $self->etp_config; |
56
|
|
|
|
|
|
|
my $etp_params = $c->stash->{etp_params} || $self->etp_params; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $excel = $self->create_template_object($c => ( |
59
|
|
|
|
|
|
|
engine => $etp_engine, |
60
|
|
|
|
|
|
|
template => $template, |
61
|
|
|
|
|
|
|
config => $etp_config, |
62
|
|
|
|
|
|
|
params => $etp_params, |
63
|
|
|
|
|
|
|
)); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$excel->param( $self->get_template_params($c) ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$c->response->content_type('application/x-msexcel'); |
68
|
|
|
|
|
|
|
$c->response->body($excel->output); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub create_template_object { |
72
|
|
|
|
|
|
|
my ($self, $c, %options) = @_; |
73
|
|
|
|
|
|
|
Excel::Template::Plus->new( %options ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub get_template_filename { |
77
|
|
|
|
|
|
|
my ($self, $c) = @_; |
78
|
|
|
|
|
|
|
$c->stash->{template} |
79
|
|
|
|
|
|
|
|| |
80
|
|
|
|
|
|
|
($c->action . '.xml' . $self->config->{TEMPLATE_EXTENSION}); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub get_template_params { |
84
|
|
|
|
|
|
|
my ($self, $c) = @_; |
85
|
|
|
|
|
|
|
my $cvar = $self->config->{CATALYST_VAR} || 'c'; |
86
|
|
|
|
|
|
|
return ( $cvar => $c, %{ $c->stash } ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=pod |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 NAME |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Catalyst::View::Excel::Template::Plus - A Catalyst View for Excel::Template::Plus |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 SYNOPSIS |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# use the helper to create your View |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
MyApp_create.pl view Excel Excel::Template::Plus |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 DESCRIPTION |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This is a Catalyst View subclass which can handle rendering excel content |
108
|
|
|
|
|
|
|
through Excel::Template::Plus. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 CONFIG OPTIONS |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=over 4 |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item I<etp_engine> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item I<etp_config> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item I<etp_params> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 METHODS |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over 4 |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item B<new> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This really just handles consuming the configuration parameters. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item B<process> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item B<get_template_filename> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item B<get_template_params> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item B<create_template_object> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=back |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 BUGS |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
All complex software has bugs lurking in it, and this module is no |
143
|
|
|
|
|
|
|
exception. If you find a bug please either email me, or add the bug |
144
|
|
|
|
|
|
|
to cpan-RT. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 AUTHOR |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Stevan Little E<lt>stevan.little@iinteractive.comE<gt> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Robert Bohne E<lt>rbo@cpan.orgE<gt> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Copyright 2007 by Infinity Interactive, Inc. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
L<http://www.iinteractive.com> |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
161
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |