diff --git a/modules/views_rss_core/views_rss_core.module b/modules/views_rss_core/views_rss_core.module index 776bfd71d24476f57ce956a9b2cdaba17fbd10c6..bf0dc44adbbabc971d31ecb2d9867961058e5bd9 100644 --- a/modules/views_rss_core/views_rss_core.module +++ b/modules/views_rss_core/views_rss_core.module @@ -82,7 +82,12 @@ function views_rss_core_views_rss_channel_elements_alter(&$elements) { 'theme' => 'views_rss_core_element_skip', 'help' => 'http://www.rssboard.org/rss-profile#element-channel-skipdays', ); - // @TODO: add 'image', 'pubDate' and 'lastBuildDate', ignore 'textInput'. + $elements['lastBuildDate'] = array( + 'configurable' => FALSE, + 'preprocess functions' => array('views_rss_core_preprocess_channel_lastbuilddate'), + 'help' => 'http://www.rssboard.org/rss-profile#element-channel-lastbuilddate', + ); + // @TODO: add 'image' and 'pubDate', ignore 'textInput'. } /** @@ -145,6 +150,19 @@ function views_rss_core_views_rss_item_elements_alter(&$elements) { ); } +/** + * Implementation of hook_views_data_alter(). + */ +function views_rss_core_views_query_alter(&$view, &$query) { + if ($view->style_plugin->definition['handler'] == 'views_plugin_style_rss_fields') { + // Select the most recent node creation date for element. + $query->fields['views_rss_max_created'] = array( + 'field' => '(SELECT MAX(created) FROM node)', + 'alias' => 'views_rss_max_created', + ); + } +} + /** * Preprocess function for channel element. */ @@ -177,6 +195,15 @@ function views_rss_core_preprocess_channel_link($vars) { return $base_url; } +/** + * Preprocess function for item <lastBuildDate> element. + */ +function views_rss_core_preprocess_channel_lastbuilddate($vars) { + if (isset($vars['view']->result[0]->views_rss_max_created)) { + return date('r', $vars['view']->result[0]->views_rss_max_created); + } +} + /** * Preprocess function for item <description> element. */ diff --git a/views/views_plugin_style_rss_fields.inc b/views/views_plugin_style_rss_fields.inc index a890b86a043f3737a36c4cfe88badf463e9b01f6..e948a324e25f09fc46e9aa4a1c3f9a54aeba3d64 100644 --- a/views/views_plugin_style_rss_fields.inc +++ b/views/views_plugin_style_rss_fields.inc @@ -43,7 +43,7 @@ class views_plugin_style_rss_fields extends views_plugin_style { // Channel element defaults. $channel_elements = $this->xml_channel_elements(); if (count($channel_elements)) { - foreach (array_keys($channel_elements) as $element_name) { + foreach (array_keys($channel_elements) as $element) { list($namespace, $element_name) = $this->extract_element_names($element, 'core'); $options['channel'][$namespace][$element_name] = array('default' => ''); }