| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Wiki::Toolkit::Plugin; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
72070
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
79
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
11
|
use vars qw( $VERSION ); |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
634
|
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.04'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Wiki::Toolkit::Plugin - A base class for Wiki::Toolkit plugins. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Provides methods for accessing the backend store, search and formatter |
|
15
|
|
|
|
|
|
|
objects of the L object that a plugin instance is |
|
16
|
|
|
|
|
|
|
registered with. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
package Wiki::Toolkit::Plugin::Foo; |
|
21
|
|
|
|
|
|
|
use base qw( Wiki::Toolkit::Plugin); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# And then in your script: |
|
24
|
|
|
|
|
|
|
my $wiki = Wiki::Toolkit->new( ... ); |
|
25
|
|
|
|
|
|
|
my $plugin = Wiki::Toolkit::Plugin::Foo->new; |
|
26
|
|
|
|
|
|
|
$wiki->register_plugin( plugin => $plugin ); |
|
27
|
|
|
|
|
|
|
my $node = $plugin->datastore->retrieve_node( "Home" ); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 POSSIBLE METHODS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=over 4 |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item B |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Called before moderation is performed. |
|
36
|
|
|
|
|
|
|
Allows changes to the parameters used in moderation. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my %args = @_; |
|
39
|
|
|
|
|
|
|
my ($name_ref,$version_ref) = @args{ qw( node version ) }; |
|
40
|
|
|
|
|
|
|
$$name_ref =~ s/\s/_/g; |
|
41
|
|
|
|
|
|
|
return 0; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item B |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Called after moderation has been performed. |
|
46
|
|
|
|
|
|
|
Allows additional actions to occur after node moderation. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my %args = @_; |
|
49
|
|
|
|
|
|
|
my ($node,$node_id,$version) = |
|
50
|
|
|
|
|
|
|
@args{ qw( node node_id version ) }; |
|
51
|
|
|
|
|
|
|
&update_pending_list($node,$version); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item B |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Called before a rename is performed. |
|
56
|
|
|
|
|
|
|
Allows changes to the parameters used by rename. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my %args = @_; |
|
59
|
|
|
|
|
|
|
my ($old_name_ref,$new_name_ref,$create_new_versions_ref) = |
|
60
|
|
|
|
|
|
|
@args{ qw( old_name new_name create_new_versions ) }; |
|
61
|
|
|
|
|
|
|
$$old_name_ref =~ s/\s/_/g; |
|
62
|
|
|
|
|
|
|
$$new_name_ref =~ s/\s/_/g; |
|
63
|
|
|
|
|
|
|
return 0; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item B |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Called after a rename has been performed. |
|
68
|
|
|
|
|
|
|
Allows additional actions to occur after node renames. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my %args = @_; |
|
71
|
|
|
|
|
|
|
my ($old_name,$new_name,$node_id) = |
|
72
|
|
|
|
|
|
|
@args{ qw( old_name new_name node_id ) }; |
|
73
|
|
|
|
|
|
|
&recalculate_category_listings(); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item B |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Called before a retrieve is performed. |
|
78
|
|
|
|
|
|
|
Allows changes to the parameters used by retrieve. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my %args = @_; |
|
81
|
|
|
|
|
|
|
my ($name_ref,$version_ref) = @args{ qw( node version ) }; |
|
82
|
|
|
|
|
|
|
return &check_retrive_allowed($$name_ref); |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
TODO: Allow declining of the read. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item B |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Called before a write is performed. |
|
89
|
|
|
|
|
|
|
Allows changes to the parameters used by the write; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
my %args = @_; |
|
92
|
|
|
|
|
|
|
my ($node_ref,$content_ref,$metadata_ref) = |
|
93
|
|
|
|
|
|
|
@args{ qw( node content metadata ) }; |
|
94
|
|
|
|
|
|
|
$$content_ref =~ s/\bpub\b/Pub/g; |
|
95
|
|
|
|
|
|
|
return 1; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item B |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Called after a write has been performed. |
|
100
|
|
|
|
|
|
|
Allows additional actions to occur after node writes. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my %args = @_; |
|
103
|
|
|
|
|
|
|
my ($node,$node_id,$version,$content,$metadata) = |
|
104
|
|
|
|
|
|
|
@args{ qw( node node_id version content metadata ) }; |
|
105
|
|
|
|
|
|
|
&log_node_write($node,gmtime); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item B |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Called after a delete has been performed. |
|
110
|
|
|
|
|
|
|
Allows additional actions to occur after node deletions. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my %args = @_; |
|
113
|
|
|
|
|
|
|
my ($node,$node_id,$version) = |
|
114
|
|
|
|
|
|
|
@args{ qw( node node_id version ) }; |
|
115
|
|
|
|
|
|
|
&log_node_delete($node,gmtime); |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 DECLINING ACTIONS FROM PRE_ METHODS |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Note: This functionality is missing for pre_retrieve |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
It is possible for the pre_ methods (eg C) to |
|
124
|
|
|
|
|
|
|
decline the action. This could be due to an authentication |
|
125
|
|
|
|
|
|
|
check done by the plugin, due to the content, or whatever else |
|
126
|
|
|
|
|
|
|
the plugin fancies. There are three possible return values from |
|
127
|
|
|
|
|
|
|
a pre_ plugin: |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
C<-1> - Deny this action |
|
130
|
|
|
|
|
|
|
C<0> or C - I have no opinion |
|
131
|
|
|
|
|
|
|
C<1> - Allow this action |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
If you have only zeros, the action will be allowed. If you have ones |
|
134
|
|
|
|
|
|
|
and zeros, it will also be allowed. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
If you have minus ones and zeros, it will be denied. If you have minus |
|
137
|
|
|
|
|
|
|
ones, ones and zeros, the sum will be used to decide. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
For default deny, have one plugin return -1, and another only return 1 |
|
140
|
|
|
|
|
|
|
if the action is explicity allowed) |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 METHODS |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=over 4 |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item B |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub new { |
|
149
|
|
|
|
|
|
|
my $class = shift; |
|
150
|
|
|
|
|
|
|
my $self = bless {}, $class; |
|
151
|
|
|
|
|
|
|
$self->_init if $self->can("_init"); |
|
152
|
|
|
|
|
|
|
return $self; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Generic contructor, just returns a blessed object. |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub new { |
|
160
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
161
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
|
162
|
0
|
0
|
|
|
|
|
$self->_init if $self->can("_init"); |
|
163
|
0
|
|
|
|
|
|
return $self; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item B |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Returns the Wiki::Toolkit object, or C if the C |
|
169
|
|
|
|
|
|
|
method hasn't been called on a L object yet. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub wiki { |
|
174
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
175
|
0
|
0
|
|
|
|
|
$self->{_wiki} = $_[0] if $_[0]; |
|
176
|
0
|
|
|
|
|
|
return $self->{_wiki}; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item B |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Returns the backend store object, or C if the C |
|
182
|
|
|
|
|
|
|
method hasn't been called on a L object yet. |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub datastore { |
|
187
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
188
|
0
|
0
|
|
|
|
|
$self->{_datastore} = $_[0] if $_[0]; |
|
189
|
0
|
|
|
|
|
|
return $self->{_datastore}; |
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item B |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Returns the backend search object, or C if the |
|
195
|
|
|
|
|
|
|
C method hasn't been called on a L object |
|
196
|
|
|
|
|
|
|
yet, or if the wiki object had no search object defined. |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub indexer { |
|
201
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
202
|
0
|
0
|
|
|
|
|
$self->{_indexer} = $_[0] if $_[0]; |
|
203
|
0
|
|
|
|
|
|
return $self->{_indexer}; |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item B |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Returns the backend formatter object, or C if the C |
|
209
|
|
|
|
|
|
|
method hasn't been called on a L object yet. |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=cut |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub formatter { |
|
214
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
215
|
0
|
0
|
|
|
|
|
$self->{_formatter} = $_[0] if $_[0]; |
|
216
|
0
|
|
|
|
|
|
return $self->{_formatter}; |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=back |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
L |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head1 AUTHOR |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Kake Pugh (kake@earth.li). |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Copyright (C) 2003-4 Kake Pugh. All Rights Reserved. |
|
232
|
|
|
|
|
|
|
Copyright (C) 2006 the Wiki::Toolkit team. All Rights Reserved. |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
|
235
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=cut |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
1; |