]> git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/_thread.pm
0cea038ab6649bdc92f0bcb0b104eb00e50e6952
[selfforum.git] / selfforum-cgi / shared / Template / _thread.pm
1 # Template/_thread.pm
2
3 # ====================================================
4 # Autor: n.d.p. / 2001-01-11
5 # lm : n.d.p. / 2001-01-11
6 # ====================================================
7 # Funktion:
8 # HTML-Darstellung eines Threads
9 # ====================================================
10
11 use strict;
12
13 package Template::_thread;
14
15 use Encode::Plain; $Encode::Plain::utf8 = 1;
16 use Posting::_lib qw(short_hr_time);
17 use Template;
18 use Template::_query;
19
20 # ====================================================
21 # Funktionsexport
22 # ====================================================
23
24 use base qw(Exporter);
25 @Template::_thread::EXPORT = qw(html_thread);
26
27 ################################
28 # sub html_thread
29 #
30 # Thread erzeugen
31 ################################
32
33 sub html_thread ($$$) {
34 my ($msg, $template, $par) = @_;
35
36 return \'' unless @$msg;
37
38 my $temp = $par -> {template};
39 my $i = $par -> {cgi} -> {user};
40 my $t = $par -> {cgi} -> {thread};
41 my $p = $par -> {cgi} -> {posting};
42 my $c = $par -> {cgi} -> {command};
43 my $tid = $par -> {thread};
44 my $html='';
45 my $startlevel=0;
46 my $oldlevel=0;
47 my @indexes;
48
49 # ganzer Thread
50 if ($par -> {start} == -1) {
51 $_ = $msg -> [0];
52 @indexes = (1..$_ -> {answers});
53
54 if ($_ -> {answers}) {
55 $html = '<dd><dl><dt>'
56 .${$template -> scrap ($temp -> {(length $_ -> {cat})?'start':'startNC'},
57 {$temp -> {name} => $_ -> {name},
58 $temp -> {subject} => $_ -> {subject},
59 $temp -> {cat} => $_ -> {cat},
60 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
61 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}})},
62 $par -> {addParam})}
63 .'</dt>';}
64
65 else {
66 $html = '<dd>'
67 .${$template -> scrap ($temp -> {(length $_ -> {cat})?'start':'startNC'},
68 {$temp -> {name} => $_ -> {name},
69 $temp -> {subject} => $_ -> {subject},
70 $temp -> {cat} => $_ -> {cat},
71 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
72 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}})},
73 $par -> {addParam})}
74 .'</dd>';
75
76 return \$html;}}
77
78 # Teilthread
79 else {
80 my $start=-1;
81 for (@$msg) {$start++; last if ($_ -> {mid} == $par -> {start});}
82 my $end = $start + $msg -> [$start] -> {answers};
83 $start++;
84 @indexes = ($start..$end);
85 $oldlevel = $startlevel = $msg -> [$start] -> {level};}
86
87 # HTML erzeugen
88 for (@$msg[@indexes]) {
89
90 if ($_ -> {level} < $oldlevel) {
91 $html.='</dl></dd>' x ($oldlevel - $_ -> {level});}
92
93 $oldlevel = $_ -> {level};
94
95 if ($_ -> {answers}) {
96 $html.='<dd><dl><dt>'
97 .${$template -> scrap ($temp -> {(length $_ -> {cat})?'line':'lineNC'},
98 {$temp -> {name} => $_ -> {name},
99 $temp -> {subject} => $_ -> {subject},
100 $temp -> {cat} => $_ -> {cat},
101 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
102 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}})},
103 $par -> {addParam})}
104 .'</dt>';
105 }
106 else {
107 $html.='<dd>'
108 .${$template -> scrap ($temp -> {(length $_ -> {cat})?'line':'lineNC'},
109 {$temp -> {name} => $_ -> {name},
110 $temp -> {subject} => $_ -> {subject},
111 $temp -> {cat} => $_ -> {cat},
112 $temp -> {time} => plain(short_hr_time ($_ -> {time})),
113 $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}})},
114 $par -> {addParam})}
115 .'</dd>';
116 }
117 }
118
119 $html.='</dl></dd>' x ($oldlevel - $startlevel);
120
121 \$html;
122 }
123
124 # ====================================================
125 # Modulinitialisierung
126 # ====================================================
127
128 # making require happy
129 1;
130
131 # ====================================================
132 # end of Template::_thread
133 # ====================================================

patrick-canterino.de