Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/modules/node/views_plugin_row_node_rss.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* Contains the node RSS row style plugin.
|
|
5 |
* Definition of views_plugin_row_node_rss.
|
|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
... | ... | |
10 | 10 |
* and formats it as an RSS item. |
11 | 11 |
*/ |
12 | 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'; |
|
16 | 13 |
|
17 |
// Stores the nodes loaded with pre_render. |
|
18 |
var $nodes = array(); |
|
14 |
/** |
|
15 |
* Basic properties that let the row style follow relationships. |
|
16 |
*/ |
|
17 |
public $base_table = 'node'; |
|
18 |
|
|
19 |
/** |
|
20 |
* |
|
21 |
*/ |
|
22 |
public $base_field = 'nid'; |
|
19 | 23 |
|
20 |
function option_definition() { |
|
24 |
/** |
|
25 |
* Stores the nodes loaded with pre_render. |
|
26 |
*/ |
|
27 |
public $nodes = array(); |
|
28 |
|
|
29 |
/** |
|
30 |
* {@inheritdoc} |
|
31 |
*/ |
|
32 |
public function option_definition() { |
|
21 | 33 |
$options = parent::option_definition(); |
22 | 34 |
|
23 | 35 |
$options['item_length'] = array('default' => 'default'); |
... | ... | |
29 | 41 |
/** |
30 | 42 |
* Override init function to convert fulltext view-mode to full. |
31 | 43 |
*/ |
32 |
function init(&$view, &$display, $options = NULL) { |
|
44 |
public function init(&$view, &$display, $options = NULL) {
|
|
33 | 45 |
parent::init($view, $display, $options); |
34 | 46 |
|
35 | 47 |
if ($this->options['item_length'] == 'fulltext') { |
... | ... | |
37 | 49 |
} |
38 | 50 |
} |
39 | 51 |
|
40 |
function options_form(&$form, &$form_state) { |
|
52 |
/** |
|
53 |
* {@inheritdoc} |
|
54 |
*/ |
|
55 |
public function options_form(&$form, &$form_state) { |
|
41 | 56 |
parent::options_form($form, $form_state); |
42 | 57 |
|
43 | 58 |
$form['item_length'] = array( |
... | ... | |
56 | 71 |
/** |
57 | 72 |
* Return the main options, which are shown in the summary title. |
58 | 73 |
*/ |
59 |
function options_form_summary_options() { |
|
74 |
public function options_form_summary_options() {
|
|
60 | 75 |
$entity_info = entity_get_info('node'); |
61 | 76 |
$options = array(); |
62 | 77 |
if (!empty($entity_info['view modes'])) { |
... | ... | |
69 | 84 |
return $options; |
70 | 85 |
} |
71 | 86 |
|
72 |
function summary_title() { |
|
87 |
/** |
|
88 |
* {@inheritdoc} |
|
89 |
*/ |
|
90 |
public function summary_title() { |
|
73 | 91 |
$options = $this->options_form_summary_options(); |
74 | 92 |
return check_plain($options[$this->options['item_length']]); |
75 | 93 |
} |
76 | 94 |
|
77 |
|
|
78 |
function pre_render($values) { |
|
95 |
/** |
|
96 |
* {@inheritdoc} |
|
97 |
*/ |
|
98 |
public function pre_render($values) { |
|
79 | 99 |
$nids = array(); |
80 | 100 |
foreach ($values as $row) { |
81 | 101 |
$nids[] = $row->{$this->field_alias}; |
... | ... | |
85 | 105 |
} |
86 | 106 |
} |
87 | 107 |
|
88 |
function render($row) { |
|
89 |
// For the most part, this code is taken from node_feed() in node.module |
|
108 |
/** |
|
109 |
* {@inheritdoc} |
|
110 |
*/ |
|
111 |
public function render($row) { |
|
112 |
// For the most part; This code is taken from node_feed() in node.module. |
|
90 | 113 |
global $base_url; |
91 | 114 |
|
92 | 115 |
$nid = $row->{$this->field_alias}; |
... | ... | |
99 | 122 |
$display_mode = variable_get('feed_item_length', 'teaser'); |
100 | 123 |
} |
101 | 124 |
|
102 |
// Load the specified node:
|
|
125 |
// Load the specified node.
|
|
103 | 126 |
$node = $this->nodes[$nid]; |
104 | 127 |
if (empty($node)) { |
105 | 128 |
return; |
... | ... | |
128 | 151 |
|
129 | 152 |
// The node gets built and modules add to or modify $node->rss_elements |
130 | 153 |
// and $node->rss_namespaces. |
131 |
|
|
132 | 154 |
$build_mode = $display_mode; |
133 | 155 |
|
134 | 156 |
$build = node_view($node, $build_mode); |
... | ... | |
168 | 190 |
return theme($this->theme_functions(), array( |
169 | 191 |
'view' => $this->view, |
170 | 192 |
'options' => $this->options, |
171 |
'row' => $item |
|
193 |
'row' => $item,
|
|
172 | 194 |
)); |
173 | 195 |
} |
196 |
|
|
174 | 197 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules