Keep original field names when export definition is created from import definition

This commit is contained in:
Nathan Gray 2011-12-14 16:33:54 +00:00
parent 5c8bf4ec27
commit bf9632b14a
3 changed files with 32 additions and 15 deletions

View File

@ -294,6 +294,9 @@ class importexport_definitions_bo {
// Try to use heading from import file, if possible // Try to use heading from import file, if possible
$e_options['mapping'][$field] = $i_options['csv_fields'][$col_num] ? $i_options['csv_fields'][$col_num] : $field; $e_options['mapping'][$field] = $i_options['csv_fields'][$col_num] ? $i_options['csv_fields'][$col_num] : $field;
} }
// Keep field names
$e_options['no_header_translation'] = true;
$export->plugin_options = $e_options; $export->plugin_options = $e_options;
// Permissions // Permissions

View File

@ -155,20 +155,23 @@ class importexport_export_csv implements importexport_iface_export_record
if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name
// Get translations from wizard, if possible // Get translations from wizard, if possible
$backtrace = debug_backtrace(); if(!$this->csv_options['no_header_translation'])
$plugin = $backtrace[1]['class']; {
$wizard_name = $appname . '_wizard_' . str_replace($appname . '_', '', $plugin); $backtrace = debug_backtrace();
try { $plugin = $backtrace[1]['class'];
$wizard = new $wizard_name; $wizard_name = $appname . '_wizard_' . str_replace($appname . '_', '', $plugin);
$fields = $wizard->get_export_fields(); try {
foreach($this->mapping as $field => &$label) $wizard = new $wizard_name;
{ $fields = $wizard->get_export_fields();
if($fields[$field]) $label = $fields[$field]; foreach($this->mapping as $field => &$label)
} {
} catch (Exception $e) { if($fields[$field]) $label = $fields[$field];
translation::add_app($appname); }
foreach($this->mapping as $field => &$label) { } catch (Exception $e) {
$label = lang($label); translation::add_app($appname);
foreach($this->mapping as $field => &$label) {
$label = lang($label);
}
} }
} }
} }

View File

@ -73,7 +73,18 @@ class importexport_wizard_basic_export_csv
// return from step30 // return from step30
if ($content['step'] == 'wizard_step30') if ($content['step'] == 'wizard_step30')
{ {
$content['mapping'] = array_combine($content['fields']['export'], $content['fields']['export']); foreach($content['fields']['export'] as $field_name)
{
// Preserve original field names, where available
if($content['plugin_options']['no_header_translation'] && $content['plugin_options']['mapping'][$field_name])
{
$content['mapping'][$field_name] = $content['plugin_options']['mapping'][$field_name];
}
else
{
$content['mapping'][$field_name] = $field_name;
}
}
if($content['mapping']['all_custom_fields']) { if($content['mapping']['all_custom_fields']) {
// Need the appname during actual export, to fetch the fields // Need the appname during actual export, to fetch the fields
$parts = explode('_', get_class($this)); $parts = explode('_', get_class($this));