[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/filefield/views/ -> filefield_handler_field_data.inc (source)

   1  <?php
   2  // $Id: filefield_handler_field_data.inc,v 1.3 2010/12/08 04:57:07 quicksketch Exp $
   3  
   4  /**
   5   * @file
   6   * filefield_handler_field_data.inc
   7   *
   8   * Provides a handler for displaying values within the serialized data column.
   9   */
  10  class filefield_handler_field_data extends views_handler_field_node {
  11  
  12    function option_definition() {
  13      $options = parent::option_definition();
  14      $options['data_key'] = array('default' => 'description');
  15      return $options;
  16    }
  17  
  18    function options_form(&$form, &$form_state) {
  19      parent::options_form($form, $form_state);
  20  
  21      $options = array();
  22      $info = filefield_data_info();
  23      foreach ($info as $key => $data) {
  24        $options[$key] = $data['title'] . ' (' . $data['module'] .')';
  25      }
  26  
  27      $form['data_key'] = array(
  28        '#title' => t('Data key'),
  29        '#type' => 'radios',
  30        '#options' => $options,
  31        '#required' => TRUE,
  32        '#default_value' => $this->options['data_key'],
  33        '#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 parathesis.'),
  34        '#weight' => 4,
  35      );
  36    }
  37  
  38    function admin_summary() {
  39      // Display the data to be displayed.
  40      $info = filefield_data_info();
  41      return isset($info[$this->options['data_key']]['title']) ? $info[$this->options['data_key']]['title'] : $this->options['data_key'];
  42    }
  43  
  44    function render($values) {
  45      $values = drupal_clone($values); // Prevent affecting the original.
  46      $data = unserialize($values->{$this->field_alias});
  47      $values->{$this->field_alias} = filefield_data_value($this->options['data_key'], $data[$this->options['data_key']]);
  48      return parent::render($values);
  49    }
  50  
  51  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7