Index: feedapi.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feedapi/feedapi.module,v
retrieving revision 1.23.2.119.2.15
diff -u -r1.23.2.119.2.15 feedapi.module
--- feedapi.module	9 May 2008 13:30:34 -0000	1.23.2.119.2.15
+++ feedapi.module	12 May 2008 15:08:10 -0000
@@ -37,6 +37,17 @@
 }
 
 /**
+ * Implementation of hook_theme()
+ */
+function feedapi_theme() {
+  return array(
+    'feedapi_export_opml' => array(
+      'arguments' => array('feeds' => NULL),
+    ),
+  );
+}
+
+/**
  * Implementation of hook_menu().
  */
 function feedapi_menu() {
@@ -61,7 +72,7 @@
   $items['admin/content/feed/export_opml'] = array(
     'title' => 'Export all feeds as OPML',
     'access arguments' => array('administer feedapi'),
-    'page callback' => '_feedapi_export_opml',
+    'page callback' => 'feedapi_export_opml',
   );
   $items['admin/settings/feedapi'] = array(
     'title' => 'FeedAPI settings',
@@ -1405,24 +1416,45 @@
 }
 
 /**
- * Generates an OPML representation of all feeds.
+ * Menu callback; generates an OPML representation of all feeds.
+ * 
+ * @return
+ *   The output XML.
  */
-function _feedapi_export_opml() {
+function feedapi_export_opml() {
   $result = db_query(db_rewrite_sql('SELECT n.title, f.url FROM {feedapi} f INNER JOIN {node} n ON f.nid = n.nid ORDER BY n.title ASC'));
+  
+  $feeds = array();
+  while ($feed = db_fetch_object($result)) {
+    $feeds[] = $feed;
+  }
+  
+  return theme('feedapi_export_opml', $feeds);
+}
+
+/**
+ * Theme the OPML feed output.
+ *
+ * @param $feeds
+ *   An array of the feeds to theme.
+ * @ingroup themeable
+ */
+function theme_feedapi_export_opml($feeds) {
+  drupal_set_header('Content-Type: text/xml; charset=utf-8');
+
   $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
   $output .= "<opml version=\"1.1\">\n";
   $output .= "<head>\n";
-  $output .= '<title>'. variable_get('site_name', 'drupal') .' - '. variable_get('site_slogan', '') ."</title>\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_plain($feed->url) .'" />'."\n";
+  foreach ($feeds as $feed) {
+    $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');
-  drupal_set_header('Content-Disposition: attachment; filename="'. variable_get('site_name', 'drupal') .'.opml"');
+
   print $output;
 }
 
