line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OurCal::View::HTML; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
902
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
2658
|
use Template; |
|
1
|
|
|
|
|
26665
|
|
|
1
|
|
|
|
|
18
|
|
5
|
1
|
|
|
1
|
|
33
|
use OurCal::Todo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
19
|
use OurCal::Event; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
OurCal::View::HTML - an HTML view for OurCal |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 METHODS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head2 new |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
0
|
|
|
0
|
1
|
|
my ($class, %what) = @_; |
22
|
0
|
|
|
|
|
|
return bless \%what, $class; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 mime_type |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Returns the mime_type for this view 'text/html' |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub mime_type { |
33
|
0
|
|
|
0
|
1
|
|
return "text/html"; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 handle |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Returns HTML representing the current mode. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub handle { |
43
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
44
|
0
|
|
|
|
|
|
my %opts = @_; |
45
|
0
|
|
|
|
|
|
my $handler = $self->{handler}; |
46
|
0
|
|
|
|
|
|
my $config = $self->{config}; |
47
|
0
|
|
|
|
|
|
my $cal = $self->{calendar}; |
48
|
0
|
|
|
|
|
|
my $mode = $handler->mode; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
if ("save_todo" eq $mode) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my %what = ( description => $handler->param('description') ); |
53
|
0
|
0
|
|
|
|
|
$what{user} = $handler->user if defined $handler->user; |
54
|
0
|
|
|
|
|
|
$cal->save_todo( OurCal::Todo->new(%what)); |
55
|
|
|
|
|
|
|
} elsif ("del_todo" eq $mode) { |
56
|
0
|
|
|
|
|
|
$cal->del_todo( OurCal::Todo->new( id => $handler->param('id') ) ); |
57
|
|
|
|
|
|
|
} elsif ("save_event" eq $mode) { |
58
|
0
|
0
|
|
|
|
|
die "Can't add an event to anything but a day\n" |
59
|
|
|
|
|
|
|
unless $cal->span_name eq 'day'; |
60
|
0
|
|
|
|
|
|
my %what = ( description => $handler->param('description'), date => $cal->date ); |
61
|
0
|
0
|
|
|
|
|
$what{user} = $handler->user if defined $handler->user; |
62
|
0
|
|
|
|
|
|
$cal->save_event( OurCal::Event->new(%what) ); |
63
|
|
|
|
|
|
|
} elsif ("del_event" eq $mode) { |
64
|
0
|
|
|
|
|
|
$cal->del_event( OurCal::Event->new( id => $handler->param('id') ) ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $span = $cal->span_name; |
69
|
0
|
|
|
|
|
|
my $vars = { |
70
|
|
|
|
|
|
|
image_url => $config->{image_url}, |
71
|
|
|
|
|
|
|
handler => $handler, |
72
|
|
|
|
|
|
|
calendar => $cal, |
73
|
|
|
|
|
|
|
$span => $cal->span, |
74
|
|
|
|
|
|
|
}; |
75
|
0
|
|
0
|
|
|
|
my $template = Template->new({ INCLUDE_PATH => $config->{template_path}, RELATIVE => 1}) || die "${Template::ERROR}\n"; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my $return; |
79
|
0
|
0
|
|
|
|
|
$template->process($span,$vars, \$return) |
80
|
|
|
|
|
|
|
|| die "Template process failed: ".$template->error()."\n"; |
81
|
0
|
|
|
|
|
|
return $return; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 DESIGN |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
The default template design is ripped off http://www.chimpfactory.com/ |
89
|
|
|
|
|
|
|
with permission. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Don't blame them for the horrible way it's implemented - that's all my |
92
|
|
|
|
|
|
|
fault. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |