]> git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/Archive.pm
Initial release
[selfforum.git] / selfforum-cgi / shared / Template / Archive.pm
1 package Template::Archive;
2
3 ################################################################################
4 # #
5 # File: shared/Template/Archive.pm #
6 # #
7 # Authors: Frank Schoenmann <fs@tower.de>, 2001-06-04 #
8 # #
9 # Description: archive display #
10 # #
11 ################################################################################
12
13 use strict;
14
15 use Lock qw(:READ);
16 use Encode::Posting;
17 use Encode::Plain; $Encode::Plain::utf8 = 1;
18 use Posting::_lib qw(
19 get_message_node
20 get_message_header
21 get_message_body
22
23 parse_single_thread
24 parse_xml_file
25
26 hr_time
27
28 KILL_DELETED
29 );
30 use Template;
31 use Template::_conf;
32 use Template::_thread;
33
34 ################################################################################
35 #
36 # Export
37 #
38 use base qw(Exporter);
39 @Template::Archive::EXPORT = qw(print_thread_as_HTML);
40
41
42 ### print_year_as_HTML () ######################################################
43 #
44 # yearly overview over months
45 #
46 # Params:
47 # $tempfile template filename
48 # $param hash reference
49 # Return: -none-
50 #
51
52
53 ### print_month_as_HTML () #####################################################
54 #
55 # monthly overview over threads
56 #
57 # Params: $mainfile XML file on a per-month base
58 # $tempfile template filename
59 # $param hash reference
60 # Return: -none-
61 #
62 sub print_month_as_HTML($$$) {
63 my ($mainfile, $tempfile, $param) = @_;
64
65 my $template = new Template $tempfile;
66
67
68 }
69
70 ### print_thread_as_HTML () ####################################################
71 #
72 # print a complete thread
73 #
74 # Params: $mainfile thread XML file
75 # $tempfile template filename
76 # $param hash reference
77 # Return: -none-
78 #
79 sub print_thread_as_HTML($$$) {
80 my ($mainfile, $tempfile, $param) = @_;
81
82 my $assign = $param->{'assign'};
83 my $tree = $param->{'tree'};
84 my $tid = $param->{'thread'};
85
86 my $template = new Template $tempfile;
87
88 my $view = get_view_params ({
89 'adminDefault' => $param->{'adminDefault'}
90 });
91 my $xml = parse_xml_file($mainfile);
92 my $tnode = $xml->getElementsByTagName('Thread', 1)->item(0);
93 my $thread = parse_single_thread($tnode, KILL_DELETED);
94
95 my $addparam = {
96 $tree->{'year'} => $param->{'year'},
97 $tree->{'month'} => $param->{'month'}
98 };
99
100 my $tpar = {
101 'thread' => $param->{'thread'},
102 'template' => $param->{'tree'},
103 'start' => '-1',
104 'cgi' => $param->{'cgi'},
105 'addParam' => $addparam
106 };
107
108 my $tmplparam = {
109 $assign->{'threadCategory'} => $thread->[0]->{'cat'},
110 $assign->{'threadTitle'} => $thread->[0]->{'subject'},
111 $assign->{'threadYear'} => $param->{'year'},
112 $assign->{'threadMonth'} => $param->{'month'},
113 $param->{'tree'}->{'main'} => html_thread($thread, $template, $tpar)
114 };
115
116 print ${$template->scrap(
117 $assign->{'threadDocStart'},
118 $tmplparam
119 )};
120
121 for (@$thread) {
122 my $mnode = get_message_node($xml, 't'.$tid, 'm'.$_->{'mid'});
123 my $header = get_message_header($mnode);
124 my $body = get_message_body($xml, 'm'.$_->{'mid'});
125
126 my $text = message_field (
127 $body,
128 {
129 'quoteChars' => plain($view->{'quoteChars'}),
130 'quoting' => $view->{'quoting'},
131 'startCite' => ${$template->scrap($assign->{'startCite'})},
132 'endCite' => ${$template->scrap($assign->{'endCite'})}
133 }
134 );
135
136
137 print ${$template->scrap(
138 $assign->{'posting'},
139 {
140 $assign->{'msgID'} => $_->{'mid'},
141 $assign->{'msgAuthor'} => $_->{'name'},
142 $assign->{'msgMail'} => $header->{'email'},
143 $assign->{'msgHomepage'} => $header->{'home'},
144 $assign->{'msgTime'} => hr_time($header->{'time'}),
145 $assign->{'msgCategory'} => plain($header->{'category'}),
146 $assign->{'msgSubject'} => plain($header->{'subject'}),
147 $assign->{'msgBody'} => $text
148 }
149 )};
150 }
151
152 print ${$template->scrap(
153 $assign->{'threadDocEnd'},
154 $tmplparam
155 )};
156 }
157
158
159 # keep require happy
160 1;
161
162 #
163 #
164 ### end of Template::Archive ###################################################

patrick-canterino.de