line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Toader::Page::Manage; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
20233
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
136
|
|
4
|
5
|
|
|
5
|
|
23
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
98
|
|
5
|
5
|
|
|
5
|
|
482
|
use Toader::isaToaderDir; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
168
|
|
6
|
5
|
|
|
5
|
|
542
|
use Toader::Page::Helper; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
129
|
|
7
|
5
|
|
|
5
|
|
3086
|
use Toader::Page; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
155
|
|
8
|
5
|
|
|
5
|
|
39
|
use base 'Error::Helper'; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
390
|
|
9
|
5
|
|
|
5
|
|
28
|
use Toader::pathHelper; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
9523
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Toader::Page::Manage - Manage pages for a specified Toader directory. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 0.1.0 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Toader::Page::Manage; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 new |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This initiates the object. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
One argument is required and that is a L object. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
After calling this, you should call setDir to set the directory to use. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $foo = Toader::Page::Manage->new( $toader ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new{ |
43
|
0
|
|
|
0
|
1
|
|
my $toader=$_[1]; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $self={ |
46
|
|
|
|
|
|
|
error=>undef, |
47
|
|
|
|
|
|
|
errorString=>'', |
48
|
|
|
|
|
|
|
dir=>undef, |
49
|
|
|
|
|
|
|
pdir=>undef, |
50
|
|
|
|
|
|
|
isatd=>Toader::isaToaderDir->new, |
51
|
|
|
|
|
|
|
helper=>undef, |
52
|
|
|
|
|
|
|
VCSusable=>0, |
53
|
|
|
|
|
|
|
toader=>undef, |
54
|
|
|
|
|
|
|
errorExtra=>{ |
55
|
|
|
|
|
|
|
flags=>{ |
56
|
|
|
|
|
|
|
1=>'noDirSpecified', |
57
|
|
|
|
|
|
|
2=>'isaToaderDir', |
58
|
|
|
|
|
|
|
3=>'notAtoaderDir', |
59
|
|
|
|
|
|
|
4=>'noDirSpecified', |
60
|
|
|
|
|
|
|
5=>'openDirFailed', |
61
|
|
|
|
|
|
|
6=>'noEntrySpecified', |
62
|
|
|
|
|
|
|
7=>'invalidEntryName', |
63
|
|
|
|
|
|
|
8=>'pageDoesNotExist', |
64
|
|
|
|
|
|
|
9=>'unlinkFailed', |
65
|
|
|
|
|
|
|
10=>'openPageFailed', |
66
|
|
|
|
|
|
|
11=>'pageObjCreationFailed', |
67
|
|
|
|
|
|
|
12=>'notAtoaderObj', |
68
|
|
|
|
|
|
|
13=>'getVCSerrored', |
69
|
|
|
|
|
|
|
14=>'VCSusableErrored', |
70
|
|
|
|
|
|
|
15=>'underVCSerrored', |
71
|
|
|
|
|
|
|
16=>'VCSdeleteErrored', |
72
|
|
|
|
|
|
|
17=>'noToaderObj', |
73
|
|
|
|
|
|
|
18=>'helperNewErrored', |
74
|
|
|
|
|
|
|
}, |
75
|
|
|
|
|
|
|
}, |
76
|
|
|
|
|
|
|
}; |
77
|
0
|
|
|
|
|
|
bless $self; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#if we have a Toader object, reel it in |
80
|
0
|
0
|
|
|
|
|
if ( ! defined( $toader ) ){ |
81
|
0
|
|
|
|
|
|
$self->{perror}=1; |
82
|
0
|
|
|
|
|
|
$self->{error}=17; |
83
|
0
|
|
|
|
|
|
$self->{errorString}='No Toader object passed'; |
84
|
0
|
|
|
|
|
|
$self->warn; |
85
|
0
|
|
|
|
|
|
return $self; |
86
|
|
|
|
|
|
|
} |
87
|
0
|
0
|
|
|
|
|
if ( ref( $toader ) ne "Toader" ){ |
88
|
0
|
|
|
|
|
|
$self->{perror}=1; |
89
|
0
|
|
|
|
|
|
$self->{error}=12; |
90
|
0
|
|
|
|
|
|
$self->{errorString}='The object specified is a "'.ref($toader).'"'; |
91
|
0
|
|
|
|
|
|
$self->warn; |
92
|
0
|
|
|
|
|
|
return $self; |
93
|
|
|
|
|
|
|
} |
94
|
0
|
|
|
|
|
|
$self->{toader}=$toader; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#inits the helper object |
97
|
0
|
|
|
|
|
|
$self->{helper}=Toader::Page::Helper->new( $toader ); |
98
|
0
|
0
|
|
|
|
|
if ( $self->{helper}->error ){ |
99
|
0
|
|
|
|
|
|
$self->{perror}=1; |
100
|
0
|
|
|
|
|
|
$self->{error}=18; |
101
|
|
|
|
|
|
|
$self->{errorString}='Failed to initialize Toader::Page::Helper.'. |
102
|
0
|
|
|
|
|
|
'error="'.$self->{helper}->error.'" errorString="'.$self->{helper}->errorString.'"'; |
103
|
0
|
|
|
|
|
|
$self->warn; |
104
|
0
|
|
|
|
|
|
return $self; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
#gets the Toader::VCS object |
108
|
0
|
|
|
|
|
|
$self->{vcs}=$self->{toader}->getVCS; |
109
|
0
|
0
|
|
|
|
|
if ( $self->{toader}->error ){ |
110
|
0
|
|
|
|
|
|
$self->{perror}=1; |
111
|
0
|
|
|
|
|
|
$self->{error}=13; |
112
|
|
|
|
|
|
|
$self->{errorString}='Toader->getVCS errored. error="'. |
113
|
0
|
|
|
|
|
|
$self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"'; |
114
|
0
|
|
|
|
|
|
$self->warn; |
115
|
0
|
|
|
|
|
|
return $self; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
#checks if VCS is usable |
119
|
0
|
|
|
|
|
|
$self->{VCSusable}=$self->{vcs}->usable; |
120
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
121
|
0
|
|
|
|
|
|
$self->{perror}=1; |
122
|
0
|
|
|
|
|
|
$self->{error}=14; |
123
|
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->usable errored. error="'. |
124
|
0
|
|
|
|
|
|
$self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"'; |
125
|
0
|
|
|
|
|
|
$self->warn; |
126
|
0
|
|
|
|
|
|
return $self; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
return $self; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 list |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This lists the available pages. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
my @pages=$foo->list; |
137
|
|
|
|
|
|
|
if($foo->error){ |
138
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub list{ |
144
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
#blank any previous errors |
147
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
148
|
0
|
|
|
|
|
|
return undef; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
#make sure a directory has been set |
152
|
0
|
0
|
|
|
|
|
if (!defined($self->{dir})) { |
153
|
0
|
|
|
|
|
|
$self->{error}='4'; |
154
|
0
|
|
|
|
|
|
$self->{errorString}='No directory has been set yet'; |
155
|
0
|
|
|
|
|
|
$self->warn; |
156
|
0
|
|
|
|
|
|
return undef; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
#this will be returned |
160
|
0
|
|
|
|
|
|
my @pages; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
#makes sure we have a entry directory |
163
|
0
|
0
|
|
|
|
|
if ( ! -d $self->{pdir}) { |
164
|
0
|
|
|
|
|
|
return @pages; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
#read what is present in the directory |
168
|
0
|
|
|
|
|
|
my $dh; |
169
|
0
|
0
|
|
|
|
|
if (! opendir( $dh, $self->{pdir} ) ) { |
170
|
0
|
|
|
|
|
|
$self->{error}='5'; |
171
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to open the directory "'.$self->{dir}.'"'; |
172
|
0
|
|
|
|
|
|
$self->warn; |
173
|
0
|
|
|
|
|
|
return undef; |
174
|
|
|
|
|
|
|
} |
175
|
0
|
|
|
|
|
|
@pages=grep( { -f $self->{pdir}.'/'.$_ } readdir($dh) ); |
|
0
|
|
|
|
|
|
|
176
|
0
|
|
|
|
|
|
close($dh); |
177
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
my @toreturn; |
179
|
0
|
|
|
|
|
|
my $int=0; |
180
|
0
|
|
|
|
|
|
while( defined( $pages[$int] ) ){ |
181
|
0
|
0
|
|
|
|
|
if ( $self->{helper}->validPageName( $pages[$int] ) ){ |
182
|
0
|
|
|
|
|
|
push( @toreturn, $pages[$int] ); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
$int++; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
0
|
|
|
|
|
|
return @toreturn; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 published |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=cut |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub published{ |
196
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
197
|
0
|
|
|
|
|
|
my $bool=$_[1]; |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
#blank any previous errors |
200
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
201
|
0
|
|
|
|
|
|
return undef; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
#set the default |
205
|
0
|
0
|
|
|
|
|
if ( ! defined( $bool ) ){ |
206
|
0
|
|
|
|
|
|
$bool='1'; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
#make sure the boolean is definitely zero or one |
210
|
0
|
0
|
|
|
|
|
if ( $bool ){ |
211
|
0
|
|
|
|
|
|
$bool='1'; |
212
|
|
|
|
|
|
|
}else{ |
213
|
0
|
|
|
|
|
|
$bool='0'; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
my @pages=$self->list; |
217
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
218
|
0
|
|
|
|
|
|
$self->warnString('Failed to list the pages'); |
219
|
0
|
|
|
|
|
|
return undef; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
#checks for them all |
223
|
0
|
|
|
|
|
|
my @published; |
224
|
0
|
|
|
|
|
|
my $int=0; |
225
|
0
|
|
|
|
|
|
while ( defined( $pages[$int] ) ){ |
226
|
0
|
|
|
|
|
|
my $page=$self->read( $pages[$int] ); |
227
|
|
|
|
|
|
|
|
228
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
229
|
0
|
|
|
|
|
|
$self->warnString('Failed to read page "'.$pages[$int].'"'); |
230
|
|
|
|
|
|
|
}else{ |
231
|
0
|
|
|
|
|
|
my $ispublished=$page->publishGet; |
232
|
0
|
0
|
|
|
|
|
if ( $ispublished eq $bool ){ |
233
|
0
|
|
|
|
|
|
push( @published, $pages[$int] ); |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
0
|
|
|
|
|
|
$int++; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
0
|
|
|
|
|
|
return @published; |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 read |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
This reads a page. |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
One argument is required and it is entry name. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
The returned value is a L object. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
my $page=$foo->read($pageName); |
252
|
|
|
|
|
|
|
if($foo->error){ |
253
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=cut |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
sub read{ |
259
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
260
|
0
|
|
|
|
|
|
my $page=$_[1]; |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
#blank any previous errors |
263
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
264
|
0
|
|
|
|
|
|
return undef; |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
#makes sure a directory is specified |
268
|
0
|
0
|
|
|
|
|
if (!defined($page)) { |
269
|
0
|
|
|
|
|
|
$self->{error}='6'; |
270
|
0
|
|
|
|
|
|
$self->{errorString}='No pagespecified'; |
271
|
0
|
|
|
|
|
|
$self->warn; |
272
|
0
|
|
|
|
|
|
return undef; |
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
#make sure a directory has been set |
276
|
0
|
0
|
|
|
|
|
if (!defined($self->{dir})) { |
277
|
0
|
|
|
|
|
|
$self->{error}='4'; |
278
|
0
|
|
|
|
|
|
$self->{errorString}='No directory has been set yet'; |
279
|
0
|
|
|
|
|
|
$self->warn; |
280
|
0
|
|
|
|
|
|
return undef; |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
#make sure it is valid and exists |
284
|
0
|
|
|
|
|
|
my $returned=$self->{helper}->pageExists($page); |
285
|
0
|
0
|
|
|
|
|
if (!$returned) { |
286
|
0
|
0
|
|
|
|
|
if ($self->{helper}->error){ |
287
|
0
|
|
|
|
|
|
$self->{error}=7; |
288
|
0
|
|
|
|
|
|
$self->{errorString}='The page name is not valid'; |
289
|
|
|
|
|
|
|
}else { |
290
|
0
|
|
|
|
|
|
$self->{error}=8; |
291
|
0
|
|
|
|
|
|
$self->{errorString}='The page does not exist'; |
292
|
|
|
|
|
|
|
} |
293
|
0
|
|
|
|
|
|
$self->warn; |
294
|
0
|
|
|
|
|
|
return undef; |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
#figure out the file will be |
298
|
0
|
|
|
|
|
|
my $file=$self->{dir}.'/.toader/pages/'.$page; |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
#reads it |
301
|
0
|
|
|
|
|
|
my $pageString; |
302
|
|
|
|
|
|
|
my $fh; |
303
|
0
|
0
|
|
|
|
|
if ( ! open($fh, '<', $file) ){ |
304
|
0
|
|
|
|
|
|
$self->{error}=10; |
305
|
0
|
|
|
|
|
|
$self->{errorString}='Unable to open "'.$file.'" for reading'; |
306
|
0
|
|
|
|
|
|
$self->warn; |
307
|
0
|
|
|
|
|
|
return undef; |
308
|
|
|
|
|
|
|
} |
309
|
0
|
|
|
|
|
|
$pageString=join("", <$fh>); |
310
|
0
|
|
|
|
|
|
close($fh); |
311
|
|
|
|
|
|
|
|
312
|
0
|
|
|
|
|
|
my $pageObj=Toader::Page->newFromString($pageString, $self->{toader}); |
313
|
0
|
0
|
|
|
|
|
if ($pageObj->error) { |
314
|
0
|
|
|
|
|
|
$self->{error}=11; |
315
|
0
|
|
|
|
|
|
$self->{errorString}='Unable to generate a Toader::Page object from '; |
316
|
0
|
|
|
|
|
|
$self->warn; |
317
|
0
|
|
|
|
|
|
return undef; |
318
|
|
|
|
|
|
|
} |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
#sets the directory |
321
|
0
|
|
|
|
|
|
$pageObj->dirSet($self->{dir}); |
322
|
|
|
|
|
|
|
|
323
|
0
|
|
|
|
|
|
return $pageObj; |
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=head2 remove |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
This removes a page. |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
One argument is required and it is page name. |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
$foo->remove($page); |
333
|
|
|
|
|
|
|
if($foo->error){ |
334
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
335
|
|
|
|
|
|
|
} |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
=cut |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
sub remove{ |
340
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
341
|
0
|
|
|
|
|
|
my $page=$_[1]; |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
#blank any previous errors |
344
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
345
|
0
|
|
|
|
|
|
return undef; |
346
|
|
|
|
|
|
|
} |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
#makes sure a directory is specified |
349
|
0
|
0
|
|
|
|
|
if (defined($page)) { |
350
|
0
|
|
|
|
|
|
$self->{error}='6'; |
351
|
0
|
|
|
|
|
|
$self->{errorString}='No page specified'; |
352
|
0
|
|
|
|
|
|
$self->warn; |
353
|
0
|
|
|
|
|
|
return undef; |
354
|
|
|
|
|
|
|
} |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
#make sure a directory has been set |
357
|
0
|
0
|
|
|
|
|
if (!defined($self->{dir})) { |
358
|
0
|
|
|
|
|
|
$self->{error}='4'; |
359
|
0
|
|
|
|
|
|
$self->{errorString}='No directory has been set yet'; |
360
|
0
|
|
|
|
|
|
$self->warn; |
361
|
0
|
|
|
|
|
|
return undef; |
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
#make sure it is valid and exists |
365
|
0
|
|
|
|
|
|
my $returned=$self->{helper}->pageExists($page); |
366
|
0
|
0
|
|
|
|
|
if (!$returned) { |
367
|
0
|
0
|
|
|
|
|
if ($self->{helper}->error){ |
368
|
0
|
|
|
|
|
|
$self->{error}=7; |
369
|
0
|
|
|
|
|
|
$self->{errorString}='The page name is not valid'; |
370
|
|
|
|
|
|
|
}else { |
371
|
0
|
|
|
|
|
|
$self->{error}=8; |
372
|
0
|
|
|
|
|
|
$self->{errorString}='The page does not exist'; |
373
|
|
|
|
|
|
|
} |
374
|
0
|
|
|
|
|
|
$self->warn; |
375
|
0
|
|
|
|
|
|
return undef; |
376
|
|
|
|
|
|
|
} |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
#the file in question |
379
|
0
|
|
|
|
|
|
my $file=$self->{pdir}.'/'.$page; |
380
|
|
|
|
|
|
|
|
381
|
0
|
0
|
|
|
|
|
if (!unlink( $file ) ){ |
382
|
0
|
|
|
|
|
|
$self->{error}=9; |
383
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to unlink the page, "'.$file.'",'; |
384
|
0
|
|
|
|
|
|
$self->warn; |
385
|
0
|
|
|
|
|
|
return undef; |
386
|
|
|
|
|
|
|
} |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
#if VCS is not usable, return here |
389
|
0
|
0
|
|
|
|
|
if ( ! $self->{VCSusable} ){ |
390
|
0
|
|
|
|
|
|
return 1; |
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
#if it is not under VCS, we have nothing to do |
394
|
0
|
|
|
|
|
|
my $underVCS=$self->{vcs}->underVCS( $file ); |
395
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
396
|
0
|
|
|
|
|
|
$self->{error}=15; |
397
|
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->underVCS errored. error="'. |
398
|
0
|
|
|
|
|
|
$self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"'; |
399
|
0
|
|
|
|
|
|
$self->warn; |
400
|
0
|
|
|
|
|
|
return undef; |
401
|
|
|
|
|
|
|
} |
402
|
0
|
0
|
|
|
|
|
if ( $underVCS ){ |
403
|
0
|
|
|
|
|
|
return 1; |
404
|
|
|
|
|
|
|
} |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
#delete it as if we reach here it is not under VCS and VCS is being used |
407
|
0
|
|
|
|
|
|
$self->{vcs}->delete( $file ); |
408
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
409
|
0
|
|
|
|
|
|
$self->{error}=16; |
410
|
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->delete errored. error="'. |
411
|
0
|
|
|
|
|
|
$self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"'; |
412
|
0
|
|
|
|
|
|
$self->warn; |
413
|
0
|
|
|
|
|
|
return undef; |
414
|
|
|
|
|
|
|
} |
415
|
|
|
|
|
|
|
|
416
|
0
|
|
|
|
|
|
return 1; |
417
|
|
|
|
|
|
|
} |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
=head2 setDir |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
This sets the directory the module will work on. |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
One argument is taken and that is the path for the Toader directory |
424
|
|
|
|
|
|
|
in question. |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
$foo->setDir($toaderDirectory) |
427
|
|
|
|
|
|
|
if($foo->error){ |
428
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
=cut |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
sub setDir{ |
434
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
435
|
0
|
|
|
|
|
|
my $directory=$_[1]; |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
#blank any previous errors |
438
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
439
|
0
|
|
|
|
|
|
return undef; |
440
|
|
|
|
|
|
|
} |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
#makes sure a directory is specified |
443
|
0
|
0
|
|
|
|
|
if (!defined($directory)) { |
444
|
0
|
|
|
|
|
|
$self->{error}='1'; |
445
|
0
|
|
|
|
|
|
$self->{errorString}='No directory specified'; |
446
|
0
|
|
|
|
|
|
$self->warn; |
447
|
0
|
|
|
|
|
|
return undef; |
448
|
|
|
|
|
|
|
} |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
#cleans up the naming |
451
|
0
|
|
|
|
|
|
my $pathHelper=Toader::pathHelper->new( $directory ); |
452
|
0
|
|
|
|
|
|
$directory=$pathHelper->cleanup( $directory ); |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
#makes sure it is a directory |
455
|
0
|
|
|
|
|
|
my $returned=$self->{isatd}->isaToaderDir($directory); |
456
|
0
|
0
|
|
|
|
|
if(!$returned){ |
457
|
0
|
0
|
|
|
|
|
if($self->{isatd}->error){ |
458
|
0
|
|
|
|
|
|
$self->{error}='2'; |
459
|
0
|
|
|
|
|
|
$self->{errorString}='isaToaderDir errored. error="'.$self->{isatd}->error.'" errorString="'.$self->{isatd}->errorString.'"'; |
460
|
0
|
|
|
|
|
|
$self->warn; |
461
|
0
|
|
|
|
|
|
return undef; |
462
|
|
|
|
|
|
|
} |
463
|
0
|
|
|
|
|
|
$self->{error}='3'; |
464
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$directory.'" is not a Toader directory'; |
465
|
0
|
|
|
|
|
|
$self->warn; |
466
|
0
|
|
|
|
|
|
return undef; |
467
|
|
|
|
|
|
|
} |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
#it has been verified, so set it |
470
|
0
|
|
|
|
|
|
$self->{dir}=$directory; |
471
|
0
|
|
|
|
|
|
$self->{helper}->setDir($directory); #if the previous check has been worked, then this well |
472
|
0
|
|
|
|
|
|
$self->{pdir}=$self->{helper}->pageDirectory; |
473
|
|
|
|
|
|
|
|
474
|
0
|
|
|
|
|
|
return 1; |
475
|
|
|
|
|
|
|
} |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
=head1 ERROR CODES/FLAGS |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
=head2 1, noDirSpecified |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
No directory specified. |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
=head2 2, isaToaderDirErrored |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
isaToaderDir errored. |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
=head2 3, notAtoaderDir |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
Is not a L directory. |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
=head2 4, noDirDefined |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
No directory has been defined. |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
=head2 5, openDirFailed |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
Failed to open the directory. |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
=head2 6, noEntrySpecified |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
No entry specified. |
502
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
=head2 7, invalidEntryName |
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
The entry is not a valid name. |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
=head2 8, pageDoesNotExist |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
The entry does not exist. |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
=head2 9, unlinkFailed |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
Failed to unlink the entry. |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
=head2 10, openPageFailed |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
Unable to open the page file for reading. |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
=head2 11, pageObjCreationFailed |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
Unable to generate a L object from the file. |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
=head2 12, notAtoaderObj |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
The object specified is not a Toader object. |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
=head2 13, getVCSerrored |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
L->getVCS errored. |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
=head2 14, VCSusableErrored |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
L->usable errored. |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
=head2 15, underVCSerrored |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
L->underVCS errored. |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
=head2 16, VCSdeleteErrored |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
L->delete errored. |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
=head2 17, noToaderObj |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
No L object specified. |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=head2 18, helperNewErrored |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
L->new errored. |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
=head1 AUTHOR |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
=head1 BUGS |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
558
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
559
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
=head1 SUPPORT |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
perldoc Toader::Page::Manage |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
You can also look for information at: |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
=over 4 |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
L |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
L |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
=item * CPAN Ratings |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
L |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
=item * Search CPAN |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
L |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
=back |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
Copyright 2011 Zane C. Bowers-Hadley. |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
602
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
603
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
=cut |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
1; # End of Toader |