%DEF .show_forum>
<%PERL>
my $sth = $dbh->prepare("SELECT * from $tree WHERE parent=$parent_id;");
if (! $sth) {
$m->out("Error: " . $dbh->errstr . "
");
return;
}
if (! $sth->execute()) {
$m->out("Error: " . $dbh->errstr . "
");
return;
}
while( my $ref = $sth->fetchrow_hashref ) {
$m->out('- ');
if ($ref->{resource} > 0) # file
{
my $sth1 = $dbh->prepare("SELECT * from $resource_table WHERE id=".$ref->{resource}.";");
if (! $sth1) {
$m->out("Error: " . $dbh->errstr . "
");
return;
}
if (! $sth1->execute()) {
$m->out("Error: " . $dbh->errstr . "
");
return;
}
my $ref1 = $sth1->fetchrow_hashref;
%PERL>
% if ($ref1) {
% my $time = $ref1->{mtime} if (defined $ref1->{mtime});
% my ($y,$m,$d,$h,$min)=($time =~ /^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)/);
% $time = "$y-$m-$d $h:$min";
<% $ref1->{author} %> '<% $ref1->{subj} %>'
<% $time %>
| Reply
% if ($ref1->{email}) {
| EMail
% }
% } else {
Неверная запись: id=<% $ref->{id} %>, resource=<% $ref->{resource} %>
% }
<%PERL>
$sth1->finish;
if ($recursion_level > 1 ) {
$m->comp('.show_forum',
tree=>$tree,
resource_table=>$resource_table,
parent_id=>$ref->{id},
recursion_level=>($recursion_level-1),
admin=>$admin,
dbh=>$dbh);
}
}
else # folder
{
%PERL>
ТЕМА: <% $ref->{title} %>
<%PERL>
if ($recursion_level > 1 ) {
$m->comp('.show_forum',
tree=>$tree,
resource_table=>$resource_table,
parent_id=>$ref->{id},
recursion_level=>($recursion_level-1),
admin=>$admin,
dbh=>$dbh);
}
}
$m->out(' ');
}
%PERL>
<%ARGS>
$resource_table
$tree
$parent_id
$recursion_level
$admin
$dbh
%ARGS>
%DEF>
<%INIT>
use strict;
return -1 if $tree !~ /^tree_\w+$/;
return -1 if $resource_table !~ /^resource_\w+$/;
return -1 if $parent_id !~ /^\d+$/;
return -1 if $recursion_level !~ /^\d+$/;
return -1 if $recursion_level > 30;
my $dbh = $m->comp("/includes/dbcon.msn");
return unless $dbh;
$m->comp('.show_forum',
tree=>$tree,
resource_table=>$resource_table,
recursion_level=>$recursion_level,
parent_id=>$parent_id,
admin=>$admin,
dbh=>$dbh
);
$dbh->disconnect();
%INIT>
<%ARGS>
$resource_table
$tree
$parent_id => 0
$recursion_level => 30
$admin => undef
%ARGS>