Index: contributions/modules/atom/atom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/atom/atom.module,v
retrieving revision 1.21.2.3
diff -u -p -r1.21.2.3 atom.module
--- contributions/modules/atom/atom.module 5 Dec 2007 14:55:35 -0000 1.21.2.3
+++ contributions/modules/atom/atom.module 17 Feb 2008 11:48:14 -0000
@@ -136,6 +136,7 @@ function atom_user_blog_feed() {
* @param array feed information
*/
function _atom_print_feed($nodes, $feed_info) {
+ _atom_contrib_load();
$output = '';
$last_mod = 0;
while ($node = db_fetch_object($nodes)) {
@@ -155,6 +156,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 .= " \n";
$output .= ' '. check_plain(strip_tags($item->title)) ."\n";
@@ -188,13 +192,19 @@ function _atom_print_feed($nodes, $feed_
$output .= check_markup($item->body, $item->format, FALSE);
$output .= variable_get('atom_ad_location', 'off') == 'append' ? str_replace('%link', urlencode($link), str_replace('%id', $node->nid, variable_get('atom_ad_code', ''))) : '';
$output .= " ]]>\n";
+ // Add any extended atom_feed items from modules
+ if (count($extra)>0) {
+ $output .= format_xml_elements($extra);
+ }
$output .= " \n";
}
drupal_set_header('Content-Type: application/xml');
print ''. "\n";
- print ''. "\n";
+ // Add extra namespaces added by modules
+ $extra_ns = _atom_contrib_get_ns();
+ print '\n";
print ' '. $feed_info['title'] ."\n";
print $feed_info['subtitle'] == '' ? '' : ' '. $feed_info['subtitle'] . "\n";
print ' '. "\n";
@@ -206,19 +216,12 @@ function _atom_print_feed($nodes, $feed_
}
/**
- * @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_entries'] = array(
@@ -244,5 +247,48 @@ function atom_admin_settings() {
'#cols' => 40, '#rows' => 10,
'#description' => t('Ad unit code to insert in atom feed content.')
);
+ $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) : '';
+}
Index: contributions/modules/atom/contrib/atom_video.inc
===================================================================
RCS file: contributions/modules/atom/contrib/atom_video.inc
diff -N contributions/modules/atom/contrib/atom_video.inc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ contributions/modules/atom/contrib/atom_video.inc 17 Feb 2008 11:48:14 -0000
@@ -0,0 +1,45 @@
+type != 'video' || !variable_get('atom_video_enabled', TRUE)) {
+ return;
+ }
+ include_once(drupal_get_path('module', 'video') .'/video.module');
+
+ $attributes['rel'] = 'enclosure';
+ $attributes['href'] = _video_get_fileurl($item->vidfile);
+ $attributes['length'] = $item->size;
+ $mime_type = _video_get_mime_type($item);
+ if ($mime_type) {
+ $attributes['type'] = $mime_type;
+ }
+ return array(array('key' => 'link', 'attributes' => $attributes));
+}
+
+/**
+ * Implementation of hook_atom_ns for video module.
+ *
+ * @return string additional ns eg. xmlns:dc="http://purl.org/dc/elements/1.1"
+ */
+function video_atom_ns() {
+}
+
+/**
+ * Implementation of hook_atom_admin_settings for video module.
+ *
+ * @return array with key for admin settings form_api
+ */
+function video_atom_admin_settings() {
+ return array( 'atom_video_enabled' => array(
+ '#type' => 'checkbox',
+ '#title' => t('Video atom enclosures'),
+ '#default_value' => variable_get('atom_video_enabled', TRUE),
+ '#description' => t('Enables video module nodes to have enclosures links to video'),
+ ));
+}