Add an option for charset to use the current user's preferred charset

This commit is contained in:
Nathan Gray 2011-05-24 15:50:38 +00:00
parent cae8752274
commit 8af97a3c10
4 changed files with 8 additions and 3 deletions

View File

@ -95,6 +95,7 @@ class importexport_export_csv implements importexport_iface_export_record
}
$this->translation = &$GLOBALS['egw']->translation;
$this->handle = $_stream;
if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
$this->csv_charset = $_options['charset'] ? $_options['charset'] : 'utf-8';
if ( !empty( $_options ) ) {
$this->csv_options = array_merge( $this->csv_options, $_options );

View File

@ -83,6 +83,7 @@ class importexport_import_csv implements importexport_iface_import_record { //,
public function __construct( $_resource, array $_options ) {
$this->resource = $_resource;
$this->csv_fieldsep = $_options['fieldsep'];
if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
$this->csv_charset = $_options['charset'];
return;
} // end of member function __construct

View File

@ -173,7 +173,7 @@ class importexport_wizard_basic_export_csv
$content['delimiter'] = ';';
}
if(!$content['charset'] && $content['plugin_options']['charset']) {
$content['charset'] = $content['plugin_options']['charset'];
$content['charset'] = $content['plugin_options']['charset'] ? $content['plugin_options']['charset'] : 'user';
}
if(!array_key_exists('begin_with_fieldnames', $content) && array_key_exists('begin_with_fieldnames', $content['plugin_options'])) {
$content['begin_with_fieldnames'] = $content['plugin_options']['begin_with_fieldnames'];
@ -189,7 +189,7 @@ class importexport_wizard_basic_export_csv
'label' => lang('Field labels')
);
$sel_options['charset'] = $GLOBALS['egw']->translation->get_installed_charsets()+
array('utf-8' => 'utf-8 (Unicode)');
array('utf-8' => 'utf-8 (Unicode)', 'user' => lang('User preference'));
$sel_options['convert'] = array(
0 => lang('Database values'),
1 => lang('Human friendly values')

View File

@ -197,7 +197,10 @@ class importexport_wizard_basic_import_csv
}
$sel_options['charset'] = $GLOBALS['egw']->translation->get_installed_charsets()+
array('utf-8' => 'utf-8 (Unicode)');
array(
'utf-8' => 'utf-8 (Unicode)',
'user' => lang('User preference')
);
$preserv = $content;
if($this->mapping_fields['cat_id']) {
$sel_options['update_cats'] = array(