Index: aggregator.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator.module,v
retrieving revision 1.190
diff -u -F^f -r1.190 aggregator.module
--- aggregator.module	3 Jul 2004 08:37:48 -0000	1.190
+++ aggregator.module	9 Jul 2004 03:39:49 -0000
@@ -145,6 +145,8 @@ function aggregator_menu() {
     'weight' => 5);
   $items[] = array('path' => 'aggregator/sources', 'title' => t('sources'),
     'callback' => 'aggregator_page_sources', 'access' => $view);
+  $items[] = array('path' => 'aggregator/rss', 'title' => t('RSS feed'),
+    'callback' => 'aggregator_page_rss', 'access' => $view );
   $items[] = array('path' => 'aggregator/categories', 'title' => t('categories'),
     'callback' => 'aggregator_page_categories', 'access' => $view,
     'type' => MENU_ITEM_GROUPING);
@@ -183,6 +185,10 @@ function aggregator_menu() {
     }
   }
 
+  $items[] = array('path' => 'aggregator/rss', 'title' => t('rss'),
+    'callback' => 'aggregator_page_rss', 'access' => $view,
+    'type' => MENU_CALLBACK);
+
   $items[] = array('path' => 'aggregator/opml', 'title' => t('opml'),
     'callback' => 'aggregator_page_opml', 'access' => $view,
     'type' => MENU_CALLBACK);
@@ -890,6 +896,8 @@ function _aggregator_page_list($sql, $op
   }
   $output .= '</div>';
 
+  $output .= theme('xml_icon', url('aggregator/rss'));
+
   if ($pager = theme('pager', NULL, 20, 0)) {
     $output .= $pager;
   }
@@ -923,6 +931,34 @@ function aggregator_page_sources() {
 }
 
 /**
+ * Menu callback; generate an RSS 0.92 feed of the default news aggregator page.
+ *
+ * This allows the drupal aggregator.module to act as RSS feed itself to other
+ * RSS readers like Trillian, etc.
+ */
+function aggregator_page_rss() {
+  global $base_url;
+
+  // Return only the first 75 items or less. This used to be configurable with
+  // variable_get("aggregator_page_limit", 75) in the Drupal 4.4.x tree. Now
+  // everything is just paged at 20 items....what to do?
+  $result = db_query_range('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC', 0, 75);
+
+  while ($item = db_fetch_object($result)) {
+    $items .= format_rss_item($item->title . " [".$item->ftitle."]", $item->link, $item->description, array("pubDate" => date("r", $item->timestamp))); 
+  }
+
+  $output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
+  $output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n";
+  $output .= "<rss version=\"0.92\">\n";
+  $output .= format_rss_channel("drupal", $base_url."/aggregator", "Drupal news aggregator XML feed", $items, "en");
+  $output .= "</rss>\n";
+
+  drupal_set_header("Content-Type: text/xml; charset=utf-8");
+  print $output;
+}
+
+/**
  * Menu callback; generates an OPML representation of all feeds.
  */
 function aggregator_page_opml() {
