]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/_thread.pm
f4ee5b28086f81ddfda4728233ebf04681277a1d
1 package Template
::_thread
;
3 ################################################################################
5 # File: shared/Template/_thread.pm #
7 # Authors: André Malo <nd@o3media.de> #
9 # Description: convert parsed thread to HTML #
11 ################################################################################
18 use Encode
::Plain
; $Encode::Plain
::utf8
= 1;
19 use Posting
::_lib
qw(short_hr_time);
23 ################################################################################
31 sub VERSION
{(q
$Revision$ =~ /([\d.]+)\s*$/)[0] or '0.0'}
33 ################################################################################
37 use base
qw(Exporter);
38 @EXPORT = qw(html_thread);
40 ### html_thread () #############################################################
44 # Params: $msg - Reference of Message-Array
45 # (Output of parse_single_thread in Posting::_lib)
46 # $template - Template object
47 # $par - Hash Reference (see doc for details)
49 # Return: Reference of HTML String
51 sub html_thread
($$$) {
52 my ($msg, $template, $par) = @_;
54 return \'' unless @$msg;
56 my $temp = $par -> {template};
57 my $i = $par -> {cgi} -> {user};
58 my $t = $par -> {cgi} -> {thread};
59 my $p = $par -> {cgi} -> {posting};
60 my $c = $par -> {cgi} -> {command};
61 my $tid = $par -> {thread};
68 if ($par -> {start} == -1) {
70 @indexes = (1..$_ -> {answers});
72 if ($_ -> {answers}) {
76 ${$template -> scrap (
82 { $temp -> {name} => $_ -> {name},
83 $temp -> {subject} => $_ -> {subject},
84 $temp -> {cat} => $_ -> {cat},
85 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
86 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
87 $temp -> {tid} => $tid,
88 $temp -> {mid} => $_ -> {mid},
98 ${$template -> scrap (
104 { $temp -> {name} => $_ -> {name},
105 $temp -> {subject} => $_ -> {subject},
106 $temp -> {cat} => $_ -> {cat},
107 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
108 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
109 $temp -> {tid} => $tid,
110 $temp -> {mid} => $_ -> {mid},
124 for (@$msg) {$start++; last if ($_ -> {mid} == $par -> {start});}
125 my $end = $start + $msg -> [$start] -> {answers};
127 @indexes = ($start..$end);
128 $oldlevel = $startlevel = $msg -> [$start] -> {level}
129 if (defined $msg -> [$start] -> {level});
134 for (@$msg[@indexes]) {
136 if ($_ -> {level} < $oldlevel) {
137 $html.='</dl></dd>' x ($oldlevel - $_ -> {level});}
139 $oldlevel = $_ -> {level};
141 if ($_ -> {answers}) {
144 ${$template -> scrap (
150 { $temp -> {name} => $_ -> {name},
151 $temp -> {subject} => $_ -> {subject},
152 $temp -> {cat} => $_ -> {cat},
153 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
154 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
155 $temp -> {tid} => $tid,
156 $temp -> {mid} => $_ -> {mid},
165 ${$template -> scrap (
171 { $temp -> {name} => $_ -> {name},
172 $temp -> {subject} => $_ -> {subject},
173 $temp -> {cat} => $_ -> {cat},
174 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
175 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
176 $temp -> {tid} => $tid,
177 $temp -> {mid} => $_ -> {mid},
184 $html.='</dl></dd>' x ($oldlevel - $startlevel);
189 # keep 'require' happy
194 ### end of Template::_thread ###################################################
patrick-canterino.de