Index: duration.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/duration/duration.module,v retrieving revision 1.12 diff -u -r1.12 duration.module --- duration.module 8 Oct 2008 06:36:24 -0000 1.12 +++ duration.module 23 Dec 2010 04:46:17 -0000 @@ -42,6 +42,7 @@ 'length' => '64', 'not null' => TRUE, 'default' => '', + 'views' => TRUE, ), 'approx_seconds' => array( 'type' => 'int', @@ -49,6 +50,7 @@ 'not null' => TRUE, 'default' => 0, 'sortable' => TRUE, + 'views' => TRUE, ), ); @@ -61,6 +63,14 @@ // hook_field($op='load')), because CCK's standard field handler doesn't // do that. $data[$table_alias][$field['field_name'] .'_iso8601']['field']['handler'] = 'duration_handler_field'; + + // For some reason the field definition of the 'approx_seconds' isn't created properly + $data[$table_alias][$field['field_name'] .'_approx_seconds']['field'] = $data[$table_alias][$field['field_name'] .'_iso8601']['field']; + $approx_seconds =& $data[$table_alias][$field['field_name'] .'_approx_seconds']; + $approx_seconds['field']['field'] = $approx_seconds['argument']['field']; + $approx_seconds['field']['title'] = $approx_seconds['title']; + $approx_seconds['field']['title short'] = $approx_seconds['title short']; + $approx_seconds['field']['handler'] = 'duration_seconds_handler_field'; return $data; } @@ -112,6 +122,11 @@ 'field types' => array('duration'), 'multiple values' => CONTENT_HANDLE_CORE, ), + 'seconds' => array( + 'label' => t('Approx. seconds'), + 'field types' => array('duration'), + 'multiple values' => CONTENT_HANDLE_CORE, + ), ); } @@ -129,6 +144,9 @@ 'duration_formatter_colons' => array( 'arguments' => array('element' => NULL), ), + 'duration_formatter_seconds' => array( + 'arguments' => array('element' => NULL), + ), ); } @@ -162,6 +180,17 @@ return duration_format_custom($element['#item']['duration'], '%h:%M:%S'); } +/** + * Theme function for the 'seconds' duration field formatter. + */ +function theme_duration_formatter_seconds($element) { + if (isset($element['#node']->duration)) { // loaded by duration_handler_field + $element['#item']['duration'] = $element['#node']->duration; + } + + return $element['#item']['approx_seconds']; +} + /** * Implementation of hook_widget_info().