]>
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-04 #
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(
49 ### print_year_as_HTML () ######################################################
51 # yearly overview over months
54 # $tempfile template filename
55 # $param hash reference
60 ### print_month_as_HTML () #####################################################
62 # monthly overview over threads
64 # Params: $mainfile XML file on a per-month base
65 # $tempfile template filename
66 # $param hash reference
69 sub print_month_as_HTML
($$$) {
70 my ($mainfile, $tempfile, $param) = @_;
72 my $assign = $param->{'assign'};
74 my $template = new Template
$tempfile;
77 # check if XML file exists
79 unless (-e
$mainfile) {
80 print ${$template->scrap(
83 $assign->{'errorText'} => "Es existieren keine Nachrichten für diesen Monat."
90 # try locking and read/parse threads
92 my ($threads, $locked);
93 unless ($locked = lock_file
($mainfile) and $threads = get_all_threads
($mainfile, KILL_DELETED
)) {
94 print ${$template->scrap(
97 $assign->{'errorText'} => "Fehler beim Locking."
102 unlock_file
($mainfile);
105 $assign->{'year'} => $param->{'year'},
106 $assign->{'month'} => $param->{'month'},
107 $assign->{'monthName'} => month
($param->{'month'})
113 print ${$template->scrap(
114 $assign->{'monthDocStart'},
121 for (sort keys %$threads) {
122 print ${$template->scrap(
123 $assign->{'monthThreadEntry'},
125 $assign->{'threadID'} => $_,
126 $assign->{'threadCategory'} => $threads->{$_}->[0]->{'cat'},
127 $assign->{'threadTitle'} => $threads->{$_}->[0]->{'subject'},
128 $assign->{'threadTime'} => short_hr_time
($threads->{$_}->[0]->{'time'}),
129 $assign->{'threadDate'} => very_short_hr_time
($threads->{$_}->[0]->{'time'}),
130 $assign->{'year'} => $param->{'year'},
131 $assign->{'month'} => $param->{'month'}
139 print ${$template->scrap(
140 $assign->{'monthDocEnd'},
147 ### print_thread_as_HTML () ####################################################
149 # print a complete thread
151 # Params: $mainfile thread XML file
152 # $tempfile template filename
153 # $param hash reference
156 sub print_thread_as_HTML
($$$) {
157 my ($mainfile, $tempfile, $param) = @_;
159 my $assign = $param->{'assign'};
160 my $tree = $param->{'tree'};
161 my $tid = $param->{'thread'};
163 my $template = new Template
$tempfile;
166 # check if XML file exists
168 unless (-e
$mainfile) {
169 print ${$template->scrap(
172 $assign->{'errorText'} => "Der gewünschte Thread existiert nicht."
178 my $view = get_view_params
({
179 'adminDefault' => $param->{'adminDefault'}
181 my $xml = parse_xml_file
($mainfile);
182 my $tnode = $xml->getElementsByTagName('Thread', 1)->item(0);
183 my $thread = parse_single_thread
($tnode, KILL_DELETED
);
186 $tree->{'year'} => $param->{'year'},
187 $tree->{'month'} => $param->{'month'}
191 # used to print the thread view
194 'thread' => $param->{'thread'},
195 'template' => $param->{'tree'},
197 'cgi' => $param->{'cgi'},
198 'addParam' => $addparam
205 $assign->{'threadCategory'} => $thread->[0]->{'cat'},
206 $assign->{'threadTitle'} => $thread->[0]->{'subject'},
207 $assign->{'year'} => $param->{'year'},
208 $assign->{'month'} => $param->{'month'},
209 $assign->{'monthName'} => month
($param->{'month'}),
210 $param->{'tree'}->{'main'} => html_thread
($thread, $template, $tpar)
213 print ${$template->scrap(
214 $assign->{'threadDocStart'},
223 my $mnode = get_message_node
($xml, 't'.$tid, 'm'.$_->{'mid'});
224 my $header = get_message_header
($mnode);
225 my $body = get_message_body
($xml, 'm'.$_->{'mid'});
227 my $text = message_field
(
230 'quoteChars' => plain
($view->{'quoteChars'}),
231 'quoting' => $view->{'quoting'},
232 'startCite' => ${$template->scrap($assign->{'startCite'})},
233 'endCite' => ${$template->scrap($assign->{'endCite'})}
238 print ${$template->scrap(
239 $assign->{'posting'},
241 $assign->{'msgID'} => $_->{'mid'},
242 $assign->{'msgAuthor'} => $_->{'name'},
243 $assign->{'msgMail'} => $header->{'email'},
244 $assign->{'msgHomepage'} => $header->{'home'},
245 $assign->{'msgTime'} => hr_time
($header->{'time'}),
246 $assign->{'msgCategory'} => plain
($header->{'category'}),
247 $assign->{'msgSubject'} => plain
($header->{'subject'}),
248 $assign->{'msgBody'} => $text
257 print ${$template->scrap(
258 $assign->{'threadDocEnd'},
270 ### end of Template::Archive ###################################################
patrick-canterino.de