~ubuntu-fr-webteam/ubuntu-fr-www/6.x

« back to all changes in this revision

Viewing changes to sites/all/modules/filefield/filefield_meta/includes/filefield_meta_handler_field_bitrate.inc

  • Committer: YoBoY
  • Date: 2011-02-22 09:03:45 UTC
  • mfrom: (309.1.26 dev.ubuntu-fr.org)
  • Revision ID: yoboy.leguesh@gmail.com-20110222090345-47gub5hwz2eu5yaq
Merge avec la branche de dev comprenant:
- mise à jour vers Drupal 6.20
- Nouveau thème ubuntu-2010
- Mise à jour des plugins

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
// $Id: filefield_meta_handler_field_bitrate.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 Kbps.
 
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_bitrate 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 and alter 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 (Mbps or Kbps)'),
 
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_bitrate', $value);
 
59
    }
 
60
 
 
61
    return check_plain($this->options['prefix']) . $output . check_plain($this->options['suffix']);
 
62
  }
 
63
}