% if( ($valsi!=0) && ($natlangword!=0) ) { Erm. I'm not sure what kinds of games you're trying to play, but, you can't specify both the valsi and the natural language word ID if you're trying to display a thread. % return; % } % if( ($valsi==0) && ($natlangword==0) ) { Sorry, you'll have to specify either a valsi, or a natural language word for which to retrieve the thread. % return; % } <%perl> my $threadquery = $dbh->prepare("SELECT * FROM convenientthreads WHERE valsiid=? AND natlangwordid=? AND definitionId=?"); $threadquery->execute($valsi,$natlangword,$definition); my $threadrow = $threadquery->fetchrow_hashref; my $commentquery = $dbh->prepare("SELECT * FROM convenientcomments WHERE threadid = ?"); $commentquery->execute($threadrow->{'threadid'}); my(@comments, $main_parent_id, $main_comment); while(defined(my $commentrow=$commentquery->fetchrow_hashref)) { if ($commentrow->{'commentid'} == $commentid) { $main_parent_id = $commentrow->{'parentid'}; $main_comment = $commentrow; } push @{ $comments[ $commentrow->{'parentid'} ] }, $commentrow; } sub gencomment { my $comment = shift; my $comments = shift; my $myvalsi = shift; my $mynatlangword = shift; my $mydefinition = shift; my $content = $comment->{'content'}; # let wiki keep the lines proper; make sure not to double up # any existing %%% that a user manually entered. $content =~ s/%%%\r?\n/\n/mg; $content =~ s/\r?\n/%%%/mg; $m->out( "
Comment #$comment->{'commentnum'}: {'commentid'};" . "definition=$mydefinition" . "\">" . Wiki::interpret( $comment->{'subject'}, undef, 1 ) . " |
" . (sprintf("%s", $comment->{'username'},$comment->{'realname'})) . " (" . (scalar localtime $comment->{'time'}) . ") |
" . Wiki::interpret( $content ) . (defined($session{'username'}) ? sprintf("[reply]",$comment->{'commentid'}) : "") . " |
|