]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/_thread.pm
c47f28c3ee4a577d8b411b0978cfcdba8eca96fa
1 package Template
::_thread
;
3 ################################################################################
5 # File: shared/Template/_thread.pm #
7 # Authors: Andre Malo <nd@o3media.de>, 2001-06-16 #
9 # Description: convert parsed thread to HTML #
11 ################################################################################
19 use Encode
::Plain
; $Encode::Plain
::utf8
= 1;
20 use Posting
::_lib
qw(short_hr_time);
24 ################################################################################
28 $VERSION = do { my @r =(q
$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x
$#r, @r };
30 ################################################################################
34 use base
qw(Exporter);
35 @EXPORT = qw(html_thread);
37 ### html_thread () #############################################################
41 # Params: $msg - Reference of Message-Array
42 # (Output of parse_single_thread in Posting::_lib)
43 # $template - Template object
44 # $par - Hash Reference (see doc for details)
46 # Return: Reference of HTML String
48 sub html_thread
($$$) {
49 my ($msg, $template, $par) = @_;
51 return \'' unless @$msg;
53 my $temp = $par -> {template};
54 my $i = $par -> {cgi} -> {user};
55 my $t = $par -> {cgi} -> {thread};
56 my $p = $par -> {cgi} -> {posting};
57 my $c = $par -> {cgi} -> {command};
58 my $tid = $par -> {thread};
65 if ($par -> {start} == -1) {
67 @indexes = (1..$_ -> {answers});
69 if ($_ -> {answers}) {
73 ${$template -> scrap (
79 { $temp -> {name} => $_ -> {name},
80 $temp -> {subject} => $_ -> {subject},
81 $temp -> {cat} => $_ -> {cat},
82 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
83 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
84 $temp -> {tid} => $tid,
85 $temp -> {mid} => $_ -> {mid},
95 ${$template -> scrap (
101 { $temp -> {name} => $_ -> {name},
102 $temp -> {subject} => $_ -> {subject},
103 $temp -> {cat} => $_ -> {cat},
104 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
105 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
106 $temp -> {tid} => $tid,
107 $temp -> {mid} => $_ -> {mid},
121 for (@$msg) {$start++; last if ($_ -> {mid} == $par -> {start});}
122 my $end = $start + $msg -> [$start] -> {answers};
124 @indexes = ($start..$end);
125 $oldlevel = $startlevel = $msg -> [$start] -> {level}
126 if (defined $msg -> [$start] -> {level});
131 for (@$msg[@indexes]) {
133 if ($_ -> {level} < $oldlevel) {
134 $html.='</dl></dd>' x ($oldlevel - $_ -> {level});}
136 $oldlevel = $_ -> {level};
138 if ($_ -> {answers}) {
141 ${$template -> scrap (
147 { $temp -> {name} => $_ -> {name},
148 $temp -> {subject} => $_ -> {subject},
149 $temp -> {cat} => $_ -> {cat},
150 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
151 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
152 $temp -> {tid} => $tid,
153 $temp -> {mid} => $_ -> {mid},
162 ${$template -> scrap (
168 { $temp -> {name} => $_ -> {name},
169 $temp -> {subject} => $_ -> {subject},
170 $temp -> {cat} => $_ -> {cat},
171 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
172 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
173 $temp -> {tid} => $tid,
174 $temp -> {mid} => $_ -> {mid},
181 $html.='</dl></dd>' x ($oldlevel - $startlevel);
186 # keep 'require' happy
191 ### end of Template::_thread ###################################################
patrick-canterino.de