| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @file 5 * filefield_handler_field_data.inc 6 * 7 * Provides a handler for displaying values within the serialized data column. 8 */ 9 class filefield_handler_field_data extends views_handler_field_node { 10 11 function option_definition() { 12 $options = parent::option_definition(); 13 $options['data_key'] = array('default' => 'description'); 14 return $options; 15 } 16 17 function options_form(&$form, &$form_state) { 18 parent::options_form($form, $form_state); 19 20 $options = array(); 21 $info = filefield_data_info(); 22 foreach ($info as $key => $data) { 23 $options[$key] = $data['title'] . ' (' . $data['module'] .')'; 24 } 25 26 $form['data_key'] = array( 27 '#title' => t('Data key'), 28 '#type' => 'radios', 29 '#options' => $options, 30 '#required' => TRUE, 31 '#default_value' => $this->options['data_key'], 32 '#description' => t('The data column may contain only a few or none any of these data options. The name of the module that provides the data is shown in parentheses.'), 33 '#weight' => 4, 34 ); 35 } 36 37 function admin_summary() { 38 // Display the data to be displayed. 39 $info = filefield_data_info(); 40 return isset($info[$this->options['data_key']]['title']) ? $info[$this->options['data_key']]['title'] : $this->options['data_key']; 41 } 42 43 function render($values) { 44 $values = drupal_clone($values); // Prevent affecting the original. 45 $data = unserialize($values->{$this->field_alias}); 46 $values->{$this->field_alias} = filefield_data_value($this->options['data_key'], $data[$this->options['data_key']]); 47 48 // Copied from views_handler_field_node(). We just remove the call to 49 // sanitize_value() from the original call, becaue our value has already 50 // been cleaned by filefield_data_value(). 51 return $this->render_link($values->{$this->field_alias}, $values); 52 } 53 54 }
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 |