mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 07:53:39 +01:00
Use addressbook vCard charset preference for exporting vcards using Import/Export
This commit is contained in:
parent
a2744f82f0
commit
9f4118e947
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Wizard for exporting vCard with import/export
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package addressbook
|
||||
* @subpackage importexport
|
||||
* @link http://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
*/
|
||||
|
||||
/**
|
||||
* We need to allow choosing of charset, so we'll just use the standard one from CSV
|
||||
*/
|
||||
class addressbook_wizard_export_vcard
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->steps = array(
|
||||
'wizard_step40' => ''
|
||||
);
|
||||
$this->step_templates = array(
|
||||
'wizard_step40' => 'addressbook.importexport_wizard_vcard_charset'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* choose charset
|
||||
*
|
||||
* @param array $content
|
||||
* @param array $sel_options
|
||||
* @param array $readonlys
|
||||
* @param array $preserv
|
||||
* @return string template name
|
||||
*/
|
||||
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_step40($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'] ? $content['plugin_options']['charset'] : 'user';
|
||||
}
|
||||
$sel_options['charset'] = $GLOBALS['egw']->translation->get_installed_charsets()+
|
||||
array(
|
||||
'user' => lang('User preference'),
|
||||
);
|
||||
$preserv = $content;
|
||||
|
||||
// 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));
|
||||
}
|
||||
unset ($preserv['button']);
|
||||
return $this->step_templates[$content['step']];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -544,7 +544,9 @@ class importexport_definitions_ui
|
||||
$next_step = $this->plugin->$content['step']($content);
|
||||
}
|
||||
else
|
||||
{
|
||||
$next_step = $this->$content['step']($content);
|
||||
}
|
||||
} else {
|
||||
die('Cannot find next step');
|
||||
}
|
||||
@ -730,9 +732,9 @@ class importexport_definitions_ui
|
||||
{
|
||||
case 'next':
|
||||
// There's no real reason the plugin has to come from any of these, as long as it has a $steps variable
|
||||
if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv) {
|
||||
if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) {
|
||||
$content['type'] = 'import';
|
||||
} elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv) {
|
||||
} elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) {
|
||||
$content['type'] = 'export';
|
||||
} else {
|
||||
throw new egw_exception('Invalid plugin');
|
||||
|
@ -275,7 +275,17 @@ class importexport_export_ui {
|
||||
if (! $charset = $definition->plugin_options['charset']) {
|
||||
$charset = $GLOBALS['egw']->translation->charset();
|
||||
}
|
||||
if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
|
||||
if($charset == 'user')
|
||||
{
|
||||
switch($definition->plugin)
|
||||
{
|
||||
case 'addressbook_export_vcard':
|
||||
$charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
|
||||
break;
|
||||
default:
|
||||
$charset = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
|
||||
}
|
||||
}
|
||||
$plugin_object = new $definition->plugin;
|
||||
$result = $plugin_object->export( $file, $definition );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user