• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

plugins/views_plugin_style_rss.inc

Go to the documentation of this file.
00001 <?php
00012 class views_plugin_style_rss extends views_plugin_style {
00013   function attach_to($display_id, $path, $title) {
00014     $display = $this->view->display[$display_id]->handler;
00015     $url_options = array();
00016     $input = $this->view->get_exposed_input();
00017     if ($input) {
00018       $url_options['query'] = $input;
00019     }
00020     $url_options['absolute'] = TRUE;
00021 
00022     $url = url($this->view->get_url(NULL, $path), $url_options);
00023     if ($display->has_path()) {
00024       if (empty($this->preview)) {
00025         drupal_add_feed($url, $title);
00026       }
00027     }
00028     else {
00029       if (empty($this->view->feed_icon)) {
00030         $this->view->feed_icon = '';
00031       }
00032 
00033       $this->view->feed_icon .= theme('feed_icon', array('url' => $url, 'title' => $title));
00034       drupal_add_html_head_link(array(
00035         'rel' => 'alternate',
00036         'type' => 'application/rss+xml',
00037         'title' => $title,
00038         'href' => $url
00039       ));
00040     }
00041   }
00042 
00043   function option_definition() {
00044     $options = parent::option_definition();
00045 
00046     $options['description'] = array('default' => '', 'translatable' => TRUE);
00047 
00048     return $options;
00049   }
00050 
00051   function options_form(&$form, &$form_state) {
00052     parent::options_form($form, $form_state);
00053 
00054     $form['description'] = array(
00055       '#type' => 'textfield',
00056       '#title' => t('RSS description'),
00057       '#default_value' => $this->options['description'],
00058       '#description' => t('This will appear in the RSS feed itself.'),
00059       '#maxlength' => 1024,
00060     );
00061   }
00062 
00069   function get_channel_elements() {
00070     return array();
00071   }
00072 
00073   function render() {
00074     if (empty($this->row_plugin)) {
00075       vpr('views_plugin_style_default: Missing row plugin');
00076       return;
00077     }
00078     $rows = '';
00079 
00080     // This will be filled in by the row plugin and is used later on in the
00081     // theming output.
00082     $this->namespaces = array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/');
00083 
00084     // Fetch any additional elements for the channel and merge in their
00085     // namespaces.
00086     $this->channel_elements = $this->get_channel_elements();
00087     foreach ($this->channel_elements as $element) {
00088       if (isset($element['namespace'])) {
00089         $this->namespaces = array_merge($this->namespaces, $element['namespace']);
00090       }
00091     }
00092 
00093     foreach ($this->view->result as $row_index => $row) {
00094       $this->view->row_index = $row_index;
00095       $rows .= $this->row_plugin->render($row);
00096     }
00097 
00098     $output = theme($this->theme_functions(),
00099       array(
00100         'view' => $this->view,
00101         'options' => $this->options,
00102         'rows' => $rows
00103       ));
00104     unset($this->view->row_index);
00105     return $output;
00106   }
00107 }

Generated on Sun Feb 26 2012 12:52:52 for Views by  doxygen 1.7.1