summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
69cc2ea)
single postings, you can now call html_thread() with an additional
parameter to set the base link of the posting display script. This is
needed by fo_delete.pm, which has its own view for the forum index.
[Christian Kruse]
# File: shared/Template/_thread.pm #
# #
# Authors: André Malo <nd@o3media.de> #
# File: shared/Template/_thread.pm #
# #
# Authors: André Malo <nd@o3media.de> #
+# Christian Kruse <ckruse@wwwtech.de> #
# #
# Description: convert parsed thread to HTML #
# #
# #
# Description: convert parsed thread to HTML #
# #
use Posting::_lib qw(short_hr_time);
use Template;
use Template::_query;
use Posting::_lib qw(short_hr_time);
use Template;
use Template::_query;
################################################################################
#
################################################################################
#
-# Params: $msg - Reference of Message-Array
+# Params: $msg Reference of Message-Array
# (Output of parse_single_thread in Posting::_lib)
# (Output of parse_single_thread in Posting::_lib)
-# $template - Template object
-# $par - Hash Reference (see doc for details)
+# $template Template object
+# $par Hash Reference (see doc for details)
+# $params Additional parameters
#
# Return: Reference of HTML String
#
#
# Return: Reference of HTML String
#
-sub html_thread ($$$) {
- my ($msg, $template, $par) = @_;
+sub html_thread ($$$;$) {
+ my ($msg, $template, $par, $params) = @_;
+ my $additionalVariables = $params->{'additionalVariables'} || {};
+ my $actions = {
+ 'action' => $params->{'action'},
+ 'actionDeleted' => $params->{'actionDeleted'}
+ };
+ my $base = $params->{'base_link'};
- my $temp = $par -> {template};
- my $i = $par -> {cgi} -> {user};
- my $t = $par -> {cgi} -> {thread};
- my $p = $par -> {cgi} -> {posting};
- my $c = $par -> {cgi} -> {command};
- my $tid = $par -> {thread};
- my $html='';
- my $startlevel=0;
- my $oldlevel=0;
+ my $temp = $par->{'template'};
+ my $i = $par->{'cgi'}->{'user'};
+ my $t = $par->{'cgi'}->{'thread'};
+ my $p = $par->{'cgi'}->{'posting'};
+ my $c = $par->{'cgi'}->{'command'};
+ my $tid = $par->{'thread'};
+ my $html = '';
+ my $startlevel = 0;
+ my $oldlevel = 0;
my @indexes;
# whole thread
my @indexes;
# whole thread
- if ($par -> {start} == -1) {
- $_ = $msg -> [0];
- @indexes = (1..$_ -> {answers});
+ if ($par->{'start'} == -1) {
+ $_ = $msg->[0];
+ @indexes = (1 .. $_->{answers});
+ my $del = $_->{deleted} ? 'Deleted' : '';
+ my $action = $actions->{'action'.$del}; $action =~ s/\Q{mid}\E/$_->{mid}/g;
+
+ if ($_->{answers}) {
- ${$template -> scrap (
- $temp -> {
- length $_ -> {cat}
+ ${$template->scrap(
+ $temp->{
+ (length $_->{'cat'}
- { $temp -> {name} => $_ -> {name},
- $temp -> {subject} => $_ -> {subject},
- $temp -> {cat} => $_ -> {cat},
- $temp -> {time} => plain(short_hr_time ($_ -> {time})),
- $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
- $temp -> {tid} => $tid,
- $temp -> {mid} => $_ -> {mid},
+ { $temp->{'name'} => $_->{'name'},
+ $temp->{'subject'} => $_->{'subject'},
+ $temp->{'cat'} => $_->{'cat'},
+ $temp->{'time'} => plain(short_hr_time($_->{'time'})),
+ $temp->{'link'} => $base.query_string({$t => $tid, $p => $_->{'mid'}}),
+ $temp->{'tid'} => $tid,
+ $temp->{'mid'} => $_->{'mid'},
+ $temp->{'command'} => $action,
+ %{$additionalVariables}
- ${$template -> scrap (
- $temp -> {
- length $_ -> {cat}
- ? 'start'
- : 'startNC'
+ ${$template->scrap(
+ $temp->{
+ (length $_->{'cat'}
+ ? 'start'
+ : 'startNC').$del
- { $temp -> {name} => $_ -> {name},
- $temp -> {subject} => $_ -> {subject},
- $temp -> {cat} => $_ -> {cat},
- $temp -> {time} => plain(short_hr_time ($_ -> {time})),
- $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
- $temp -> {tid} => $tid,
- $temp -> {mid} => $_ -> {mid},
+ { $temp->{'name'} => $_->{'name'},
+ $temp->{'subject'} => $_->{'subject'},
+ $temp->{'cat'} => $_->{'cat'},
+ $temp->{'time'} => plain(short_hr_time ($_->{'time'})),
+ $temp->{'link'} => $base.query_string({$t => $tid, $p => $_->{'mid'}}),
+ $temp->{'tid'} => $tid,
+ $temp->{'mid'} => $_->{'mid'},
+ $temp->{'command'} => $action,
+ %{$additionalVariables}
# only subthread
#
else {
# only subthread
#
else {
- my $start=-1;
- for (@$msg) {$start++; last if ($_ -> {mid} == $par -> {start});}
- my $end = $start + $msg -> [$start] -> {answers};
+ my $start = -1;
+ for (@$msg) { $start++; last if ($_->{'mid'} == $par->{'start'}); }
+ my $end = $start + $msg->[$start]->{'answers'};
- @indexes = ($start..$end);
- $oldlevel = $startlevel = $msg -> [$start] -> {level}
- if (defined $msg -> [$start] -> {level});
+ @indexes = ($start .. $end);
+ $oldlevel = $startlevel = $msg->[$start]->{'level'}
+ if (defined $msg->[$start]->{'level'});
}
# create HTML
#
for (@$msg[@indexes]) {
}
# create HTML
#
for (@$msg[@indexes]) {
+ my $del = $_->{'deleted'} ? 'Deleted' : '';
+ my $action = $actions->{'action'.$del}; $action =~ s/\Q{mid}\E/$_->{mid}/g;
- if ($_ -> {level} < $oldlevel) {
- $html.='</dl></dd>' x ($oldlevel - $_ -> {level});}
+ if ($_->{'level'} < $oldlevel) {
+ $html .= '</dl></dd>' x ($oldlevel - $_->{'level'});
+ }
- $oldlevel = $_ -> {level};
+ $oldlevel = $_->{'level'};
- if ($_ -> {answers}) {
- $html.=
+ if ($_->{'answers'}) {
+ $html .=
- ${$template -> scrap (
- $temp -> {
- length $_ -> {cat}
+ ${$template->scrap(
+ $temp->{
+ (length $_->{'cat'}
- { $temp -> {name} => $_ -> {name},
- $temp -> {subject} => $_ -> {subject},
- $temp -> {cat} => $_ -> {cat},
- $temp -> {time} => plain(short_hr_time ($_ -> {time})),
- $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
- $temp -> {tid} => $tid,
- $temp -> {mid} => $_ -> {mid},
+ { $temp->{'name'} => $_->{'name'},
+ $temp->{'subject'} => $_->{'subject'},
+ $temp->{'cat'} => $_->{'cat'},
+ $temp->{'time'} => plain(short_hr_time ($_->{'time'})),
+ $temp->{'link'} => $base.query_string({$t => $tid, $p => $_->{'mid'}}),
+ $temp->{'tid'} => $tid,
+ $temp->{'mid'} => $_->{'mid'},
+ $temp->{'command'} => $action,
+ %{$additionalVariables}
- ${$template -> scrap (
- $temp -> {
- length $_ -> {cat}
+ ${$template->scrap(
+ $temp->{
+ (length $_->{'cat'}
- { $temp -> {name} => $_ -> {name},
- $temp -> {subject} => $_ -> {subject},
- $temp -> {cat} => $_ -> {cat},
- $temp -> {time} => plain(short_hr_time ($_ -> {time})),
- $temp -> {link} => query_string({$t => $tid, $p => $_ -> {mid}}),
- $temp -> {tid} => $tid,
- $temp -> {mid} => $_ -> {mid},
+ { $temp->{'name'} => $_->{'name'},
+ $temp->{'subject'} => $_->{'subject'},
+ $temp->{'cat'} => $_->{'cat'},
+ $temp->{'time'} => plain(short_hr_time ($_->{'time'})),
+ $temp->{'link'} => $base.query_string({$t => $tid, $p => $_->{'mid'}}),
+ $temp->{'tid'} => $tid,
+ $temp->{'mid'} => $_->{'mid'},
+ $temp->{'command'} => $action,
+ %{$additionalVariables}
- $html.='</dl></dd>' x ($oldlevel - $startlevel);
+ $html .= '</dl></dd>' x ($oldlevel - $startlevel);
-### end of Template::_thread ###################################################
\ No newline at end of file
+### end of Template::_thread ###################################################