Add ability to set charset in import vcard wizard

This commit is contained in:
Nathan Gray 2012-10-01 17:59:44 +00:00
parent 4e2a7dab80
commit 23772bb9d1
4 changed files with 77 additions and 1 deletions

View File

@ -109,6 +109,8 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
// fetch the addressbook bo
$this->bocontacts = new addressbook_vcal();
$charset = $_definition->plugin_options['charset'];
// Start counting successes
$this->current = 0;
$count = 0;

View File

@ -20,11 +20,57 @@ class addressbook_wizard_import_vcard extends addressbook_import_vcard
{
$this->steps = array(
'wizard_step40' => lang('Choose charset'),
'wizard_step60' => lang('Choose owner of imported data'),
);
}
function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv)
{
if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true));
// return from step40
if ($content['step'] == 'wizard_step40')
{
switch (array_search('pressed', $content['button']))
{
case 'next':
return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
case 'previous' :
return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
case 'finish':
return 'wizard_finish';
default :
return $this->wizard_step60($content,$sel_options,$readonlys,$preserv);
}
}
// init step40
else
{
$content['msg'] = $this->steps['wizard_step40'];
$content['step'] = 'wizard_step40';
if(!$content['charset'] && $content['plugin_options']['charset']) {
$content['charset'] = $content['plugin_options']['charset'];
}
$sel_options['charset'] = $GLOBALS['egw']->translation->get_installed_charsets()+
array(
'user' => lang('User preference'),
);
// Add in extra allowed charsets
$config = config::read('importexport');
$extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings());
if($extra_charsets)
{
$sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets));
}
$preserv = $content;
unset ($preserv['button']);
return 'addressbook.importexport_wizard_vcard_charset';
}
}
function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv)
{
if($this->debug) error_log(__METHOD__.print_r($content,true));

View File

@ -2,7 +2,7 @@
/**
* EGroupware - eTemplates for Application addressbook
* http://www.egroupware.org
* generated by soetemplate::dump4setup() 2012-09-25 11:00
* generated by soetemplate::dump4setup() 2012-10-01 11:46
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package addressbook
@ -72,6 +72,8 @@ $templ_data[] = array('name' => 'addressbook.export_explode_fields','template' =
$templ_data[] = array('name' => 'addressbook.importexport_wizard_chooseowner','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:6:{i:0;a:1:{s:2:"h2";s:14:",@no_owner_map";}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"name";s:3:"msg";s:7:"no_lang";s:1:"1";}}i:2;a:1:{s:1:"A";a:3:{s:4:"type";s:8:"checkbox";s:5:"label";s:30:"Use field from CSV if possible";s:4:"name";s:14:"owner_from_csv";}}i:3;a:1:{s:1:"A";a:2:{s:4:"type";s:6:"select";s:4:"name";s:13:"contact_owner";}}i:4;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}i:5;a:1:{s:1:"A";a:3:{s:4:"type";s:11:"select-bool";s:5:"label";s:32:"Change addressbook when updating";s:4:"name";s:12:"change_owner";}}}s:4:"rows";i:5;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1320351347',);
$templ_data[] = array('name' => 'addressbook.importexport_wizard_vcard_charset','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:1:{s:1:"B";s:5:"180px";}i:1;a:2:{s:1:"A";a:4:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:4:"span";s:3:"all";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:15:"Charset of file";}s:1:"B";a:4:{s:4:"type";s:6:"select";s:7:"no_lang";s:1:"1";s:4:"name";s:7:"charset";s:4:"span";s:9:",width180";}}}s:4:"rows";i:2;s:4:"cols";i:2;}}','size' => '','style' => '.width180 select { width:150px;}','modified' => '1349113607',);
$templ_data[] = array('name' => 'addressbook.importexport_wizard_vcard_chooseowner','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:4:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"name";s:3:"msg";s:7:"no_lang";s:1:"1";}}i:2;a:1:{s:1:"A";a:2:{s:4:"type";s:6:"select";s:4:"name";s:13:"contact_owner";}}i:3;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:3;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1347980440',);
$templ_data[] = array('name' => 'addressbook.importexport_wizzard_chooseowner','template' => '','lang' => '','group' => '0','version' => '0.0.1','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"name";s:3:"msg";s:7:"no_lang";s:1:"1";}}i:2;a:1:{s:1:"A";a:3:{s:4:"type";s:6:"select";s:4:"name";s:13:"contact_owner";s:4:"size";s:4:"None";}}}s:4:"rows";i:2;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1146646360',);

View File

@ -0,0 +1,26 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="addressbook.importexport_wizard_vcard_charset" template="" lang="" group="0" version="1.9.001">
<grid>
<columns>
<column/>
<column width="180px"/>
</columns>
<rows>
<row>
<description id="msg" no_lang="1" span="all"/>
</row>
<row>
<description value="Charset of file"/>
<menulist class="width180">
<menupopup id="charset" no_lang="1"/>
</menulist>
</row>
</rows>
</grid>
<styles>
.width180 select { width:150px;}
</styles>
</template>
</overlay>