--- modules/tracker/tracker.pages.inc   3 Dec 2008 16:32:22 -0000   1.13
+++ modules/tracker/tracker.pages.inc   4 Dec 2008 11:39:11 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: tracker.pages.inc,v 1.13 2008/12/03 16:32:22 dries Exp $
+// $Id: tracker.pages.inc,v 1.12 2008/10/26 18:06:39 dries Exp $
 
 /**
  * @file
@@ -22,9 +22,9 @@
       drupal_set_title($account->name);
     }
   // TODO: These queries are very expensive, see http://drupal.org/node/105639
-    $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comment} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_updated DESC';
+    $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_updated DESC';
     $sql = db_rewrite_sql($sql);
-    $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n LEFT JOIN {comment} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)';
+    $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)';
     $sql_count = db_rewrite_sql($sql_count);
     $result = pager_query($sql, 25, 0, $sql_count, COMMENT_PUBLISHED, $account->uid, $account->uid);
   }
@@ -38,26 +38,23 @@
 
   $rows = array();
   while ($node = db_fetch_object($result)) {
-    // Determine the number of comments:
-    $comments = 0;
-    if ($node->comment_count) {
-      $comments = $node->comment_count;
-
-      if ($new = comment_num_new($node->nid)) {
-        $comments .= '<br />';
-        $comments .= l(format_plural($new, '1 new', '@count new'), "node/$node->nid", array('query' => comment_new_page_count($node->comment_count, $new, $node), 'fragment' => 'new'));
-      }
-    }
-
-    $rows[] = array(
-      check_plain(node_get_types('name', $node->type)),
-      l($node->title, "node/$node->nid") . ' ' . theme('mark', node_mark($node->nid, $node->changed)),
-      theme('username', $node),
-      array('class' => 'replies', 'data' => $comments),
-      t('!time ago', array('!time' => format_interval(REQUEST_TIME - $node->last_updated)))
-    );
+    $rows[] = theme('tracker_item', $node);
   }
 
+  $output = theme('tracker', $rows);
+  
+  return $output;
+}
+
+/**
+ * Theme overall tracker output.
+ * @param $rows
+ * array of themed tracker items (rows)
+ * 
+ * @return $output
+ * html string - themed tracker output
+ */
+function theme_tracker($rows){
   if (!$rows) {
     $rows[] = array(array('data' => t('No posts available.'), 'colspan' => '5'));
   }
@@ -68,6 +65,38 @@
   $output .= theme('table', $header, $rows);
   $output .= theme('pager', NULL, 25, 0);
   $output .= '</div>';
-
+  
   return $output;
 }
+
+/**
+ * theme an individual tracker item.
+ * 
+ * @param $node
+ * node object.
+ * 
+ * @return $row
+ * themed tracker item (row)
+ */
+function theme_tracker_item($node){
+  // Determine the number of comments:
+  $comments = 0;
+  if ($node->comment_count) {
+    $comments = $node->comment_count;
+
+    if ($new = comment_num_new($node->nid)) {
+      $comments .= '<br />';
+      $comments .= l(format_plural($new, '1 new', '@count new'), "node/$node->nid", array('query' => comment_new_page_count($node->comment_count, $new, $node), 'fragment' => 'new'));
+    }
+  }
+
+  $row = array(
+    check_plain(node_get_types('name', $node->type)),
+    l($node->title, "node/$node->nid") . ' ' . theme('mark', node_mark($node->nid, $node->changed)),
+    theme('username', $node),
+    array('class' => 'replies', 'data' => $comments),
+    t('!time ago', array('!time' => format_interval(REQUEST_TIME - $node->last_updated)))
+  );
+  
+  return $row;
+}
