You are here

function aggregator_page_opml in Drupal 5

Same name and namespace in other branches
  1. 4 modules/aggregator.module \aggregator_page_opml()
  2. 6 modules/aggregator/aggregator.pages.inc \aggregator_page_opml()
  3. 7 modules/aggregator/aggregator.pages.inc \aggregator_page_opml()

Menu callback; generates an OPML representation of all feeds.

1 string reference to 'aggregator_page_opml'
aggregator_menu in modules/aggregator/aggregator.module
Implementation of hook_menu().

File

modules/aggregator/aggregator.module, line 1249
Used to aggregate syndicated content (RSS, RDF, and Atom).

Code

function aggregator_page_opml($cid = NULL) {
  if ($cid) {
    $result = db_query('SELECT f.title, f.url FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} c on f.fid = c.fid WHERE c.cid = %d ORDER BY title', $cid);
  }
  else {
    $result = db_query('SELECT * FROM {aggregator_feed} ORDER BY title');
  }
  $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
  $output .= "<opml version=\"1.1\">\n";
  $output .= "<head>\n";
  $output .= '<title>' . check_plain(variable_get('site_name', 'Drupal')) . "</title>\n";
  $output .= '<dateModified>' . gmdate('r') . "</dateModified>\n";
  $output .= "</head>\n";
  $output .= "<body>\n";
  while ($feed = db_fetch_object($result)) {
    $output .= '<outline text="' . check_plain($feed->title) . '" xmlUrl="' . check_url($feed->url) . "\" />\n";
  }
  $output .= "</body>\n";
  $output .= "</opml>\n";
  drupal_set_header('Content-Type: text/xml; charset=utf-8');
  print $output;
}