2
// $Id: views_plugin_row_node_rss.inc,v 1.6 2009/04/07 22:02:40 merlinofchaos Exp $
5
* Contains the node RSS row style plugin.
9
* Plugin which performs a node_view on the resulting object
10
* and formats it as an RSS item.
12
class views_plugin_row_node_rss extends views_plugin_row {
13
// Basic properties that let the row style follow relationships.
14
var $base_table = 'node';
15
var $base_field = 'nid';
17
function option_definition() {
18
$options = parent::option_definition();
20
$options['item_length'] = array('default' => 'default');
25
function options_form(&$form, &$form_state) {
26
parent::options_form($form, $form_state);
28
$form['item_length'] = array(
30
'#title' => t('Display type'),
32
'fulltext' => t('Full text'),
33
'teaser' => t('Title plus teaser'),
34
'title' => t('Title only'),
35
'default' => t('Use default RSS settings'),
37
'#default_value' => $this->options['item_length'],
41
function render($row) {
42
// For the most part, this code is taken from node_feed() in node.module
45
$nid = $row->{$this->field_alias};
46
if (!is_numeric($nid)) {
50
$item_length = $this->options['item_length'];
51
if ($item_length == 'default') {
52
$item_length = variable_get('feed_item_length', 'teaser');
55
// Load the specified node:
56
$node = node_load($nid);
61
$node->build_mode = NODE_BUILD_RSS;
63
if ($item_length != 'title') {
64
$teaser = ($item_length == 'teaser') ? TRUE : FALSE;
66
// Filter and prepare node teaser
67
if (node_hook($node, 'view')) {
68
$node = node_invoke($node, 'view', $teaser, FALSE);
71
$node = node_prepare($node, $teaser);
74
// Allow modules to change $node->teaser before viewing.
75
node_invoke_nodeapi($node, 'view', $teaser, FALSE);
78
// Set the proper node part, then unset unused $node part so that a bad
79
// theme can not open a security hole.
80
$content = drupal_render($node->content);
82
$node->teaser = $content;
86
$node->body = $content;
90
// Allow modules to modify the fully-built node.
91
node_invoke_nodeapi($node, 'alter', $teaser, FALSE);
93
$item = new stdClass();
94
$item->title = $node->title;
95
$item->link = url("node/$row->nid", array('absolute' => TRUE));
97
// Allow modules to add additional item fields and/or modify $item
98
$extra = node_invoke_nodeapi($node, 'rss item');
99
$item->elements = array_merge($extra,
101
array('key' => 'pubDate', 'value' => format_date($node->created, 'custom', 'r', variable_get('date_default_timezone', 0))),
103
'key' => 'dc:creator',
104
'value' => $node->name,
105
'namespace' => array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/'),
109
'value' => $node->nid . ' at ' . $base_url,
110
'attributes' => array('isPermaLink' => 'false')
115
foreach ($item->elements as $element) {
116
if (isset($element['namespace'])) {
117
$this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $element['namespace']);
121
// Prepare the item description
122
switch ($item_length) {
124
$item->description = $node->body;
127
$item->description = $node->teaser;
128
if (!empty($item->readmore)) {
129
$item->description .= '<p>' . l(t('read more'), 'node/' . $item->nid, array('absolute' => TRUE, 'attributes' => array('target' => '_blank'))) . '</p>';
133
$item->description = '';
137
return theme($this->theme_functions(), $this->view, $this->options, $item);