Index: duration.module =================================================================== RCS file: /cvs/drupal/contributions/modules/duration/duration.module,v retrieving revision 1.11 diff -r1.11 duration.module 2c2 < // $Id: duration.module,v 1.11 2008/07/17 17:25:47 jpetso Exp $ --- > // $Id: duration.module,v 1.10 2008/05/27 02:00:22 jpetso Exp $ 40,45d39 < 'iso8601' => array( < 'type' => 'varchar', < 'length' => '64', < 'not null' => TRUE, < 'default' => '', < ), 52a47,52 > 'iso8601' => array( > 'type' => 'varchar', > 'length' => '64', > 'not null' => TRUE, > 'default' => '', > ), 53a54,195 > > case 'views data': > return duration_views_field_views_data($field); > } > } > > /** > * Copied from content.views.inc > * Provide all columns instead of only the first column > */ > function duration_views_field_views_data($field) { > $field_types = _content_field_types(); > > // Check the field module is available. > // TODO: is this really how we should do it ? > if (isset($field_types[$field['type']])) { > $db_info = content_database_info($field); > $table_alias = content_views_tablename($field); > > $types = array(); > foreach(content_types() as $type) { > if (isset($type['fields'][$field['field_name']])) { > $types[] = $type['name']; > } > } > > $data = array(); > $data['table']['group'] = t('Content'); > $data['table']['join']['node'] = array( > 'table' => $db_info['table'], > 'left_field' => 'vid', > 'field' => 'vid', > ); > > $columns = array(); > $arguments = array(); > $filters = array(); > foreach ($db_info['columns'] as $column => $attributes) { > $columns[] = $attributes['column']; > $sorts[] = !empty($attributes['sortable']) ? TRUE : FALSE; > > // Identify likely filters and arguments for each column based on field type. > switch ($attributes['type']) { > case 'int': > case 'mediumint': > case 'tinyint': > case 'bigint': > case 'serial': > $filters[] = 'content_handler_filter_numeric'; > $arguments[] = 'content_handler_argument_numeric'; > break; > case 'numeric': > case 'float': > $filters[] = class_exists('views_handler_filter_float') ? 'content_handler_filter_float' : 'content_handler_filter_numeric'; > $arguments[] = 'content_handler_argument_numeric'; > break; > > case 'text': > case 'blob': > // TODO add markup handlers for these types > default: > $filters[] = 'content_handler_filter_string'; > $arguments[] = 'content_handler_argument_string'; > break; > } > } > > $additional_fields = $columns; > if ($field['multiple']) { > array_push($additional_fields, 'delta'); > } > > $data[$columns[0]] = array( > 'group' => t('Content'), > 'title' => t($field_types[$field['type']]['label']) .'(ISO): '. t($field['widget']['label']) . ' ('. $field['field_name'] .')', > 'help' => t($field_types[$field['type']]['label']) .'(ISO) - '. t('Appears in: @types', array('@types' => implode(', ', $types))), > 'field' => array( > 'field' => $columns[0], > 'table' => $db_info['table'], > 'handler' => 'content_handler_field_multiple', > 'click sortable' => $sorts[0], > 'additional fields' => $additional_fields, > 'content_field_name' => $field['field_name'], > 'allow empty' => TRUE, > // Access control modules should implement content_views_access_callback(). > 'access callback' => 'content_views_access_callback', > 'access arguments' => array($field), > ), > ); > > $data[$columns[1]] = array( > 'group' => t('Content'), > 'title' => t($field_types[$field['type']]['label']) .': '. t($field['widget']['label']) . ' ('. $field['field_name'] .')', > 'help' => t($field_types[$field['type']]['label']) .' - '. t('Appears in: @types', array('@types' => implode(', ', $types))), > 'field' => array( > 'field' => $columns[1], > 'table' => $db_info['table'], > 'handler' => 'content_handler_field_multiple', > 'click sortable' => $sorts[1], > 'additional fields' => $additional_fields, > 'content_field_name' => $field['field_name'], > 'allow empty' => TRUE, > // Access control modules should implement content_views_access_callback(). > 'access callback' => 'content_views_access_callback', > 'access arguments' => array($field), > ), > 'argument' => array( > 'field' => $columns[1], > 'table' => $db_info['table'], > 'handler' => $arguments[1], > 'click sortable' => $sorts[1], // TODO used in once place in node.views.inc, should we use it here? > 'name field' => '', // TODO > 'additional fields' => $additional_fields, > 'content_field_name' => $field['field_name'], > 'empty field name' => t(''), > 'allow empty' => TRUE, > ), > 'filter' => array( > 'field' => $columns[1], > 'title' => t($field['widget']['label']), > 'table' => $db_info['table'], > 'handler' => $filters[1], > 'additional fields' => $additional_fields, > 'content_field_name' => $field['field_name'], > 'allow empty' => TRUE, > ), > ); > // TODO do we need different handling for sorts with Views 2, > // especially when relationships are involved? > if (!empty($sorts[1])) { > $data[$columns[1]]['sort'] = array( > 'field' => $columns[1], > 'table' => $db_info['table'], > 'handler' => 'content_handler_sort', > 'additional fields' => $additional_fields, > 'content_field_name' => $field['field_name'], > 'allow empty' => TRUE, > ); > } > > // TODO: provide automatic filters, sorts, and arguments for each column, not just the first? > return array($table_alias => $data); 62a205 > case 'sanitize': 65a209,213 > if (empty($item['iso8601'])) { > unset($items[$delta]); > continue; > } >