]>
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(
50 ### print_year_as_HTML () ######################################################
52 # yearly overview over months
55 # $tempfile template filename
56 # $param hash reference
59 sub print_year_as_HTML
($$$) {
60 my ($yeardir, $tempfile, $param) = @_;
62 my $assign = $param->{'assign'};
64 my $template = new Template
$tempfile;
67 # check if this year's archive exist
69 unless (-e
$yeardir) {
70 print ${$template->scrap(
73 $assign->{'errorText'} => "Es existieren keine Nachrichten für dieses Jahr."
79 $assign->{'year'} => $param->{'year'},
80 # $assign->{'month'} => $param->{'month'},
81 # $assign->{'monthName'} => month($param->{'month'})
87 print ${$template->scrap(
88 $assign->{'yearDocStart'},
92 for (my $month = 1; $month <= 12; $month++) {
93 if (-e
$yeardir.$month.'/') {
94 print ${$template->scrap(
95 $assign->{'yearDocEntry'},
97 $assign->{'year'} => $param->{'year'},
98 $assign->{'month'} => $month,
99 $assign->{'monthName'} => month
($month)
108 print ${$template->scrap(
109 $assign->{'yearDocEnd'},
114 ### print_month_as_HTML () #####################################################
116 # monthly overview over threads
118 # Params: $mainfile XML file on a per-month base
119 # $tempfile template filename
120 # $param hash reference
123 sub print_month_as_HTML
($$$) {
124 my ($mainfile, $tempfile, $param) = @_;
126 my $assign = $param->{'assign'};
128 my $template = new Template
$tempfile;
131 # check if XML file exists
133 unless (-e
$mainfile) {
134 print ${$template->scrap(
137 $assign->{'errorText'} => "Es existieren keine Nachrichten für diesen Monat."
144 # try locking and read/parse threads
146 my ($threads, $locked);
147 unless ($locked = lock_file
($mainfile) and $threads = get_all_threads
($mainfile, KILL_DELETED
)) {
148 print ${$template->scrap(
151 $assign->{'errorText'} => "Fehler beim Locking."
156 unlock_file
($mainfile);
159 $assign->{'year'} => $param->{'year'},
160 $assign->{'month'} => $param->{'month'},
161 $assign->{'monthName'} => month
($param->{'month'})
167 print ${$template->scrap(
168 $assign->{'monthDocStart'},
175 for (sort keys %$threads) {
176 print ${$template->scrap(
177 $assign->{'monthThreadEntry'},
179 $assign->{'threadID'} => $_,
180 $assign->{'threadCategory'} => $threads->{$_}->[0]->{'cat'},
181 $assign->{'threadTitle'} => $threads->{$_}->[0]->{'subject'},
182 $assign->{'threadTime'} => short_hr_time
($threads->{$_}->[0]->{'time'}),
183 $assign->{'threadDate'} => very_short_hr_time
($threads->{$_}->[0]->{'time'}),
184 $assign->{'year'} => $param->{'year'},
185 $assign->{'month'} => $param->{'month'}
193 print ${$template->scrap(
194 $assign->{'monthDocEnd'},
201 ### print_thread_as_HTML () ####################################################
203 # print a complete thread
205 # Params: $mainfile thread XML file
206 # $tempfile template filename
207 # $param hash reference
210 sub print_thread_as_HTML
($$$) {
211 my ($mainfile, $tempfile, $param) = @_;
213 my $assign = $param->{'assign'};
214 my $tree = $param->{'tree'};
215 my $tid = $param->{'thread'};
217 my $template = new Template
$tempfile;
220 # check if XML file exists
222 unless (-e
$mainfile) {
223 print ${$template->scrap(
226 $assign->{'errorText'} => "Der gewünschte Thread existiert nicht."
232 my $view = get_view_params
({
233 'adminDefault' => $param->{'adminDefault'}
235 my $xml = parse_xml_file
($mainfile);
236 my $tnode = $xml->getElementsByTagName('Thread', 1)->item(0);
237 my $thread = parse_single_thread
($tnode, KILL_DELETED
);
240 $tree->{'year'} => $param->{'year'},
241 $tree->{'month'} => $param->{'month'}
245 # used to print the thread view
248 'thread' => $param->{'thread'},
249 'template' => $param->{'tree'},
251 'cgi' => $param->{'cgi'},
252 'addParam' => $addparam
259 $assign->{'threadCategory'} => $thread->[0]->{'cat'},
260 $assign->{'threadTitle'} => $thread->[0]->{'subject'},
261 $assign->{'year'} => $param->{'year'},
262 $assign->{'month'} => $param->{'month'},
263 $assign->{'monthName'} => month
($param->{'month'}),
264 $param->{'tree'}->{'main'} => html_thread
($thread, $template, $tpar)
267 print ${$template->scrap(
268 $assign->{'threadDocStart'},
277 my $mnode = get_message_node
($xml, 't'.$tid, 'm'.$_->{'mid'});
278 my $header = get_message_header
($mnode);
279 my $body = get_message_body
($xml, 'm'.$_->{'mid'});
281 my $text = message_field
(
284 'quoteChars' => plain
($view->{'quoteChars'}),
285 'quoting' => $view->{'quoting'},
286 'startCite' => ${$template->scrap($assign->{'startCite'})},
287 'endCite' => ${$template->scrap($assign->{'endCite'})}
292 print ${$template->scrap(
293 $assign->{'posting'},
295 $assign->{'msgID'} => $_->{'mid'},
296 $assign->{'msgAuthor'} => $_->{'name'},
297 $assign->{'msgMail'} => $header->{'email'},
298 $assign->{'msgHomepage'} => $header->{'home'},
299 $assign->{'msgTime'} => hr_time
($header->{'time'}),
300 $assign->{'msgCategory'} => plain
($header->{'category'}),
301 $assign->{'msgSubject'} => plain
($header->{'subject'}),
302 $assign->{'msgBody'} => $text
311 print ${$template->scrap(
312 $assign->{'threadDocEnd'},
324 ### end of Template::Archive ###################################################
patrick-canterino.de