[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

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

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


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7