summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/views_rss_core/views_rss_core.module29
-rw-r--r--views/views_plugin_style_rss_fields.inc2
2 files changed, 29 insertions, 2 deletions
diff --git a/modules/views_rss_core/views_rss_core.module b/modules/views_rss_core/views_rss_core.module
index 2f49ac1..a87ed80 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'.
}
/**
@@ -146,6 +151,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 <lastBuildDate> element.
+ $query->fields['views_rss_max_created'] = array(
+ 'field' => '(SELECT MAX(created) FROM node)',
+ 'alias' => 'views_rss_max_created',
+ );
+ }
+}
+
+/**
* Preprocess function for channel <title> element.
*/
function views_rss_core_preprocess_channel_title($vars) {
@@ -178,6 +196,15 @@ function views_rss_core_preprocess_channel_link($vars) {
}
/**
+ * 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.
*/
function views_rss_core_preprocess_item_description($vars) {
diff --git a/views/views_plugin_style_rss_fields.inc b/views/views_plugin_style_rss_fields.inc
index 2215e87..31e4e9b 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' => '');
}