Index: contributions/modules/atom/atom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/atom/atom.module,v
retrieving revision 1.24
diff -u -p -r1.24 atom.module
--- contributions/modules/atom/atom.module	15 Feb 2008 20:30:44 -0000	1.24
+++ contributions/modules/atom/atom.module	17 Feb 2008 12:22:06 -0000
@@ -202,6 +202,8 @@ function atom_taxonomy_feed($str_tids) {
  * @param array feed information
  */
 function _atom_print_feed($nodes, $feed_info) {
+  _atom_contrib_load();
+  $feed_info['extra_ns'] = _atom_contrib_get_ns();
   $output = '';
   $last_mod = 0;
   while ($node = db_fetch_object($nodes)) {
@@ -221,6 +223,9 @@ function _atom_print_feed($nodes, $feed_
 
     // Allow modules to change $node->teaser before viewing.
     node_invoke_nodeapi($item, 'view', true, false);
+    // Allow modules to change $node, or add elements,
+    // specifically for an atom feed.
+    $extra = module_invoke_all('atom_feed', $item);
 
     $output .= "  <entry>\n";
     $output .= '    <title>'. check_plain(strip_tags($item->title)) ."</title>\n";
@@ -262,6 +267,12 @@ function _atom_print_feed($nodes, $feed_
       $output .= variable_get('atom_ad_location', 'off') == 'append' ? str_replace('%link', urlencode($link), str_replace('%id', $node->nid, variable_get('atom_ad_code', ''))) : '';
       $output .= "    ]]></content>\n";
     }
+
+    // Add any extended atom_feed items from modules
+    if (count($extra)>0) {
+      $output .= format_xml_elements($extra);
+    }
+
     $output .= "  </entry>\n";
   }
 
@@ -289,7 +300,7 @@ function theme_atom_feed($feed_info, $la
   drupal_set_header('Content-Type: application/xml');
 
   $feed = '<?xml version="1.0" encoding="utf-8"?>'."\n";
-  $feed .= '<feed xmlns="http://www.w3.org/2005/Atom">'."\n";
+  $feed .= '<feed xmlns="http://www.w3.org/2005/Atom"'. $feed_info['extra_ns'] .">\n";
   $feed .= '  <title>'. $feed_info['title'] ."</title>\n";
   $feed .= $feed_info['subtitle'] == '' ? '' : '  <subtitle>'. $feed_info['subtitle'] ."</subtitle>\n";
   $feed .= '  <link rel="alternate" type="text/html" href="'. $feed_info['html_url'] .'"/>'."\n";
@@ -303,19 +314,12 @@ function theme_atom_feed($feed_info, $la
 }
 
 /**
- * @return string
- */
-function _atom_timestamp2w3dtf($timestamp) {
-  $tz = date("O", $timestamp);
-  return date("Y-m-d", $timestamp) .'T'. date("H:i:s", $timestamp) . substr($tz, 0, 3) .':'. substr($tz, 3, 2);
-}
-
-/**
  * Module configuration settings
  *
  * @return array of settings form options or deny access
  */
 function atom_admin_settings() {
+  _atom_contrib_load();
   $form = array();
 
   $form['atom_feed_options'] = array(
@@ -366,5 +370,48 @@ function atom_admin_settings() {
     '#default_value' => variable_get('atom_ad_code', ''),
     '#cols' => 40, '#rows' => 10
   );
+  $extra = module_invoke_all('atom_admin_settings');
+  if (count($extra)>0) {
+    $form['extra'] = $extra;
+    $form['extra']['#type'] = 'fieldset';
+    $form['extra']['#title'] = t('Extra module settings');
+  }
+
   return system_settings_form($form);
 }
+
+/**
+ * @return string
+ */
+function _atom_timestamp2w3dtf($timestamp) {
+  $tz = date("O", $timestamp);
+  return date("Y-m-d", $timestamp) .'T'. date("H:i:s", $timestamp) . substr($tz, 0, 3) .':'. substr($tz, 3, 2);
+}
+
+/**
+ * Load contrib module element handlers.
+ */
+function _atom_contrib_load() {
+  static $loaded = FALSE;
+  if (!$loaded) {
+    // Load all atom contrib module elements handlers from ./contrib
+    $path = drupal_get_path('module', 'atom') .'/contrib';
+    $files = drupal_system_listing('.*\.inc$', $path, 'name', 0);
+    foreach ($files as $file) {
+      require_once("./$file->filename");
+    }
+    // Rebuild cache.
+    module_implements('', FALSE, TRUE);
+  }
+  $loaded = TRUE;
+}
+
+/**
+ * @return string any additional namespaces used by contrib modules.
+ */
+function _atom_contrib_get_ns() {
+  _atom_contrib_load();
+
+  $ns_array = module_invoke_all('atom_ns');
+  return count($ns_array) > 0 ? "\n      ". implode("\n      ", $ns_array) : '';
+}
