| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: calendar_plugin_display_page.inc,v 1.1.2.25 2011/01/03 02:39:05 karens Exp $ 3 /** 4 * The plugin that handles a full calendar page. 5 * 6 * The only style option that will be available is the calendar 7 * style, which creates the navigation and links to other calendar 8 * displays. All options for paging, row plugins, etc. are 9 * deferred to the attachments. 10 */ 11 class calendar_plugin_display_page extends views_plugin_display_page { 12 13 function render() { 14 if (!empty($this->view->date_info->forbid)) { 15 drupal_not_found(); 16 exit; 17 } 18 return parent::render(); 19 } 20 21 /** 22 * Display validation. 23 */ 24 function validate() { 25 $errors = parent::validate(); 26 27 $arguments = $this->display->handler->get_option('arguments'); 28 if (!in_array('date_argument', array_keys($arguments))) { 29 if (empty($this->view->date_info->arg_missing)) { 30 $errors[] = t("The Calendar display '@display_title' will not work without a Date argument.", array('@display_title' => $this->definition['title'])); 31 } 32 $this->view->date_info->arg_missing = TRUE; 33 } 34 elseif ($arguments['date_argument']['default_action'] != 'default' || $arguments['date_argument']['default_argument_type'] != 'date') { 35 if (empty($this->view->date_info->arg_missing_default)) { 36 $errors[] = calendar_errors('missing_argument_default'); 37 } 38 $this->view->date_info->arg_missing_default = TRUE; 39 } 40 41 return $errors; 42 } 43 44 function get_style_type() { return 'calendar'; } 45 46 function defaultable_sections($section = NULL) { 47 if (in_array($section, array('style_plugin', 'row_options', 'row_plugin', 'items_per_page'))) { 48 return FALSE; 49 } 50 return parent::defaultable_sections($section); 51 } 52 53 /** 54 * Override some of the parent options. 55 */ 56 function options(&$display) { 57 parent::options($display); 58 $display['style_plugin'] = 'calendar_nav'; 59 $display['items_per_page'] = 0; 60 $display['row_plugin'] = ''; 61 $display['defaults']['style_plugin'] = FALSE; 62 $display['defaults']['style_options'] = FALSE; 63 $display['defaults']['row_plugin'] = FALSE; 64 $display['defaults']['row_options'] = FALSE; 65 $display['defaults']['items_per_page'] = FALSE; 66 } 67 68 /** 69 * Add custom option definitions. 70 */ 71 function option_definition () { 72 $options = parent::option_definition(); 73 $options['calendar_colors'] = array('default' => array()); 74 $options['calendar_colors_vocabulary'] = array('default' => array()); 75 $options['calendar_colors_taxonomy'] = array('default' => array()); 76 $options['calendar_colors_group'] = array('default' => array()); 77 $options['calendar_popup'] = array('default' => 0); 78 $options['calendar_date_link'] = array('default' => ''); 79 return $options; 80 } 81 82 /** 83 * Provide the summary for attachment options in the views UI. 84 * 85 * This output is returned as an array. 86 */ 87 function options_summary(&$categories, &$options) { 88 // It is very important to call the parent function here: 89 parent::options_summary($categories, $options); 90 91 $categories['calendar_settings'] = array( 92 'title' => theme('advanced_help_topic', 'calendar', 'settings') . t('Calendar settings'), 93 ); 94 95 $colors = $this->get_option('calendar_colors'); 96 $colors_taxonomy = $this->get_option('calendar_colors_taxonomy'); 97 $options['calendar_colors'] = array( 98 'category' => 'calendar_settings', 99 'title' => t('Legend Content Types'), 100 'value' => t('Edit'), 101 ); 102 $options['calendar_colors_vocabulary'] = array( 103 'category' => 'calendar_settings', 104 'title' => t('Legend Vocabularies'), 105 'value' => t('Edit'), 106 ); 107 $options['calendar_colors_taxonomy'] = array( 108 'category' => 'calendar_settings', 109 'title' => t('Legend Terms'), 110 'value' => t('Edit'), 111 ); 112 if (function_exists('og_all_groups_options')) { 113 $colors_group = $this->get_option('calendar_colors_group'); 114 $options['calendar_colors_group'] = array( 115 'category' => 'calendar_settings', 116 'title' => t('Legend Groups'), 117 'value' => t('Edit'), 118 ); 119 } 120 $popup_options = $this->popup_options(); 121 $default = $this->get_option('calendar_popup'); 122 $options['calendar_popup'] = array( 123 'category' => 'calendar_settings', 124 'title' => t('Date changer'), 125 'value' => isset($default) ? $popup_options[$default] : $popup_options[0], 126 ); 127 $default = $this->get_option('calendar_date_link'); 128 $options['calendar_date_link'] = array( 129 'category' => 'calendar_settings', 130 'title' => t('Add new date link'), 131 'value' => !empty($default) ? check_plain(node_get_types('name', $default)) : t('None'), 132 ); 133 134 } 135 136 function popup_options() { 137 return array(0 => t('No'), 1 => t('Yes')); 138 } 139 140 function options_form(&$form, &$form_state) { 141 // It is very important to call the parent function here: 142 parent::options_form($form, $form_state); 143 144 switch ($form_state['section']) { 145 case 'calendar_popup': 146 $form['#title'] .= t('Date changer'); 147 $form['calendar_popup'] = array( 148 '#type' => 'radios', 149 '#default_value' => $this->get_option('calendar_popup'), 150 '#options' => $this->popup_options(), 151 '#description' => t('Display a popup calendar date selector?'), 152 ); 153 break; 154 155 case 'calendar_date_link': 156 $form['#title'] .= t('Add new date link'); 157 $form['calendar_date_link'] = array( 158 '#type' => 'radios', 159 '#default_value' => $this->get_option('calendar_date_link'), 160 '#options' => array('' => t('No link')) + node_get_types('names'), 161 '#description' => t('Display a link to add a new date of the specified content type. Displayed only to users with appropriate permissions.'), 162 ); 163 break; 164 165 case 'calendar_colors': 166 $method = 'types'; 167 // TODO Move the embedded styles other than the color into a stylesheet. 168 $form['#title'] .= t('Content Type Legend Colors'); 169 $form['calendar_colors']['#tree'] = TRUE; 170 $form['calendar_colors']['#prefix'] .= '<div class="form-item"><label>'. t('Content Type') .'</label><p>'. t('Set a hex color value (like #ffffff) to use in the calendar legend for each content type. Types with empty values will have no stripe in the calendar and will not be added to the legend.') .'</p></div>'; 171 $form['calendar_colors']['colorpicker'] = array( 172 '#type' => 'calendar_colorpicker', 173 '#prefix' => '<div class="clear-block"><div style="float:left">', 174 '#suffix' => '</div>', 175 ); 176 $colors = $this->get_option('calendar_colors'); 177 178 switch ($method) { 179 case 'types': 180 $color_types = node_get_types('names'); 181 break; 182 } 183 foreach ($color_types as $key => $name) { 184 $form['calendar_colors']['color'][$key] = array( 185 '#title' => $name, 186 '#type' => 'calendar_colorfield', 187 '#default_value' => isset($colors[$key]) ? $colors[$key] : '#ffffff', 188 '#calendar_colorpicker' => 'calendar-colors-colorpicker', 189 '#prefix' => '<div style="float:left;margin-right:10px">', 190 '#suffix' => '</div>', 191 ); 192 } 193 $form['calendar_colors']['color']['#suffix'] = '</div>'; 194 break; 195 196 case 'calendar_colors_vocabulary': 197 $taxonomies = taxonomy_get_vocabularies(); 198 $options = array(); 199 foreach ($taxonomies as $vid => $vocab) { 200 $options[$vid] = $vocab->name; 201 } 202 $colors_vocabulary = $this->get_option('calendar_colors_vocabulary'); 203 $form['#title'] .= t('Vocabulary Legend Types'); 204 $form['calendar_colors_vocabulary'] = array( 205 '#type' => 'checkboxes', 206 '#default_value' => isset($colors_vocabulary) ? $colors_vocabulary : array(), 207 '#multiple' => TRUE, 208 '#options' => $options, 209 ); 210 $form['calendar_colors_vocabulary']['#prefix'] .= '<div class="form-item"><label>'. t('Vocabularies') .'</label>'. t('Select vocabularies to use for setting calendar legend colors by taxonomy term. This works best for vocabularies with only a limited number of possible terms.') .'</div>'; 211 break; 212 213 case 'calendar_colors_taxonomy': 214 $taxonomies = (array) $this->get_option('calendar_colors_vocabulary'); 215 $colors_taxonomy = $this->get_option('calendar_colors_taxonomy'); 216 $form['#title'] .= t('Taxonomy Legend Colors'); 217 $form['calendar_colors_taxonomy']['#prefix'] = ''; 218 if (empty($taxonomies)) { 219 $form['calendar_colors_taxonomy']['#prefix'] .= '<div class="form-item warning">'. t('Please select Legend vocabularies first!') .'</div>'; 220 } 221 $form['calendar_colors_taxonomy']['#prefix'] .= '<div class="form-item"><label>'. t('Taxonomy Terms') .'</label><p>'. t('Set a hex color value (like #ffffff) to use in the calendar legend for each taxonomy term. Terms with empty values will have no stripe in the calendar and will not be added to the legend.') .'</p></div>'; 222 $form['calendar_colors_taxonomy']['#tree'] = TRUE; 223 $form['calendar_colors_taxonomy']['colorpicker'] = array( 224 '#type' => 'calendar_colorpicker', 225 '#prefix' => '<div class="clear-block"><div style="float:left">', 226 '#suffix' => '</div>', 227 ); 228 foreach ($taxonomies as $vid => $taxonomy){ 229 $vocab = taxonomy_get_tree($vid); 230 foreach ($vocab as $tid => $term){ 231 $form['calendar_colors_taxonomy']['color'][$term->tid] = array( 232 '#title' => t($term->name), 233 '#type' => 'calendar_colorfield', 234 '#default_value' => isset($colors_taxonomy[$term->tid]) ? $colors_taxonomy[$term->tid] : '#ffffff', 235 '#calendar_colorpicker' => 'calendar-colors-taxonomy-colorpicker', 236 '#prefix' => '<div style="float:left;margin-right:10px">', 237 '#suffix' => '</div>', 238 ); 239 } 240 } 241 $form['calendar_colors_taxonomy']['color']['#suffix'] = '</div>'; 242 break; 243 244 case 'calendar_colors_group': 245 $colors_group = $this->get_option('calendar_colors_group'); 246 $form['#title'] .= t('Group Legend Colors'); 247 $form['calendar_colors_group']['#prefix'] = ''; 248 $form['calendar_colors_group']['#prefix'] .= '<div class="form-item"><label>' . t('Group') . '</label><p>' . t('Set a hex color value (like #ffffff) to use in the calendar legend for each group. Groups with empty values will have no stripe in the calendar and will not be added to the legend.') .'</p></div>'; 249 $form['calendar_colors_group']['#tree'] = TRUE; 250 $form['calendar_colors_group']['colorpicker'] = array( 251 '#type' => 'calendar_colorpicker', 252 '#prefix' => '<div class="clear-block"><div style="float:left">', 253 '#suffix' => '</div>', 254 ); 255 $groups = og_all_groups_options(); 256 foreach ($groups as $gid => $group_name){ 257 $form['calendar_colors_group']['color'][$gid] = array( 258 '#title' => t($group_name), 259 '#type' => 'calendar_colorfield', 260 '#default_value' => isset($colors_group[$gid]) ? $colors_group[$gid] : '#ffffff', 261 '#calendar_colorpicker' => 'calendar-colors-group-colorpicker', 262 '#prefix' => '<div style="float:left;margin-right:10px">', 263 '#suffix' => '</div>', 264 ); 265 } 266 $form['calendar_colors_group']['color']['#suffix'] = '</div>'; 267 break; 268 } 269 } 270 271 /** 272 * Perform any necessary changes to the form values prior to storage. 273 * There is no need for this function to actually store the data. 274 */ 275 function options_submit($form, &$form_state) { 276 // It is very important to call the parent function here: 277 parent::options_submit($form, $form_state); 278 switch ($form_state['section']) { 279 case 'calendar_popup': 280 $this->set_option($form_state['section'], $form_state['values'][$form_state['section']]['popup']); 281 break; 282 case 'calendar_colors': 283 case 'calendar_colors_taxonomy': 284 case 'calendar_colors_group': 285 $this->set_option($form_state['section'], $form_state['values'][$form_state['section']]['color']); 286 break; 287 case 'calendar_colors_vocabulary': 288 $this->set_option($form_state['section'], array_filter($form_state['values'][$form_state['section']])); 289 break; 290 case 'calendar_date_link': 291 $this->set_option($form_state['section'], ($form_state['values'][$form_state['section']])); 292 variable_set('calendar_date_link_'. $form_state['values']['calendar_date_link'], $this->display->handler->get_option('path')); 293 break; 294 } 295 } 296 297 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |