Issues (4868)

inc/class.addressbook_wizard_export_vcard.inc.php (4 issues)

1
<?php
2
/**
3
 * Wizard for exporting vCard with import/export
4
 *
5
 * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
6
 * @package addressbook
7
 * @subpackage importexport
8
 * @link http://www.egroupware.org
9
 * @author Nathan Gray
10
 */
11
12
use EGroupware\Api;
13
14
/**
15
 * We need to allow choosing of charset, so we'll just use the standard one from CSV
16
 */
17
class addressbook_wizard_export_vcard
18
{
19
	public function __construct()
20
	{
21
		$this->steps = array(
0 ignored issues
show
Bug Best Practice introduced by
The property steps does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
22
			'wizard_step40' => ''
23
		);
24
		$this->step_templates = array(
0 ignored issues
show
Bug Best Practice introduced by
The property step_templates does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
25
			'wizard_step40' => 'addressbook.importexport_wizard_vcard_charset'
26
		);
27
	}
28
29
	/**
30
         * choose charset
31
         *
32
         * @param array $content
33
         * @param array $sel_options
34
         * @param array $readonlys
35
         * @param array $preserv
36
         * @return string template name
37
         */
38
        function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv)
39
        {
40
                if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true));
0 ignored issues
show
Bug Best Practice introduced by
The property debug does not exist on addressbook_wizard_export_vcard. Did you maybe forget to declare it?
Loading history...
41
                // return from step40
42
                if ($content['step'] == 'wizard_step40') {
43
                        switch (array_search('pressed', $content['button']))
44
                        {
45
                                case 'next':
46
                                        return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
47
                                case 'previous' :
48
                                        return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
49
                                case 'finish':
50
                                        return 'wizard_finish';
51
                                default :
52
                                        return $this->wizard_step40($content,$sel_options,$readonlys,$preserv);
53
                        }
54
                }
55
                // init step40
56
                else
57
                {
58
                        $content['msg'] = $this->steps['wizard_step40'];
59
                        $content['step'] = 'wizard_step40';
60
			if(!$content['charset'] && $content['plugin_options']['charset']) {
61
                                $content['charset'] = $content['plugin_options']['charset'] ? $content['plugin_options']['charset'] : 'user';
62
                        }
63
			$sel_options['charset'] = Api\Translation::get_installed_charsets()+
64
                        array(
65
                                'user'  => lang('User preference'),
66
                        );
67
			$preserv = $content;
68
69
                        // Add in extra allowed charsets
70
                        $config = Api\Config::read('importexport');
71
                        $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings());
72
                        if($extra_charsets)
0 ignored issues
show
Bug Best Practice introduced by
The expression $extra_charsets of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
73
                        {
74
                                $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets));
75
                        }
76
			unset ($preserv['button']);
77
                        return $this->step_templates[$content['step']];
78
		}
79
	}
80
81
}
82