Skip to content
Snippets Groups Projects
Commit 234895c9 authored by Alex Barth's avatar Alex Barth
Browse files

Better display of data table mapping.

parent e2a7ba82
No related branches found
No related tags found
No related merge requests found
...@@ -141,8 +141,15 @@ class FeedsDataProcessor extends FeedsProcessor { ...@@ -141,8 +141,15 @@ class FeedsDataProcessor extends FeedsProcessor {
foreach ($schema['fields'] as $field_name => $field) { foreach ($schema['fields'] as $field_name => $field) {
if (!in_array($field_name, array('id', 'feed_nid'))) { if (!in_array($field_name, array('id', 'feed_nid'))) {
// Any existing field can be optionally unique. // Any existing field can be optionally unique.
// @todo: push this reverse mapping of spec to short name into data
// module.
$type = $field['type'];
if ($type == 'int' && $field['unsigned']) {
$type = 'unsigned int';
}
$existing_fields[$field_name] = array( $existing_fields[$field_name] = array(
'name' => empty($meta['fields'][$field_name]['label']) ? $field_name : $meta['fields'][$field_name]['label'], 'name' => empty($meta['fields'][$field_name]['label']) ? $field_name : $meta['fields'][$field_name]['label'],
'description' => t('Field of type !type.', array('!type' => $type)),
'optional_unique' => TRUE, 'optional_unique' => TRUE,
); );
} }
...@@ -156,8 +163,13 @@ class FeedsDataProcessor extends FeedsProcessor { ...@@ -156,8 +163,13 @@ class FeedsDataProcessor extends FeedsProcessor {
foreach ($schema['fields'] as $field_name => $field) { foreach ($schema['fields'] as $field_name => $field) {
if (!in_array($field_name, array('id', 'feed_nid'))) { if (!in_array($field_name, array('id', 'feed_nid'))) {
// Fields in joined tables can't be unique. // Fields in joined tables can't be unique.
$type = $field['type'];
if ($type == 'int' && $field['unsigned']) {
$type = 'unsigned int';
}
$existing_fields["$table.$field_name"] = array( $existing_fields["$table.$field_name"] = array(
'name' => $table .'.'. (empty($meta['fields'][$field_name]['label']) ? $field_name : $meta['fields'][$field_name]['label']), 'name' => $table .'.'. (empty($meta['fields'][$field_name]['label']) ? $field_name : $meta['fields'][$field_name]['label']),
'description' => t('Joined field of type !type.', array('!type' => $type)),
'optional_unique' => FALSE, 'optional_unique' => FALSE,
); );
} }
...@@ -168,7 +180,10 @@ class FeedsDataProcessor extends FeedsProcessor { ...@@ -168,7 +180,10 @@ class FeedsDataProcessor extends FeedsProcessor {
// Now add data field types as mapping targets. // Now add data field types as mapping targets.
$field_types = drupal_map_assoc(array_keys(data_get_field_definitions())); $field_types = drupal_map_assoc(array_keys(data_get_field_definitions()));
foreach ($field_types as $k => $v) { foreach ($field_types as $k => $v) {
$new_fields['new:'. $k] = t('[new] !type', array('!type' => $v)); $new_fields['new:'. $k] = array(
'name' => t('[new] !type', array('!type' => $v)),
'description' => t('Creates a new column of type !type.', array('!type' => $v)),
);
} }
return $new_fields + $existing_fields; return $new_fields + $existing_fields;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment