class filefield_meta_handler_field_bitrate in FileField 6.3
Render a field as a readable value in hours, minutes, and seconds.
Hierarchy
- class \filefield_meta_handler_field_bitrate extends \views_handler_field_numeric
Expanded class hierarchy of filefield_meta_handler_field_bitrate
1 string reference to 'filefield_meta_handler_field_bitrate'
- filefield_meta_views_data in filefield_meta/
includes/ filefield_meta.views.inc - Implementation of hook_views_data()
File
- filefield_meta/
includes/ filefield_meta_handler_field_bitrate.inc, line 13 - A special handler that properly formats bit rate fields as Kbps.
View source
class filefield_meta_handler_field_bitrate extends views_handler_field_numeric {
function option_definition() {
$options = parent::option_definition();
$options['format'] = array(
'default' => 'default',
'translatable' => TRUE,
);
// Remove the separator options since we don't need them.
unset($options['separator']);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
// Remove the separator and alter options since we don't need them.
unset($form['separator']);
$form['prefix']['#weight'] = 10;
$form['suffix']['#weight'] = 10;
$form['format'] = array(
'#type' => 'select',
'#title' => t('Format'),
'#default_value' => $this->options['format'],
'#options' => array(
'default' => t('Default (Mbps or Kbps)'),
'raw' => t('Raw numberic value'),
),
);
}
function render($values) {
$value = $values->{$this->field_alias};
// Check to see if hiding should happen before adding prefix and suffix.
if ($this->options['hide_empty'] && empty($value) && ($value !== 0 || $this->options['empty_zero'])) {
return '';
}
switch ($this->options['format']) {
case 'raw':
$output = $value;
break;
default:
$output = theme('filefield_meta_bitrate', $value);
}
return check_plain($this->options['prefix']) . $output . check_plain($this->options['suffix']);
}
}