Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simplefeed/README.txt,v
retrieving revision 1.18.4.15
diff -u -F^f -r1.18.4.15 README.txt
--- README.txt	26 Sep 2008 04:20:36 -0000	1.18.4.15
+++ README.txt	28 Sep 2008 04:50:19 -0000
@@ -48,7 +48,7 @@
 - optional views support
 - optional token support
 - optionally verify feeds before adding to database
-
+- optional stats collecting module for per-feed stats and global stats on feed usage
 
 
 ###   INSTALLATION   #############################################################################
@@ -108,6 +108,7 @@
 
 3.x, 2008-xx-xx
 ----------------------
+- #314087 - new feed stats
 - #297991 - move refresh/empty links to local tasks instead of links
 - #301290 - improved performance with feeds throwing errors, new option to verify feeds at input
 - #307686 - fix Feedburner feeds and improve performance of feed checking
Index: simplefeed.css
===================================================================
RCS file: simplefeed.css
diff -N simplefeed.css
--- simplefeed.css	3 Oct 2007 21:19:05 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,15 +0,0 @@
-/* $Id: simplefeed.css,v 1.3 2007/10/03 21:19:05 m3avrck Exp $ */
-ul.simplefeed, ul.simplefeed-item {
-margin:0;
-padding:0.3em;
-border:1px solid #ccc;
-background:#eee;
-}
-
-ul.simplefeed li, ul.simplefeed-item li {
-display: inline;
-list-style-type: none;
-background:none;
-margin:0;
-padding:0 2em 0 0;
-}
\ No newline at end of file
Index: simplefeed.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simplefeed/simplefeed.module,v
retrieving revision 1.46.2.12
diff -u -F^f -r1.46.2.12 simplefeed.module
--- simplefeed.module	26 Sep 2008 04:15:47 -0000	1.46.2.12
+++ simplefeed.module	28 Sep 2008 04:50:19 -0000
@@ -30,22 +30,25 @@ function simplefeed_menu() {
     'description' => t('Configure how feeds are parsed.'),
     'page callback' => 'drupal_get_form',
     'page arguments' => array('simplefeed_admin_settings'),
+    'access callback' => 'user_access',
     'access arguments' => array('administer feeds'),
     'file' => 'simplefeed.admin.inc',
   );
-  $items['node/%/refresh'] = array(
+  $items['node/%node/refresh'] = array(
     'title' => t('Refresh feed'),
     'page callback' => 'simplefeed_feed_refresh',
     'page arguments' => array(1),
-    'access arguments' => array('administer feeds'),
+    'access callback' => 'simplefeed_feed_access',
+    'access arguments' => array(1),
     'type' => MENU_LOCAL_TASK,
     'weight' => 2
   );
-  $items['node/%/empty'] = array(
+  $items['node/%node/empty'] = array(
     'title' => t('Empty feed'),
     'page callback' => 'simplefeed_feed_empty',
     'page arguments' => array(1),
-    'access arguments' => array('administer feeds'),
+    'access callback' => 'simplefeed_feed_access',
+    'access arguments' => array(1),
     'type' => MENU_LOCAL_TASK,
     'weight' => 3
   );
@@ -53,16 +56,16 @@ function simplefeed_menu() {
   return $items;
 }
 
-
 /**
- * Implementation of hook_theme().
+ * Determine access for feed callbacks.
  */
-function simplefeed_theme() {
-  return array(
-    'simplefeed_node_view' => array(
-      'arguments' => array('values' => NULL),
-    ),
-  );
+function simplefeed_feed_access($node) {
+  if ($node->type == 'feed' && user_access('administer feeds')) {
+    return TRUE;
+  }
+  else {
+    return FALSE;
+  }
 }
 
 
@@ -284,58 +287,6 @@ function simplefeed_nodeapi(&$node, $op,
 
 
 /**
- * Implementation of hook_view().
- */
-function simplefeed_view($node, $teaser = FALSE, $page = FALSE) {
-  $node = node_prepare($node, $teaser);
-
-  $node->content['simplefeed']['#theme'] = 'simplefeed_node_view';
-  $node->content['simplefeed']['#weight'] = 2;
-  $node->content['simplefeed']['url'] = array(
-    '#value' => check_url($node->url),
-    '#weight' => 1,
-  );
-
-  // since only administrators can edit when a feed expires, only admins can see what this value is
-  if (user_access('administer feeds')) {
-    $node->content['simplefeed']['expires'] = array(
-      '#value' => format_interval($node->expires),
-    );
-    $node->content['simplefeed']['refresh'] = array(
-      '#value' => format_interval($node->refresh),
-    );
-    $node->content['simplefeed']['checked'] = array(
-      '#value' => $node->checked > 0 ? format_interval(time() - $node->checked) . t(' ago') : t('Never'),
-    );
-  }
-
-  return $node;
-}
-
-
-/**
- * Theme the display of a feed node.
- */
-function theme_simplefeed_node_view($values) {
-  // needs to be a space so default values aren't outputed
-  $output = ' ';
-
-  // since only administrators can edit when a feed expires, only admins can see what this value is
-  if (user_access('administer feeds')) {
-    drupal_add_css(drupal_get_path('module', 'simplefeed') .'/simplefeed.css');
-
-    $output .= '<ul class="simplefeed">';
-    $output .= '<li><strong>Expires:</strong> '. $values['expires']['#value'] .'</li>';
-    $output .= '<li><strong>Refresh:</strong> '. $values['refresh']['#value'] .'</li>';
-    $output .= '<li><strong>Checked:</strong> '. $values['checked']['#value'] .'</li>';
-    $output .= '</ul>';
-  }
-
-  return $output;
-}
-
-
-/**
  * Implementation of hook_link().
  */
 function simplefeed_link($type, $node = NULL, $teaser = FALSE) {
@@ -367,12 +318,12 @@ function simplefeed_cron() {
 /**
  * Refresh a feed, downloading any new feed items and creating nodes for them.
  */
-function simplefeed_feed_refresh($nid = NULL) {
+function simplefeed_feed_refresh($node = NULL) {
   // initialize simplepie
   // we want to do this only once and not each time per feed, which would be slower
   include_once './'. drupal_get_path('module', 'simplefeed') .'/simplepie.inc';
 
-  if (!$nid) {
+  if (!$node) {
     // refresh all feeds
     $limit = variable_get('simplefeed_cron_throttle', 50);
     // limit in ASC order so we grab the top N that haven't been checked recently
@@ -389,14 +340,10 @@ function simplefeed_feed_refresh($nid = 
       simplefeed_feed_process($process_feed->nid);
     }
   }
-  else if (is_numeric($nid)) {
-    simplefeed_feed_process($nid);
-    drupal_set_message(t('Feed refreshed.'));
-    drupal_goto('node/'. $nid);
-  }
   else {
-    drupal_not_found();
-    exit;
+    simplefeed_feed_process($node->nid);
+    drupal_set_message(t('Feed refreshed.'));
+    drupal_goto('node/'. $node->nid);
   }
 }
 
@@ -444,7 +391,12 @@ function simplefeed_feed_process($nid) {
   }
   else if (isset($feed->error)) {
     db_query("UPDATE {simplefeed_feed} SET error = 1 WHERE vid = %d", $process_feed->vid);
-    watchdog('simplefeed', 'The feed %feed could not be processed due to the following error: %error', array('%feed' => $process_feed->title, '%error' => $feed->error), WATCHDOG_ERROR, l('view', 'node/'. $process_feed->nid));
+    if (module_exists('simplefeed_stats')) {
+      simplefeed_stats_feed_fail($process_feed, $feed->error);
+    }
+    else {
+      watchdog('simplefeed', 'The feed %feed could not be processed due to the following error: %error', array('%feed' => $process_feed->title, '%error' => $feed->error), WATCHDOG_ERROR, l('view', 'node/'. $process_feed->nid));
+    }
   }
   else {
     watchdog('simplefeed', 'You shouldn\'t be here. Something has gone terribly wrong.');
@@ -455,20 +407,19 @@ function simplefeed_feed_process($nid) {
 /**
  * Delete all feed items associated with a feed.
  */
-function simplefeed_feed_empty($nid) {
-  if (is_numeric($nid)) {
-    $nodes = db_query("SELECT nid FROM {simplefeed_feed_item} WHERE fid = %d", $nid);
-    while ($node = db_fetch_object($nodes)) {
-      node_delete($node->nid);
-    }
-    db_query("UPDATE {simplefeed_feed} SET hash = '' WHERE nid = %d", $nid);
-    drupal_set_message(t('Feed emptied.'));
-    drupal_goto('node/'. $nid);
+function simplefeed_feed_empty($node) {
+  $feeds = db_query("SELECT nid FROM {simplefeed_feed_item} WHERE fid = %d", $node->nid);
+  while ($feed = db_fetch_object($feeds)) {
+    node_delete($feed->nid);
   }
-  else {
-    drupal_not_found();
-    exit;
+  db_query("UPDATE {simplefeed_feed} SET hash = NULL WHERE nid = %d", $node->nid);
+
+  if (module_exists('simplefeed_stats')) {
+    simplefeed_stats_feed_empty($node->nid);
   }
+
+  drupal_set_message(t('Feed emptied.'));
+  drupal_goto('node/'. $node->nid);
 }
 
 /**
Index: simplefeed_item.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simplefeed/simplefeed_item.module,v
retrieving revision 1.52.2.12
diff -u -F^f -r1.52.2.12 simplefeed_item.module
--- simplefeed_item.module	26 Sep 2008 01:03:44 -0000	1.52.2.12
+++ simplefeed_item.module	28 Sep 2008 04:50:19 -0000
@@ -8,18 +8,6 @@
 
 
 /**
- * Implementation of hook_theme().
- */
-function simplefeed_item_theme() {
-  return array(
-    'simplefeed_item_node_view' => array(
-      'arguments' => array('values' => NULL),
-    ),
-  );
-}
-
-
-/**
  * Implementation of hook_perm().
  */
 function simplefeed_item_perm() {
@@ -178,7 +166,7 @@ function simplefeed_item_load($node) {
  * @todo - currently feed items that are manually created have blank iid -- need a way to invoke SimplePie to generate an iid for duplicate checking
  */
 function simplefeed_item_insert($node) {
-  $iid = md5($node->title . $node->url);  
+  $iid = md5($node->title . $node->url);
   db_query("INSERT INTO {simplefeed_feed_item} (vid, nid, iid, fid, expires, url) VALUES (%d, %d, '%s', %d, %d, '%s')", $node->vid, $node->nid, $iid, $node->fid, $node->expires, $node->url);
 }
 
@@ -227,51 +215,6 @@ function simplefeed_item_nodeapi(&$node,
 
 
 /**
- * Implementation of hook_view().
- */
-function simplefeed_item_view($node, $teaser = FALSE, $page = FALSE) {
-  $node = node_prepare($node, $teaser);
-
-  $node->content['simplefeed_item']['#theme'] = 'simplefeed_item_node_view';
-  $node->content['simplefeed_item']['#weight'] = 2;
-  $node->content['simplefeed_item']['url'] = array(
-    '#value' => check_url($node->url),
-    '#weight' => 1,
-  );
-
-  // since only administrators can edit when a feed item expires, only admins can see what this value is
-  if (user_access('administer feeds')) {
-    $node->content['simplefeed_item']['expires'] = array(
-      '#value' => format_interval($node->expires),
-      '#weight' => 2,
-    );
-  }
-
-  return $node;
-}
-
-
-/**
- * Theme the display of a feed node.
- */
-function theme_simplefeed_item_node_view($values) {
-  // needs to be a space so default values aren't outputed
-  $output = ' ';
-
-  // since only administrators can edit when a feed item expires, only admins can see what this value is
-  if (user_access('administer feeds')) {
-    drupal_add_css(drupal_get_path('module', 'simplefeed') .'/simplefeed.css');
-
-    $output = '<ul class="simplefeed-item">';
-    $output .= '<li><strong>Expires:</strong> '. $values['expires']['#value'] .'</li>';
-    $output .= '</ul>';
-  }
-
-  return $output;
-}
-
-
-/**
  * Implementation of hook_link().
  */
 function simplefeed_item_link($type, $node = NULL, $teaser = FALSE) {
@@ -318,7 +261,7 @@ function simplefeed_item_feed_expire() {
   // and switch back to current user at the end
   $current_user = $user;
   $user = user_load(array('uid' => 1));
-  
+
   // delete all expired feed items, ignore $vid since we expire *every* feed item in one call, not specific ones
   // note if a feed item has multiple revisions, any revision's expiration can trigger deletion of the entire node
   $items = db_query('SELECT n.nid FROM {node} n JOIN {simplefeed_feed_item} s ON n.vid = s.vid WHERE s.expires <> 0 AND s.expires <= (%d - n.created)', time());
@@ -335,7 +278,7 @@ function simplefeed_item_feed_expire() {
       db_query('OPTIMIZE TABLE {simplefeed_feed_item}');
     }
   }
-  
+
   $user = $current_user;
 }
 
@@ -351,10 +294,11 @@ function simplefeed_item_feed_expire() {
 function simplefeed_item_feed_parse($process_feed, $feed) {
   // loop through all of the items in the feed, faster than foreach
   $max = $feed->get_item_quantity();
+  $count = 0;
   module_load_include('inc', 'node', 'node.pages');
   module_load_include('inc', 'node', 'content_types');
   $node = node_get_types('type', 'feed_item');
-  
+
   for ($i = 0; $i < $max; $i++) {
     $item = $feed->get_item($i);
 
@@ -397,15 +341,15 @@ function simplefeed_item_feed_parse($pro
 
     if (!$duplicate) {
       static $type, $vid, $categories;
-      if (!isset($type)) {        
+      if (!isset($type)) {
         $categories = variable_get('simplefeed_categories', 0);
-        $vid = variable_get('simplefeed_vocab', 0);        
+        $vid = variable_get('simplefeed_vocab', 0);
         // before we add terms we have to make sure this is a freetagging vocabulary
         // this is because Drupal doesn't tell us on node_load, just gives us terms
         $type = db_fetch_object(db_query('SELECT multiple, tags FROM {vocabulary} WHERE vid = %d', $vid));
       }
 
-      
+
       if ($vid) {
         // free tagging case
         if ($type->tags == 1) {
@@ -417,7 +361,7 @@ function simplefeed_item_feed_parse($pro
               $tags[] = $category->get_label();
             }
           }
-          // inherit terms from parent feed to feed item if there are terms to inherit          
+          // inherit terms from parent feed to feed item if there are terms to inherit
           if ($process_feed->taxonomy) {
             foreach ($process_feed->taxonomy as $tid => $term) {
               $tags[] = $term->name;
@@ -443,7 +387,7 @@ function simplefeed_item_feed_parse($pro
 
       $form_state = array();
       // create a feed item node
-      $form_state['values']['type'] = 'feed_item';     
+      $form_state['values']['type'] = 'feed_item';
       $form_state['values']['title'] = $title;
       if ($date) {
         // "created" is a node property, however we have to use "date" to set this with drupal_execute since it is the form element name
@@ -457,10 +401,11 @@ function simplefeed_item_feed_parse($pro
       $form_state['values']['url'] = $link != '' ? $link : $feed->get_permalink();
       $form_state['values']['fid'] = $process_feed->nid;
       $form_state['values']['taxonomy'] = isset($item->taxonomy)?$item->taxonomy:NULL;
-      
+
       // this is required to get node form submits to work correctly
       $form_state['submit_handlers'] = array('node_form_submit');
-      
+
+      $count++;
       // create a new feed-item node, adding in all of the other node defaults
       drupal_execute('feed_item_node_form', $form_state, $node);
     }
@@ -468,4 +413,8 @@ function simplefeed_item_feed_parse($pro
     // we unset $item each time to prevent any pass by reference memory leaks that PHP encounters with objects in foreach loops
     unset($item);
   }
+
+  if (module_exists('simplefeed_stats')) {
+    simplefeed_stats_updated_feed($count, $process_feed);
+  }
 }
Index: simplefeed_stats.info
===================================================================
RCS file: simplefeed_stats.info
diff -N simplefeed_stats.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ simplefeed_stats.info	28 Sep 2008 04:50:19 -0000
@@ -0,0 +1,6 @@
+; $Id: $
+name = SimpleFeed Statistics
+description = Collects statistics about Simplefeed usage.
+package = SimpleFeed
+dependencies[] = simplefeed
+core=6.x
\ No newline at end of file
Index: simplefeed_stats.install
===================================================================
RCS file: simplefeed_stats.install
diff -N simplefeed_stats.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ simplefeed_stats.install	28 Sep 2008 04:50:19 -0000
@@ -0,0 +1,62 @@
+<?php
+// $Id: $
+
+/**
+ * Implementation of hook_install().
+ */
+function simplefeed_stats_install() {
+  // Create tables.
+  drupal_install_schema('simplefeed_stats');
+  drupal_set_message(t('SimpleFeed Stats successfully installed.'));
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function simplefeed_stats_uninstall() {
+  drupal_uninstall_schema('simplefeed_stats');
+}
+
+/**
+ * Implementation of hook_schema().
+ */
+function simplefeed_stats_schema() {
+  $schema['simplefeed_feed_stats'] = array(
+    'description' => t('Stores stats about SimpleFeed feeds.'),
+    'fields' => array(
+      'sid' => array(
+        'type' => 'serial',
+        'description' => t('Stat id.'),
+      ),
+      'fid' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'description' => t('Feed id.'),
+      ),
+      'new_nodes' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => t('Number of new nodes per feed refresh.'),
+      ),
+      'msg' => array(
+        'type' => 'text',
+        'description' => t('Message text from feed refresh.'),
+      ),
+      'timestamp' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'description' => t('When the feed was refreshed.'),
+      ),
+    ),
+    'primary key' => array('sid'),
+    'indexes' => array(
+      'fid' => array('fid'),
+    ),
+  );
+
+  return $schema;
+}
Index: simplefeed_stats.module
===================================================================
RCS file: simplefeed_stats.module
diff -N simplefeed_stats.module
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ simplefeed_stats.module	28 Sep 2008 04:50:19 -0000
@@ -0,0 +1,201 @@
+<?php
+// $Id: simplefeed_stats.module,v 1.1.2.1 2008/09/28 02:59:38 m3avrck Exp $
+
+/**
+ * @file
+ * Produces stats about simple feed and provides an admin interface
+ */
+
+/**
+ * Implentation of hook_menu
+ */
+function simplefeed_stats_menu() {
+  $items = array();
+
+  $items['admin/content/simplefeed'] = array(
+    'title' => t('Feeds'),
+    'description' => t('View statistics about SimpleFeed processing.'),    
+    'page callback' => 'simplefeed_stats_admin',
+    'access callback' => 'user_access',
+    'access arguments' => array('administer feeds'),
+  );
+
+  $items['node/%node/log'] = array(
+    'title' => t('Feed log'),
+    'page callback' => 'simplefeed_stats_log',
+    'page arguments' => array(1),
+    'access callback' => 'simplefeed_stats_access',
+    'access arguments' => array(1),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 4,
+  );
+
+  return $items;
+}
+
+/**
+ * Determine stats access.
+ */
+function simplefeed_stats_access($node) {
+  global $user;
+  if ($node->type == 'feed' && (user_access('view simplefeed logs') || (user_access('view own simplefeed logs') && $user->uid == $node->uid))) {
+    return TRUE;
+  }
+  else {
+    return FALSE;
+  }
+}
+
+function simplefeed_stats_perm() {
+  return array('view simplefeed logs', 'view own simplefeed logs');
+}
+
+/**
+ * Page callback for the status page of simplefeed
+ */
+function simplefeed_stats_admin() {
+  $header = array(
+    array(
+      'data' => t('Title'),
+      'sort' => 'ASC',
+      'field' => 'title',
+    ),
+    array(
+      'data' => t('Last Refresh'),
+      'sort' => 'DESC',
+      'field' => 'timestamp',
+    ),
+    array(
+      'data' => t('Number of Posts'),
+      'field' => 'number',
+    ),
+    array(
+      'data' => t('Average Posts per Update'),
+      'field' => 'average',
+    ),
+    array(
+      'data' => t('Errors'),
+      'field' => 'error',
+    ),
+    t('Actions'),
+   );
+
+   $sql = "SELECT n.nid, n.title, s.timestamp, count(DISTINCT(i.vid)) as number, count(DISTINCT(i.vid)) / count(DISTINCT(s.sid)) as average, f.error FROM {node} n JOIN {simplefeed_feed} f ON n.nid = f.nid JOIN {simplefeed_feed_stats} s ON s.fid = n.nid LEFT JOIN {simplefeed_feed_item} i ON i.fid = s.fid GROUP BY s.fid";
+   $count_sql = "SELECT count(s.nid) FROM {simplefeed_feed} s";
+   $results = pager_query($sql . tablesort_sql($header), 15, 0, $count_sql);
+
+   while ($feed_array = db_fetch_array($results)) {
+     $nid = $feed_array['nid'];
+     unset($feed_array['nid']);
+
+     $actions_column = theme('item_list', array(
+       l('Empty', 'node/' . $nid . '/empty'),
+       l('Refresh', 'node/' . $nid . '/refresh'),
+       l('View Log', 'node/' . $nid . '/log'),
+      )
+     );
+
+     $feed_array['timestamp'] = format_date($feed_array['timestamp'], 'small');
+     $feed_array['title'] = l($feed_array['title'], 'node/' . $nid);
+     $feed_array['average'] = round($feed_array['average'], 2);
+     $feed_array['actions'] = $actions_column;
+     $rows[] = $feed_array;
+   }
+
+   if (count($rows) > 0) {
+     $output = theme('table', $header, $rows);
+     $output .= theme('pager', NULL, 15);
+   }
+   else {
+     $output .= t('Cron needs to run first to collect feed stats.');
+   }
+
+   return $output;
+}
+
+/**
+ * recieves the number of simplefeed_items created by a given feed
+ * and adds to the db table
+ *
+ * @param $count
+ * number of nodes created
+ *
+ * @param $feed_node
+ * the feed node
+ */
+function simplefeed_stats_updated_feed($count, $feed_node) {
+  // update the table add in the count msg et al to the table
+  // php5 use $_REQUEST['time'] instead of time()
+  // insert even if no nodes were added
+  db_query("INSERT INTO {simplefeed_feed_stats} (fid, new_nodes, timestamp, msg) VALUES (%d, %d, %d, '%s')", $feed_node->nid, $count, time(), 'Success');
+}
+
+/**
+ * Recieves the error msg when a feed fails and logs it
+ *
+ * @param $feed_node
+ * the feed node that failed
+ *
+ * @param error_msg
+ * error message recieve when it failed
+ */
+function simplefeed_stats_feed_fail($feed_node, $error_msg) {
+  db_query("INSERT INTO {simplefeed_feed_stats} (fid, msg, timestamp) VALUES (%d, '%s', %d)", $feed_node->nid, $error_msg, time());
+}
+
+/**
+ * Recieves a nid that was just emptied
+ *
+ * @param $fid
+ * fid that was just emptied
+ */
+function simplefeed_stats_feed_empty($fid) {
+  db_query("INSERT INTO {simplefeed_feed_stats} (fid, msg, timestamp) VALUES (%d, '%s', %d)", $fid, 'Feed was emptied', time());
+}
+
+/**
+ * Displays the log of the feed
+ *
+ * @param $nid
+ * nid of the feed node
+ */
+function simplefeed_stats_log($node) {
+  $nid = $node->nid;
+  $output = '';
+  drupal_set_title('Feed log');
+
+  // need a check to make sure the node is a feed ?
+  $header = array(
+    array(
+      'data' => t('Date'),
+      'field' => 'timestamp',
+      'sort' => 'DESC',
+    ),
+    array(
+      'data' => t('New Posts'),
+      'field' => 'new_nodes',
+    ),
+    t('Message'),
+  );
+
+  $sql = "SELECT timestamp, new_nodes, msg FROM {simplefeed_feed_stats} WHERE fid = %d";
+  $count_sql = "SELECT COUNT(sid) FROM {simplefeed_feed_stats} WHERE fid = %d";
+  $log_result = pager_query($sql . tablesort_sql($header), 15, 0, $count_sql, $nid);
+  $rows = array();
+  while ($log_object = db_fetch_object($log_result)) {
+    $rows[] = array(
+      format_date($log_object->timestamp, 'small'),
+      $log_object->new_nodes,
+      t($log_object->msg),
+    );
+  }
+
+  if (count($rows) > 0) {
+    $output .= theme('table', $header, $rows) . theme('pager', NULL, 15);
+  }
+  else {
+    $output .= t('Stats for this feed will appear after it has been processed.');
+  }
+
+  return $output;
+}
