line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Toader::Page; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
19744
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
168
|
|
4
|
6
|
|
|
6
|
|
27
|
use strict; |
|
6
|
|
|
|
|
89
|
|
|
6
|
|
|
|
|
147
|
|
5
|
6
|
|
|
6
|
|
2613
|
use Email::MIME; |
|
6
|
|
|
|
|
190913
|
|
|
6
|
|
|
|
|
137
|
|
6
|
6
|
|
|
6
|
|
2363
|
use File::MimeInfo; |
|
6
|
|
|
|
|
14834
|
|
|
6
|
|
|
|
|
354
|
|
7
|
6
|
|
|
6
|
|
647
|
use Toader::isaToaderDir; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
161
|
|
8
|
6
|
|
|
6
|
|
31
|
use File::Path qw(make_path); |
|
6
|
|
|
|
|
918
|
|
|
6
|
|
|
|
|
287
|
|
9
|
6
|
|
|
6
|
|
30
|
use base 'Error::Helper'; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
412
|
|
10
|
6
|
|
|
6
|
|
530
|
use Toader::pathHelper; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
30825
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Toader::Page - This provides methods for a named page. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Version 1.0.0 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '1.0.0'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
For information on the storage and rendering of entries, |
27
|
|
|
|
|
|
|
please see 'Documentation/Page.pod'. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NEW METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
If any of the new methods error, the error is permanent. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 new |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This creates the a object that represents a page. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Two arguments are taken. The first is a hash reference that |
38
|
|
|
|
|
|
|
is documented below. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head3 args hash |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head4 renderer |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This is the rendering engine the body should use. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
If not defined, html will be used. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head4 body |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This is the body. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head4 name |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This is the short name of the page. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head4 from |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This is the from address to use. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head4 files |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This is a list of files that will be made available with this page. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head4 publish |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Wether or not to publish it or not. This is a boolean value and uses "0" |
67
|
|
|
|
|
|
|
and "1". |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
If not specified, it uses "1". |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head4 toader |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This is a L object. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $foo = Toader::isaToaderDir->new(\%args); |
76
|
|
|
|
|
|
|
if ($foo->error){ |
77
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub new{ |
83
|
0
|
|
|
0
|
1
|
|
my %args; |
84
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
85
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
0
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my $self={ |
89
|
|
|
|
|
|
|
error=>undef, |
90
|
|
|
|
|
|
|
errorString=>'', |
91
|
|
|
|
|
|
|
perror=>undef, |
92
|
|
|
|
|
|
|
dir=>undef, |
93
|
|
|
|
|
|
|
errorExtra=>{ |
94
|
|
|
|
|
|
|
flags=>{ |
95
|
|
|
|
|
|
|
1=>'noPageName', |
96
|
|
|
|
|
|
|
2=>'emailMIMEcreationFailed', |
97
|
|
|
|
|
|
|
3=>'notAnArray', |
98
|
|
|
|
|
|
|
4=>'fileDoesNotExist', |
99
|
|
|
|
|
|
|
5=>'MIMEinfoError', |
100
|
|
|
|
|
|
|
6=>'unableToOpenFile', |
101
|
|
|
|
|
|
|
7=>'emailMIMEerror', |
102
|
|
|
|
|
|
|
8=>'noBody', |
103
|
|
|
|
|
|
|
9=>'notAtoaderDir', |
104
|
|
|
|
|
|
|
10=>'noLongAtoaderDir', |
105
|
|
|
|
|
|
|
11=>'nodirSet', |
106
|
|
|
|
|
|
|
12=>'pagesDirCreationFailed', |
107
|
|
|
|
|
|
|
13=>'publishValError', |
108
|
|
|
|
|
|
|
14=>'notAtoaderObj', |
109
|
|
|
|
|
|
|
15=>'getVCSerrored', |
110
|
|
|
|
|
|
|
16=>'VCSusableErrored', |
111
|
|
|
|
|
|
|
17=>'underVCSerror', |
112
|
|
|
|
|
|
|
18=>'VCSaddError', |
113
|
|
|
|
|
|
|
19=>'noToaderObj', |
114
|
|
|
|
|
|
|
}, |
115
|
|
|
|
|
|
|
}, |
116
|
|
|
|
|
|
|
VCSusable=>0, |
117
|
|
|
|
|
|
|
}; |
118
|
0
|
|
|
|
|
|
bless $self; |
119
|
|
|
|
|
|
|
|
120
|
0
|
0
|
|
|
|
|
if (!defined($args{renderer})) { |
121
|
0
|
|
|
|
|
|
$args{renderer}='html'; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
|
if (!defined($args{summary})) { |
125
|
0
|
|
|
|
|
|
$args{summary}=''; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
0
|
0
|
|
|
|
|
if (!defined($args{name})) { |
129
|
0
|
|
|
|
|
|
$self->{error}=1; |
130
|
0
|
|
|
|
|
|
$self->{perror}=1; |
131
|
0
|
|
|
|
|
|
$self->{errorString}='No name specified'; |
132
|
0
|
|
|
|
|
|
$self->warn; |
133
|
0
|
|
|
|
|
|
return $self; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
0
|
0
|
|
|
|
|
if (!defined($args{from})) { |
137
|
0
|
|
|
|
|
|
$args{from}=''; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
0
|
0
|
|
|
|
|
if (!defined($args{body})) { |
141
|
0
|
|
|
|
|
|
$args{body}=''; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
0
|
0
|
|
|
|
|
if (!defined($args{publish})) { |
145
|
0
|
|
|
|
|
|
$args{publish}='1'; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
0
|
0
|
0
|
|
|
|
if ( |
149
|
|
|
|
|
|
|
( $args{publish} ne "0" ) && |
150
|
|
|
|
|
|
|
( $args{publish} ne "1" ) |
151
|
|
|
|
|
|
|
){ |
152
|
0
|
|
|
|
|
|
$self->{error}=13; |
153
|
0
|
|
|
|
|
|
$self->{perror}=1; |
154
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$args{publish}.'" not a published boolean'; |
155
|
0
|
|
|
|
|
|
$self->warn; |
156
|
0
|
|
|
|
|
|
return $self; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
#this will hold the various parts |
160
|
0
|
|
|
|
|
|
my @parts; |
161
|
0
|
|
|
|
|
|
my $int=0; |
162
|
0
|
0
|
|
|
|
|
if (defined($args{files})) { |
163
|
0
|
0
|
|
|
|
|
if ( ref( $args{files} ne "ARRAY" ) ) { |
164
|
0
|
|
|
|
|
|
$self->{perror}=1; |
165
|
0
|
|
|
|
|
|
$self->{error}=3; |
166
|
0
|
|
|
|
|
|
$self->{errorString}="Has files specified, but the passed object is not a array"; |
167
|
0
|
|
|
|
|
|
$self->warn; |
168
|
0
|
|
|
|
|
|
return $self; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
#puts all the parts together |
172
|
0
|
|
|
|
|
|
while (defined( $args{files}[$int] )) { |
173
|
0
|
0
|
|
|
|
|
if (! -f $args{files}[$int] ) { |
174
|
0
|
|
|
|
|
|
$self->{error}=4; |
175
|
0
|
|
|
|
|
|
$self->{perror}=1; |
176
|
0
|
|
|
|
|
|
$self->{errorString}="'".$args{files}[$int]."' is not a file or does not exist"; |
177
|
0
|
|
|
|
|
|
$self->warn; |
178
|
0
|
|
|
|
|
|
return $self; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
#gets the MIME type |
182
|
0
|
|
|
|
|
|
my $mimetype=mimetype( $args{files}[$int] ); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
#makes sure it is a mimetype |
185
|
0
|
0
|
|
|
|
|
if ( !defined( $mimetype ) ) { |
186
|
0
|
|
|
|
|
|
$self->{error}=5; |
187
|
0
|
|
|
|
|
|
$self->{perror}=1; |
188
|
0
|
|
|
|
|
|
$self->{errorString}="'".$args{files}[$int]."' could not be read or does not exist"; |
189
|
0
|
|
|
|
|
|
$self->warn; |
190
|
0
|
|
|
|
|
|
return $self; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
#open and read the file |
194
|
0
|
|
|
|
|
|
my $fh; |
195
|
0
|
0
|
|
|
|
|
if ( ! open( $fh, '<', $args{files}[$int] ) ) { |
196
|
0
|
|
|
|
|
|
$self->{error}=6; |
197
|
0
|
|
|
|
|
|
$self->{perror}=1; |
198
|
0
|
|
|
|
|
|
$self->{errorString}="unable to open '".$args{files}[$int]."'"; |
199
|
0
|
|
|
|
|
|
$self->warn; |
200
|
0
|
|
|
|
|
|
return $self; |
201
|
|
|
|
|
|
|
} |
202
|
0
|
|
|
|
|
|
my $file=join('',<$fh>); |
203
|
0
|
|
|
|
|
|
close $fh; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
#create a short name for it... removing the path |
206
|
0
|
|
|
|
|
|
my $filename=$args{files}[$int]; |
207
|
0
|
|
|
|
|
|
$filename=~s/.*\///g; |
208
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
my $part=Email::MIME->create(attributes=>{ |
210
|
|
|
|
|
|
|
filename=>$filename, |
211
|
|
|
|
|
|
|
content_type=>$mimetype, |
212
|
|
|
|
|
|
|
encode=>"base64", |
213
|
|
|
|
|
|
|
}, |
214
|
|
|
|
|
|
|
body=>$file, |
215
|
|
|
|
|
|
|
); |
216
|
|
|
|
|
|
|
|
217
|
0
|
0
|
|
|
|
|
if (!defined( $part )) { |
218
|
0
|
|
|
|
|
|
$self->{error}=7; |
219
|
0
|
|
|
|
|
|
$self->{perror}=1; |
220
|
0
|
|
|
|
|
|
$self->{errorString}='Unable to create a MIME object for one of the files'; |
221
|
0
|
|
|
|
|
|
$self->warn; |
222
|
0
|
|
|
|
|
|
return $self; |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
push(@parts, $part); |
226
|
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
$int++; |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
#creates it |
233
|
0
|
|
|
|
|
|
my $mime=Email::MIME->create( |
234
|
|
|
|
|
|
|
header=>[ |
235
|
|
|
|
|
|
|
renderer=>$args{renderer}, |
236
|
|
|
|
|
|
|
name=>$args{name}, |
237
|
|
|
|
|
|
|
summary=>$args{summary}, |
238
|
|
|
|
|
|
|
publish=>$args{publish}, |
239
|
|
|
|
|
|
|
], |
240
|
|
|
|
|
|
|
body=>$args{body}, |
241
|
|
|
|
|
|
|
); |
242
|
|
|
|
|
|
|
|
243
|
0
|
0
|
|
|
|
|
if (!defined($mime)) { |
244
|
0
|
|
|
|
|
|
$self->{error}=2; |
245
|
0
|
|
|
|
|
|
$self->{perror}=1; |
246
|
0
|
|
|
|
|
|
$self->{errorString}='Unable to create Email::MIME object'; |
247
|
0
|
|
|
|
|
|
$self->warn; |
248
|
0
|
|
|
|
|
|
return $self; |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
#this sets the parts if needed |
252
|
0
|
0
|
|
|
|
|
if ( defined( $parts[0] ) ){ |
253
|
0
|
|
|
|
|
|
$mime->set_parts( \@parts ); |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
0
|
|
|
|
|
|
$self->{mime}=$mime; |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
#if we have a Toader object, reel it in |
259
|
0
|
0
|
|
|
|
|
if ( ! defined( $args{toader} ) ){ |
260
|
0
|
|
|
|
|
|
$self->{perror}=1; |
261
|
0
|
|
|
|
|
|
$self->{error}=19; |
262
|
0
|
|
|
|
|
|
$self->{errorString}='No $args{toader} specified'; |
263
|
0
|
|
|
|
|
|
$self->warn; |
264
|
0
|
|
|
|
|
|
return $self; |
265
|
|
|
|
|
|
|
} |
266
|
0
|
0
|
|
|
|
|
if ( ref( $args{toader} ) ne "Toader" ){ |
267
|
0
|
|
|
|
|
|
$self->{perror}=1; |
268
|
0
|
|
|
|
|
|
$self->{error}=14; |
269
|
0
|
|
|
|
|
|
$self->{errorString}='The object specified is a "'.ref($args{toader}).'"'; |
270
|
0
|
|
|
|
|
|
$self->warn; |
271
|
0
|
|
|
|
|
|
return $self; |
272
|
|
|
|
|
|
|
} |
273
|
0
|
|
|
|
|
|
$self->{toader}=$args{toader}; |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
#gets the Toader::VCS object |
276
|
0
|
|
|
|
|
|
$self->{vcs}=$self->{toader}->getVCS; |
277
|
0
|
0
|
|
|
|
|
if ( $self->{toader}->error ){ |
278
|
0
|
|
|
|
|
|
$self->{perror}=1; |
279
|
0
|
|
|
|
|
|
$self->{error}=15; |
280
|
0
|
|
|
|
|
|
$self->{errorString}='Toader->getVCS errored. error="'. |
281
|
|
|
|
|
|
|
$self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"'; |
282
|
0
|
|
|
|
|
|
$self->warn; |
283
|
0
|
|
|
|
|
|
return $self; |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
#checks if VCS is usable |
287
|
0
|
|
|
|
|
|
$self->{VCSusable}=$self->{vcs}->usable; |
288
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
289
|
0
|
|
|
|
|
|
$self->{perror}=1; |
290
|
0
|
|
|
|
|
|
$self->{error}=16; |
291
|
0
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->usable errored. error="'. |
292
|
|
|
|
|
|
|
$self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"'; |
293
|
0
|
|
|
|
|
|
$self->warn; |
294
|
0
|
|
|
|
|
|
return $self; |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
0
|
|
|
|
|
|
return $self; |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=head2 newFromString |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
This creates a new page from a string. |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
There are two required arguments, the first being a string |
305
|
|
|
|
|
|
|
containing the page in question and the second being |
306
|
|
|
|
|
|
|
L object. |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
my $foo=Toader::Page->newFromString($pageString, $toader); |
309
|
|
|
|
|
|
|
if($foo->error){ |
310
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
311
|
|
|
|
|
|
|
} |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=cut |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
sub newFromString{ |
316
|
0
|
|
|
0
|
1
|
|
my $string=$_[1]; |
317
|
0
|
|
|
|
|
|
my $toader=$_[2]; |
318
|
|
|
|
|
|
|
|
319
|
0
|
|
|
|
|
|
my $self={ |
320
|
|
|
|
|
|
|
error=>undef, |
321
|
|
|
|
|
|
|
errorString=>'', |
322
|
|
|
|
|
|
|
module=>'Toader-Page', |
323
|
|
|
|
|
|
|
perror=>undef, |
324
|
|
|
|
|
|
|
dir=>undef, |
325
|
|
|
|
|
|
|
errorExtra=>{ |
326
|
|
|
|
|
|
|
flags=>{ |
327
|
|
|
|
|
|
|
1=>'noPageName', |
328
|
|
|
|
|
|
|
2=>'emailMIMEcreationFailed', |
329
|
|
|
|
|
|
|
3=>'notAnArray', |
330
|
|
|
|
|
|
|
4=>'fileDoesNotExist', |
331
|
|
|
|
|
|
|
5=>'MIMEinfoError', |
332
|
|
|
|
|
|
|
6=>'unableToOpenFile', |
333
|
|
|
|
|
|
|
7=>'emailMIMEerror', |
334
|
|
|
|
|
|
|
8=>'noBody', |
335
|
|
|
|
|
|
|
9=>'notAtoaderDir', |
336
|
|
|
|
|
|
|
10=>'noLongAtoaderDir', |
337
|
|
|
|
|
|
|
11=>'nodirSet', |
338
|
|
|
|
|
|
|
12=>'pagesDirCreationFailed', |
339
|
|
|
|
|
|
|
13=>'publishValError', |
340
|
|
|
|
|
|
|
14=>'notAtoaderObj', |
341
|
|
|
|
|
|
|
15=>'getVCSfailed', |
342
|
|
|
|
|
|
|
16=>'VCSusableFailed', |
343
|
|
|
|
|
|
|
17=>'underVCSerror', |
344
|
|
|
|
|
|
|
18=>'VCSaddError', |
345
|
|
|
|
|
|
|
19=>'noToaderObj', |
346
|
|
|
|
|
|
|
}, |
347
|
|
|
|
|
|
|
}, |
348
|
|
|
|
|
|
|
VCSusable=>0, |
349
|
|
|
|
|
|
|
}; |
350
|
0
|
|
|
|
|
|
bless $self; |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
#Email::MIME will exit if we pass it a null value |
353
|
0
|
0
|
|
|
|
|
if (!defined($string)) { |
354
|
0
|
|
|
|
|
|
$self->{error}=8; |
355
|
0
|
|
|
|
|
|
$self->{perror}=1; |
356
|
0
|
|
|
|
|
|
$self->{errorString}='The string is null'; |
357
|
0
|
|
|
|
|
|
$self->warn; |
358
|
0
|
|
|
|
|
|
return $self; |
359
|
|
|
|
|
|
|
} |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
#creates the MIME object |
362
|
0
|
|
|
|
|
|
my $mime=Email::MIME->new($string); |
363
|
0
|
0
|
|
|
|
|
if (!defined($mime)) { |
364
|
0
|
|
|
|
|
|
$self->{error}=2; |
365
|
0
|
|
|
|
|
|
$self->{perror}=1; |
366
|
0
|
|
|
|
|
|
$self->{errorString}='Unable to create Email::MIME object'; |
367
|
0
|
|
|
|
|
|
$self->warn; |
368
|
0
|
|
|
|
|
|
return $self; |
369
|
|
|
|
|
|
|
} |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
#make sure we have a short name |
372
|
0
|
0
|
|
|
|
|
if (!defined( $mime->header( "name" ) )) { |
373
|
0
|
|
|
|
|
|
$self->{error}=1; |
374
|
0
|
|
|
|
|
|
$self->{perror}=1; |
375
|
0
|
|
|
|
|
|
$self->{errorString}='No name specified'; |
376
|
0
|
|
|
|
|
|
$self->warn; |
377
|
0
|
|
|
|
|
|
return $self; |
378
|
|
|
|
|
|
|
} |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
#make sure we have a from and if not set it to blank |
381
|
0
|
0
|
|
|
|
|
if (!defined( $mime->header( "from" ) )) { |
382
|
0
|
|
|
|
|
|
$mime->header_set(from=>''); |
383
|
|
|
|
|
|
|
} |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
#set blank summary if not is specified |
386
|
0
|
0
|
|
|
|
|
if (!defined( $mime->header( "summary" ) )) { |
387
|
0
|
|
|
|
|
|
$mime->header_set(summary=>''); |
388
|
|
|
|
|
|
|
} |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
#make sure we have a renderer type |
392
|
0
|
0
|
|
|
|
|
if (!defined( $mime->header( "renderer" ) )) { |
393
|
0
|
|
|
|
|
|
$mime->header_set(renderer=>'html'); |
394
|
|
|
|
|
|
|
} |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
#make sure we have publish set |
397
|
0
|
0
|
|
|
|
|
if (!defined( $mime->header( "publish" ) )) { |
398
|
0
|
|
|
|
|
|
$mime->header_set(publish=>'1'); |
399
|
|
|
|
|
|
|
} |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
#makes sure the publish value is good |
402
|
0
|
0
|
0
|
|
|
|
if ( |
403
|
|
|
|
|
|
|
( $mime->header( "publish" ) ne "0" ) && |
404
|
|
|
|
|
|
|
( $mime->header( "publish" ) ne "1" ) |
405
|
|
|
|
|
|
|
){ |
406
|
0
|
|
|
|
|
|
$self->{perror}=1; |
407
|
0
|
|
|
|
|
|
$self->{error}=13; |
408
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$mime->header( "publish" ). |
409
|
|
|
|
|
|
|
'" is not a recognized boolean value'; |
410
|
0
|
|
|
|
|
|
$self->warn; |
411
|
0
|
|
|
|
|
|
return $self; |
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
|
414
|
0
|
|
|
|
|
|
$self->{mime}=$mime; |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
#if we have a Toader object, reel it in |
417
|
0
|
0
|
|
|
|
|
if ( ! defined( $toader ) ){ |
418
|
0
|
|
|
|
|
|
$self->{perror}=1; |
419
|
0
|
|
|
|
|
|
$self->{error}=19; |
420
|
0
|
|
|
|
|
|
$self->{errorString}='No Toader object specified'; |
421
|
0
|
|
|
|
|
|
$self->warn; |
422
|
0
|
|
|
|
|
|
return $self; |
423
|
|
|
|
|
|
|
} |
424
|
0
|
0
|
|
|
|
|
if ( ref( $toader ) ne "Toader" ){ |
425
|
0
|
|
|
|
|
|
$self->{perror}=1; |
426
|
0
|
|
|
|
|
|
$self->{error}=14; |
427
|
0
|
|
|
|
|
|
$self->{errorString}='The object specified is a "'.ref($toader).'"'; |
428
|
0
|
|
|
|
|
|
$self->warn; |
429
|
0
|
|
|
|
|
|
return $self; |
430
|
|
|
|
|
|
|
} |
431
|
0
|
|
|
|
|
|
$self->{toader}=$toader; |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
#gets the Toader::VCS object |
434
|
0
|
|
|
|
|
|
$self->{vcs}=$self->{toader}->getVCS; |
435
|
0
|
0
|
|
|
|
|
if ( $toader->error ){ |
436
|
0
|
|
|
|
|
|
$self->{perror}=1; |
437
|
0
|
|
|
|
|
|
$self->{error}=15; |
438
|
0
|
|
|
|
|
|
$self->{errorString}='Toader->getVCS errored. error="'. |
439
|
|
|
|
|
|
|
$self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"'; |
440
|
0
|
|
|
|
|
|
$self->warn; |
441
|
0
|
|
|
|
|
|
return $self; |
442
|
|
|
|
|
|
|
} |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
#checks if VCS is usable |
445
|
0
|
|
|
|
|
|
$self->{VCSusable}=$self->{vcs}->usable; |
446
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
447
|
0
|
|
|
|
|
|
$self->{perror}=1; |
448
|
0
|
|
|
|
|
|
$self->{error}=16; |
449
|
0
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->usable errored. error="'. |
450
|
|
|
|
|
|
|
$self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"'; |
451
|
0
|
|
|
|
|
|
$self->warn; |
452
|
0
|
|
|
|
|
|
return $self; |
453
|
|
|
|
|
|
|
} |
454
|
|
|
|
|
|
|
|
455
|
0
|
|
|
|
|
|
return $self; |
456
|
|
|
|
|
|
|
} |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
=head1 GENERAL METHODS |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
=head2 as_string |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
This returns the page as a string. |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
my $mimeString=$foo->as_string; |
465
|
|
|
|
|
|
|
if($foo->error) |
466
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
467
|
|
|
|
|
|
|
} |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
=cut |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
sub as_string{ |
472
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
473
|
|
|
|
|
|
|
|
474
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
475
|
0
|
|
|
|
|
|
return undef; |
476
|
|
|
|
|
|
|
} |
477
|
|
|
|
|
|
|
|
478
|
0
|
|
|
|
|
|
return $self->{mime}->as_string; |
479
|
|
|
|
|
|
|
} |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
=head2 bodyGet |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
This gets body. |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
my $body=$foo->bodyGet; |
486
|
|
|
|
|
|
|
if($foo->error){ |
487
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
488
|
|
|
|
|
|
|
} |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
=cut |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
sub bodyGet{ |
493
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
494
|
|
|
|
|
|
|
|
495
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
496
|
0
|
|
|
|
|
|
return undef; |
497
|
|
|
|
|
|
|
} |
498
|
|
|
|
|
|
|
|
499
|
0
|
|
|
|
|
|
my @parts=$self->{mime}->subparts; |
500
|
|
|
|
|
|
|
|
501
|
0
|
|
|
|
|
|
my $int=0; |
502
|
0
|
|
|
|
|
|
while ( defined( $parts[$int] ) ){ |
503
|
0
|
0
|
|
|
|
|
if ( ! defined( $parts[$int]->filename ) ){ |
504
|
0
|
|
|
|
|
|
return $parts[$int]->body; |
505
|
|
|
|
|
|
|
} |
506
|
|
|
|
|
|
|
|
507
|
0
|
|
|
|
|
|
$int++; |
508
|
|
|
|
|
|
|
} |
509
|
|
|
|
|
|
|
|
510
|
0
|
|
|
|
|
|
return $self->{mime}->body; |
511
|
|
|
|
|
|
|
} |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
=head2 bodySet |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
This sets the body. |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
One argument is required and it is the body. |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
$foo->bodySet($body); |
520
|
|
|
|
|
|
|
if($foo->error){ |
521
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
522
|
|
|
|
|
|
|
} |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
=cut |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
sub bodySet{ |
527
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
528
|
0
|
|
|
|
|
|
my $body=$_[1]; |
529
|
|
|
|
|
|
|
|
530
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
531
|
0
|
|
|
|
|
|
return undef; |
532
|
|
|
|
|
|
|
} |
533
|
|
|
|
|
|
|
|
534
|
0
|
0
|
|
|
|
|
if (!defined($body)) { |
535
|
0
|
|
|
|
|
|
$self->{error}=8; |
536
|
0
|
|
|
|
|
|
$self->{errorString}='No body defined'; |
537
|
0
|
|
|
|
|
|
$self->warn; |
538
|
0
|
|
|
|
|
|
return undef; |
539
|
|
|
|
|
|
|
} |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
|
542
|
0
|
|
|
|
|
|
my @parts=$self->{mime}->subparts; |
543
|
|
|
|
|
|
|
|
544
|
0
|
0
|
|
|
|
|
if ( defined( $parts[1] ) ){ |
545
|
0
|
|
|
|
|
|
my $int=0; |
546
|
0
|
|
|
|
|
|
while ( defined( $parts[$int] ) ){ |
547
|
0
|
0
|
|
|
|
|
if ( ! defined( $parts[$int]->filename ) ){ |
548
|
0
|
|
|
|
|
|
$parts[$int]->body_set($body); |
549
|
|
|
|
|
|
|
} |
550
|
|
|
|
|
|
|
|
551
|
0
|
|
|
|
|
|
$int++; |
552
|
|
|
|
|
|
|
} |
553
|
|
|
|
|
|
|
|
554
|
0
|
|
|
|
|
|
$self->{mime}->parts_set( \@parts ); |
555
|
|
|
|
|
|
|
|
556
|
0
|
|
|
|
|
|
return 1; |
557
|
|
|
|
|
|
|
} |
558
|
|
|
|
|
|
|
|
559
|
0
|
|
|
|
|
|
$self->{mime}->body_set($body); |
560
|
|
|
|
|
|
|
|
561
|
0
|
|
|
|
|
|
return 1; |
562
|
|
|
|
|
|
|
} |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
=head2 dirGet |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
This gets L directory this entry is associated with. |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
This will only error if a permanent error is set. |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
my $dir=$foo->dirGet; |
571
|
|
|
|
|
|
|
if($foo->error){ |
572
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
573
|
|
|
|
|
|
|
} |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
=cut |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
sub dirGet{ |
578
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
579
|
|
|
|
|
|
|
|
580
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
581
|
0
|
|
|
|
|
|
return undef; |
582
|
|
|
|
|
|
|
} |
583
|
|
|
|
|
|
|
|
584
|
0
|
|
|
|
|
|
return $self->{dir}; |
585
|
|
|
|
|
|
|
} |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
=head2 dirSet |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
This sets L directory this entry is associated with. |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
One argument is taken and it is the L directory to set it to. |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
$foo->dirSet($toaderDirectory); |
594
|
|
|
|
|
|
|
if($foo->error){ |
595
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
596
|
|
|
|
|
|
|
} |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
=cut |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
sub dirSet{ |
601
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
602
|
0
|
|
|
|
|
|
my $dir=$_[1]; |
603
|
|
|
|
|
|
|
|
604
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
605
|
0
|
|
|
|
|
|
return undef; |
606
|
|
|
|
|
|
|
} |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
#cleans up the naming |
609
|
0
|
|
|
|
|
|
my $pathHelper=Toader::pathHelper->new($dir); |
610
|
0
|
|
|
|
|
|
$dir=$pathHelper->cleanup($dir); |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
#checks if the directory is Toader directory or not |
613
|
0
|
|
|
|
|
|
my $isatd=Toader::isaToaderDir->new; |
614
|
0
|
|
|
|
|
|
my $returned=$isatd->isaToaderDir($dir); |
615
|
0
|
0
|
|
|
|
|
if (! $returned ) { |
616
|
0
|
|
|
|
|
|
$self->{error}=9; |
617
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$dir.'" is not a Toader directory'; |
618
|
0
|
|
|
|
|
|
$self->warn; |
619
|
0
|
|
|
|
|
|
return undef; |
620
|
|
|
|
|
|
|
} |
621
|
|
|
|
|
|
|
|
622
|
0
|
|
|
|
|
|
$self->{dir}=$dir; |
623
|
|
|
|
|
|
|
|
624
|
0
|
|
|
|
|
|
return 1; |
625
|
|
|
|
|
|
|
} |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
=head2 fromGet |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
This returns the from. |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
my $from=$foo->fromGet; |
632
|
|
|
|
|
|
|
if($foo->error){ |
633
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
=cut |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
sub fromGet{ |
639
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
640
|
|
|
|
|
|
|
|
641
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
642
|
0
|
|
|
|
|
|
return undef; |
643
|
|
|
|
|
|
|
} |
644
|
|
|
|
|
|
|
|
645
|
0
|
|
|
|
|
|
return $self->{mime}->header('From'); |
646
|
|
|
|
|
|
|
} |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
=head2 fromSet |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
This sets the from. |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
One argument is taken and it is the name. |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
$foo->fromSet($name); |
655
|
|
|
|
|
|
|
if($foo->error){ |
656
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
657
|
|
|
|
|
|
|
} |
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
=cut |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
sub fromSet{ |
662
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
663
|
0
|
|
|
|
|
|
my $from=$_[1]; |
664
|
|
|
|
|
|
|
|
665
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
666
|
0
|
|
|
|
|
|
return undef; |
667
|
|
|
|
|
|
|
} |
668
|
|
|
|
|
|
|
|
669
|
0
|
0
|
|
|
|
|
if (!defined( $from )) { |
670
|
0
|
|
|
|
|
|
$self->{error}=9; |
671
|
0
|
|
|
|
|
|
$self->{errorString}='No short name specified'; |
672
|
0
|
|
|
|
|
|
$self->warn; |
673
|
0
|
|
|
|
|
|
return $self; |
674
|
|
|
|
|
|
|
} |
675
|
|
|
|
|
|
|
|
676
|
0
|
|
|
|
|
|
$self->{mime}->header_set('From'=>$from); |
677
|
|
|
|
|
|
|
|
678
|
0
|
|
|
|
|
|
return 1; |
679
|
|
|
|
|
|
|
} |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
=head2 nameGet |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
This returns the name. |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
my $name=$foo->nameGet; |
686
|
|
|
|
|
|
|
if($foo->error){ |
687
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
688
|
|
|
|
|
|
|
} |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
=cut |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
sub nameGet{ |
693
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
694
|
|
|
|
|
|
|
|
695
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
696
|
0
|
|
|
|
|
|
return undef; |
697
|
|
|
|
|
|
|
} |
698
|
|
|
|
|
|
|
|
699
|
0
|
|
|
|
|
|
return $self->{mime}->header('name'); |
700
|
|
|
|
|
|
|
} |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
=head2 nameSet |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
This sets the short name. |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
One argument is taken and it is the name. |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
$foo->nameSet($name); |
709
|
|
|
|
|
|
|
if($foo->error){ |
710
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
711
|
|
|
|
|
|
|
} |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
=cut |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
sub nameSet{ |
716
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
717
|
0
|
|
|
|
|
|
my $name=$_[1]; |
718
|
|
|
|
|
|
|
|
719
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
720
|
0
|
|
|
|
|
|
return undef; |
721
|
|
|
|
|
|
|
} |
722
|
|
|
|
|
|
|
|
723
|
0
|
0
|
|
|
|
|
if (!defined( $name )) { |
724
|
0
|
|
|
|
|
|
$self->{error}=1; |
725
|
0
|
|
|
|
|
|
$self->{errorString}='No short name specified'; |
726
|
0
|
|
|
|
|
|
$self->warn; |
727
|
0
|
|
|
|
|
|
return $self; |
728
|
|
|
|
|
|
|
} |
729
|
|
|
|
|
|
|
|
730
|
0
|
|
|
|
|
|
$self->{mime}->header_set('name'=>$name); |
731
|
|
|
|
|
|
|
|
732
|
0
|
|
|
|
|
|
return 1; |
733
|
|
|
|
|
|
|
} |
734
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
=head2 publishGet |
736
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
This returns the publish value. |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
my $publish=$foo->publishGet; |
740
|
|
|
|
|
|
|
if($foo->error){ |
741
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
742
|
|
|
|
|
|
|
} |
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
=cut |
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
sub publishGet{ |
747
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
748
|
|
|
|
|
|
|
|
749
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
750
|
0
|
|
|
|
|
|
return undef; |
751
|
|
|
|
|
|
|
} |
752
|
|
|
|
|
|
|
|
753
|
0
|
|
|
|
|
|
my $publish=$self->{mime}->header('publish'); |
754
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
#if not defined, return the default |
756
|
0
|
0
|
|
|
|
|
if ( ! defined( $publish ) ){ |
757
|
0
|
|
|
|
|
|
return '1'; |
758
|
|
|
|
|
|
|
} |
759
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
#make sure it is a recognized boolean value |
761
|
0
|
0
|
0
|
|
|
|
if ( |
762
|
|
|
|
|
|
|
( $publish ne '0' ) && |
763
|
|
|
|
|
|
|
( $publish ne '1' ) |
764
|
|
|
|
|
|
|
){ |
765
|
0
|
|
|
|
|
|
$self->{error}=13; |
766
|
0
|
|
|
|
|
|
$self->{errorString}='Not a recognized boolean value'; |
767
|
0
|
|
|
|
|
|
$self->warn; |
768
|
0
|
|
|
|
|
|
return undef; |
769
|
|
|
|
|
|
|
} |
770
|
|
|
|
|
|
|
|
771
|
0
|
|
|
|
|
|
return $publish; |
772
|
|
|
|
|
|
|
} |
773
|
|
|
|
|
|
|
|
774
|
|
|
|
|
|
|
=head2 publishSet |
775
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
This sets the publish value. |
777
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
One argument is taken and it is the publish value. |
779
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
If no value is set, it uses the default, "1". |
781
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
It must be a recognized boolean value, either "0" or "1". |
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
$foo->publishSet($publish); |
785
|
|
|
|
|
|
|
if($foo->error){ |
786
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
787
|
|
|
|
|
|
|
} |
788
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
=cut |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
sub publishSet{ |
792
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
793
|
0
|
|
|
|
|
|
my $publish=$_[1]; |
794
|
|
|
|
|
|
|
|
795
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
796
|
0
|
|
|
|
|
|
return undef; |
797
|
|
|
|
|
|
|
} |
798
|
|
|
|
|
|
|
|
799
|
0
|
0
|
|
|
|
|
if (!defined( $publish )) { |
800
|
0
|
|
|
|
|
|
$publish='1'; |
801
|
|
|
|
|
|
|
} |
802
|
|
|
|
|
|
|
|
803
|
0
|
0
|
0
|
|
|
|
if ( |
804
|
|
|
|
|
|
|
( $publish ne '0' ) && |
805
|
|
|
|
|
|
|
( $publish ne '1' ) |
806
|
|
|
|
|
|
|
){ |
807
|
0
|
|
|
|
|
|
$self->error=13; |
808
|
0
|
|
|
|
|
|
$self->errorString='The publish value is not "0" or "1", but "'.$publish.'"'; |
809
|
0
|
|
|
|
|
|
$self->warn; |
810
|
0
|
|
|
|
|
|
return undef; |
811
|
|
|
|
|
|
|
} |
812
|
|
|
|
|
|
|
|
813
|
|
|
|
|
|
|
|
814
|
0
|
|
|
|
|
|
$self->{mime}->header_set('publish'=>$publish); |
815
|
|
|
|
|
|
|
|
816
|
0
|
|
|
|
|
|
return 1; |
817
|
|
|
|
|
|
|
} |
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
=head2 rendererGet |
820
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
This returns the renderer type. |
822
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
my $renderer=$foo->rendererGet; |
824
|
|
|
|
|
|
|
if($foo->error){ |
825
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
826
|
|
|
|
|
|
|
} |
827
|
|
|
|
|
|
|
|
828
|
|
|
|
|
|
|
=cut |
829
|
|
|
|
|
|
|
|
830
|
|
|
|
|
|
|
sub rendererGet{ |
831
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
832
|
|
|
|
|
|
|
|
833
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
834
|
0
|
|
|
|
|
|
return undef; |
835
|
|
|
|
|
|
|
} |
836
|
|
|
|
|
|
|
|
837
|
0
|
|
|
|
|
|
return $self->{mime}->header('renderer'); |
838
|
|
|
|
|
|
|
} |
839
|
|
|
|
|
|
|
|
840
|
|
|
|
|
|
|
=head2 rendererSet |
841
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
This sets the renderer type. |
843
|
|
|
|
|
|
|
|
844
|
|
|
|
|
|
|
One argument is taken and it is the render type. |
845
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
A value of undef sets it to the default, 'html'. |
847
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
my $renderer=$foo->rendererGet; |
849
|
|
|
|
|
|
|
if($foo->error){ |
850
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
851
|
|
|
|
|
|
|
} |
852
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
=cut |
854
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
sub rendererSet{ |
856
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
857
|
0
|
|
|
|
|
|
my $renderer=$_[1]; |
858
|
|
|
|
|
|
|
|
859
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
860
|
0
|
|
|
|
|
|
return undef; |
861
|
|
|
|
|
|
|
} |
862
|
|
|
|
|
|
|
|
863
|
0
|
0
|
|
|
|
|
if (!defined( $renderer )) { |
864
|
0
|
|
|
|
|
|
$renderer='html'; |
865
|
|
|
|
|
|
|
} |
866
|
|
|
|
|
|
|
|
867
|
0
|
|
|
|
|
|
$self->{mime}->header_set('renderer'=>$renderer); |
868
|
|
|
|
|
|
|
|
869
|
0
|
|
|
|
|
|
return 1; |
870
|
|
|
|
|
|
|
} |
871
|
|
|
|
|
|
|
|
872
|
|
|
|
|
|
|
=head2 subpartsAdd |
873
|
|
|
|
|
|
|
|
874
|
|
|
|
|
|
|
This adds a new file as a subpart. |
875
|
|
|
|
|
|
|
|
876
|
|
|
|
|
|
|
One argument is required and it is the path to the file. |
877
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
$foo->subpartsAdd( $file ); |
879
|
|
|
|
|
|
|
if ( $foo->error ){ |
880
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
881
|
|
|
|
|
|
|
} |
882
|
|
|
|
|
|
|
|
883
|
|
|
|
|
|
|
=cut |
884
|
|
|
|
|
|
|
|
885
|
|
|
|
|
|
|
sub subpartsAdd{ |
886
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
887
|
0
|
|
|
|
|
|
my $file=$_[1]; |
888
|
|
|
|
|
|
|
|
889
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
890
|
0
|
|
|
|
|
|
return undef; |
891
|
|
|
|
|
|
|
} |
892
|
|
|
|
|
|
|
|
893
|
|
|
|
|
|
|
#makes sure a file is specified |
894
|
0
|
0
|
|
|
|
|
if ( ! defined( $file ) ){ |
895
|
0
|
|
|
|
|
|
$self->{error}=18; |
896
|
0
|
|
|
|
|
|
$self->{errorstring}='No file specified'; |
897
|
0
|
|
|
|
|
|
$self->warn; |
898
|
0
|
|
|
|
|
|
return undef; |
899
|
|
|
|
|
|
|
} |
900
|
|
|
|
|
|
|
|
901
|
|
|
|
|
|
|
#makes sure the file exists and is a file |
902
|
0
|
0
|
|
|
|
|
if ( ! -f $file ){ |
903
|
0
|
|
|
|
|
|
$self->{error}=4; |
904
|
0
|
|
|
|
|
|
$self->{errorString}='The file, "'.$file.'", does not exist or is not a file'; |
905
|
0
|
|
|
|
|
|
$self->warn; |
906
|
0
|
|
|
|
|
|
return undef; |
907
|
|
|
|
|
|
|
} |
908
|
|
|
|
|
|
|
|
909
|
|
|
|
|
|
|
#gets the MIME type |
910
|
0
|
|
|
|
|
|
my $mimetype=mimetype( $file ); |
911
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
#makes sure it is a mimetype |
913
|
0
|
0
|
|
|
|
|
if ( !defined( $mimetype ) ) { |
914
|
0
|
|
|
|
|
|
$self->{error}=5; |
915
|
0
|
|
|
|
|
|
$self->{errorString}="'".$file."' could not be read or does not exist"; |
916
|
0
|
|
|
|
|
|
$self->warn; |
917
|
0
|
|
|
|
|
|
return $self; |
918
|
|
|
|
|
|
|
} |
919
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
#create a short name for it... removing the path |
921
|
0
|
|
|
|
|
|
my $filename=$file; |
922
|
0
|
|
|
|
|
|
$filename=~s/.*\///g; |
923
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
#open and read the file |
925
|
0
|
|
|
|
|
|
my $fh; |
926
|
0
|
0
|
|
|
|
|
if ( ! open( $fh, '<', $file ) ) { |
927
|
0
|
|
|
|
|
|
$self->{error}=6; |
928
|
0
|
|
|
|
|
|
$self->{errorString}="Unable to open '".$file."'"; |
929
|
0
|
|
|
|
|
|
$self->warn; |
930
|
0
|
|
|
|
|
|
return undef; |
931
|
|
|
|
|
|
|
} |
932
|
0
|
|
|
|
|
|
my $body=join('',<$fh>); |
933
|
0
|
|
|
|
|
|
close $fh; |
934
|
|
|
|
|
|
|
|
935
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
#creates the part |
937
|
0
|
|
|
|
|
|
my $part=Email::MIME->create(attributes=>{ |
938
|
|
|
|
|
|
|
filename=>$filename, |
939
|
|
|
|
|
|
|
content_type=>$mimetype, |
940
|
|
|
|
|
|
|
encode=>"base64", |
941
|
|
|
|
|
|
|
}, |
942
|
|
|
|
|
|
|
body=>$body, |
943
|
|
|
|
|
|
|
); |
944
|
0
|
|
|
|
|
|
my @parts; |
945
|
0
|
|
|
|
|
|
push( @parts, $part ); |
946
|
0
|
|
|
|
|
|
$self->{mime}->parts_add( \@parts ); |
947
|
|
|
|
|
|
|
|
948
|
0
|
|
|
|
|
|
return 1; |
949
|
|
|
|
|
|
|
} |
950
|
|
|
|
|
|
|
|
951
|
|
|
|
|
|
|
=head2 subpartsExtract |
952
|
|
|
|
|
|
|
|
953
|
|
|
|
|
|
|
This extracts the subparts of a entry. |
954
|
|
|
|
|
|
|
|
955
|
|
|
|
|
|
|
One argument is extracted, it is the directory |
956
|
|
|
|
|
|
|
to extract the files to. |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
$foo->subpartsExtract( $dir ); |
959
|
|
|
|
|
|
|
if ( $foo->error ){ |
960
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
961
|
|
|
|
|
|
|
} |
962
|
|
|
|
|
|
|
|
963
|
|
|
|
|
|
|
=cut |
964
|
|
|
|
|
|
|
|
965
|
|
|
|
|
|
|
sub subpartsExtract{ |
966
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
967
|
0
|
|
|
|
|
|
my $dir=$_[1]; |
968
|
|
|
|
|
|
|
|
969
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
970
|
0
|
|
|
|
|
|
return undef; |
971
|
|
|
|
|
|
|
} |
972
|
|
|
|
|
|
|
|
973
|
0
|
0
|
|
|
|
|
if ( ! defined( $dir ) ){ |
974
|
0
|
|
|
|
|
|
$self->{error}=11; |
975
|
0
|
|
|
|
|
|
$self->{errorString}='No directory specified'; |
976
|
0
|
|
|
|
|
|
$self->warn; |
977
|
0
|
|
|
|
|
|
return undef; |
978
|
|
|
|
|
|
|
} |
979
|
|
|
|
|
|
|
|
980
|
|
|
|
|
|
|
#make sure it exists and is a directory |
981
|
0
|
0
|
|
|
|
|
if ( ! -d $dir ){ |
982
|
0
|
|
|
|
|
|
$self->{error}=17; |
983
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$dir.'" is not a directory or does not exist'; |
984
|
0
|
|
|
|
|
|
$self->warn; |
985
|
0
|
|
|
|
|
|
return undef; |
986
|
|
|
|
|
|
|
} |
987
|
|
|
|
|
|
|
|
988
|
0
|
|
|
|
|
|
my @subparts=$self->subpartsGet; |
989
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
990
|
0
|
|
|
|
|
|
$self->warnString('Failed to get the subparts'); |
991
|
0
|
|
|
|
|
|
return undef; |
992
|
|
|
|
|
|
|
} |
993
|
|
|
|
|
|
|
|
994
|
|
|
|
|
|
|
# no subparts to write to the FS |
995
|
0
|
0
|
|
|
|
|
if ( ! defined( $subparts[0] ) ){ |
996
|
0
|
|
|
|
|
|
return 1; |
997
|
|
|
|
|
|
|
} |
998
|
|
|
|
|
|
|
|
999
|
0
|
|
|
|
|
|
my $int=0; |
1000
|
0
|
|
|
|
|
|
while ( defined( $subparts[$int] ) ){ |
1001
|
0
|
|
|
|
|
|
my $file=$subparts[$int]->filename; |
1002
|
0
|
0
|
|
|
|
|
if( defined( $file ) ){ |
1003
|
0
|
|
|
|
|
|
my $file=$dir.'/'.$file; |
1004
|
|
|
|
|
|
|
|
1005
|
0
|
|
|
|
|
|
my $fh; |
1006
|
0
|
0
|
|
|
|
|
if ( ! open( $fh, '>', $file ) ){ |
1007
|
0
|
|
|
|
|
|
$self->{error}=18; |
1008
|
0
|
|
|
|
|
|
$self->{errorString}='"Failed to open "'.$file. |
1009
|
|
|
|
|
|
|
'" for writing the body of a subpart out to'; |
1010
|
0
|
|
|
|
|
|
$self->warn; |
1011
|
0
|
|
|
|
|
|
return undef; |
1012
|
|
|
|
|
|
|
} |
1013
|
0
|
|
|
|
|
|
print $fh $subparts[$int]->body; |
1014
|
0
|
|
|
|
|
|
close( $fh ); |
1015
|
|
|
|
|
|
|
} |
1016
|
|
|
|
|
|
|
|
1017
|
0
|
|
|
|
|
|
$int++; |
1018
|
|
|
|
|
|
|
} |
1019
|
|
|
|
|
|
|
|
1020
|
0
|
|
|
|
|
|
return 1; |
1021
|
|
|
|
|
|
|
} |
1022
|
|
|
|
|
|
|
|
1023
|
|
|
|
|
|
|
=head2 subpartsGet |
1024
|
|
|
|
|
|
|
|
1025
|
|
|
|
|
|
|
This returns the results from the subparts |
1026
|
|
|
|
|
|
|
methods from the internal L object. |
1027
|
|
|
|
|
|
|
|
1028
|
|
|
|
|
|
|
my @parts=$foo->subpartsGet; |
1029
|
|
|
|
|
|
|
if ( $foo->error ){ |
1030
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
1031
|
|
|
|
|
|
|
} |
1032
|
|
|
|
|
|
|
|
1033
|
|
|
|
|
|
|
=cut |
1034
|
|
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
sub subpartsGet{ |
1036
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
1037
|
|
|
|
|
|
|
|
1038
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
1039
|
0
|
|
|
|
|
|
return undef; |
1040
|
|
|
|
|
|
|
} |
1041
|
|
|
|
|
|
|
|
1042
|
0
|
|
|
|
|
|
return $self->{mime}->subparts; |
1043
|
|
|
|
|
|
|
} |
1044
|
|
|
|
|
|
|
|
1045
|
|
|
|
|
|
|
=head2 subpartsList |
1046
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
This returns a list filenames for the subparts. |
1048
|
|
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
my @files=$foo->subpartsList; |
1050
|
|
|
|
|
|
|
if ( $foo->error ){ |
1051
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
1052
|
|
|
|
|
|
|
} |
1053
|
|
|
|
|
|
|
|
1054
|
|
|
|
|
|
|
=cut |
1055
|
|
|
|
|
|
|
|
1056
|
|
|
|
|
|
|
sub subpartsList{ |
1057
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
1058
|
|
|
|
|
|
|
|
1059
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
1060
|
0
|
|
|
|
|
|
return undef; |
1061
|
|
|
|
|
|
|
} |
1062
|
|
|
|
|
|
|
|
1063
|
0
|
|
|
|
|
|
my @subparts=$self->subpartsGet; |
1064
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
1065
|
0
|
|
|
|
|
|
$self->warnString('Failed to get the subparts'); |
1066
|
0
|
|
|
|
|
|
return undef; |
1067
|
|
|
|
|
|
|
} |
1068
|
|
|
|
|
|
|
|
1069
|
0
|
|
|
|
|
|
my @files; |
1070
|
0
|
|
|
|
|
|
my $int=0; |
1071
|
0
|
|
|
|
|
|
while( defined( $subparts[$int] ) ){ |
1072
|
0
|
0
|
|
|
|
|
if ( defined( $subparts[$int]->filename ) ){ |
1073
|
0
|
|
|
|
|
|
push( @files, $subparts[$int]->filename ); |
1074
|
|
|
|
|
|
|
} |
1075
|
|
|
|
|
|
|
|
1076
|
0
|
|
|
|
|
|
$int++; |
1077
|
|
|
|
|
|
|
} |
1078
|
|
|
|
|
|
|
|
1079
|
0
|
|
|
|
|
|
return @files; |
1080
|
|
|
|
|
|
|
} |
1081
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
=head2 subpartsRemove |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
This removes the specified subpart. |
1085
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
One argument is required and it is the name of the |
1087
|
|
|
|
|
|
|
file to remove. |
1088
|
|
|
|
|
|
|
|
1089
|
|
|
|
|
|
|
$foo->subpartsRemove( $filename ); |
1090
|
|
|
|
|
|
|
if ( $foo->error ){ |
1091
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
1092
|
|
|
|
|
|
|
} |
1093
|
|
|
|
|
|
|
|
1094
|
|
|
|
|
|
|
=cut |
1095
|
|
|
|
|
|
|
|
1096
|
|
|
|
|
|
|
sub subpartsRemove{ |
1097
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
1098
|
0
|
|
|
|
|
|
my $file=$_[1]; |
1099
|
|
|
|
|
|
|
|
1100
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
1101
|
0
|
|
|
|
|
|
return undef; |
1102
|
|
|
|
|
|
|
} |
1103
|
|
|
|
|
|
|
|
1104
|
|
|
|
|
|
|
#makes sure a file is specified |
1105
|
0
|
0
|
|
|
|
|
if ( ! defined( $file ) ){ |
1106
|
0
|
|
|
|
|
|
$self->{error}=18; |
1107
|
0
|
|
|
|
|
|
$self->{errorstring}='No file specified'; |
1108
|
0
|
|
|
|
|
|
$self->warn; |
1109
|
0
|
|
|
|
|
|
return undef; |
1110
|
|
|
|
|
|
|
} |
1111
|
|
|
|
|
|
|
|
1112
|
0
|
|
|
|
|
|
my @parts=$self->{mime}->parts; |
1113
|
0
|
|
|
|
|
|
my @newparts; |
1114
|
0
|
|
|
|
|
|
my $int=0; |
1115
|
0
|
|
|
|
|
|
while ( defined( $parts[$int] ) ){ |
1116
|
0
|
|
|
|
|
|
my $partFilename=$parts[$int]->filename; |
1117
|
0
|
0
|
0
|
|
|
|
if ( ( ! defined( $partFilename ) ) || |
1118
|
|
|
|
|
|
|
( $file ne $partFilename ) ){ |
1119
|
0
|
|
|
|
|
|
push( @newparts, $parts[$int] ); |
1120
|
|
|
|
|
|
|
} |
1121
|
|
|
|
|
|
|
|
1122
|
0
|
|
|
|
|
|
$int++; |
1123
|
|
|
|
|
|
|
} |
1124
|
|
|
|
|
|
|
|
1125
|
0
|
|
|
|
|
|
$self->{mime}->parts_set( \@newparts ); |
1126
|
|
|
|
|
|
|
|
1127
|
0
|
|
|
|
|
|
return 1; |
1128
|
|
|
|
|
|
|
} |
1129
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
=head2 summaryGet |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
This returns the summary. |
1133
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
my $summary=$foo->summaryGet; |
1135
|
|
|
|
|
|
|
if($foo->error){ |
1136
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
1137
|
|
|
|
|
|
|
} |
1138
|
|
|
|
|
|
|
|
1139
|
|
|
|
|
|
|
=cut |
1140
|
|
|
|
|
|
|
|
1141
|
|
|
|
|
|
|
sub summaryGet{ |
1142
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
1143
|
|
|
|
|
|
|
|
1144
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
1145
|
0
|
|
|
|
|
|
return undef; |
1146
|
|
|
|
|
|
|
} |
1147
|
|
|
|
|
|
|
|
1148
|
0
|
|
|
|
|
|
my $summary=$self->{mime}->header('summary'); |
1149
|
|
|
|
|
|
|
|
1150
|
0
|
0
|
|
|
|
|
if ( ! defined( $summary ) ){ |
1151
|
0
|
|
|
|
|
|
$summary=''; |
1152
|
|
|
|
|
|
|
} |
1153
|
|
|
|
|
|
|
|
1154
|
0
|
|
|
|
|
|
return $summary; |
1155
|
|
|
|
|
|
|
} |
1156
|
|
|
|
|
|
|
|
1157
|
|
|
|
|
|
|
=head2 summarySet |
1158
|
|
|
|
|
|
|
|
1159
|
|
|
|
|
|
|
This sets the summary. |
1160
|
|
|
|
|
|
|
|
1161
|
|
|
|
|
|
|
One argument is taken and it is the summary. |
1162
|
|
|
|
|
|
|
|
1163
|
|
|
|
|
|
|
$foo->summarySet($summary); |
1164
|
|
|
|
|
|
|
if($foo->error){ |
1165
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
1166
|
|
|
|
|
|
|
} |
1167
|
|
|
|
|
|
|
|
1168
|
|
|
|
|
|
|
=cut |
1169
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
sub summarySet{ |
1171
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
1172
|
0
|
|
|
|
|
|
my $summary=$_[1]; |
1173
|
|
|
|
|
|
|
|
1174
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
1175
|
0
|
|
|
|
|
|
return undef; |
1176
|
|
|
|
|
|
|
} |
1177
|
|
|
|
|
|
|
|
1178
|
0
|
0
|
|
|
|
|
if (!defined( $summary )) { |
1179
|
0
|
|
|
|
|
|
$self->{error}=15; |
1180
|
0
|
|
|
|
|
|
$self->{errorString}='No summary specified'; |
1181
|
0
|
|
|
|
|
|
$self->warn; |
1182
|
0
|
|
|
|
|
|
return $self; |
1183
|
|
|
|
|
|
|
} |
1184
|
|
|
|
|
|
|
|
1185
|
0
|
|
|
|
|
|
$self->{mime}->header_set('summary'=>$summary); |
1186
|
|
|
|
|
|
|
|
1187
|
0
|
|
|
|
|
|
return 1; |
1188
|
|
|
|
|
|
|
} |
1189
|
|
|
|
|
|
|
|
1190
|
|
|
|
|
|
|
=head2 write |
1191
|
|
|
|
|
|
|
|
1192
|
|
|
|
|
|
|
This saves the page file. It requires dirSet to |
1193
|
|
|
|
|
|
|
have been called previously. |
1194
|
|
|
|
|
|
|
|
1195
|
|
|
|
|
|
|
$foo->write; |
1196
|
|
|
|
|
|
|
if($foo->error){ |
1197
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
1198
|
|
|
|
|
|
|
} |
1199
|
|
|
|
|
|
|
|
1200
|
|
|
|
|
|
|
=cut |
1201
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
sub write{ |
1203
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
1204
|
|
|
|
|
|
|
|
1205
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
1206
|
0
|
|
|
|
|
|
return undef; |
1207
|
|
|
|
|
|
|
} |
1208
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
#makes so a directory has been specified |
1210
|
0
|
0
|
|
|
|
|
if (!defined( $self->{dir} )) { |
1211
|
0
|
|
|
|
|
|
$self->{error}=11; |
1212
|
0
|
|
|
|
|
|
$self->{errorString}='No directory has been specified yet'; |
1213
|
0
|
|
|
|
|
|
$self->warn; |
1214
|
0
|
|
|
|
|
|
return undef; |
1215
|
|
|
|
|
|
|
} |
1216
|
|
|
|
|
|
|
|
1217
|
|
|
|
|
|
|
#makes sure it is still a toader directory... |
1218
|
0
|
0
|
|
|
|
|
if (! -d $self->{dir}.'/.toader/' ) { |
1219
|
0
|
|
|
|
|
|
$self->{error}=10; |
1220
|
0
|
|
|
|
|
|
$self->{errorString}='No directory has been specified yet'; |
1221
|
0
|
|
|
|
|
|
$self->warn; |
1222
|
0
|
|
|
|
|
|
return undef; |
1223
|
|
|
|
|
|
|
} |
1224
|
|
|
|
|
|
|
|
1225
|
|
|
|
|
|
|
#if there is no entry directory, generate one... |
1226
|
0
|
0
|
|
|
|
|
if (! -d $self->{dir}.'/.toader/pages/' ) { |
1227
|
0
|
0
|
|
|
|
|
if (! make_path( $self->{dir}.'/.toader/pages/' ) ) { |
1228
|
0
|
|
|
|
|
|
$self->{error}=12; |
1229
|
0
|
|
|
|
|
|
$self->{errorString}='The pages directory did not exist and was not able to create it'; |
1230
|
0
|
|
|
|
|
|
$self->warn; |
1231
|
0
|
|
|
|
|
|
return undef; |
1232
|
|
|
|
|
|
|
} |
1233
|
|
|
|
|
|
|
} |
1234
|
|
|
|
|
|
|
|
1235
|
|
|
|
|
|
|
#figure out the file will be |
1236
|
0
|
|
|
|
|
|
my $file=$self->{dir}.'/.toader/pages/'.$self->nameGet; |
1237
|
|
|
|
|
|
|
|
1238
|
|
|
|
|
|
|
#converts the page to a string |
1239
|
0
|
|
|
|
|
|
my $pageString=$self->as_string; |
1240
|
|
|
|
|
|
|
|
1241
|
|
|
|
|
|
|
#writes the file |
1242
|
0
|
|
|
|
|
|
my $fh; |
1243
|
0
|
0
|
|
|
|
|
if ( ! open($fh, '>', $file) ){ |
1244
|
0
|
|
|
|
|
|
$self->{error}=13; |
1245
|
0
|
|
|
|
|
|
$self->{errorString}='Unable to open "'.$file.'" for writing'; |
1246
|
0
|
|
|
|
|
|
$self->warn; |
1247
|
0
|
|
|
|
|
|
return undef; |
1248
|
|
|
|
|
|
|
} |
1249
|
0
|
|
|
|
|
|
print $fh $pageString; |
1250
|
0
|
|
|
|
|
|
close($fh); |
1251
|
|
|
|
|
|
|
|
1252
|
|
|
|
|
|
|
#if VCS is not usable, stop here |
1253
|
0
|
0
|
|
|
|
|
if ( ! $self->{VCSusable} ){ |
1254
|
0
|
|
|
|
|
|
return 1; |
1255
|
|
|
|
|
|
|
} |
1256
|
|
|
|
|
|
|
|
1257
|
|
|
|
|
|
|
#if it is under VCS, we have nothing to do |
1258
|
0
|
|
|
|
|
|
my $underVCS=$self->{vcs}->underVCS($file); |
1259
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
1260
|
0
|
|
|
|
|
|
$self->{error}=17; |
1261
|
0
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->underVCS errored. error="'. |
1262
|
|
|
|
|
|
|
$self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"'; |
1263
|
0
|
|
|
|
|
|
$self->warn; |
1264
|
0
|
|
|
|
|
|
return undef; |
1265
|
|
|
|
|
|
|
} |
1266
|
0
|
0
|
|
|
|
|
if ( $underVCS ){ |
1267
|
0
|
|
|
|
|
|
return 1; |
1268
|
|
|
|
|
|
|
} |
1269
|
|
|
|
|
|
|
|
1270
|
|
|
|
|
|
|
#add it as if we reach here it is not under VCS and VCS is being used |
1271
|
0
|
|
|
|
|
|
$self->{vcs}->add( $file ); |
1272
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
1273
|
0
|
|
|
|
|
|
$self->{error}=18; |
1274
|
0
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->add errored. error="'. |
1275
|
|
|
|
|
|
|
$self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"'; |
1276
|
0
|
|
|
|
|
|
$self->warn; |
1277
|
0
|
|
|
|
|
|
return undef; |
1278
|
|
|
|
|
|
|
} |
1279
|
|
|
|
|
|
|
|
1280
|
0
|
|
|
|
|
|
return 1; |
1281
|
|
|
|
|
|
|
} |
1282
|
|
|
|
|
|
|
|
1283
|
|
|
|
|
|
|
=head1 REQUIRED RENDERING METHODS |
1284
|
|
|
|
|
|
|
|
1285
|
|
|
|
|
|
|
=head2 filesDir |
1286
|
|
|
|
|
|
|
|
1287
|
|
|
|
|
|
|
This returns the file directory for the object. |
1288
|
|
|
|
|
|
|
|
1289
|
|
|
|
|
|
|
This is not a full path, but a partial path that should |
1290
|
|
|
|
|
|
|
be appended the directory current directory being outputted to. |
1291
|
|
|
|
|
|
|
|
1292
|
|
|
|
|
|
|
=cut |
1293
|
|
|
|
|
|
|
|
1294
|
|
|
|
|
|
|
sub filesDir{ |
1295
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
1296
|
|
|
|
|
|
|
|
1297
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
1298
|
0
|
|
|
|
|
|
return undef; |
1299
|
|
|
|
|
|
|
} |
1300
|
|
|
|
|
|
|
|
1301
|
0
|
0
|
|
|
|
|
if ( ! defined( $self->{mime}->header('name') ) ){ |
1302
|
0
|
|
|
|
|
|
$self->{error}=16; |
1303
|
0
|
|
|
|
|
|
$self->{errorString}='No entry name has been set'; |
1304
|
0
|
|
|
|
|
|
$self->warn; |
1305
|
0
|
|
|
|
|
|
return undef; |
1306
|
|
|
|
|
|
|
} |
1307
|
|
|
|
|
|
|
|
1308
|
0
|
|
|
|
|
|
return $self->renderDir.'/'.$self->{mime}->header('name').'/.files'; |
1309
|
|
|
|
|
|
|
} |
1310
|
|
|
|
|
|
|
|
1311
|
|
|
|
|
|
|
|
1312
|
|
|
|
|
|
|
=head2 locationID |
1313
|
|
|
|
|
|
|
|
1314
|
|
|
|
|
|
|
This returns the location ID. |
1315
|
|
|
|
|
|
|
|
1316
|
|
|
|
|
|
|
This one requires the object to be initialized. |
1317
|
|
|
|
|
|
|
|
1318
|
|
|
|
|
|
|
=cut |
1319
|
|
|
|
|
|
|
|
1320
|
|
|
|
|
|
|
sub locationID{ |
1321
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
1322
|
|
|
|
|
|
|
|
1323
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
1324
|
0
|
|
|
|
|
|
return undef; |
1325
|
|
|
|
|
|
|
} |
1326
|
|
|
|
|
|
|
|
1327
|
0
|
|
|
|
|
|
return 'Page='.$self->nameGet; |
1328
|
|
|
|
|
|
|
} |
1329
|
|
|
|
|
|
|
|
1330
|
|
|
|
|
|
|
=head2 renderDir |
1331
|
|
|
|
|
|
|
|
1332
|
|
|
|
|
|
|
This is the directory that it will be rendered to. |
1333
|
|
|
|
|
|
|
|
1334
|
|
|
|
|
|
|
The base directory that will be used for rendering. |
1335
|
|
|
|
|
|
|
|
1336
|
|
|
|
|
|
|
=cut |
1337
|
|
|
|
|
|
|
|
1338
|
|
|
|
|
|
|
sub renderDir{ |
1339
|
0
|
|
|
0
|
1
|
|
return '.pages'; |
1340
|
|
|
|
|
|
|
} |
1341
|
|
|
|
|
|
|
|
1342
|
|
|
|
|
|
|
=head2 renderUsing |
1343
|
|
|
|
|
|
|
|
1344
|
|
|
|
|
|
|
This returns the module to use for rendering. |
1345
|
|
|
|
|
|
|
|
1346
|
|
|
|
|
|
|
my $module=$foo->renderUsing; |
1347
|
|
|
|
|
|
|
|
1348
|
|
|
|
|
|
|
=cut |
1349
|
|
|
|
|
|
|
|
1350
|
|
|
|
|
|
|
sub renderUsing{ |
1351
|
0
|
|
|
0
|
1
|
|
return 'Toader::Render::Page'; |
1352
|
|
|
|
|
|
|
} |
1353
|
|
|
|
|
|
|
|
1354
|
|
|
|
|
|
|
=head2 toaderRenderable |
1355
|
|
|
|
|
|
|
|
1356
|
|
|
|
|
|
|
This method returns true and marks it as being L |
1357
|
|
|
|
|
|
|
renderable. |
1358
|
|
|
|
|
|
|
|
1359
|
|
|
|
|
|
|
=cut |
1360
|
|
|
|
|
|
|
|
1361
|
|
|
|
|
|
|
sub toaderRenderable{ |
1362
|
0
|
|
|
0
|
1
|
|
return 1; |
1363
|
|
|
|
|
|
|
} |
1364
|
|
|
|
|
|
|
|
1365
|
|
|
|
|
|
|
=head2 toDir |
1366
|
|
|
|
|
|
|
|
1367
|
|
|
|
|
|
|
This returns the relative path to the object. |
1368
|
|
|
|
|
|
|
|
1369
|
|
|
|
|
|
|
This is not a full path, but a partial path that should |
1370
|
|
|
|
|
|
|
be appended the directory current directory being outputted to. |
1371
|
|
|
|
|
|
|
|
1372
|
|
|
|
|
|
|
=cut |
1373
|
|
|
|
|
|
|
|
1374
|
|
|
|
|
|
|
sub toDir{ |
1375
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
1376
|
|
|
|
|
|
|
|
1377
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
1378
|
0
|
|
|
|
|
|
return undef; |
1379
|
|
|
|
|
|
|
} |
1380
|
|
|
|
|
|
|
|
1381
|
0
|
0
|
|
|
|
|
if ( ! defined( $self->{entryName} ) ){ |
1382
|
0
|
|
|
|
|
|
$self->{error}=16; |
1383
|
0
|
|
|
|
|
|
$self->{errorString}='No entry name has been set'; |
1384
|
0
|
|
|
|
|
|
$self->warn; |
1385
|
0
|
|
|
|
|
|
return undef; |
1386
|
|
|
|
|
|
|
} |
1387
|
|
|
|
|
|
|
|
1388
|
0
|
|
|
|
|
|
return $self->renderDir.'/'.$self->{entryName}; |
1389
|
|
|
|
|
|
|
} |
1390
|
|
|
|
|
|
|
|
1391
|
|
|
|
|
|
|
=head1 ERROR CODES/FLAGS |
1392
|
|
|
|
|
|
|
|
1393
|
|
|
|
|
|
|
=head2 1, noPageName |
1394
|
|
|
|
|
|
|
|
1395
|
|
|
|
|
|
|
No name specified. |
1396
|
|
|
|
|
|
|
|
1397
|
|
|
|
|
|
|
=head2 2, emailMIMEcreationFailed |
1398
|
|
|
|
|
|
|
|
1399
|
|
|
|
|
|
|
Unable to create L object. |
1400
|
|
|
|
|
|
|
|
1401
|
|
|
|
|
|
|
=head2 3, notAnArray |
1402
|
|
|
|
|
|
|
|
1403
|
|
|
|
|
|
|
Has files specified, but the passed object is not a array. |
1404
|
|
|
|
|
|
|
|
1405
|
|
|
|
|
|
|
=head2 4, fileDoesNotExist |
1406
|
|
|
|
|
|
|
|
1407
|
|
|
|
|
|
|
The file does not exist or is not a file. |
1408
|
|
|
|
|
|
|
|
1409
|
|
|
|
|
|
|
=head2 5, MIMEinfoError |
1410
|
|
|
|
|
|
|
|
1411
|
|
|
|
|
|
|
File::MimeInfo->mimetype returned undef, meaning the file does not exist or is not readable. |
1412
|
|
|
|
|
|
|
|
1413
|
|
|
|
|
|
|
=head2 6, unableToOpenFile |
1414
|
|
|
|
|
|
|
|
1415
|
|
|
|
|
|
|
Unable to open the file. |
1416
|
|
|
|
|
|
|
|
1417
|
|
|
|
|
|
|
=head2 7, emailMIMEerror |
1418
|
|
|
|
|
|
|
|
1419
|
|
|
|
|
|
|
Unable to create a L object for one of the parts/files. |
1420
|
|
|
|
|
|
|
|
1421
|
|
|
|
|
|
|
=head2 8, noBody |
1422
|
|
|
|
|
|
|
|
1423
|
|
|
|
|
|
|
No body defined. |
1424
|
|
|
|
|
|
|
|
1425
|
|
|
|
|
|
|
=head2 9, notAtoaderDir |
1426
|
|
|
|
|
|
|
|
1427
|
|
|
|
|
|
|
Not a L directory. |
1428
|
|
|
|
|
|
|
|
1429
|
|
|
|
|
|
|
=head2 10, noLonderAtoaderDir |
1430
|
|
|
|
|
|
|
|
1431
|
|
|
|
|
|
|
No longer appears to be a L directory. |
1432
|
|
|
|
|
|
|
|
1433
|
|
|
|
|
|
|
=head2 11, noDirSet |
1434
|
|
|
|
|
|
|
|
1435
|
|
|
|
|
|
|
No directory has been specified. |
1436
|
|
|
|
|
|
|
|
1437
|
|
|
|
|
|
|
=head2 12, pagesDirCreationFailed |
1438
|
|
|
|
|
|
|
|
1439
|
|
|
|
|
|
|
The pages directory could not be created. |
1440
|
|
|
|
|
|
|
|
1441
|
|
|
|
|
|
|
=head2 13, publishValError |
1442
|
|
|
|
|
|
|
|
1443
|
|
|
|
|
|
|
The publish value is not a recognized boolean value. |
1444
|
|
|
|
|
|
|
|
1445
|
|
|
|
|
|
|
Only '0' and '1' is recognized. |
1446
|
|
|
|
|
|
|
|
1447
|
|
|
|
|
|
|
=head2 14, notAtoaderObj |
1448
|
|
|
|
|
|
|
|
1449
|
|
|
|
|
|
|
The specified object is not a L object. |
1450
|
|
|
|
|
|
|
|
1451
|
|
|
|
|
|
|
=head2 15, getVCSerrored |
1452
|
|
|
|
|
|
|
|
1453
|
|
|
|
|
|
|
L->getVCS errored. |
1454
|
|
|
|
|
|
|
|
1455
|
|
|
|
|
|
|
=head2 16, VCSusableErrored |
1456
|
|
|
|
|
|
|
|
1457
|
|
|
|
|
|
|
L->usable errored. |
1458
|
|
|
|
|
|
|
|
1459
|
|
|
|
|
|
|
=head2 17, underVCSerror |
1460
|
|
|
|
|
|
|
|
1461
|
|
|
|
|
|
|
L->underVCS errored. |
1462
|
|
|
|
|
|
|
|
1463
|
|
|
|
|
|
|
=head2 18, VCSaddErrored |
1464
|
|
|
|
|
|
|
|
1465
|
|
|
|
|
|
|
L->add errored. |
1466
|
|
|
|
|
|
|
|
1467
|
|
|
|
|
|
|
=head2 19, noToaderObj |
1468
|
|
|
|
|
|
|
|
1469
|
|
|
|
|
|
|
No L object specified. |
1470
|
|
|
|
|
|
|
|
1471
|
|
|
|
|
|
|
=head1 AUTHOR |
1472
|
|
|
|
|
|
|
|
1473
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
1474
|
|
|
|
|
|
|
|
1475
|
|
|
|
|
|
|
=head1 BUGS |
1476
|
|
|
|
|
|
|
|
1477
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
1478
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
1479
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
1480
|
|
|
|
|
|
|
|
1481
|
|
|
|
|
|
|
|
1482
|
|
|
|
|
|
|
|
1483
|
|
|
|
|
|
|
|
1484
|
|
|
|
|
|
|
=head1 SUPPORT |
1485
|
|
|
|
|
|
|
|
1486
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
1487
|
|
|
|
|
|
|
|
1488
|
|
|
|
|
|
|
perldoc Toader::Page |
1489
|
|
|
|
|
|
|
|
1490
|
|
|
|
|
|
|
|
1491
|
|
|
|
|
|
|
You can also look for information at: |
1492
|
|
|
|
|
|
|
|
1493
|
|
|
|
|
|
|
=over 4 |
1494
|
|
|
|
|
|
|
|
1495
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
1496
|
|
|
|
|
|
|
|
1497
|
|
|
|
|
|
|
L |
1498
|
|
|
|
|
|
|
|
1499
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
1500
|
|
|
|
|
|
|
|
1501
|
|
|
|
|
|
|
L |
1502
|
|
|
|
|
|
|
|
1503
|
|
|
|
|
|
|
=item * CPAN Ratings |
1504
|
|
|
|
|
|
|
|
1505
|
|
|
|
|
|
|
L |
1506
|
|
|
|
|
|
|
|
1507
|
|
|
|
|
|
|
=item * Search CPAN |
1508
|
|
|
|
|
|
|
|
1509
|
|
|
|
|
|
|
L |
1510
|
|
|
|
|
|
|
|
1511
|
|
|
|
|
|
|
=back |
1512
|
|
|
|
|
|
|
|
1513
|
|
|
|
|
|
|
|
1514
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
1515
|
|
|
|
|
|
|
|
1516
|
|
|
|
|
|
|
|
1517
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
1518
|
|
|
|
|
|
|
|
1519
|
|
|
|
|
|
|
Copyright 2011 Zane C. Bowers-Hadley. |
1520
|
|
|
|
|
|
|
|
1521
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
1522
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
1523
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
1524
|
|
|
|
|
|
|
|
1525
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
1526
|
|
|
|
|
|
|
|
1527
|
|
|
|
|
|
|
|
1528
|
|
|
|
|
|
|
=cut |
1529
|
|
|
|
|
|
|
|
1530
|
|
|
|
|
|
|
1; # End of Toader |