Index: talk.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/talk/talk.module,v
retrieving revision 1.1.2.1.2.1.2.1
diff -u -p -u -p -r1.1.2.1.2.1.2.1 talk.module
--- talk.module	17 Sep 2008 16:07:26 -0000	1.1.2.1.2.1.2.1
+++ talk.module	3 Mar 2009 01:01:44 -0000
@@ -192,3 +192,57 @@ function theme_talkpage($node, $add_comm
   }
   return $output;
 }
+
+/**
+ * Add a new handler for comments with appropriate  
+ */
+function talk_views_tables_alter(&$tables) {
+  $tables['node_comment_statistics']['fields']['comment_count']['handler']['views_handler_field_commentlink_talk'] = t('Normal (Talk)');
+  $tables['node_comment_statistics']['fields']['comment_count']['handler']['views_handler_comments_with_new_talk'] = t('With New Count (Talk)');
+}
+
+/**
+ * Format a field as a number of comments, plus the number of unread comments.
+ * This is almost the same as the standard views one, except that it links to a
+ * talk page if enabled for that content type.
+ */
+function views_handler_comments_with_new_talk($fieldinfo, $fielddata, $value, $data) {
+  $comments = intval($value);
+  if ($comments && $new = comment_num_new($data->nid)) {
+    $talk = '';
+    $node = $data;
+    if (!isset($node->type)) {
+      // Only load the node if we don't have a type available already (via a field, for example).
+      // This saves doing lots of unnecessary node_loads for a long listing.
+      $node = node_load($data->nid);
+    }
+    if (talk_activated($node->type)) {
+      $talk = '/talk';
+    }
+    $comments .= '<br />';
+    $comments .= l(t('@num new', array('@num' => $new)), "node/$data->nid$talk", NULL, NULL, 'new');
+  }
+  return $comments;
+}
+
+/*
+ * Format a field as a link to a comment.
+ * This is almost the same as the standard views one, except that it links to a
+ * talk page if enabled for that content type.
+ */
+function views_handler_field_commentlink_talk($fieldinfo, $fielddata, $value, $data) {
+  $comments = intval($value);
+  if ($fielddata['options'] == 'nolink' || !$comments) {
+    return check_plain($value);
+  }
+  $node = $data;
+  if (!isset($node->type)) {
+    // Only load the node if we don't have a type available already (via a field, for example).
+    // This saves doing lots of unnecessary node_loads for a long listing.
+    $node = node_load($data->nid);
+  }
+  if (talk_activated($node->type)) {
+    $talk = '/talk';
+  }
+  return l($value, "node/$data->nid$talk", NULL, NULL, "comment-$data->comments_cid");
+}
\ No newline at end of file
