]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/_thread.pm
ba7ae87cc3adda6afab00026cf7faf4037885a61
1 package Template
::_thread
;
3 ################################################################################
5 # File: shared/Template/_thread.pm #
7 # Authors: André Malo <nd@o3media.de> #
8 # Christian Kruse <ckruse@wwwtech.de> #
10 # Description: convert parsed thread to HTML #
12 ################################################################################
19 use Encode
::Plain
; $Encode::Plain
::utf8
= 1;
20 use Posting
::_lib
qw(short_hr_time);
25 ################################################################################
33 sub VERSION
{(q
$Revision$ =~ /([\d.]+)\s*$/)[0] or '0.0'}
35 ################################################################################
39 use base
qw(Exporter);
40 @EXPORT = qw(html_thread);
42 ### html_thread () #############################################################
46 # Params: $msg Reference of Message-Array
47 # (Output of parse_single_thread in Posting::_lib)
48 # $template Template object
49 # $par Hash Reference (see doc for details)
50 # $params Additional parameters
52 # Return: Reference of HTML String
54 sub html_thread
($$$;$) {
55 my ($msg, $template, $par, $params) = @_;
56 my $additionalVariables = $params->{'additionalVariables'} || {};
58 'action' => $params->{'action'},
59 'actionDeleted' => $params->{'actionDeleted'}
61 my $base = $params->{'base_link'};
63 return \'' unless @$msg;
65 my $temp = $par->{'template
'};
66 my $i = $par->{'cgi
'}->{'user
'};
67 my $t = $par->{'cgi
'}->{'thread
'};
68 my $p = $par->{'cgi
'}->{'posting
'};
69 my $c = $par->{'cgi
'}->{'command
'};
70 my $tid = $par->{'thread
'};
77 if ($par->{'start
'} == -1) {
79 @indexes = (1 .. $_->{answers});
81 my $del = $_->{deleted} ? 'Deleted
' : '';
82 my $action = $actions->{'action
'.$del}; $action =~ s/\Q{mid}\E/$_->{mid}/g;
94 { $temp->{'name
'} => $_->{'name
'},
95 $temp->{'subject
'} => $_->{'subject
'},
96 $temp->{'cat
'} => $_->{'cat
'},
97 $temp->{'time'} => plain(short_hr_time($_->{'time'})),
98 $temp->{'link'} => $base.query_string({$t => $tid, $p => $_->{'mid
'}}),
99 $temp->{'tid
'} => $tid,
100 $temp->{'mid
'} => $_->{'mid
'},
101 $temp->{'command
'} => $action,
102 %{$additionalVariables}
118 { $temp->{'name
'} => $_->{'name
'},
119 $temp->{'subject
'} => $_->{'subject
'},
120 $temp->{'cat
'} => $_->{'cat
'},
121 $temp->{'time'} => plain(short_hr_time ($_->{'time'})),
122 $temp->{'link'} => $base.query_string({$t => $tid, $p => $_->{'mid
'}}),
123 $temp->{'tid
'} => $tid,
124 $temp->{'mid
'} => $_->{'mid
'},
125 $temp->{'command
'} => $action,
126 %{$additionalVariables}
140 for (@$msg) { $start++; last if ($_->{'mid
'} == $par->{'start
'}); }
141 my $end = $start + $msg->[$start]->{'answers
'};
143 @indexes = ($start .. $end);
144 $oldlevel = $startlevel = $msg->[$start]->{'level
'}
145 if (defined $msg->[$start]->{'level
'});
150 for (@$msg[@indexes]) {
151 my $del = $_->{'deleted
'} ? 'Deleted
' : '';
152 my $action = $actions->{'action
'.$del}; $action =~ s/\Q{mid}\E/$_->{mid}/g;
154 if ($_->{'level
'} < $oldlevel) {
155 $html .= '</dl></dd>' x ($oldlevel - $_->{'level
'});
158 $oldlevel = $_->{'level
'};
160 if ($_->{'answers
'}) {
169 { $temp->{'name
'} => $_->{'name
'},
170 $temp->{'subject
'} => $_->{'subject
'},
171 $temp->{'cat
'} => $_->{'cat
'},
172 $temp->{'time'} => plain(short_hr_time ($_->{'time'})),
173 $temp->{'link'} => $base.query_string({$t => $tid, $p => $_->{'mid
'}}),
174 $temp->{'tid
'} => $tid,
175 $temp->{'mid
'} => $_->{'mid
'},
176 $temp->{'command
'} => $action,
177 %{$additionalVariables}
192 { $temp->{'name
'} => $_->{'name
'},
193 $temp->{'subject
'} => $_->{'subject
'},
194 $temp->{'cat
'} => $_->{'cat
'},
195 $temp->{'time'} => plain(short_hr_time ($_->{'time'})),
196 $temp->{'link'} => $base.query_string({$t => $tid, $p => $_->{'mid
'}}),
197 $temp->{'tid
'} => $tid,
198 $temp->{'mid
'} => $_->{'mid
'},
199 $temp->{'command
'} => $action,
200 %{$additionalVariables}
207 $html .= '</dl></dd>' x ($oldlevel - $startlevel);
212 # keep 'require' happy
217 ### end of Template::_thread ###################################################
patrick-canterino.de