/[drupal]/contributions/modules/views/plugins/views_plugin_style_rss.inc
ViewVC logotype

Contents of /contributions/modules/views/plugins/views_plugin_style_rss.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Tue Dec 2 00:02:06 2008 UTC (11 months, 3 weeks ago) by merlinofchaos
Branch: MAIN
CVS Tags: DRUPAL-6--2-7, DRUPAL-6--2-6, DRUPAL-6--2-5, DRUPAL-6--2-4, DRUPAL-6--2-3, DRUPAL-6--2-2, DRUPAL-6--3-0-ALPHA1, HEAD
Branch point for: DRUPAL-6--2, DRUPAL-6--3, DRUPAL-7--3
Changes since 1.1: +20 -1 lines
File MIME type: text/x-php
#338632 by drewish: Remove use of format_rss_channel and use proper templating instead.
1 <?php
2 // $Id: views_plugin_style_rss.inc,v 1.1 2008/09/03 19:21:30 merlinofchaos Exp $
3 /**
4 * @file
5 * Contains the RSS style plugin.
6 */
7
8 /**
9 * Default style plugin to render an RSS feed.
10 *
11 * @ingroup views_style_plugins
12 */
13 class views_plugin_style_rss extends views_plugin_style {
14 function attach_to($display_id, $path, $title) {
15 $display = $this->view->display[$display_id]->handler;
16 $url_options = array();
17 $input = $this->view->get_exposed_input();
18 if ($input) {
19 $url_options['query'] = $input;
20 }
21
22 $url = url($this->view->get_url(NULL, $path), $url_options);
23 if ($display->has_path()) {
24 if (empty($this->preview)) {
25 drupal_add_feed($url, $title);
26 }
27 }
28 else {
29 if (empty($this->view->feed_icon)) {
30 $this->view->feed_icon = '';
31 }
32
33 $this->view->feed_icon .= theme('feed_icon', $url, $title);
34 drupal_add_link(array(
35 'rel' => 'alternate',
36 'type' => 'application/rss+xml',
37 'title' => $title,
38 'href' => $url
39 ));
40 }
41 }
42
43 function option_definition() {
44 $options = parent::option_definition();
45
46 $options['description'] = array('default' => '', 'translatable' => TRUE);
47 $options['mission_description'] = array('default' => '', 'translatable' => TRUE);
48
49 return $options;
50 }
51
52 function options_form(&$form, &$form_state) {
53 $form['mission_description'] = array(
54 '#type' => 'checkbox',
55 '#default_value' => !empty($this->options['mission_description']),
56 '#title' => t('Use the site mission for the description'),
57 );
58 $form['description'] = array(
59 '#type' => 'textfield',
60 '#title' => t('RSS description'),
61 '#default_value' => $this->options['description'],
62 '#description' => t('This will appear in the RSS feed itself.'),
63 '#process' => array('views_process_dependency'),
64 '#dependency' => array('edit-style-options-override' => array(FALSE)),
65 );
66 }
67
68 /**
69 * Return an array of additional XHTML elements to add to the channel.
70 *
71 * @return
72 * An array that can be passed to format_xml_elements().
73 */
74 function get_channel_elements() {
75 return array();
76 }
77
78 function render() {
79 if (empty($this->row_plugin)) {
80 vpr('views_plugin_style_default: Missing row plugin');
81 return;
82 }
83 $rows = '';
84
85 // This will be filled in by the row plugin and is used later on in the
86 // theming output.
87 $this->namespaces = array();
88
89 // Fetch any additional elements for the channel and merge in their
90 // namespaces.
91 $this->channel_elements = $this->get_channel_elements();
92 foreach ($this->channel_elements as $element) {
93 if (isset($element['namespace'])) {
94 $this->namespaces = array_merge($this->namespaces, $element['namespace']);
95 }
96 }
97
98 foreach ($this->view->result as $row) {
99 $rows .= $this->row_plugin->render($row);
100 }
101
102 return theme($this->theme_functions(), $this->view, $this->options, $rows);
103 }
104 }

  ViewVC Help
Powered by ViewVC 1.1.2