1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of views_plugin_row_aggregator_rss.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Plugin which loads an aggregator item and formats it as an RSS item.
|
10
|
*/
|
11
|
class views_plugin_row_aggregator_rss extends views_plugin_row {
|
12
|
|
13
|
/**
|
14
|
*
|
15
|
*/
|
16
|
public $base_table = 'aggregator_item';
|
17
|
|
18
|
/**
|
19
|
*
|
20
|
*/
|
21
|
public $base_field = 'iid';
|
22
|
|
23
|
/**
|
24
|
* {@inheritdoc}
|
25
|
*/
|
26
|
public function option_definition() {
|
27
|
$options = parent::option_definition();
|
28
|
|
29
|
$options['item_length'] = array('default' => 'default');
|
30
|
|
31
|
return $options;
|
32
|
}
|
33
|
|
34
|
/**
|
35
|
* {@inheritdoc}
|
36
|
*/
|
37
|
public function options_form(&$form, &$form_state) {
|
38
|
$form['item_length'] = array(
|
39
|
'#type' => 'select',
|
40
|
'#title' => t('Display type'),
|
41
|
'#options' => array(
|
42
|
'fulltext' => t('Full text'),
|
43
|
'teaser' => t('Title plus teaser'),
|
44
|
'title' => t('Title only'),
|
45
|
'default' => t('Use default RSS settings'),
|
46
|
),
|
47
|
'#default_value' => $this->options['item_length'],
|
48
|
);
|
49
|
}
|
50
|
|
51
|
/**
|
52
|
* {@inheritdoc}
|
53
|
*/
|
54
|
public function render($row) {
|
55
|
$iid = $row->{$this->field_alias};
|
56
|
$sql = "SELECT ai.iid, ai.fid, ai.title, ai.link, ai.author, ai.description, ";
|
57
|
$sql .= "ai.timestamp, ai.guid, af.title AS feed_title, ai.link AS feed_LINK ";
|
58
|
$sql .= "FROM {aggregator_item} ai LEFT JOIN {aggregator_feed} af ON ai.fid = af.fid ";
|
59
|
$sql .= "WHERE ai.iid = :iid";
|
60
|
|
61
|
$item = db_query($sql, array(':iid' => $iid))->fetchObject();
|
62
|
|
63
|
$item->elements = array(
|
64
|
array(
|
65
|
'key' => 'pubDate',
|
66
|
'value' => gmdate('r', $item->timestamp),
|
67
|
),
|
68
|
array(
|
69
|
'key' => 'dc:creator',
|
70
|
'value' => $item->author,
|
71
|
),
|
72
|
array(
|
73
|
'key' => 'guid',
|
74
|
'value' => $item->guid,
|
75
|
'attributes' => array('isPermaLink' => 'false')
|
76
|
),
|
77
|
);
|
78
|
|
79
|
foreach ($item->elements as $element) {
|
80
|
if (isset($element['namespace'])) {
|
81
|
$this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $element['namespace']);
|
82
|
}
|
83
|
}
|
84
|
|
85
|
return theme($this->theme_functions(), array(
|
86
|
'view' => $this->view,
|
87
|
'options' => $this->options,
|
88
|
'row' => $item
|
89
|
));
|
90
|
}
|
91
|
|
92
|
}
|