Take field translations from wizard, if available, otherwise leave them alone

This commit is contained in:
Nathan Gray 2011-12-12 18:11:11 +00:00
parent 97c45ff7c8
commit fd57cd738c

View File

@ -153,9 +153,23 @@ class importexport_export_csv implements importexport_iface_export_record
// Load translations for app
list($appname, $part2) = explode('_', get_class($_record));
if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name
translation::add_app($appname);
foreach($this->mapping as $field => &$label) {
$label = lang($label);
// Get translations from wizard, if possible
$backtrace = debug_backtrace();
$plugin = $backtrace[1]['class'];
$wizard_name = $appname . '_wizard_' . str_replace($appname . '_', '', $plugin);
try {
$wizard = new $wizard_name;
$fields = $wizard->get_export_fields();
foreach($this->mapping as $field => &$label)
{
if($fields[$field]) $label = $fields[$field];
}
} catch (Exception $e) {
translation::add_app($appname);
foreach($this->mapping as $field => &$label) {
$label = lang($label);
}
}
}
$mapping = ! empty( $this->mapping ) ? $this->mapping : array_keys ( $this->record );