rendered paste bodyfunction node_feed($nodes = 0, $channel = array()) { global $base_url, $locale; if (!$nodes) { $nodes = db_query_range(db_rewrite_sql('SELECT n.nid, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, variable_get('feed_default_items', 10)); } $item_length = variable_get('feed_item_length', 'teaser'); $namespaces = array('xmlns:dc="http://purl.org/dc/elements/1.1/"'); while ($node = db_fetch_object($nodes)) { // Load the specified node: $item = node_load($node->nid); $link = url("node/$node->nid", NULL, NULL, 1); if ($item_length != 'title') { $teaser = ($item_length == 'teaser') ? TRUE : FALSE; // Filter and prepare node teaser if (node_hook($item, 'view')) { node_invoke($item, 'view', $teaser, FALSE); } else { $item = node_prepare($item, $teaser); } // Allow modules to change $node->teaser before viewing. node_invoke_nodeapi($item, 'view', $teaser, FALSE); } // Allow modules to add additional item fields and/or modify $item $extra = node_invoke_nodeapi($item, 'rss item'); $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => date('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 ($element['namespace']) { $namespaces = array_merge($namespaces, $element['namespace']); } } // Prepare the item description switch ($item_length) { case 'fulltext': $item_text = $item->body; break; case 'teaser': $item_text = $item->teaser; if ($item->readmore) { $item_text .= '<p>'. l(t('read more'), 'node/'. $item->nid, NULL, NULL, NULL, TRUE) .'</p>'; } break; case 'title': $item_text = ''; break; } $items .= format_rss_item($item->title, $link, $item_text, $extra); } $channel_defaults = array( 'version' => '2.0', 'title' => variable_get('site_name', 'drupal') .' - '. variable_get('site_slogan', ''), 'link' => $base_url, 'description' => variable_get('site_mission', ''), 'language' => $locale ); $channel = array_merge($channel_defaults, $channel); $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $output .= "<?xml-stylesheet type=\"text\/xsl\" href=\"stylesheet.xslt\"?>\n"; $output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $base_url ."\" ". implode(' ', $namespaces) .">\n"; $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']); $output .= "</rss>\n"; drupal_set_header('Content-Type: application/rss+xml; charset=utf-8'); print $output;}