]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/Archive.pm
d3706a43d88647bc297360fb4346bcc9fa20c034
1 package Template
::Archive
;
3 ################################################################################
5 # File: shared/Template/Archive.pm #
7 # Authors: Andre Malo <nd@o3media.de>, 2001-06-16 #
8 # Frank Schoenmann <fs@tower.de>, 2001-06-08 #
10 # Description: archive display #
12 ################################################################################
22 use Encode
::Plain
; $Encode::Plain
::utf8
= 1;
41 use Template
::_thread
;
43 ################################################################################
47 $VERSION = do { my @r =(q
$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x
$#r, @r };
49 ################################################################################
53 use base
qw(Exporter);
55 print_overview_as_HTML
62 ### print_overview_as_HTML () ##################################################
66 # Params: $arcdir main archive directory
67 # $tempfile template filename
68 # $param hash reference
71 sub print_overview_as_HTML
($$$) {
72 my ($arcdir, $tempfile, $param) = @_;
74 my $assign = $param->{'assign'};
76 my $template = new Template
$tempfile;
81 print ${$template->scrap(
82 $assign->{'archiveDocStart'}
86 # globbing to find year directories
90 print ${$template->scrap(
91 $assign->{'archiveDocEntry'},
93 $assign->{'year'} => $_
99 # for (my $month = 1; $month <= 12; $month++) {
100 # if (-e $yeardir.$month.'/') {
101 # print ${$template->scrap(
102 # $assign->{'yearDocEntry'},
104 # $assign->{'year'} => $param->{'year'},
105 # $assign->{'month'} => $month,
106 # $assign->{'monthName'} => month($month)
115 print ${$template->scrap(
116 $assign->{'archiveDocEnd'}
120 ### print_year_as_HTML () ######################################################
122 # yearly overview over months
124 # Params: $yeardir directory, which contains month directories
125 # $tempfile template filename
126 # $param hash reference
129 sub print_year_as_HTML
($$$) {
130 my ($yeardir, $tempfile, $param) = @_;
132 my $assign = $param->{'assign'};
134 my $template = new Template
$tempfile;
137 # check if this year's archive exist
139 unless (-e
$yeardir) {
140 print ${$template->scrap(
143 $assign->{'errorText'} => "Es existieren keine Nachrichten für dieses Jahr."
149 $assign->{'year'} => $param->{'year'},
155 print ${$template->scrap(
156 $assign->{'yearDocStart'},
160 for (my $month = 1; $month <= 12; $month++) {
161 if (-e
$yeardir.$month.'/') {
162 print ${$template->scrap(
163 $assign->{'yearDocEntry'},
165 $assign->{'year'} => $param->{'year'},
166 $assign->{'month'} => $month,
167 $assign->{'monthName'} => month
($month)
176 print ${$template->scrap(
177 $assign->{'yearDocEnd'},
182 ### print_month_as_HTML () #####################################################
184 # monthly overview over threads
186 # Params: $mainfile XML file on a per-month base
187 # $tempfile template filename
188 # $param hash reference
191 sub print_month_as_HTML
($$$) {
192 my ($mainfile, $tempfile, $param) = @_;
194 my $assign = $param->{'assign'};
196 my $template = new Template
$tempfile;
199 # check if XML file exists
201 unless (-e
$mainfile) {
202 print ${$template->scrap(
205 $assign->{'errorText'} => "Es existieren keine Nachrichten für diesen Monat."
212 # try locking and read/parse threads
214 my ($threads, $locked);
215 unless ($locked = lock_file
($mainfile) and $threads = get_all_threads
($mainfile, KILL_DELETED
)) {
216 print ${$template->scrap(
219 $assign->{'errorText'} => "Fehler beim Locking."
224 unlock_file
($mainfile);
227 $assign->{'year'} => $param->{'year'},
228 $assign->{'month'} => $param->{'month'},
229 $assign->{'monthName'} => month
($param->{'month'})
235 print ${$template->scrap(
236 $assign->{'monthDocStart'},
243 for (sort keys %$threads) {
244 print ${$template->scrap(
245 $assign->{'monthThreadEntry'},
247 $assign->{'threadID'} => $_,
248 $assign->{'threadCategory'} => $threads->{$_}->[0]->{'cat'},
249 $assign->{'threadTitle'} => $threads->{$_}->[0]->{'subject'},
250 $assign->{'threadTime'} => short_hr_time
($threads->{$_}->[0]->{'time'}),
251 $assign->{'threadDate'} => very_short_hr_time
($threads->{$_}->[0]->{'time'}),
252 $assign->{'year'} => $param->{'year'},
253 $assign->{'month'} => $param->{'month'}
261 print ${$template->scrap(
262 $assign->{'monthDocEnd'},
267 ### print_thread_as_HTML () ####################################################
269 # print a complete thread
271 # Params: $mainfile thread XML file
272 # $tempfile template filename
273 # $param hash reference
276 sub print_thread_as_HTML
($$$) {
277 my ($mainfile, $tempfile, $param) = @_;
279 my $assign = $param->{'assign'};
280 my $tree = $param->{'tree'};
281 my $tid = $param->{'thread'};
283 my $template = new Template
$tempfile;
286 # check if XML file exists
288 unless (-e
$mainfile) {
289 print ${$template->scrap(
292 $assign->{'errorText'} => "Der gewünschte Thread existiert nicht."
298 my $view = get_view_params
({
299 'adminDefault' => $param->{'adminDefault'}
301 my $xml = parse_xml_file
($mainfile);
302 my $tnode = $xml->getElementsByTagName('Thread', 1)->item(0);
303 my $thread = parse_single_thread
($tnode, KILL_DELETED
);
306 $tree->{'year'} => $param->{'year'},
307 $tree->{'month'} => $param->{'month'}
311 # used to print the thread view
314 'thread' => $param->{'thread'},
315 'template' => $param->{'tree'},
317 'cgi' => $param->{'cgi'},
318 'addParam' => $addparam
325 $assign->{'threadCategory'} => $thread->[0]->{'cat'},
326 $assign->{'threadTitle'} => $thread->[0]->{'subject'},
327 $assign->{'year'} => $param->{'year'},
328 $assign->{'month'} => $param->{'month'},
329 $assign->{'monthName'} => month
($param->{'month'}),
330 $param->{'tree'}->{'main'} => html_thread
($thread, $template, $tpar)
333 print ${$template->scrap(
334 $assign->{'threadDocStart'},
343 my $mnode = get_message_node
($xml, 't'.$tid, 'm'.$_->{'mid'});
344 my $header = get_message_header
($mnode);
345 my $body = get_message_body
($xml, 'm'.$_->{'mid'});
347 my $text = message_field
(
350 'quoteChars' => plain
($view->{'quoteChars'}),
351 'quoting' => $view->{'quoting'},
352 'startCite' => ${$template->scrap($assign->{'startCite'})},
353 'endCite' => ${$template->scrap($assign->{'endCite'})}
358 print ${$template->scrap(
359 $assign->{'posting'},
361 $assign->{'msgID'} => $_->{'mid'},
362 $assign->{'msgAuthor'} => $_->{'name'},
363 $assign->{'msgMail'} => $header->{'email'},
364 $assign->{'msgHomepage'} => $header->{'home'},
365 $assign->{'msgTime'} => hr_time
($header->{'time'}),
366 $assign->{'msgCategory'} => plain
($header->{'category'}),
367 $assign->{'msgSubject'} => plain
($header->{'subject'}),
368 $assign->{'msgBody'} => $text
377 print ${$template->scrap(
378 $assign->{'threadDocEnd'},
385 # keep 'require' happy
390 ### end of Template::Archive ###################################################
patrick-canterino.de