From 10eefa1f9b43420c8609f5809bfe9dd81ebaca7d Mon Sep 17 00:00:00 2001 From: ndparker <> Date: Mon, 2 Apr 2001 08:46:04 +0000 Subject: [PATCH] fixed a warning producing bug, style changes, some comments added --- selfforum-cgi/shared/Template/_thread.pm | 183 ++++++++++++++--------- 1 file changed, 112 insertions(+), 71 deletions(-) diff --git a/selfforum-cgi/shared/Template/_thread.pm b/selfforum-cgi/shared/Template/_thread.pm index 0cea038..7b65d1d 100644 --- a/selfforum-cgi/shared/Template/_thread.pm +++ b/selfforum-cgi/shared/Template/_thread.pm @@ -1,35 +1,40 @@ -# Template/_thread.pm +package Template::_thread; -# ==================================================== -# Autor: n.d.p. / 2001-01-11 -# lm : n.d.p. / 2001-01-11 -# ==================================================== -# Funktion: -# HTML-Darstellung eines Threads -# ==================================================== +################################################################################ +# # +# File: shared/Template/_thread.pm # +# # +# Authors: Andre Malo , 2001-04-02 # +# # +# Description: convert parsed thread to HTML # +# # +################################################################################ use strict; -package Template::_thread; - use Encode::Plain; $Encode::Plain::utf8 = 1; use Posting::_lib qw(short_hr_time); use Template; use Template::_query; -# ==================================================== -# Funktionsexport -# ==================================================== - +################################################################################ +# +# Export +# use base qw(Exporter); @Template::_thread::EXPORT = qw(html_thread); -################################ -# sub html_thread +### sub html_thread ($$$) ###################################################### +# +# create HTML string +# +# Params: $msg - Reference of Message-Array +# (Output of parse_single_thread in Posting::_lib) +# $template - Template object +# $par - Hash Reference (see doc for details) +# +# Return: Reference of HTML String # -# Thread erzeugen -################################ - sub html_thread ($$$) { my ($msg, $template, $par) = @_; @@ -46,45 +51,69 @@ sub html_thread ($$$) { my $oldlevel=0; my @indexes; - # ganzer Thread + # whole thread if ($par -> {start} == -1) { $_ = $msg -> [0]; @indexes = (1..$_ -> {answers}); if ($_ -> {answers}) { - $html = '
' - .${$template -> scrap ($temp -> {(length $_ -> {cat})?'start':'startNC'}, - {$temp -> {name} => $_ -> {name}, - $temp -> {subject} => $_ -> {subject}, - $temp -> {cat} => $_ -> {cat}, - $temp -> {time} => plain(short_hr_time ($_ -> {time})), - $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}})}, - $par -> {addParam})} - .'
';} + $html = + '
'. + + ${$template -> scrap ( + $temp -> { + length $_ -> {cat} + ? 'start' + : 'startNC' + }, + { $temp -> {name} => $_ -> {name}, + $temp -> {subject} => $_ -> {subject}, + $temp -> {cat} => $_ -> {cat}, + $temp -> {time} => plain(short_hr_time ($_ -> {time})), + $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}) + }, + $par -> {addParam} + )} . + '
'; + } else { - $html = '
' - .${$template -> scrap ($temp -> {(length $_ -> {cat})?'start':'startNC'}, - {$temp -> {name} => $_ -> {name}, - $temp -> {subject} => $_ -> {subject}, - $temp -> {cat} => $_ -> {cat}, - $temp -> {time} => plain(short_hr_time ($_ -> {time})), - $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}})}, - $par -> {addParam})} - .'
'; - - return \$html;}} - - # Teilthread + $html = + '
'. + ${$template -> scrap ( + $temp -> { + length $_ -> {cat} + ? 'start' + : 'startNC' + }, + { $temp -> {name} => $_ -> {name}, + $temp -> {subject} => $_ -> {subject}, + $temp -> {cat} => $_ -> {cat}, + $temp -> {time} => plain(short_hr_time ($_ -> {time})), + $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}) + }, + $par -> {addParam} + )}. + '
'; + + return \$html; + } + } + + # only subthread + # else { my $start=-1; for (@$msg) {$start++; last if ($_ -> {mid} == $par -> {start});} my $end = $start + $msg -> [$start] -> {answers}; $start++; @indexes = ($start..$end); - $oldlevel = $startlevel = $msg -> [$start] -> {level};} + $oldlevel = $startlevel = $msg -> [$start] -> {level} + if (defined $msg -> [$start] -> {level}); + } - # HTML erzeugen + # create HTML + # for (@$msg[@indexes]) { if ($_ -> {level} < $oldlevel) { @@ -93,41 +122,53 @@ sub html_thread ($$$) { $oldlevel = $_ -> {level}; if ($_ -> {answers}) { - $html.='
' - .${$template -> scrap ($temp -> {(length $_ -> {cat})?'line':'lineNC'}, - {$temp -> {name} => $_ -> {name}, - $temp -> {subject} => $_ -> {subject}, - $temp -> {cat} => $_ -> {cat}, - $temp -> {time} => plain(short_hr_time ($_ -> {time})), - $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}})}, - $par -> {addParam})} - .'
'; + $html.= + '
'. + ${$template -> scrap ( + $temp -> { + length $_ -> {cat} + ? 'line' + : 'lineNC' + }, + { $temp -> {name} => $_ -> {name}, + $temp -> {subject} => $_ -> {subject}, + $temp -> {cat} => $_ -> {cat}, + $temp -> {time} => plain(short_hr_time ($_ -> {time})), + $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}) + }, + $par -> {addParam} + )}. + '
'; } else { - $html.='
' - .${$template -> scrap ($temp -> {(length $_ -> {cat})?'line':'lineNC'}, - {$temp -> {name} => $_ -> {name}, - $temp -> {subject} => $_ -> {subject}, - $temp -> {cat} => $_ -> {cat}, - $temp -> {time} => plain(short_hr_time ($_ -> {time})), - $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}})}, - $par -> {addParam})} - .'
'; + $html.= + '
'. + ${$template -> scrap ( + $temp -> { + length $_ -> {cat} + ? 'line' + : 'lineNC' + }, + { $temp -> {name} => $_ -> {name}, + $temp -> {subject} => $_ -> {subject}, + $temp -> {cat} => $_ -> {cat}, + $temp -> {time} => plain(short_hr_time ($_ -> {time})), + $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}) + }, + $par -> {addParam} + )}. + '
'; } } - $html.='
' x ($oldlevel - $startlevel); \$html; } -# ==================================================== -# Modulinitialisierung -# ==================================================== - -# making require happy +# keep require happy 1; -# ==================================================== -# end of Template::_thread -# ==================================================== \ No newline at end of file +# +# +### end of Template::_thread ################################################### + -- 2.34.1