| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: views_plugin_display_feed.inc,v 1.7 2009/09/15 22:20:01 merlinofchaos Exp $ 3 /** 4 * @file 5 * Contains the feed display plugin. 6 */ 7 8 /** 9 * The plugin that handles a feed, such as RSS or atom. 10 * 11 * For the most part, feeds are page displays but with some subtle differences. 12 * 13 * @ingroup views_display_plugins 14 */ 15 class views_plugin_display_feed extends views_plugin_display_page { 16 function uses_breadcrumb() { return FALSE; } 17 function get_style_type() { return 'feed'; } 18 19 /** 20 * Feeds do not go through the normal page theming mechanism. Instead, they 21 * go through their own little theme function and then return NULL so that 22 * Drupal believes that the page has already rendered itself...which it has. 23 */ 24 function execute() { 25 $output = $this->view->render(); 26 if (empty($output)) { 27 return drupal_not_found(); 28 } 29 print $output; 30 } 31 32 function preview() { 33 if (!empty($this->live_preview)) { 34 return '<pre>' . check_plain($this->view->render()) . '</pre>'; 35 } 36 return $this->view->render(); 37 } 38 39 /** 40 * Instead of going through the standard views_view.tpl.php, delegate this 41 * to the style handler. 42 */ 43 function render() { 44 return $this->view->style_plugin->render($this->view->result); 45 } 46 47 function defaultable_sections($section = NULL) { 48 if (in_array($section, array('style_options', 'style_plugin', 'row_options', 'row_plugin',))) { 49 return FALSE; 50 } 51 52 $sections = parent::defaultable_sections($section); 53 54 // Tell views our sitename_title option belongs in the title section. 55 if ($section == 'title') { 56 $sections[] = 'sitename_title'; 57 } 58 elseif (!$section) { 59 $sections['title'][] = 'sitename_title'; 60 } 61 return $sections; 62 } 63 64 function option_definition() { 65 $options = parent::option_definition(); 66 67 $options['displays'] = array('default' => array()); 68 69 // Overrides for standard stuff: 70 $options['style_plugin']['default'] = 'rss'; 71 $options['style_options']['default'] = array('mission_description' => FALSE, 'description' => ''); 72 $options['sitename_title']['default'] = FALSE; 73 $options['row_plugin']['default'] = ''; 74 $options['defaults']['default']['style_plugin'] = FALSE; 75 $options['defaults']['default']['style_options'] = FALSE; 76 $options['defaults']['default']['row_plugin'] = FALSE; 77 $options['defaults']['default']['row_options'] = FALSE; 78 79 return $options; 80 } 81 82 function options_summary(&$categories, &$options) { 83 // It is very important to call the parent function here: 84 parent::options_summary($categories, $options); 85 86 // Since we're childing off the 'page' type, we'll still *call* our 87 // category 'page' but let's override it so it says feed settings. 88 $categories['page'] = array( 89 'title' => t('Feed settings'), 90 ); 91 92 if ($this->get_option('sitename_title')) { 93 $options['title']['value'] = t('Using the site name'); 94 } 95 96 // I don't think we want to give feeds menus directly. 97 unset($options['menu']); 98 99 $displays = array_filter($this->get_option('displays')); 100 if (count($displays) > 1) { 101 $attach_to = t('Multiple displays'); 102 } 103 else if (count($displays) == 1) { 104 $display = array_shift($displays); 105 if (!empty($this->view->display[$display])) { 106 $attach_to = check_plain($this->view->display[$display]->display_title); 107 } 108 } 109 110 if (!isset($attach_to)) { 111 $attach_to = t('None'); 112 } 113 114 $options['displays'] = array( 115 'category' => 'page', 116 'title' => t('Attach to'), 117 'value' => $attach_to, 118 ); 119 } 120 121 /** 122 * Provide the default form for setting options. 123 */ 124 function options_form(&$form, &$form_state) { 125 // It is very important to call the parent function here. 126 parent::options_form($form, $form_state); 127 128 switch ($form_state['section']) { 129 case 'title': 130 $title = $form['title']; 131 // A little juggling to move the 'title' field beyond our checkbox. 132 unset($form['title']); 133 $form['sitename_title'] = array( 134 '#type' => 'checkbox', 135 '#title' => t('Use the site name for the title'), 136 '#default_value' => $this->get_option('sitename_title'), 137 ); 138 $form['title'] = $title; 139 $form['title']['#process'] = array('views_process_dependency'); 140 $form['title']['#dependency'] = array('edit-sitename-title' => array(FALSE)); 141 break; 142 case 'displays': 143 $form['#title'] .= t('Attach to'); 144 $displays = array(); 145 foreach ($this->view->display as $display_id => $display) { 146 if (!empty($display->handler) && $display->handler->accept_attachments()) { 147 $displays[$display_id] = $display->display_title; 148 } 149 } 150 $form['displays'] = array( 151 '#type' => 'checkboxes', 152 '#description' => t('The feed icon will be available only to the selected displays.'), 153 '#options' => $displays, 154 '#default_value' => $this->get_option('displays'), 155 ); 156 break; 157 case 'path': 158 $form['path']['#description'] = t('This view will be displayed by visiting this path on your site. It is recommended that the path be something like "path/%/%/feed" or "path/%/%/rss.xml", putting one % in the path for each argument you have defined in the view.'); 159 } 160 } 161 162 /** 163 * Perform any necessary changes to the form values prior to storage. 164 * There is no need for this function to actually store the data. 165 */ 166 function options_submit(&$form, &$form_state) { 167 // It is very important to call the parent function here: 168 parent::options_submit($form, $form_state); 169 switch ($form_state['section']) { 170 case 'title': 171 $this->set_option('sitename_title', $form_state['values']['sitename_title']); 172 break; 173 case 'displays': 174 $this->set_option($form_state['section'], $form_state['values'][$form_state['section']]); 175 break; 176 } 177 } 178 179 /** 180 * Attach to another view. 181 */ 182 function attach_to($display_id) { 183 $displays = $this->get_option('displays'); 184 if (empty($displays[$display_id])) { 185 return; 186 } 187 188 // Defer to the feed style; it may put in meta information, and/or 189 // attach a feed icon. 190 $plugin = $this->get_plugin(); 191 if ($plugin) { 192 $clone = $this->view->clone_view(); 193 $clone->set_display($this->display->id); 194 $clone->build_title(); 195 $plugin->attach_to($display_id, $this->get_path(), $clone->get_title()); 196 } 197 } 198 199 function uses_link_display() { 200 return TRUE; 201 } 202 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |