2
// $Id: filefield_meta_handler_field_bitrate.inc,v 1.1 2010/04/24 06:28:03 quicksketch Exp $
6
* A special handler that properly formats bit rate fields as Kbps.
10
* Render a field as a readable value in hours, minutes, and seconds.
12
* @ingroup views_field_handlers
14
class filefield_meta_handler_field_bitrate extends views_handler_field_numeric {
15
function option_definition() {
16
$options = parent::option_definition();
18
$options['format'] = array('default' => 'default', 'translatable' => TRUE);
20
// Remove the separator options since we don't need them.
21
unset($options['separator']);
26
function options_form(&$form, &$form_state) {
27
parent::options_form($form, $form_state);
29
// Remove the separator and alter options since we don't need them.
30
unset($form['separator']);
32
$form['prefix']['#weight'] = 10;
33
$form['suffix']['#weight'] = 10;
34
$form['format'] = array(
36
'#title' => t('Format'),
37
'#default_value' => $this->options['format'],
39
'default' => t('Default (Mbps or Kbps)'),
40
'raw' => t('Raw numberic value'),
45
function render($values) {
46
$value = $values->{$this->field_alias};
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'])) {
53
switch ($this->options['format']) {
58
$output = theme('filefield_meta_bitrate', $value);
61
return check_plain($this->options['prefix']) . $output . check_plain($this->options['suffix']);