[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/filefield/filefield_meta/includes/ -> filefield_meta_handler_field_samplerate.inc (source)

   1  <?php
   2  // $Id: filefield_meta_handler_field_samplerate.inc,v 1.1 2010/04/24 06:28:03 quicksketch Exp $
   3  
   4  /**
   5   * @file
   6   * A special handler that properly formats bit rate fields as kHz.
   7   */
   8  
   9  /**
  10   * Render a field as a readable value in hours, minutes, and seconds.
  11   *
  12   * @ingroup views_field_handlers
  13   */
  14  class filefield_meta_handler_field_samplerate extends views_handler_field_numeric {
  15    function option_definition() {
  16      $options = parent::option_definition();
  17  
  18      $options['format'] = array('default' => 'default', 'translatable' => TRUE);
  19  
  20      // Remove the separator options since we don't need them.
  21      unset($options['separator']);
  22  
  23      return $options;
  24    }
  25  
  26    function options_form(&$form, &$form_state) {
  27      parent::options_form($form, $form_state);
  28  
  29      // Remove the separator options since we don't need them.
  30      unset($form['separator']);
  31  
  32      $form['prefix']['#weight'] = 10;
  33      $form['suffix']['#weight'] = 10;
  34      $form['format'] = array(
  35        '#type' => 'select',
  36        '#title' => t('Format'),
  37        '#default_value' => $this->options['format'],
  38        '#options' => array(
  39          'default' => t('Default (kHz)'),
  40          'raw' => t('Raw numberic value'),
  41        ),
  42      );
  43    }
  44  
  45    function render($values) {
  46      $value = $values->{$this->field_alias};
  47  
  48      // Check to see if hiding should happen before adding prefix and suffix.
  49      if ($this->options['hide_empty'] && empty($value) && ($value !== 0 || $this->options['empty_zero'])) {
  50        return '';
  51      }
  52  
  53      switch ($this->options['format']) {
  54        case 'raw':
  55          $output = $value;
  56          break;
  57        default:
  58          $output = theme('filefield_meta_samplerate', $value);
  59      }
  60  
  61      return check_plain($this->options['prefix']) . $output . check_plain($this->options['suffix']);
  62    }
  63  }


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