From 7c064384241df7c887129c6cdcf6453bcdb5890d Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 15 Nov 2003 10:03:31 +0000 Subject: - Made the comment module themable. Patch by CodeMonkeyX. --- modules/comment/comment.module | 77 ++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 36 deletions(-) (limited to 'modules/comment/comment.module') diff --git a/modules/comment/comment.module b/modules/comment/comment.module index a0bcad654..7007c01bb 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -230,7 +230,7 @@ function comment_reply($pid, $nid) { if ($pid) { $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $pid)); - comment_view($comment); + print theme("comment_view", $comment); } else if (user_access("access content")) { node_view(node_load(array("nid" => $nid))); @@ -275,13 +275,13 @@ function comment_preview($edit) { ** Preview the comment: */ - comment_view($comment, t("reply to this comment")); + print theme("comment_view", $comment, t("reply to this comment")); print theme("box", t("Reply"), comment_form($edit)); if ($edit["pid"]) { $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $edit["pid"])); - comment_view($comment); + print theme("comment_view", $comment); } else { node_view(node_load(array("nid" => $edit["nid"]))); @@ -535,27 +535,7 @@ function comment_links($comment, $return = 1) { return theme("links", $links); } -function comment_view($comment, $links = "", $visible = 1) { - /* - ** Switch to folded/unfolded view of the comment - */ - - if (node_is_new($comment->nid, $comment->timestamp)) { - $comment->new = 1; - print "\n"; - } - - print "cid\">\n"; - - if ($visible) { - $comment->comment = check_output($comment->comment); - print theme("comment", $comment, $links); - } - else { - print theme("comment_folded", $comment); - } -} function comment_render($node, $cid = 0) { global $user; @@ -615,7 +595,7 @@ function comment_render($node, $cid = 0) { $result = db_query("SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users", $cid); if ($comment = db_fetch_object($result)) { - comment_view($comment, comment_links($comment)); + print theme("comment_view",$comment, comment_links($comment)); } if ((comment_user_can_moderate($node)) && $user->uid != $comment->uid && !(comment_already_moderated($user->uid, $comment->users))) { @@ -1263,6 +1243,29 @@ function comment_admin() { ** overridden by themes. */ +function theme_comment_view($comment, $links = "", $visible = 1) { + + /* + ** Switch to folded/unfolded view of the comment + */ + $output = ""; + if (node_is_new($comment->nid, $comment->timestamp)) { + $comment->new = 1; + $output .= "\n"; + } + + $output .= "cid\">\n"; + + if ($visible) { + $comment->comment = check_output($comment->comment); + $output .= theme("comment", $comment, $links); + } + else { + $output .= theme("comment_folded", $comment); + } + return $output; +} + function theme_comment_mode_form($mode) { $modes = _comment_get_modes(); @@ -1367,30 +1370,31 @@ function theme_comment($comment, $links = 0) { $output .= "
". check_output($comment->comment) ."
"; $output .= "
$links
"; $output .= ""; - print $output; + return $output; } function theme_comment_folded($comment) { - print "
". l($comment->subject, comment_referer_load() ."/$comment->cid#$comment->cid") ." ". t("by") ." ". format_name($comment) ."
"; + return "
". l($comment->subject, comment_referer_load() ."/$comment->cid#$comment->cid") ." ". t("by") ." ". format_name($comment) ."
"; } function theme_comment_flat_collapsed($comment, $threshold) { if (comment_visible($comment, $threshold)) { - print comment_view($comment, "", 0); + return theme("comment_view", $comment, "", 0); } + return ""; } function theme_comment_flat_expanded($comment, $threshold) { - comment_view($comment, comment_links($comment, 0), comment_visible($comment, $threshold)); + return theme("comment_view", $comment, comment_links($comment, 0), comment_visible($comment, $threshold)); } function theme_comment_thread_min($comment, $threshold, $pid = 0) { if (comment_visible($comment, $threshold)) { - print "
depth * 25) ."\">
\n"; - print comment_view($comment, "", 0); - - print "
\n"; + $output = "
depth * 25) ."\">
\n"; + $output .= theme("comment_view", $comment, "", 0); + $output .= "
\n"; } + return $output; } function theme_comment_thread_max($comment, $threshold, $level = 0) { @@ -1402,16 +1406,17 @@ function theme_comment_thread_max($comment, $threshold, $level = 0) { ** for slow rendering and cluttered HTML. This is the best work-around ** in terms of speed and size. */ - + $output = ""; if ($comment->depth) { - print "
depth * 25) ."\"> \n"; + $output .= "
depth * 25) ."\"> \n"; } - comment_view($comment, comment_links($comment, 0), comment_visible($comment, $threshold)); + $output .= theme("comment_view", $comment, comment_links($comment, 0), comment_visible($comment, $threshold)); if ($comment->depth) { - print "
\n"; + $output .= "
\n"; } + return $output; } function theme_comment_post_forbidden() { -- cgit v1.2.3