Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.646
diff -u -p -r1.646 comment.module
--- modules/comment/comment.module 14 Aug 2008 19:42:26 -0000 1.646
+++ modules/comment/comment.module 19 Aug 2008 06:11:17 -0000
@@ -135,6 +135,9 @@ function comment_theme() {
'template' => 'comment-folded',
'arguments' => array('comment' => NULL),
),
+ 'comment_list' => array(
+ 'arguments' => array('comments' => NULL, 'mode' => NULL),
+ ),
'comment_flat_collapsed' => array(
'arguments' => array('comment' => NULL, 'node' => NULL),
),
@@ -820,6 +823,66 @@ function comment_links($comment, $return
}
/**
+ * Theme comment list threaded list.
+ *
+ * @param $comments
+ * An array containing comments.
+ * @param $node
+ * The node which comment(s) needs rendering.
+ * @ingroup themeable
+ */
+function theme_comment_list($comments, $node) {
+
+ $mode = _comment_get_display_setting('mode', $node);
+ $divs = 0;
+ $num_rows = FALSE;
+ $depth0 = FALSE;
+ $output = '';
+ drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css');
+
+ foreach($comments as $comment) {
+ // add divs for threaded mode
+ if ($mode == COMMENT_MODE_THREADED_COLLAPSED || $mode == COMMENT_MODE_THREADED_EXPANDED) {
+
+ if ($comment->depth > $divs) {
+ $divs++;
+ $output .= '
';
+ }
+ }
+
+ // add enclosing div for first level
+ if ($comment->depth == 0) {
+ if($depth0) $output .= '';
+ $output .= '';
+ $depth0 = TRUE;
+ }
+ }
+ if ($mode == COMMENT_MODE_FLAT_COLLAPSED) {
+ $output .= theme('comment_flat_collapsed', $comment, $node);
+ }
+ else if ($mode == COMMENT_MODE_FLAT_EXPANDED) {
+ $output .= theme('comment_flat_expanded', $comment, $node);
+ }
+ else if ($mode == COMMENT_MODE_THREADED_COLLAPSED) {
+ $output .= theme('comment_thread_collapsed', $comment, $node);
+ }
+ else if ($mode == COMMENT_MODE_THREADED_EXPANDED) {
+ $output .= theme('comment_thread_expanded', $comment, $node);
+ }
+ }
+ while ($divs-- > 0) {
+ $output .= '
';
+ }
+ if($depth0) $output .= '';
+ return $output;
+}
+
+/**
* Renders comment(s).
*
* @param $node
@@ -941,46 +1004,20 @@ function comment_render($node, $cid = 0)
$result = pager_query($query, $comments_per_page, 0, $query_count, $query_args);
- $divs = 0;
$num_rows = FALSE;
- $comments = '';
+ $comments = array();
drupal_add_css(drupal_get_path('module', 'comment') . '/comment.css');
while ($comment = db_fetch_object($result)) {
$comment = drupal_unpack($comment);
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
$comment->depth = count(explode('.', $comment->thread)) - 1;
- if ($mode == COMMENT_MODE_THREADED_COLLAPSED || $mode == COMMENT_MODE_THREADED_EXPANDED) {
- if ($comment->depth > $divs) {
- $divs++;
- $comments .= '';
- }
- else {
- while ($comment->depth < $divs) {
- $divs--;
- $comments .= '
';
- }
- }
- }
-
- if ($mode == COMMENT_MODE_FLAT_COLLAPSED) {
- $comments .= theme('comment_flat_collapsed', $comment, $node);
- }
- elseif ($mode == COMMENT_MODE_FLAT_EXPANDED) {
- $comments .= theme('comment_flat_expanded', $comment, $node);
- }
- elseif ($mode == COMMENT_MODE_THREADED_COLLAPSED) {
- $comments .= theme('comment_thread_collapsed', $comment, $node);
- }
- elseif ($mode == COMMENT_MODE_THREADED_EXPANDED) {
- $comments .= theme('comment_thread_expanded', $comment, $node);
- }
$num_rows = TRUE;
}
while ($divs-- > 0) {
$comments .= '';
}
- $output .= $comments;
+ $output .= theme('comment_list', $comments, $node);
$output .= theme('pager', NULL, $comments_per_page, 0);
}