mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
Improve handling of headers, checking translations and message_id
This commit is contained in:
parent
288469e66c
commit
fc8bb745d7
@ -172,6 +172,8 @@ class importexport_export_csv implements importexport_iface_export_record
|
|||||||
foreach($this->mapping as $field => &$label)
|
foreach($this->mapping as $field => &$label)
|
||||||
{
|
{
|
||||||
if($fields[$field]) $label = $fields[$field];
|
if($fields[$field]) $label = $fields[$field];
|
||||||
|
// Make sure no *
|
||||||
|
if(substr($label,-1) == '*') $label = substr($label,0,-1);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
translation::add_app($appname);
|
translation::add_app($appname);
|
||||||
|
@ -361,16 +361,45 @@
|
|||||||
// Skipped column in definition
|
// Skipped column in definition
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Check column headers, taking into account different translations
|
else if ($index > count($options['csv_fields']))
|
||||||
elseif($index < count($options['csv_fields']) && strtoupper($options['csv_fields'][$index]) != strtoupper($header) && strtoupper(lang($options['csv_fields'][$index])) != strtoupper($header) && strtoupper($options['csv_fields'][$index]) != strtoupper(lang($header)))
|
|
||||||
{
|
{
|
||||||
|
// File has extra columns - already warned, above
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for matching headers
|
||||||
|
if($options['csv_fields'][$index] == $header)
|
||||||
|
{
|
||||||
|
// Simple match
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Check column headers, taking into account different translations - make sure no *
|
||||||
|
$lang_defn = mb_strtoupper(translation::translate($options['csv_fields'][$index],false,''));
|
||||||
|
$lang_file = mb_strtoupper(translation::translate($header,false,''));
|
||||||
|
|
||||||
|
if($lang_defn == $lang_file ||
|
||||||
|
$lang_defn == mb_strtoupper($header) ||
|
||||||
|
$lang_file == mb_strtoupper($options['csv_fields'][$index])
|
||||||
|
)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to go back to translation message ID for a match
|
||||||
|
$file_message_id = translation::get_message_id($header, $definition->application);
|
||||||
|
$defn_message_id = translation::get_message_id($options['csv_fields'][$index], $definition->application);
|
||||||
|
|
||||||
|
if($file_message_id && $defn_message_id && $file_message_id == $defn_message_id)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Problem
|
// Problem
|
||||||
$message[] = lang("Column mismatch: %1 should be %2, not %3",
|
$message[] = lang("Column mismatch: %1 should be %2, not %3",
|
||||||
$index,$options['csv_fields'][$index], $header);
|
$index,$options['csv_fields'][$index], $header);
|
||||||
// But can still continue
|
// But can still continue
|
||||||
// $ok = false;
|
// $ok = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(!$ok || count($message) != $message_count)
|
if(!$ok || count($message) != $message_count)
|
||||||
{
|
{
|
||||||
// Add links for new / edit definition
|
// Add links for new / edit definition
|
||||||
|
Loading…
Reference in New Issue
Block a user