From a8c30ed91ea00e24f809adc965b05f8292fbc236 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 3 May 2009 10:11:35 +0000 Subject: - Patch #449718 by alienbrain: node_feed() is now using new node building API. --- modules/node/node.module | 76 ++++++++++++++---------------------------------- 1 file changed, 22 insertions(+), 54 deletions(-) (limited to 'modules/node/node.module') diff --git a/modules/node/node.module b/modules/node/node.module index 92a088871..b557a56cb 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1950,70 +1950,38 @@ function node_feed($nids = FALSE, $channel = array()) { $item_length = variable_get('feed_item_length', 'teaser'); $namespaces = array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/'); + $teaser = ($item_length == 'teaser'); // Load all nodes to be rendered. $nodes = node_load_multiple($nids); $items = ''; - foreach ($nodes as $item) { - $item->build_mode = NODE_BUILD_RSS; - $item->link = url("node/$item->nid", array('absolute' => TRUE)); - - if ($item_length != 'title') { - $teaser = ($item_length == 'teaser'); - - // Filter and prepare node teaser - if (node_hook($item, 'view')) { - $item = node_invoke($item, 'view', $teaser, FALSE); - } - else { - $item = node_prepare($item, $teaser); - } - - // Allow modules to change $node->content before the node is rendered. - module_invoke_all('node_view', $item, $teaser); - - // Set the proper node property, then unset unused $node property so that a - // bad theme can not open a security hole. - $content = drupal_render($item->content); - if ($teaser) { - $item->teaser = $content; - unset($item->body); - } - else { - $item->body = $content; - unset($item->teaser); - } + foreach ($nodes as $node) { + $item_text = ''; + + $node->build_mode = NODE_BUILD_RSS; + $node->link = url("node/$node->nid", array('absolute' => TRUE)); + $node->rss_namespaces = array(); + $node->rss_elements = array( + array('key' => 'pubDate', 'value' => gmdate('r', $node->created)), + array('key' => 'dc:creator', 'value' => $node->name), + array('key' => 'guid', 'value' => $node->nid . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false')) + ); - // Allow modules to modify the fully-built node. - module_invoke_all('node_alter', $item, $teaser, FALSE); - } + // The node gets built and modules add to or modify $node->rss_elements + // and $node->rss_namespaces. + $node = node_build_content($node, $teaser); - // Allow modules to add additional item fields and/or modify $item - $extra = module_invoke_all('node_rss_item', $item); - $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => gmdate('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false')))); - foreach ($extra as $element) { - if (isset($element['namespace'])) { - $namespaces = array_merge($namespaces, $element['namespace']); - } + if (!empty($node->rss_namespaces)) { + $namespaces = array_merge($namespaces, $node->rss_namespaces); } - // Prepare the item description - switch ($item_length) { - case 'fulltext': - $item_text = $item->body; - break; - case 'teaser': - $item_text = $item->teaser; - if (!empty($item->readmore)) { - $item_text .= '

' . l(t('read more'), 'node/' . $item->nid, array('absolute' => TRUE, 'attributes' => array('target' => '_blank'))) . '

'; - } - break; - case 'title': - $item_text = ''; - break; + if ($item_length != 'title' && !empty($node->content)) { + // We render node contents and force links to be last. + $links = drupal_render($node->content['links']); + $item_text .= drupal_render($node->content) . $links; } - $items .= format_rss_item($item->title, $item->link, $item_text, $extra); + $items .= format_rss_item($node->title, $node->link, $item_text, $node->rss_elements); } $channel_defaults = array( -- cgit v1.2.3