]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/_thread.pm
1 package Template
::_thread
;
3 ################################################################################
5 # File: shared/Template/_thread.pm #
7 # Authors: Andre Malo <nd@o3media.de>, 2001-04-02 #
9 # Description: convert parsed thread to HTML #
11 ################################################################################
15 use Encode
::Plain
; $Encode::Plain
::utf8
= 1;
16 use Posting
::_lib
qw(short_hr_time);
20 ################################################################################
24 use base
qw(Exporter);
25 @Template::_thread
::EXPORT
= qw(html_thread);
27 ### sub html_thread ($$$) ######################################################
31 # Params: $msg - Reference of Message-Array
32 # (Output of parse_single_thread in Posting::_lib)
33 # $template - Template object
34 # $par - Hash Reference (see doc for details)
36 # Return: Reference of HTML String
38 sub html_thread
($$$) {
39 my ($msg, $template, $par) = @_;
41 return \'' unless @$msg;
43 my $temp = $par -> {template};
44 my $i = $par -> {cgi} -> {user};
45 my $t = $par -> {cgi} -> {thread};
46 my $p = $par -> {cgi} -> {posting};
47 my $c = $par -> {cgi} -> {command};
48 my $tid = $par -> {thread};
55 if ($par -> {start} == -1) {
57 @indexes = (1..$_ -> {answers});
59 if ($_ -> {answers}) {
63 ${$template -> scrap (
69 { $temp -> {name} => $_ -> {name},
70 $temp -> {subject} => $_ -> {subject},
71 $temp -> {cat} => $_ -> {cat},
72 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
73 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
74 $temp -> {tid} => $tid,
75 $temp -> {mid} => $_ -> {mid},
85 ${$template -> scrap (
91 { $temp -> {name} => $_ -> {name},
92 $temp -> {subject} => $_ -> {subject},
93 $temp -> {cat} => $_ -> {cat},
94 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
95 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
96 $temp -> {tid} => $tid,
97 $temp -> {mid} => $_ -> {mid},
111 for (@$msg) {$start++; last if ($_ -> {mid} == $par -> {start});}
112 my $end = $start + $msg -> [$start] -> {answers};
114 @indexes = ($start..$end);
115 $oldlevel = $startlevel = $msg -> [$start] -> {level}
116 if (defined $msg -> [$start] -> {level});
121 for (@$msg[@indexes]) {
123 if ($_ -> {level} < $oldlevel) {
124 $html.='</dl></dd>' x ($oldlevel - $_ -> {level});}
126 $oldlevel = $_ -> {level};
128 if ($_ -> {answers}) {
131 ${$template -> scrap (
137 { $temp -> {name} => $_ -> {name},
138 $temp -> {subject} => $_ -> {subject},
139 $temp -> {cat} => $_ -> {cat},
140 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
141 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
142 $temp -> {tid} => $tid,
143 $temp -> {mid} => $_ -> {mid},
152 ${$template -> scrap (
158 { $temp -> {name} => $_ -> {name},
159 $temp -> {subject} => $_ -> {subject},
160 $temp -> {cat} => $_ -> {cat},
161 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
162 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
163 $temp -> {tid} => $tid,
164 $temp -> {mid} => $_ -> {mid},
171 $html.='</dl></dd>' x ($oldlevel - $startlevel);
181 ### end of Template::_thread ###################################################
patrick-canterino.de