line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoMojo::Schema::ResultSet::Content; |
2
|
|
|
|
|
|
|
|
3
|
40
|
|
|
40
|
|
53661
|
use strict; |
|
40
|
|
|
|
|
106
|
|
|
40
|
|
|
|
|
1061
|
|
4
|
40
|
|
|
40
|
|
374
|
use warnings; |
|
40
|
|
|
|
|
91
|
|
|
40
|
|
|
|
|
1160
|
|
5
|
40
|
|
|
40
|
|
207
|
use parent qw/MojoMojo::Schema::Base::ResultSet/; |
|
40
|
|
|
|
|
87
|
|
|
40
|
|
|
|
|
261
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
MojoMojo::Schema::ResultSet::Content - resultset methods on content |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 METHODS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head2 format_content |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$formatted_content = format_content($c, $content, $page); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Call all available formatters to format content, according to their |
18
|
|
|
|
|
|
|
format_content_order. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub format_content { |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# FIXME: This thing should use accept-context and stop fucking around with $c everywhere |
25
|
118
|
|
|
118
|
1
|
59723
|
my ( $self, $c, $content, $page ) = @_; |
26
|
118
|
50
|
|
|
|
1380
|
MojoMojo->call_plugins( "format_content", \$content, $c, $page ) |
27
|
|
|
|
|
|
|
if ($content); |
28
|
118
|
|
|
|
|
1683
|
return $content; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 create_proto <page> |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Create a content prototype hash, as the basis for a new revision. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub create_proto { |
38
|
0
|
|
|
0
|
1
|
|
my ( $class, $page ) = @_; |
39
|
0
|
|
|
|
|
|
my %proto_content; |
40
|
0
|
|
|
|
|
|
my @columns = $class->result_source->columns; |
41
|
0
|
|
|
|
|
|
eval { |
42
|
0
|
|
|
|
|
|
$page->isa('MojoMojo::Schema::Page'); |
43
|
0
|
|
|
|
|
|
$page->content->isa('MojoMojo::Schema::Content'); |
44
|
|
|
|
|
|
|
}; |
45
|
0
|
0
|
|
|
|
|
if ($@) { |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# assume page is a simple "proto page" hashref, |
48
|
|
|
|
|
|
|
# or the page has no content yet |
49
|
0
|
|
|
|
|
|
%proto_content = map { $_ => undef } @columns; |
|
0
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$proto_content{version} = 1; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
else { |
53
|
0
|
|
|
|
|
|
my $content = $page->content; |
54
|
0
|
|
|
|
|
|
%proto_content = map { $_ => $content->$_ } @columns; |
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
@proto_content{qw/ creator created comments /} = (undef) x 3; |
56
|
0
|
|
|
|
|
|
$proto_content{version}++; |
57
|
|
|
|
|
|
|
} |
58
|
0
|
|
|
|
|
|
return \%proto_content; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 AUTHOR |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Marcus Ramberg <mramberg@cpan.org> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 LICENSE |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify |
68
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |