]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/Archive.pm
c71c359d6d31632750e429f150fd1c1deee95e2b
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;
76 my ($threads, $locked);
77 unless ($locked = lock_file
($mainfile) and $threads = get_all_threads
($mainfile, KILL_DELETED
)) {
78 print ${$template->scrap(
79 $assign->{'errorLocking'}
83 unlock_file
($mainfile);
86 $assign->{'year'} => $param->{'year'},
87 $assign->{'month'} => $param->{'month'},
88 $assign->{'monthName'} => month
($param->{'month'})
94 print ${$template->scrap(
95 $assign->{'monthDocStart'},
102 for (sort keys %$threads) {
103 print ${$template->scrap(
104 $assign->{'monthThreadEntry'},
106 $assign->{'threadID'} => $_,
107 $assign->{'threadCategory'} => $threads->{$_}->[0]->{'cat'},
108 $assign->{'threadTitle'} => $threads->{$_}->[0]->{'subject'},
109 $assign->{'threadTime'} => short_hr_time
($threads->{$_}->[0]->{'time'}),
110 $assign->{'threadDate'} => very_short_hr_time
($threads->{$_}->[0]->{'time'}),
111 $assign->{'year'} => $param->{'year'},
112 $assign->{'month'} => $param->{'month'}
120 print ${$template->scrap(
121 $assign->{'monthDocEnd'},
128 ### print_thread_as_HTML () ####################################################
130 # print a complete thread
132 # Params: $mainfile thread XML file
133 # $tempfile template filename
134 # $param hash reference
137 sub print_thread_as_HTML
($$$) {
138 my ($mainfile, $tempfile, $param) = @_;
140 my $assign = $param->{'assign'};
141 my $tree = $param->{'tree'};
142 my $tid = $param->{'thread'};
144 my $template = new Template
$tempfile;
146 my $view = get_view_params
({
147 'adminDefault' => $param->{'adminDefault'}
149 my $xml = parse_xml_file
($mainfile);
150 my $tnode = $xml->getElementsByTagName('Thread', 1)->item(0);
151 my $thread = parse_single_thread
($tnode, KILL_DELETED
);
154 $tree->{'year'} => $param->{'year'},
155 $tree->{'month'} => $param->{'month'}
159 # used to print the thread view
162 'thread' => $param->{'thread'},
163 'template' => $param->{'tree'},
165 'cgi' => $param->{'cgi'},
166 'addParam' => $addparam
173 $assign->{'threadCategory'} => $thread->[0]->{'cat'},
174 $assign->{'threadTitle'} => $thread->[0]->{'subject'},
175 $assign->{'year'} => $param->{'year'},
176 $assign->{'month'} => $param->{'month'},
177 $assign->{'monthName'} => month
($param->{'month'}),
178 $param->{'tree'}->{'main'} => html_thread
($thread, $template, $tpar)
181 print ${$template->scrap(
182 $assign->{'threadDocStart'},
190 my $mnode = get_message_node
($xml, 't'.$tid, 'm'.$_->{'mid'});
191 my $header = get_message_header
($mnode);
192 my $body = get_message_body
($xml, 'm'.$_->{'mid'});
194 my $text = message_field
(
197 'quoteChars' => plain
($view->{'quoteChars'}),
198 'quoting' => $view->{'quoting'},
199 'startCite' => ${$template->scrap($assign->{'startCite'})},
200 'endCite' => ${$template->scrap($assign->{'endCite'})}
205 print ${$template->scrap(
206 $assign->{'posting'},
208 $assign->{'msgID'} => $_->{'mid'},
209 $assign->{'msgAuthor'} => $_->{'name'},
210 $assign->{'msgMail'} => $header->{'email'},
211 $assign->{'msgHomepage'} => $header->{'home'},
212 $assign->{'msgTime'} => hr_time
($header->{'time'}),
213 $assign->{'msgCategory'} => plain
($header->{'category'}),
214 $assign->{'msgSubject'} => plain
($header->{'subject'}),
215 $assign->{'msgBody'} => $text
223 print ${$template->scrap(
224 $assign->{'threadDocEnd'},
235 ### end of Template::Archive ###################################################
patrick-canterino.de