From 728249cbc4a7a907bada7a8569d8a3d2052ab308 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 1 Mar 2001 21:34:09 +0000 Subject: - fixed small translation glitch in format_interval - added a couple of missing t() functions - improved the comments module, fixed the score problem Jeroen reported earlier -> it's slicker but I hope it won't break anything --- includes/comment.inc | 80 ++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 47 deletions(-) (limited to 'includes/comment.inc') diff --git a/includes/comment.inc b/includes/comment.inc index 44909ac65..7ec1d3734 100644 --- a/includes/comment.inc +++ b/includes/comment.inc @@ -53,7 +53,7 @@ function comment_reply($pid, $id) { if ($pid) { $item = db_fetch_object(db_query("SELECT comments.*, users.userid FROM comments LEFT JOIN users ON comments.author = users.id WHERE comments.cid = $pid")); - $theme->comment(new Comment($item->userid, $item->subject, $item->comment, $item->timestamp, $item->url, $item->fake_email, comment_score($comment), $comment->votes, $item->cid, $item->lid), "reply to this comment"); + comment_view(new Comment($item->userid, $item->subject, $item->comment, $item->timestamp, $item->url, $item->fake_email, comment_score($comment), $comment->votes, $item->cid, $item->lid), t("reply to this comment")); } else { $pid = 0; @@ -87,14 +87,14 @@ function comment_reply($pid, $id) { $output .= "\n"; - $theme->box("Reply", $output); + $theme->box(t("Reply"), $output); } function comment_preview($pid, $id, $subject, $comment) { global $allowed_html, $link, $REQUEST_URI, $theme, $user; // Preview comment: - $theme->comment(new Comment($user->userid, $subject, $comment, time(), $user->url, $user->fake_email, 0, 0, 0, 0), "reply to this comment"); + comment_view(new Comment($user->userid, $subject, $comment, time(), $user->url, $user->fake_email, 0, 0, 0, 0), t("reply to this comment")); // Build reply form: $output .= "
\n"; @@ -173,14 +173,16 @@ function comment_moderation($comment) { global $comment_votes, $op, $user; if ($op == "reply") { + // preview comment: $output .= " "; } else if ($user->id && $user->userid != $comment->userid && !user_get($user, "history", "c$comment->cid")) { - $output .= "\n"; + // comment hasn't been moderated yet: + foreach ($comment_votes as $key=>$value) $options .= " \n"; + $output .= "\n"; } else { + // comment has already been moderated: $output .= "
". t("score") .":". check_output($comment->score) ."
". t("votes") .":". check_output($comment->votes) ."
\n"; } @@ -202,32 +204,20 @@ function comment_controls($threshold = 1, $mode = 3, $order = 1) { } function comment_threshold($threshold) { - $output .= "\n"; - return $output; + for ($i = -1; $i < 6; $i++) $options .= " "; + return "\n"; } function comment_mode($mode) { global $cmodes; - $output .= "\n"; - return $output; + foreach ($cmodes as $key=>$value) $options .= " \n"; + return "\n"; } function comment_order($order) { global $corder; - $output .= "\n"; - return $output; + foreach ($corder as $key=>$value) $options .= " \n"; + return "\n"; } function comment_query($link, $lid, $order, $pid = -1) { @@ -254,44 +244,42 @@ function comment_uri($args = 0) { function comment_link($comment, $return = 1) { global $link, $theme; - if ($return) return "lid#$comment->cid") ."\">link\">return | lid&pid=$comment->cid") ."\">link\">reply to this comment"; - else return "lid&pid=$comment->cid") ."\">link\">reply to this comment"; + if ($return) return "lid#$comment->cid") ."\">link\">". t("return") ." | lid&pid=$comment->cid") ."\">link\">". t("reply to this comment") .""; + else return "lid&pid=$comment->cid") ."\">link\">". t("reply to this comment") .""; } -function comment_comment($comment, $folded = 0) { +function comment_view($comment, $folded = 0) { global $link, $theme; + + // calculate comment's score: + $comment->score = comment_score($comment); + + // display comment: if ($folded) $theme->comment($comment, $folded); - else print "lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ." by ". format_username($comment->userid) ." (". $score = comment_score($comment) .")"; + else print "lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ." by ". format_username($comment->userid) ." ($comment->score)

"; } function comment_thread_min($cid, $threshold) { - global $user, $theme; + global $user; $result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.pid = $cid ORDER BY c.timestamp, c.cid"); print "

"; } function comment_thread_max($cid, $mode, $threshold, $level = 0, $dummy = 0) { - global $link, $theme, $user; + global $link, $user; $result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE link = '$link' AND c.pid = $cid ORDER BY c.timestamp, c.cid"); print ""; @@ -318,7 +306,7 @@ function comment_render($lid, $cid) { if ($cid > 0) { $result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE cid = $cid"); if ($comment = db_fetch_object($result)) { - $theme->comment($comment, comment_link($comment)); + comment_view($comment, comment_link($comment)); } } else { @@ -336,22 +324,20 @@ function comment_render($lid, $cid) { else if ($mode == 2) { $result = comment_query($link, $lid, $order); while ($comment = db_fetch_object($result)) { - if (comment_visible($comment, $threshold)) { - $theme->comment($comment, comment_link($comment, 0)); - } + comment_view($comment, (comment_visible($comment, $threshold) ? comment_link($comment, 0) : 0)); } } else if ($mode == 3) { $result = comment_query($link, $lid, $order, 0); while ($comment = db_fetch_object($result)) { - comment_comment($comment); + comment_view($comment); comment_thread_min($comment->cid, $threshold); } } else { $result = comment_query($link, $lid, $order, 0); while ($comment = db_fetch_object($result)) { - comment_comment($comment, (comment_visible($comment, $threshold) ? comment_link($comment, 0) : 0)); + comment_view($comment, (comment_visible($comment, $threshold) ? comment_link($comment, 0) : 0)); comment_thread_max($comment->cid, $mode, $threshold, $level + 1); } } @@ -359,8 +345,8 @@ function comment_render($lid, $cid) { if ($user->id) { // Print moderation form: - print " \n"; - print " \n"; + print " \n"; + print " \n"; print "
\n"; } } -- cgit v1.2.3