]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/Archive.pm
1 package Template
::Archive
;
3 ################################################################################
5 # File: shared/Template/Archive.pm #
7 # Authors: Frank Schoenmann <fs@tower.de>, 2001-06-08 #
9 # Description: archive display #
11 ################################################################################
17 use Encode
::Plain
; $Encode::Plain
::utf8
= 1;
36 use Template
::_thread
;
38 ################################################################################
42 use base
qw(Exporter);
43 @Template::Archive
::EXPORT
= qw(
44 print_overview_as_HTML
51 ### print_overview_as_HTML () ##################################################
55 # Params: $arcdir main archive directory
56 # $tempfile template filename
57 # $param hash reference
60 sub print_overview_as_HTML
($$$) {
61 my ($arcdir, $tempfile, $param) = @_;
63 my $assign = $param->{'assign'};
65 my $template = new Template
$tempfile;
70 print ${$template->scrap(
71 $assign->{'archiveDocStart'}
75 # globbing to find year directories
79 print ${$template->scrap(
80 $assign->{'archiveDocEntry'},
82 $assign->{'year'} => $_
88 # for (my $month = 1; $month <= 12; $month++) {
89 # if (-e $yeardir.$month.'/') {
90 # print ${$template->scrap(
91 # $assign->{'yearDocEntry'},
93 # $assign->{'year'} => $param->{'year'},
94 # $assign->{'month'} => $month,
95 # $assign->{'monthName'} => month($month)
104 print ${$template->scrap(
105 $assign->{'archiveDocEnd'}
109 ### print_year_as_HTML () ######################################################
111 # yearly overview over months
113 # Params: $yeardir directory, which contains month directories
114 # $tempfile template filename
115 # $param hash reference
118 sub print_year_as_HTML
($$$) {
119 my ($yeardir, $tempfile, $param) = @_;
121 my $assign = $param->{'assign'};
123 my $template = new Template
$tempfile;
126 # check if this year's archive exist
128 unless (-e
$yeardir) {
129 print ${$template->scrap(
132 $assign->{'errorText'} => "Es existieren keine Nachrichten für dieses Jahr."
138 $assign->{'year'} => $param->{'year'},
144 print ${$template->scrap(
145 $assign->{'yearDocStart'},
149 for (my $month = 1; $month <= 12; $month++) {
150 if (-e
$yeardir.$month.'/') {
151 print ${$template->scrap(
152 $assign->{'yearDocEntry'},
154 $assign->{'year'} => $param->{'year'},
155 $assign->{'month'} => $month,
156 $assign->{'monthName'} => month
($month)
165 print ${$template->scrap(
166 $assign->{'yearDocEnd'},
171 ### print_month_as_HTML () #####################################################
173 # monthly overview over threads
175 # Params: $mainfile XML file on a per-month base
176 # $tempfile template filename
177 # $param hash reference
180 sub print_month_as_HTML
($$$) {
181 my ($mainfile, $tempfile, $param) = @_;
183 my $assign = $param->{'assign'};
185 my $template = new Template
$tempfile;
188 # check if XML file exists
190 unless (-e
$mainfile) {
191 print ${$template->scrap(
194 $assign->{'errorText'} => "Es existieren keine Nachrichten für diesen Monat."
201 # try locking and read/parse threads
203 my ($threads, $locked);
204 unless ($locked = lock_file
($mainfile) and $threads = get_all_threads
($mainfile, KILL_DELETED
)) {
205 print ${$template->scrap(
208 $assign->{'errorText'} => "Fehler beim Locking."
213 unlock_file
($mainfile);
216 $assign->{'year'} => $param->{'year'},
217 $assign->{'month'} => $param->{'month'},
218 $assign->{'monthName'} => month
($param->{'month'})
224 print ${$template->scrap(
225 $assign->{'monthDocStart'},
232 for (sort keys %$threads) {
233 print ${$template->scrap(
234 $assign->{'monthThreadEntry'},
236 $assign->{'threadID'} => $_,
237 $assign->{'threadCategory'} => $threads->{$_}->[0]->{'cat'},
238 $assign->{'threadTitle'} => $threads->{$_}->[0]->{'subject'},
239 $assign->{'threadTime'} => short_hr_time
($threads->{$_}->[0]->{'time'}),
240 $assign->{'threadDate'} => very_short_hr_time
($threads->{$_}->[0]->{'time'}),
241 $assign->{'year'} => $param->{'year'},
242 $assign->{'month'} => $param->{'month'}
250 print ${$template->scrap(
251 $assign->{'monthDocEnd'},
256 ### print_thread_as_HTML () ####################################################
258 # print a complete thread
260 # Params: $mainfile thread XML file
261 # $tempfile template filename
262 # $param hash reference
265 sub print_thread_as_HTML
($$$) {
266 my ($mainfile, $tempfile, $param) = @_;
268 my $assign = $param->{'assign'};
269 my $tree = $param->{'tree'};
270 my $tid = $param->{'thread'};
272 my $template = new Template
$tempfile;
275 # check if XML file exists
277 unless (-e
$mainfile) {
278 print ${$template->scrap(
281 $assign->{'errorText'} => "Der gewünschte Thread existiert nicht."
287 my $view = get_view_params
({
288 'adminDefault' => $param->{'adminDefault'}
290 my $xml = parse_xml_file
($mainfile);
291 my $tnode = $xml->getElementsByTagName('Thread', 1)->item(0);
292 my $thread = parse_single_thread
($tnode, KILL_DELETED
);
295 $tree->{'year'} => $param->{'year'},
296 $tree->{'month'} => $param->{'month'}
300 # used to print the thread view
303 'thread' => $param->{'thread'},
304 'template' => $param->{'tree'},
306 'cgi' => $param->{'cgi'},
307 'addParam' => $addparam
314 $assign->{'threadCategory'} => $thread->[0]->{'cat'},
315 $assign->{'threadTitle'} => $thread->[0]->{'subject'},
316 $assign->{'year'} => $param->{'year'},
317 $assign->{'month'} => $param->{'month'},
318 $assign->{'monthName'} => month
($param->{'month'}),
319 $param->{'tree'}->{'main'} => html_thread
($thread, $template, $tpar)
322 print ${$template->scrap(
323 $assign->{'threadDocStart'},
332 my $mnode = get_message_node
($xml, 't'.$tid, 'm'.$_->{'mid'});
333 my $header = get_message_header
($mnode);
334 my $body = get_message_body
($xml, 'm'.$_->{'mid'});
336 my $text = message_field
(
339 'quoteChars' => plain
($view->{'quoteChars'}),
340 'quoting' => $view->{'quoting'},
341 'startCite' => ${$template->scrap($assign->{'startCite'})},
342 'endCite' => ${$template->scrap($assign->{'endCite'})}
347 print ${$template->scrap(
348 $assign->{'posting'},
350 $assign->{'msgID'} => $_->{'mid'},
351 $assign->{'msgAuthor'} => $_->{'name'},
352 $assign->{'msgMail'} => $header->{'email'},
353 $assign->{'msgHomepage'} => $header->{'home'},
354 $assign->{'msgTime'} => hr_time
($header->{'time'}),
355 $assign->{'msgCategory'} => plain
($header->{'category'}),
356 $assign->{'msgSubject'} => plain
($header->{'subject'}),
357 $assign->{'msgBody'} => $text
366 print ${$template->scrap(
367 $assign->{'threadDocEnd'},
379 ### end of Template::Archive ###################################################
patrick-canterino.de