/usr/share/drupal6/modules/filefield/filefield_meta/includes/filefield_meta_handler_field_duration.inc is in drupal6-mod-filefield 3.10-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | <?php
/**
* @file
* A special handler that properly formats duration fields as minutes:seconds.
*/
/**
* Render a field as a readable value in hours, minutes, and seconds.
*
* @ingroup views_field_handlers
*/
class filefield_meta_handler_field_duration 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 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('Time format'),
'#default_value' => $this->options['format'],
'#options' => array(
'default' => t('Default (usually mm:ss)'),
'hours' => t('Hours: h'),
'minutes' => t('Minutes: mm'),
'seconds' => t('Seconds: ss'),
'total' => t('Total seconds'),
),
);
}
function render($values) {
$value = $values->{$this->field_alias};
switch ($this->options['format']) {
case 'hours':
$output = date('g', (int) $value);
break;
case 'minutes':
$output = date('i', (int) $value);
break;
case 'seconds':
$output = date('s', (int) $value);
break;
case 'total':
$output = check_plain($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']);
}
}
|