| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
OpenFrame::WebApp::Template::Factory - a factory for various types of template |
|
4
|
|
|
|
|
|
|
wrappers. |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use OpenFrame::WebApp::Template::Factory; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $tf = new OpenFrame::WebApp::Template::Factory() |
|
11
|
|
|
|
|
|
|
->type( 'tt2' ) |
|
12
|
|
|
|
|
|
|
->directory( $local_dir ) # optional |
|
13
|
|
|
|
|
|
|
->processor( new Template( ... ) ); # optional |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $tmpl = $tf->new_template( $file, @new_args ); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package OpenFrame::WebApp::Template::Factory; |
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
24252
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
40
|
|
|
22
|
1
|
|
|
1
|
|
6
|
use warnings::register; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
185
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
546
|
use OpenFrame::WebApp::Template; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $VERSION = (split(/ /, '$Revision: 1.2 $'))[1]; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use base qw ( OpenFrame::WebApp::Factory ); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub directory { |
|
31
|
|
|
|
|
|
|
my $self = shift; |
|
32
|
|
|
|
|
|
|
if (@_) { |
|
33
|
|
|
|
|
|
|
$self->{template_dir} = shift; |
|
34
|
|
|
|
|
|
|
return $self; |
|
35
|
|
|
|
|
|
|
} else { |
|
36
|
|
|
|
|
|
|
return $self->{template_dir}; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub processor { |
|
41
|
|
|
|
|
|
|
my $self = shift; |
|
42
|
|
|
|
|
|
|
if (@_) { |
|
43
|
|
|
|
|
|
|
$self->{template_processor} = shift; |
|
44
|
|
|
|
|
|
|
return $self; |
|
45
|
|
|
|
|
|
|
} else { |
|
46
|
|
|
|
|
|
|
return $self->{template_processor}; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub get_types_class { |
|
51
|
|
|
|
|
|
|
my $self = shift; |
|
52
|
|
|
|
|
|
|
return OpenFrame::WebApp::Template->types->{$self->type}; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub new_template { |
|
56
|
|
|
|
|
|
|
my $self = shift; |
|
57
|
|
|
|
|
|
|
my $path = shift; |
|
58
|
|
|
|
|
|
|
$self->new_object( @_ ) |
|
59
|
|
|
|
|
|
|
->file( $self->get_template_file($path) ) |
|
60
|
|
|
|
|
|
|
->processor( $self->processor ); |
|
61
|
|
|
|
|
|
|
# $tmpl->process should check for undef processor |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
## get path to the template file |
|
65
|
|
|
|
|
|
|
## shamelessly stolen from OpenFrame::AppKit::Segment::TT2 |
|
66
|
|
|
|
|
|
|
sub get_template_file { |
|
67
|
|
|
|
|
|
|
my $self = shift; |
|
68
|
|
|
|
|
|
|
my $path = shift; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
return $path unless ($self->directory); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
## split up the path so we know where we are |
|
73
|
|
|
|
|
|
|
my ($volume, $dirs, $file) = File::Spec->splitpath( $path ); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
## make sure we have a file |
|
76
|
|
|
|
|
|
|
if (!$file) { |
|
77
|
|
|
|
|
|
|
$file = "index.html"; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
## get the reconstituted path, with index.html tagged on if |
|
81
|
|
|
|
|
|
|
## there was no file. |
|
82
|
|
|
|
|
|
|
return File::Spec->catfile( $self->directory, $dirs, $file ); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |