You are here

function getid3_handler_field_duration::render in getID3() 7

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field_numeric::render

File

includes/getid3_handler_field_duration.inc, line 46
A special handler that properly formats duration fields as minutes:seconds.

Class

getid3_handler_field_duration
Render a field as a readable value in hours, minutes, and seconds.

Code

function render($values) {
  $value = $values->{$this->field_alias};
  switch ($this->options['format']) {
    case 'hours':
      $output = intval($value / 3600);
      break;
    case 'minutes':
      $output = intval($value % 3600 / 60);
      break;
    case 'seconds':
      $output = intval($value % 3600 % 60);
      break;
    case 'total':
      $output = $value;
      break;
    default:
      $output = theme('getid3_duration', array(
        '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']);
}