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

patrick-canterino.de