line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gantry::Template::TT; |
2
|
|
|
|
|
|
|
require Exporter; |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
52364
|
use Gantry::Init; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
106
|
|
5
|
4
|
|
|
4
|
|
22
|
use Template; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
120
|
|
6
|
4
|
|
|
4
|
|
21
|
use vars qw( @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS ); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
317
|
|
7
|
4
|
|
|
4
|
|
24
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
2441
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
############################################################ |
10
|
|
|
|
|
|
|
# Variables # |
11
|
|
|
|
|
|
|
############################################################ |
12
|
|
|
|
|
|
|
@ISA = qw( Exporter ); |
13
|
|
|
|
|
|
|
@EXPORT = qw( |
14
|
|
|
|
|
|
|
do_action |
15
|
|
|
|
|
|
|
do_error |
16
|
|
|
|
|
|
|
do_process |
17
|
|
|
|
|
|
|
template_engine |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
@EXPORT_OK = qw( ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $tt; |
23
|
|
|
|
|
|
|
my @tt_include_paths; |
24
|
|
|
|
|
|
|
my @tt_wrapper; |
25
|
|
|
|
|
|
|
my @tt_default_template; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
############################################################ |
28
|
|
|
|
|
|
|
# Functions # |
29
|
|
|
|
|
|
|
############################################################ |
30
|
|
|
|
|
|
|
#------------------------------------------------- |
31
|
|
|
|
|
|
|
# $self->do_action( 'do_main|do_edit', @p ) |
32
|
|
|
|
|
|
|
#------------------------------------------------- |
33
|
|
|
|
|
|
|
sub do_action { |
34
|
0
|
|
|
0
|
1
|
|
my( $self, $action, @p ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# stash the output from the action ie. do_main, do_edit |
37
|
|
|
|
|
|
|
# for use when do_process is call. |
38
|
0
|
|
|
|
|
|
$self->stash->controller->data( $self->$action( @p ) ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} # end do_action |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#------------------------------------------------- |
43
|
|
|
|
|
|
|
# $self->do_error( @err ) |
44
|
|
|
|
|
|
|
#------------------------------------------------- |
45
|
|
|
|
|
|
|
sub do_error { |
46
|
0
|
|
|
0
|
1
|
|
my( $self, @err ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#$self->r->log_error( join( "\n", @err ) ); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} # end do_error |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
#------------------------------------------------- |
53
|
|
|
|
|
|
|
# $site->do_process( ) |
54
|
|
|
|
|
|
|
#------------------------------------------------- |
55
|
|
|
|
|
|
|
sub do_process { |
56
|
0
|
|
|
0
|
1
|
|
my( $self ) = @_; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Check template disabled flag |
59
|
0
|
0
|
|
|
|
|
if ( $self->template_disable ) { |
60
|
0
|
|
|
|
|
|
return( $self->stash->controller->data ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Process through template tookit |
64
|
|
|
|
|
|
|
else { |
65
|
0
|
0
|
|
|
|
|
if ( not defined $tt ) { |
66
|
0
|
0
|
|
|
|
|
$tt = Template->new( |
67
|
|
|
|
|
|
|
WRAPPER => \@tt_wrapper, |
68
|
|
|
|
|
|
|
INCLUDE_PATH => \@tt_include_paths, |
69
|
|
|
|
|
|
|
DEFAULT => \@tt_default_template, |
70
|
|
|
|
|
|
|
) or die "$Template::ERROR"; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Use the template defined in controller use template from PerlSetVar |
74
|
0
|
0
|
|
|
|
|
if ( ! defined $self->stash->view->template ) { |
75
|
0
|
|
|
|
|
|
$self->stash->view->template( $self->template ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return( |
79
|
0
|
0
|
0
|
|
|
|
( $self->stash->view->data || '' ) |
|
|
|
0
|
|
|
|
|
80
|
|
|
|
|
|
|
. ( $self->stash->controller->data || '' ) |
81
|
|
|
|
|
|
|
) if ! $self->stash->view->template(); |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $tmpl_install_dir = ''; |
84
|
0
|
|
|
|
|
|
eval { |
85
|
0
|
|
|
|
|
|
$tmpl_install_dir = Gantry::Init->base_root(); |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
@tt_include_paths = ( split( ':', $self->root), $tmpl_install_dir ); |
89
|
|
|
|
|
|
|
|
90
|
0
|
0
|
|
|
|
|
if ( $self->template_wrapper ) { |
91
|
0
|
|
|
|
|
|
@tt_wrapper = ( $self->template_wrapper ); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
else { |
94
|
0
|
|
|
|
|
|
pop( @tt_wrapper ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
0
|
|
|
|
@tt_default_template = ( $self->template_default || undef ); |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
my $page = ''; |
100
|
0
|
0
|
|
|
|
|
$tt->process( |
101
|
|
|
|
|
|
|
$self->stash->view->template, |
102
|
|
|
|
|
|
|
{ |
103
|
|
|
|
|
|
|
self => $self, |
104
|
|
|
|
|
|
|
site => $self, |
105
|
|
|
|
|
|
|
view => $self->stash->view, |
106
|
|
|
|
|
|
|
}, |
107
|
|
|
|
|
|
|
\$page, |
108
|
|
|
|
|
|
|
) || die( "Template Error: " . $tt->error ); |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
return( $page ); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} # end do_process |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
#------------------------------------------------- |
115
|
|
|
|
|
|
|
# $site->template_engine |
116
|
|
|
|
|
|
|
#------------------------------------------------- |
117
|
|
|
|
|
|
|
sub template_engine { |
118
|
0
|
|
|
0
|
1
|
|
return __PACKAGE__; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} # end template_engine |
121
|
|
|
|
|
|
|
# EOF |
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |