Index: aggregator.module =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator.module,v retrieving revision 1.210 diff -u -p -r1.210 aggregator.module --- aggregator.module 16 Sep 2004 07:17:55 -0000 1.210 +++ aggregator.module 17 Sep 2004 08:18:02 -0000 @@ -86,8 +86,9 @@ function aggregator_configure() { $output = ''; $items = array(0 => t('none')) + drupal_map_assoc(array(3, 5, 10, 15, 20, 25), '_aggregator_items'); - $output .= form_select(t('Items shown in sources and categories pages'), 'aggregator_summary_items', variable_get('aggregator_summary_items', 3), $items, t('The number of items which will be shown with each feed or category in the feed and category summary pages.')); + $rss_items = array(0 => t('none')) + drupal_map_assoc(array(10, 20, 30, 50, 100), '_aggregator_items') + array(1000000 => t('all')); + $output .= form_select(t('Items shown in RSS feeds'), 'aggregator_rss_items', variable_get('aggregator_rss_items', 20), $rss_items, t('The number of items which will be generated for the RSS feed for the news aggregator or a category.')); $output .= form_radios(t('Category selection type'), 'aggregator_category_selector', variable_get('aggregator_category_selector', 'check'), array('check' => t('checkboxes'), 'select' => t('multiple selector')), t('The type of category selection widget which is shown on categorization pages. Checkboxes are easier to use; a multiple selector is good for working with large numbers of categories.')); print theme('page', system_settings_form($output)); @@ -158,6 +159,8 @@ function aggregator_menu($may_cache) { '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); @@ -937,6 +940,15 @@ function _aggregator_page_list($sql, $op $output .= $pager; } + // arg(1) is undefined if we are at the top aggregator URL + // is there a better way to do this? + 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); } @@ -966,6 +978,41 @@ 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 'aggregator_rss_items' items or 20 if undefined + $result = db_query_range($sql, 0, variable_get('aggregator_rss_items', 20)); + + 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", 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() {