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 10 Jul 2004 01:21:14 -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); @@ -894,6 +896,14 @@ function _aggregator_page_list($sql, $op $output .= $pager; } + // arg(1) is undefined if we are at the top aggregator URL + if (!arg(1)) { + $output .= theme('xml_icon', url('aggregator/rss')); + } + elseif (arg(1) == 'categories' && arg(2) && !arg(3)) { + $output .= theme('xml_icon', url('aggregator/rss/' . arg(2))); + } + print theme('page', $output); } @@ -923,6 +933,43 @@ function aggregator_page_sources() { } /** + * Menu callback; generate an RSS 0.92 feed of aggregator items or categories. + */ +function aggregator_page_rss() { + global $base_url; + + // arg(2) is the passed cid, only select for that category + if (arg(2)) { + $category = db_fetch_object(db_query('SELECT cid, title FROM {aggregator_category} WHERE cid = %d', arg(2))); + $url = '/categories/' . $category->cid; + $title = ' for ' . $category->title; + $sql = 'SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = '. $category->cid .' ORDER BY timestamp DESC, iid DESC'; + } + // or, get the default aggregator items + else { + $sql = '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'; + } + + // 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($sql, 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 .= "\n"; + $output .= "]>\n"; + $output .= "\n"; + $output .= format_rss_channel("drupal", $base_url . "/aggregator" . $url, "Drupal aggregator RSS feed" . $title, $items, "en"); + $output .= "\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() {