Index: includes/filefield_meta_handler_field_duration.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/filefield/filefield_meta/includes/filefield_meta_handler_field_duration.inc,v retrieving revision 1.2 diff -u -r1.2 filefield_meta_handler_field_duration.inc --- includes/filefield_meta_handler_field_duration.inc 19 Mar 2009 03:43:37 -0000 1.2 +++ includes/filefield_meta_handler_field_duration.inc 24 Apr 2010 06:25:21 -0000 @@ -17,9 +17,8 @@ $options['format'] = array('default' => 'default', 'translatable' => TRUE); - // Remove the separator and alter options since we don't need them. + // Remove the separator options since we don't need them. unset($options['separator']); - unset($options['alter']); return $options; } @@ -27,9 +26,8 @@ function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); - // Remove the separator and alter options since we don't need them. + // Remove the separator options since we don't need them. unset($form['separator']); - unset($form['alter']); $form['prefix']['#weight'] = 10; $form['suffix']['#weight'] = 10; @@ -49,23 +47,29 @@ function render($values) { $value = $values->{$this->field_alias}; + switch ($this->options['format']) { case 'hours': - $output = date('g', (int) $value); + $value = date('g', (int) $value); break; case 'minutes': - $output = date('i', (int) $value); + $value = date('i', (int) $value); break; case 'seconds': - $output = date('s', (int) $value); + $value = date('s', (int) $value); break; case 'total': - $output = $value; + $value = $value; break; default: $output = theme('filefield_meta_duration', $value); } + // 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 ''; + } + return check_plain($this->options['prefix']) . $output . check_plain($this->options['suffix']); } } Index: includes/filefield_meta.views.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/filefield/filefield_meta/includes/filefield_meta.views.inc,v retrieving revision 1.1 diff -u -r1.1 filefield_meta.views.inc --- includes/filefield_meta.views.inc 11 Mar 2009 06:02:24 -0000 1.1 +++ includes/filefield_meta.views.inc 24 Apr 2010 06:25:21 -0000 @@ -87,7 +87,7 @@ 'title' => t('Audio format'), 'help' => t('The audio format.'), 'field' => array( - 'handler' => 'views_handler_field_string', + 'handler' => 'views_handler_field', 'click sortable' => TRUE, ), 'sort' => array( @@ -103,7 +103,7 @@ 'title' => t('Audio sample rate'), 'help' => t('The sample rate of the audio.'), 'field' => array( - 'handler' => 'views_handler_field_numeric', + 'handler' => 'filefield_meta_handler_field_samplerate', 'click sortable' => TRUE, ), 'sort' => array( @@ -119,7 +119,7 @@ 'title' => t('Audio channel mode'), 'help' => t('The number of channels in the audio, by name (stereo or mono).'), 'field' => array( - 'handler' => 'views_handler_field_string', + 'handler' => 'views_handler_field', 'click sortable' => TRUE, ), 'sort' => array( @@ -135,7 +135,7 @@ 'title' => t('Audio bitrate'), 'help' => t('The audio bitrate.'), 'field' => array( - 'handler' => 'views_handler_field_numeric', + 'handler' => 'filefield_meta_handler_field_bitrate', 'click sortable' => TRUE, ), 'sort' => array( @@ -151,14 +151,14 @@ 'title' => t('Audio bitrate mode'), 'help' => t('The kind of audio bitrate, such as VBR. Usually empty.'), 'field' => array( - 'handler' => 'views_handler_field_numeric', + 'handler' => 'views_handler_field', 'click sortable' => TRUE, ), 'sort' => array( 'handler' => 'views_handler_sort', ), 'filter' => array( - 'handler' => 'views_handler_filter_numeric', + 'handler' => 'views_handler_filter_string', ), ); @@ -175,9 +175,15 @@ ), 'handlers' => array( // field handlers + 'filefield_meta_handler_field_bitrate' => array( + 'parent' => 'views_handler_field_numeric', + ), 'filefield_meta_handler_field_duration' => array( 'parent' => 'views_handler_field_numeric', ), + 'filefield_meta_handler_field_samplerate' => array( + 'parent' => 'views_handler_field_numeric', + ), ), ); } Index: filefield_meta.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/filefield/filefield_meta/filefield_meta.module,v retrieving revision 1.14 diff -u -r1.14 filefield_meta.module --- filefield_meta.module 20 Apr 2009 22:29:24 -0000 1.14 +++ filefield_meta.module 24 Apr 2010 06:25:21 -0000 @@ -125,12 +125,13 @@ * Formats audio sample rate. */ function theme_filefield_meta_samplerate($samplerate) { - return sprintf("%.1f kHz", $samplerate/1000); + return t('@sampleratekHz', array('@samplerate' => (int) ($samplerate/1000))); } /** * Formats audio bit rate. */ function theme_filefield_meta_bitrate($bitrate) { - return sprintf("%d Kbps", $bitrate/1000); + dsm($bitrate); + return t('@bitrateKbps', array('@bitrate' => (int) ($bitrate/1000))); } Index: includes/filefield_meta_handler_field_bitrate.inc =================================================================== RCS file: includes/filefield_meta_handler_field_bitrate.inc diff -N includes/filefield_meta_handler_field_bitrate.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ includes/filefield_meta_handler_field_bitrate.inc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,63 @@ + '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']); + } +} Index: includes/filefield_meta_handler_field_samplerate.inc =================================================================== RCS file: includes/filefield_meta_handler_field_samplerate.inc diff -N includes/filefield_meta_handler_field_samplerate.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ includes/filefield_meta_handler_field_samplerate.inc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,63 @@ + '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 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 (kHz)'), + '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_samplerate', $value); + } + + return check_plain($this->options['prefix']) . $output . check_plain($this->options['suffix']); + } +}