@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | if (!extension_loaded('dom')) |
13 | 13 | { |
14 | 14 | echo "<p>Required PHP DOM extension missing, installation of ImportExport definitions aborted.</p>\n"; |
15 | - return; // otherwise we mess up the whole eGroupware install process |
|
15 | + return; // otherwise we mess up the whole eGroupware install process |
|
16 | 16 | } |
17 | -require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.importexport_definitions_bo.inc.php'); |
|
17 | +require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.importexport_definitions_bo.inc.php'); |
|
18 | 18 | |
19 | 19 | // This sets up $GLOBALS['egw']->accounts and $GLOBALS['egw']->db |
20 | 20 | $GLOBALS['egw_setup']->setup_account_object(); |
@@ -22,22 +22,22 @@ discard block |
||
22 | 22 | // step through every source code intstalled app |
23 | 23 | $egwdir = dir(EGW_INCLUDE_ROOT); |
24 | 24 | while (false !== ($appdir = $egwdir->read())) { |
25 | - $defdir = EGW_INCLUDE_ROOT. "/$appdir/setup/"; |
|
26 | - if ( !is_dir( $defdir ) ) continue; |
|
25 | + $defdir = EGW_INCLUDE_ROOT."/$appdir/setup/"; |
|
26 | + if (!is_dir($defdir)) continue; |
|
27 | 27 | |
28 | 28 | // step through each file in defdir of app |
29 | 29 | $d = dir($defdir); |
30 | 30 | while (false !== ($entry = $d->read())) { |
31 | - $file = $defdir. '/'. $entry; |
|
32 | - list( $filename, $extension) = explode('.',$entry); |
|
33 | - if ( $extension != 'xml' ) continue; |
|
34 | - importexport_definitions_bo::import( $file ); |
|
31 | + $file = $defdir.'/'.$entry; |
|
32 | + list($filename, $extension) = explode('.', $entry); |
|
33 | + if ($extension != 'xml') continue; |
|
34 | + importexport_definitions_bo::import($file); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | 38 | // give Default and Admins group rights for ImportExport |
39 | -foreach(array('Default' => 'Default','Admins' => 'Admin') as $account_lid => $name) |
|
39 | +foreach (array('Default' => 'Default', 'Admins' => 'Admin') as $account_lid => $name) |
|
40 | 40 | { |
41 | - $account_id = $GLOBALS['egw_setup']->add_account($account_lid,$name,'Group',False,False); |
|
42 | - $GLOBALS['egw_setup']->add_acl('importexport','run',$account_id); |
|
41 | + $account_id = $GLOBALS['egw_setup']->add_account($account_lid, $name, 'Group', False, False); |
|
42 | + $GLOBALS['egw_setup']->add_acl('importexport', 'run', $account_id); |
|
43 | 43 | } |
@@ -21,16 +21,24 @@ |
||
21 | 21 | |
22 | 22 | // step through every source code intstalled app |
23 | 23 | $egwdir = dir(EGW_INCLUDE_ROOT); |
24 | -while (false !== ($appdir = $egwdir->read())) { |
|
24 | +while (false !== ($appdir = $egwdir->read())) |
|
25 | +{ |
|
25 | 26 | $defdir = EGW_INCLUDE_ROOT. "/$appdir/setup/"; |
26 | - if ( !is_dir( $defdir ) ) continue; |
|
27 | + if ( !is_dir( $defdir ) ) |
|
28 | + { |
|
29 | + continue; |
|
30 | + } |
|
27 | 31 | |
28 | 32 | // step through each file in defdir of app |
29 | 33 | $d = dir($defdir); |
30 | - while (false !== ($entry = $d->read())) { |
|
34 | + while (false !== ($entry = $d->read())) |
|
35 | + { |
|
31 | 36 | $file = $defdir. '/'. $entry; |
32 | 37 | list( $filename, $extension) = explode('.',$entry); |
33 | - if ( $extension != 'xml' ) continue; |
|
38 | + if ( $extension != 'xml' ) |
|
39 | + { |
|
40 | + continue; |
|
41 | + } |
|
34 | 42 | importexport_definitions_bo::import( $file ); |
35 | 43 | } |
36 | 44 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param array $_options options for specific backends |
34 | 34 | * @return bool |
35 | 35 | */ |
36 | - public function __construct( $_stream, array $_options ); |
|
36 | + public function __construct($_stream, array $_options); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * exports a record into resource of handle |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param object of interface egw_record _record |
42 | 42 | * @return bool |
43 | 43 | */ |
44 | - public function export_record( importexport_iface_egw_record $_record ); |
|
44 | + public function export_record(importexport_iface_egw_record $_record); |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Retruns total number of exported records. |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * cleanup |
34 | 34 | * |
35 | 35 | * @return |
36 | - */ |
|
36 | + void |
|
37 | 37 | public function __destruct( ); |
38 | 38 | |
39 | 39 | /** |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | if (!defined('IMPORTEXPORT_APP')) |
16 | 16 | { |
17 | - define('IMPORTEXPORT_APP','importexport'); |
|
17 | + define('IMPORTEXPORT_APP', 'importexport'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | class importexport_admin_prefs_sidebox_hooks |
@@ -35,40 +35,40 @@ discard block |
||
35 | 35 | array( |
36 | 36 | 'text' => 'Import', |
37 | 37 | 'link' => "javascript:egw_openWindowCentered2('". |
38 | - Egw::link('/index.php','menuaction=importexport.importexport_import_ui.import_dialog',false). |
|
38 | + Egw::link('/index.php', 'menuaction=importexport.importexport_import_ui.import_dialog', false). |
|
39 | 39 | "','_blank',850,440,'yes')", |
40 | 40 | 'icon' => 'import' |
41 | 41 | ), |
42 | 42 | ); |
43 | 43 | $export_limit = Api\Storage\Merge::getExportLimit($appname); |
44 | 44 | //error_log(__METHOD__.__LINE__.' app:'.$appname.' limit:'.$export_limit); |
45 | - if(Api\Storage\Merge::is_export_limit_excepted() || $export_limit !== 'no') |
|
45 | + if (Api\Storage\Merge::is_export_limit_excepted() || $export_limit !== 'no') |
|
46 | 46 | { |
47 | 47 | $file[] = array( |
48 | 48 | 'text' => 'Export', |
49 | 49 | 'link' => "javascript:egw_openWindowCentered2('". |
50 | - Egw::link('/index.php','menuaction=importexport.importexport_export_ui.export_dialog',false). |
|
50 | + Egw::link('/index.php', 'menuaction=importexport.importexport_export_ui.export_dialog', false). |
|
51 | 51 | "','_blank',850,440,'yes')", |
52 | 52 | 'icon' => 'export' |
53 | 53 | ); |
54 | 54 | } |
55 | 55 | $config = Api\Config::read($appname); |
56 | - if($config['users_create_definitions']) |
|
56 | + if ($config['users_create_definitions']) |
|
57 | 57 | { |
58 | - $file['Define imports|exports'] = Egw::link('/index.php',array( |
|
58 | + $file['Define imports|exports'] = Egw::link('/index.php', array( |
|
59 | 59 | 'menuaction' => 'importexport.importexport_definitions_ui.index', |
60 | 60 | 'ajax' => 'true' |
61 | - ),$GLOBALS['egw_info']['user']['apps']['admin'] ? 'admin' : 'preferences'); |
|
61 | + ), $GLOBALS['egw_info']['user']['apps']['admin'] ? 'admin' : 'preferences'); |
|
62 | 62 | } |
63 | - display_sidebox($appname,lang($appname),$file); |
|
63 | + display_sidebox($appname, lang($appname), $file); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | if ($GLOBALS['egw_info']['user']['apps']['admin']) |
67 | 67 | { |
68 | 68 | $file = Array( |
69 | - 'Site Configuration' => Egw::link('/index.php','menuaction=importexport.importexport_definitions_ui.site_config'), |
|
70 | - 'Import definitions' => Egw::link('/index.php','menuaction=importexport.importexport_definitions_ui.import_definition'), |
|
71 | - 'Define imports|exports' => Egw::link('/index.php',array( |
|
69 | + 'Site Configuration' => Egw::link('/index.php', 'menuaction=importexport.importexport_definitions_ui.site_config'), |
|
70 | + 'Import definitions' => Egw::link('/index.php', 'menuaction=importexport.importexport_definitions_ui.import_definition'), |
|
71 | + 'Define imports|exports' => Egw::link('/index.php', array( |
|
72 | 72 | 'menuaction' => 'importexport.importexport_definitions_ui.index', |
73 | 73 | 'ajax' => 'true' |
74 | 74 | )), |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | ); |
79 | 79 | if ($location == 'admin') |
80 | 80 | { |
81 | - display_section($appname,$file); |
|
81 | + display_section($appname, $file); |
|
82 | 82 | } |
83 | 83 | else |
84 | 84 | { |
85 | - display_sidebox($appname,lang('Admin'),$file); |
|
85 | + display_sidebox($appname, lang('Admin'), $file); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | } |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * Called from framework so Import / Export can add links into other apps' sidebox. |
92 | 92 | */ |
93 | 93 | public static function other_apps() { |
94 | - if(!$GLOBALS['egw_info']['user']['apps']['importexport']) return array(); |
|
95 | - if($GLOBALS['egw_info']['flags']['no_importexport'] === true) return array(); |
|
94 | + if (!$GLOBALS['egw_info']['user']['apps']['importexport']) return array(); |
|
95 | + if ($GLOBALS['egw_info']['flags']['no_importexport'] === true) return array(); |
|
96 | 96 | |
97 | 97 | $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
98 | 98 | $cache = Api\Cache::getCache(Api\Cache::SESSION, 'importexport', 'sidebox_links'); |
99 | 99 | |
100 | - if(!$cache[$appname] && $GLOBALS['egw_info']['user']['apps']['importexport']) { |
|
100 | + if (!$cache[$appname] && $GLOBALS['egw_info']['user']['apps']['importexport']) { |
|
101 | 101 | $cache[$appname]['import'] = importexport_helper_functions::has_definitions($appname, 'import'); |
102 | 102 | $cache[$appname]['export'] = importexport_helper_functions::has_definitions($appname, 'export'); |
103 | 103 | Api\Cache::setCache(Api\Cache::SESSION, 'importexport', 'sidebox_links', $cache); |
@@ -106,51 +106,51 @@ discard block |
||
106 | 106 | // Add in import / export, if available |
107 | 107 | $file = array(); |
108 | 108 | $plugins = importexport_helper_functions::get_plugins($appname); |
109 | - if($cache[$appname]['import']) |
|
109 | + if ($cache[$appname]['import']) |
|
110 | 110 | { |
111 | 111 | $file['Import CSV'] = array('link' => "javascript:egw_openWindowCentered2('". |
112 | - Egw::link('/index.php',array( |
|
112 | + Egw::link('/index.php', array( |
|
113 | 113 | 'menuaction' => 'importexport.importexport_import_ui.import_dialog', |
114 | 114 | 'appname'=>$appname |
115 | - ),false)."','_blank',850,440,'yes')", |
|
115 | + ), false)."','_blank',850,440,'yes')", |
|
116 | 116 | 'icon' => 'import', |
117 | 117 | 'app' => 'importexport', |
118 | 118 | 'text' => in_array($appname, array('sitemgr')) || count($plugins[$appname]['import']) > 1 ? 'Import' : 'Import CSV' |
119 | 119 | ); |
120 | - if($GLOBALS['egw_info']['flags']['disable_importexport']['import']) { |
|
120 | + if ($GLOBALS['egw_info']['flags']['disable_importexport']['import']) { |
|
121 | 121 | $file['Import CSV']['link'] = ''; |
122 | 122 | } |
123 | 123 | } |
124 | 124 | $export_limit = Api\Storage\Merge::getExportLimit($appname); |
125 | 125 | //error_log(__METHOD__.__LINE__.' app:'.$appname.' limit:'.$export_limit); |
126 | - if ((Api\Storage\Merge::is_export_limit_excepted() || Api\Storage\Merge::hasExportLimit($export_limit,'ISALLOWED')) && $cache[$appname]['export']) |
|
126 | + if ((Api\Storage\Merge::is_export_limit_excepted() || Api\Storage\Merge::hasExportLimit($export_limit, 'ISALLOWED')) && $cache[$appname]['export']) |
|
127 | 127 | { |
128 | 128 | $file['Export CSV'] = array('link' => "javascript:egw_openWindowCentered2('". |
129 | - Egw::link('/index.php',array( |
|
129 | + Egw::link('/index.php', array( |
|
130 | 130 | 'menuaction' => 'importexport.importexport_export_ui.export_dialog', |
131 | 131 | 'appname'=>$appname |
132 | - ),false)."','_blank',850,440,'yes')", |
|
132 | + ), false)."','_blank',850,440,'yes')", |
|
133 | 133 | 'icon' => 'export', |
134 | 134 | 'app' => 'importexport', |
135 | 135 | 'text' => in_array($appname, array('sitemgr')) || count($plugins[$appname]['export']) > 1 ? 'Export' : 'Export CSV' |
136 | 136 | ); |
137 | - if($GLOBALS['egw_info']['flags']['disable_importexport']['export']) { |
|
137 | + if ($GLOBALS['egw_info']['flags']['disable_importexport']['export']) { |
|
138 | 138 | $file['Export CSV']['link'] = ''; |
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | 142 | $config = Api\Config::read('importexport'); |
143 | - if($appname != 'admin' && ($config['users_create_definitions'] || $GLOBALS['egw_info']['user']['apps']['admin']) && |
|
143 | + if ($appname != 'admin' && ($config['users_create_definitions'] || $GLOBALS['egw_info']['user']['apps']['admin']) && |
|
144 | 144 | count(importexport_helper_functions::get_plugins($appname)) > 0 |
145 | 145 | ) |
146 | 146 | { |
147 | - $file['Define imports|exports'] = Egw::link('/index.php',array( |
|
147 | + $file['Define imports|exports'] = Egw::link('/index.php', array( |
|
148 | 148 | 'menuaction' => 'importexport.importexport_definitions_ui.index', |
149 | 149 | 'application' => $appname, |
150 | 150 | 'ajax' => 'true' |
151 | - ),$GLOBALS['egw_info']['user']['apps']['admin'] ? 'admin' : 'preferences'); |
|
151 | + ), $GLOBALS['egw_info']['user']['apps']['admin'] ? 'admin' : 'preferences'); |
|
152 | 152 | } |
153 | - if($file) display_sidebox($appname,lang('importexport'),$file); |
|
153 | + if ($file) display_sidebox($appname, lang('importexport'), $file); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -90,14 +90,22 @@ discard block |
||
90 | 90 | /** |
91 | 91 | * Called from framework so Import / Export can add links into other apps' sidebox. |
92 | 92 | */ |
93 | - public static function other_apps() { |
|
94 | - if(!$GLOBALS['egw_info']['user']['apps']['importexport']) return array(); |
|
95 | - if($GLOBALS['egw_info']['flags']['no_importexport'] === true) return array(); |
|
93 | + public static function other_apps() |
|
94 | + { |
|
95 | + if(!$GLOBALS['egw_info']['user']['apps']['importexport']) |
|
96 | + { |
|
97 | + return array(); |
|
98 | + } |
|
99 | + if($GLOBALS['egw_info']['flags']['no_importexport'] === true) |
|
100 | + { |
|
101 | + return array(); |
|
102 | + } |
|
96 | 103 | |
97 | 104 | $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
98 | 105 | $cache = Api\Cache::getCache(Api\Cache::SESSION, 'importexport', 'sidebox_links'); |
99 | 106 | |
100 | - if(!$cache[$appname] && $GLOBALS['egw_info']['user']['apps']['importexport']) { |
|
107 | + if(!$cache[$appname] && $GLOBALS['egw_info']['user']['apps']['importexport']) |
|
108 | + { |
|
101 | 109 | $cache[$appname]['import'] = importexport_helper_functions::has_definitions($appname, 'import'); |
102 | 110 | $cache[$appname]['export'] = importexport_helper_functions::has_definitions($appname, 'export'); |
103 | 111 | Api\Cache::setCache(Api\Cache::SESSION, 'importexport', 'sidebox_links', $cache); |
@@ -117,7 +125,8 @@ discard block |
||
117 | 125 | 'app' => 'importexport', |
118 | 126 | 'text' => in_array($appname, array('sitemgr')) || count($plugins[$appname]['import']) > 1 ? 'Import' : 'Import CSV' |
119 | 127 | ); |
120 | - if($GLOBALS['egw_info']['flags']['disable_importexport']['import']) { |
|
128 | + if($GLOBALS['egw_info']['flags']['disable_importexport']['import']) |
|
129 | + { |
|
121 | 130 | $file['Import CSV']['link'] = ''; |
122 | 131 | } |
123 | 132 | } |
@@ -134,7 +143,8 @@ discard block |
||
134 | 143 | 'app' => 'importexport', |
135 | 144 | 'text' => in_array($appname, array('sitemgr')) || count($plugins[$appname]['export']) > 1 ? 'Export' : 'Export CSV' |
136 | 145 | ); |
137 | - if($GLOBALS['egw_info']['flags']['disable_importexport']['export']) { |
|
146 | + if($GLOBALS['egw_info']['flags']['disable_importexport']['export']) |
|
147 | + { |
|
138 | 148 | $file['Export CSV']['link'] = ''; |
139 | 149 | } |
140 | 150 | } |
@@ -142,15 +152,17 @@ discard block |
||
142 | 152 | $config = Api\Config::read('importexport'); |
143 | 153 | if($appname != 'admin' && ($config['users_create_definitions'] || $GLOBALS['egw_info']['user']['apps']['admin']) && |
144 | 154 | count(importexport_helper_functions::get_plugins($appname)) > 0 |
145 | - ) |
|
146 | - { |
|
155 | + ) { |
|
147 | 156 | $file['Define imports|exports'] = Egw::link('/index.php',array( |
148 | 157 | 'menuaction' => 'importexport.importexport_definitions_ui.index', |
149 | 158 | 'application' => $appname, |
150 | 159 | 'ajax' => 'true' |
151 | 160 | ),$GLOBALS['egw_info']['user']['apps']['admin'] ? 'admin' : 'preferences'); |
152 | 161 | } |
153 | - if($file) display_sidebox($appname,lang('importexport'),$file); |
|
162 | + if($file) |
|
163 | + { |
|
164 | + display_sidebox($appname,lang('importexport'),$file); |
|
165 | + } |
|
154 | 166 | } |
155 | 167 | |
156 | 168 | /** |
@@ -108,7 +108,7 @@ |
||
108 | 108 | |
109 | 109 | if ($GLOBALS['egw_info']['user']['apps']['admin'] && !Api\Header\UserAgent::mobile()) |
110 | 110 | { |
111 | - $file = Array( |
|
111 | + $file = array( |
|
112 | 112 | 'Site configuration' => Egw::link('/index.php',array( |
113 | 113 | 'menuaction' => 'infolog.infolog_ui.admin' )), |
114 | 114 | 'Global Categories' => Egw::link('/index.php',array( |
@@ -30,39 +30,39 @@ discard block |
||
30 | 30 | * @param DOMElement $_node |
31 | 31 | * @return string XML string |
32 | 32 | */ |
33 | - public static function array2xml ( $_data, $_name = 'root', $_node=null ) { |
|
33 | + public static function array2xml($_data, $_name = 'root', $_node = null) { |
|
34 | 34 | $returnXML = false; |
35 | - if ( $_node === null ) { |
|
36 | - $_node = new DOMDocument( '1.0', 'utf-8' ); |
|
35 | + if ($_node === null) { |
|
36 | + $_node = new DOMDocument('1.0', 'utf-8'); |
|
37 | 37 | $_node->formatOutput = true; |
38 | 38 | $returnXML = true; |
39 | 39 | } |
40 | 40 | |
41 | - $datatype = gettype( $_data ); |
|
42 | - switch ( $datatype ) { |
|
41 | + $datatype = gettype($_data); |
|
42 | + switch ($datatype) { |
|
43 | 43 | case 'array' : |
44 | - $subnode = new DOMElement( 'entry' ); |
|
45 | - $_node->appendChild( $subnode ); |
|
46 | - $subnode->setAttribute( 'type', $datatype ); |
|
47 | - $subnode->setAttribute( 'name' , $_name ); |
|
44 | + $subnode = new DOMElement('entry'); |
|
45 | + $_node->appendChild($subnode); |
|
46 | + $subnode->setAttribute('type', $datatype); |
|
47 | + $subnode->setAttribute('name', $_name); |
|
48 | 48 | |
49 | - foreach ( $_data as $ikey => $ivalue ) { |
|
50 | - self::array2xml( $ivalue, $ikey, $subnode ); |
|
49 | + foreach ($_data as $ikey => $ivalue) { |
|
50 | + self::array2xml($ivalue, $ikey, $subnode); |
|
51 | 51 | } |
52 | 52 | break; |
53 | 53 | |
54 | 54 | default : |
55 | - switch ( $datatype ) { |
|
55 | + switch ($datatype) { |
|
56 | 56 | case 'boolean' : |
57 | 57 | $data = $_data !== false ? 'TRUE' : 'FALSE'; |
58 | 58 | break; |
59 | 59 | default: |
60 | 60 | $data = &$_data; |
61 | 61 | } |
62 | - $subnode = new DOMElement( 'entry' , $data ); |
|
63 | - $_node->appendChild( $subnode ); |
|
64 | - $subnode->setAttribute( 'type', $datatype ); |
|
65 | - $subnode->setAttribute( 'name' , $_name ); |
|
62 | + $subnode = new DOMElement('entry', $data); |
|
63 | + $_node->appendChild($subnode); |
|
64 | + $subnode->setAttribute('type', $datatype); |
|
65 | + $subnode->setAttribute('name', $_name); |
|
66 | 66 | break; |
67 | 67 | } |
68 | 68 | return $returnXML ? $_node->saveXML() : ''; |
@@ -74,28 +74,28 @@ discard block |
||
74 | 74 | * @param string $_xml |
75 | 75 | * @return array |
76 | 76 | */ |
77 | - public static function xml2array( $_xml ) { |
|
78 | - if ( $_xml instanceof DOMElement ) { |
|
77 | + public static function xml2array($_xml) { |
|
78 | + if ($_xml instanceof DOMElement) { |
|
79 | 79 | $n = &$_xml; |
80 | 80 | } else { |
81 | 81 | $n = new DOMDocument; |
82 | 82 | $loaded = $n->loadXML($_xml); |
83 | - if(!$loaded) return array(); |
|
83 | + if (!$loaded) return array(); |
|
84 | 84 | } |
85 | 85 | $xml_array = array(); |
86 | 86 | |
87 | - foreach($n->childNodes as $nc) { |
|
87 | + foreach ($n->childNodes as $nc) { |
|
88 | 88 | |
89 | - if ( $nc->nodeType != XML_ELEMENT_NODE ) continue; |
|
89 | + if ($nc->nodeType != XML_ELEMENT_NODE) continue; |
|
90 | 90 | |
91 | 91 | $name = $nc->attributes->getNamedItem('name')->nodeValue; |
92 | 92 | $type = $nc->attributes->getNamedItem('type')->nodeValue; |
93 | 93 | |
94 | 94 | //echo $nc->nodeType. "(length ): ". $nc->nodeName. " => ". $nc->nodeValue. "; Attriubtes: name=$name, type=$type \n "; |
95 | - if( $nc->childNodes->length >= 2) { |
|
95 | + if ($nc->childNodes->length >= 2) { |
|
96 | 96 | $xml_array[$name] = self::xml2array($nc); |
97 | 97 | } else { |
98 | - switch ( $type ) { |
|
98 | + switch ($type) { |
|
99 | 99 | case 'boolean' : |
100 | 100 | $value = $nc->nodeValue == 'FALSE' ? false : true; |
101 | 101 | break; |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | * @todo deal with other types like objects |
21 | 21 | * @static only namespace here |
22 | 22 | */ |
23 | -class importexport_arrayxml { |
|
23 | +class importexport_arrayxml |
|
24 | +{ |
|
24 | 25 | |
25 | 26 | /** |
26 | 27 | * converts a php array to an xml string |
@@ -30,29 +31,34 @@ discard block |
||
30 | 31 | * @param DOMElement $_node |
31 | 32 | * @return string XML string |
32 | 33 | */ |
33 | - public static function array2xml ( $_data, $_name = 'root', $_node=null ) { |
|
34 | + public static function array2xml ( $_data, $_name = 'root', $_node=null ) |
|
35 | + { |
|
34 | 36 | $returnXML = false; |
35 | - if ( $_node === null ) { |
|
37 | + if ( $_node === null ) |
|
38 | + { |
|
36 | 39 | $_node = new DOMDocument( '1.0', 'utf-8' ); |
37 | 40 | $_node->formatOutput = true; |
38 | 41 | $returnXML = true; |
39 | 42 | } |
40 | 43 | |
41 | 44 | $datatype = gettype( $_data ); |
42 | - switch ( $datatype ) { |
|
45 | + switch ( $datatype ) |
|
46 | + { |
|
43 | 47 | case 'array' : |
44 | 48 | $subnode = new DOMElement( 'entry' ); |
45 | 49 | $_node->appendChild( $subnode ); |
46 | 50 | $subnode->setAttribute( 'type', $datatype ); |
47 | 51 | $subnode->setAttribute( 'name' , $_name ); |
48 | 52 | |
49 | - foreach ( $_data as $ikey => $ivalue ) { |
|
53 | + foreach ( $_data as $ikey => $ivalue ) |
|
54 | + { |
|
50 | 55 | self::array2xml( $ivalue, $ikey, $subnode ); |
51 | 56 | } |
52 | 57 | break; |
53 | 58 | |
54 | 59 | default : |
55 | - switch ( $datatype ) { |
|
60 | + switch ( $datatype ) |
|
61 | + { |
|
56 | 62 | case 'boolean' : |
57 | 63 | $data = $_data !== false ? 'TRUE' : 'FALSE'; |
58 | 64 | break; |
@@ -74,28 +80,43 @@ discard block |
||
74 | 80 | * @param string $_xml |
75 | 81 | * @return array |
76 | 82 | */ |
77 | - public static function xml2array( $_xml ) { |
|
78 | - if ( $_xml instanceof DOMElement ) { |
|
83 | + public static function xml2array( $_xml ) |
|
84 | + { |
|
85 | + if ( $_xml instanceof DOMElement ) |
|
86 | + { |
|
79 | 87 | $n = &$_xml; |
80 | - } else { |
|
88 | + } |
|
89 | + else |
|
90 | + { |
|
81 | 91 | $n = new DOMDocument; |
82 | 92 | $loaded = $n->loadXML($_xml); |
83 | - if(!$loaded) return array(); |
|
93 | + if(!$loaded) |
|
94 | + { |
|
95 | + return array(); |
|
96 | + } |
|
84 | 97 | } |
85 | 98 | $xml_array = array(); |
86 | 99 | |
87 | - foreach($n->childNodes as $nc) { |
|
100 | + foreach($n->childNodes as $nc) |
|
101 | + { |
|
88 | 102 | |
89 | - if ( $nc->nodeType != XML_ELEMENT_NODE ) continue; |
|
103 | + if ( $nc->nodeType != XML_ELEMENT_NODE ) |
|
104 | + { |
|
105 | + continue; |
|
106 | + } |
|
90 | 107 | |
91 | 108 | $name = $nc->attributes->getNamedItem('name')->nodeValue; |
92 | 109 | $type = $nc->attributes->getNamedItem('type')->nodeValue; |
93 | 110 | |
94 | 111 | //echo $nc->nodeType. "(length ): ". $nc->nodeName. " => ". $nc->nodeValue. "; Attriubtes: name=$name, type=$type \n "; |
95 | - if( $nc->childNodes->length >= 2) { |
|
112 | + if( $nc->childNodes->length >= 2) |
|
113 | + { |
|
96 | 114 | $xml_array[$name] = self::xml2array($nc); |
97 | - } else { |
|
98 | - switch ( $type ) { |
|
115 | + } |
|
116 | + else |
|
117 | + { |
|
118 | + switch ( $type ) |
|
119 | + { |
|
99 | 120 | case 'boolean' : |
100 | 121 | $value = $nc->nodeValue == 'FALSE' ? false : true; |
101 | 122 | break; |
@@ -41,18 +41,18 @@ discard block |
||
41 | 41 | public function beforeSendToClient($cname, Array $expand = Array()) |
42 | 42 | { |
43 | 43 | $form_name = self::form_name($cname, $this->id); |
44 | - if($this->getElementAttribute($form_name, 'customfields')) |
|
44 | + if ($this->getElementAttribute($form_name, 'customfields')) |
|
45 | 45 | { |
46 | 46 | // Already done? Still need to process, or sel_options may be missing |
47 | 47 | unset(self::$request->modifications[$form_name]); |
48 | 48 | } |
49 | - $value =& self::get_array(self::$request->content, $form_name, true); |
|
49 | + $value = & self::get_array(self::$request->content, $form_name, true); |
|
50 | 50 | $fields = $value['fields']; |
51 | 51 | unset($value['fields']); |
52 | 52 | $relative_dates = $this->attrs['relative_dates']; |
53 | 53 | |
54 | 54 | // Fallback, so there's something there... |
55 | - if(!is_array($fields)) |
|
55 | + if (!is_array($fields)) |
|
56 | 56 | { |
57 | 57 | error_log("$this has no fields"); |
58 | 58 | self::$transformation = array( |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | $this->setElementAttribute($form_name, 'prefix', self::$prefix); |
70 | 70 | |
71 | 71 | $n = 1; |
72 | - foreach($fields as $lname => &$field) |
|
72 | + foreach ($fields as $lname => &$field) |
|
73 | 73 | { |
74 | - $type =& $field['type']; |
|
74 | + $type = & $field['type']; |
|
75 | 75 | |
76 | 76 | // No filters are required |
77 | 77 | $field['needed'] = false; |
78 | 78 | |
79 | - switch($type) |
|
79 | + switch ($type) |
|
80 | 80 | { |
81 | 81 | case 'date': |
82 | 82 | case 'date-time': |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | 'get_rows' => 'etemplate.ajax_select_widget.array_rows', |
94 | 94 | 'id_field' => ajax_select_widget::ARRAY_KEY, |
95 | 95 | ); |
96 | - if($field['rows']) { |
|
96 | + if ($field['rows']) { |
|
97 | 97 | $options['num_rows'] = $field['rows']; |
98 | 98 | } |
99 | 99 | |
@@ -112,15 +112,15 @@ discard block |
||
112 | 112 | break; |
113 | 113 | case 'select': |
114 | 114 | default: |
115 | - if(strpos($field['type'],'select') === 0) |
|
115 | + if (strpos($field['type'], 'select') === 0) |
|
116 | 116 | { |
117 | 117 | if (count($field['values']) == 1 && isset($field['values']['@'])) |
118 | 118 | { |
119 | 119 | $field['values'] = Api\Storage\Customfields::get_options_from_file($field['values']['@']); |
120 | 120 | } |
121 | - foreach((array)$field['values'] as $key => $val) |
|
121 | + foreach ((array)$field['values'] as $key => $val) |
|
122 | 122 | { |
123 | - if (substr($val = lang($val),-1) != '*') |
|
123 | + if (substr($val = lang($val), -1) != '*') |
|
124 | 124 | { |
125 | 125 | $field['values'][$key] = $val; |
126 | 126 | } |
@@ -132,27 +132,27 @@ discard block |
||
132 | 132 | $this->setElementAttribute($form_name.'['.self::$prefix.$lname.']', 'tags', TRUE); |
133 | 133 | $this->setElementAttribute($form_name.'['.self::$prefix.$lname.']', 'multiple', TRUE); |
134 | 134 | } |
135 | - else if( $GLOBALS['egw_info']['apps'][$field['type']]) |
|
135 | + else if ($GLOBALS['egw_info']['apps'][$field['type']]) |
|
136 | 136 | { |
137 | 137 | // Links |
138 | 138 | } |
139 | 139 | else |
140 | 140 | { |
141 | - error_log('Trying to filter with unsupported field type ' . $lname . ': ' . $field['type']); |
|
141 | + error_log('Trying to filter with unsupported field type '.$lname.': '.$field['type']); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | 145 | // Send select options |
146 | - if($field['values']) |
|
146 | + if ($field['values']) |
|
147 | 147 | { |
148 | 148 | self::$request->sel_options[self::$prefix.$lname] = $field['values']; |
149 | 149 | } |
150 | 150 | $widget = self::factory($type, '<'.$type.' type="'.$type.'" id="'.self::$prefix.$lname.'"/>', self::$prefix.$lname); |
151 | - if(method_exists($widget, 'beforeSendToClient')) |
|
151 | + if (method_exists($widget, 'beforeSendToClient')) |
|
152 | 152 | { |
153 | 153 | $widget->id = self::$prefix.$lname; |
154 | 154 | $widget->attrs['type'] = $type; |
155 | - if($type == 'link-to') |
|
155 | + if ($type == 'link-to') |
|
156 | 156 | { |
157 | 157 | $widget->attrs['only_app'] = $field['type']; |
158 | 158 | } |
@@ -164,22 +164,22 @@ discard block |
||
164 | 164 | parent::beforeSendToClient($cname, $expand); |
165 | 165 | |
166 | 166 | $this->setElementAttribute($form_name, 'customfields', $fields); |
167 | - $this->setElementAttribute($form_name, 'fields',array_fill_keys(array_keys($fields), true)); |
|
167 | + $this->setElementAttribute($form_name, 'fields', array_fill_keys(array_keys($fields), true)); |
|
168 | 168 | return false; |
169 | 169 | } |
170 | 170 | |
171 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
171 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
172 | 172 | { |
173 | 173 | $form_name = self::form_name($cname, $this->id, $expand); |
174 | 174 | if (!$this->is_readonly($cname, $form_name)) |
175 | 175 | { |
176 | 176 | $value_in = (array)self::get_array($content, $form_name); |
177 | - $valid =& self::get_array($validated, $this->id ? $form_name : $field, true); |
|
177 | + $valid = & self::get_array($validated, $this->id ? $form_name : $field, true); |
|
178 | 178 | |
179 | - foreach($value_in as $key => $value) |
|
179 | + foreach ($value_in as $key => $value) |
|
180 | 180 | { |
181 | 181 | // Client side cf widget automatically prefixes # |
182 | - $valid[substr($key,strlen(self::$prefix))] = $value; |
|
182 | + $valid[substr($key, strlen(self::$prefix))] = $value; |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
@@ -93,7 +93,8 @@ discard block |
||
93 | 93 | 'get_rows' => 'etemplate.ajax_select_widget.array_rows', |
94 | 94 | 'id_field' => ajax_select_widget::ARRAY_KEY, |
95 | 95 | ); |
96 | - if($field['rows']) { |
|
96 | + if($field['rows']) |
|
97 | + { |
|
97 | 98 | $options['num_rows'] = $field['rows']; |
98 | 99 | } |
99 | 100 | |
@@ -103,7 +104,9 @@ discard block |
||
103 | 104 | { |
104 | 105 | $options['values'] = Api\Storage\Customfields::get_options_from_file($field['values']['@']); |
105 | 106 | unset($field['values']['@']); |
106 | - } else { |
|
107 | + } |
|
108 | + else |
|
109 | + { |
|
107 | 110 | $options['values'] = array_diff_key($field['values'], array_flip(ajax_select_widget::$known_options)); |
108 | 111 | } |
109 | 112 | $options = array_merge($options, array_intersect_key($field['values'], array_flip(ajax_select_widget::$known_options))); |
@@ -38,7 +38,7 @@ |
||
38 | 38 | * |
39 | 39 | * @param string $cname |
40 | 40 | */ |
41 | - public function beforeSendToClient($cname, Array $expand = Array()) |
|
41 | + public function beforeSendToClient($cname, array $expand = array()) |
|
42 | 42 | { |
43 | 43 | $form_name = self::form_name($cname, $this->id); |
44 | 44 | if($this->getElementAttribute($form_name, 'customfields')) |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
199 | - * Get options for select boxes |
|
200 | - */ |
|
199 | + * Get options for select boxes |
|
200 | + */ |
|
201 | 201 | public static function get_select_options(Array $data) |
202 | 202 | { |
203 | 203 | $options = array( |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
264 | - * Generate a async key |
|
265 | - */ |
|
264 | + * Generate a async key |
|
265 | + */ |
|
266 | 266 | public static function generate_id($data) |
267 | 267 | { |
268 | 268 | |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
281 | - * Check that the target is valid for the type (readable or writable) |
|
282 | - * and that they're not trying to write directly to the filesystem |
|
283 | - * |
|
284 | - * $data should contain target & type |
|
285 | - */ |
|
281 | + * Check that the target is valid for the type (readable or writable) |
|
282 | + * and that they're not trying to write directly to the filesystem |
|
283 | + * |
|
284 | + * $data should contain target & type |
|
285 | + */ |
|
286 | 286 | public static function check_target(Array $data) { |
287 | 287 | $scheme = parse_url($data['target'], PHP_URL_SCHEME); |
288 | 288 | if($scheme == '' || $scheme == 'file') |
@@ -329,11 +329,11 @@ discard block |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
332 | - * Writable that checks the folder too, in case the file does not exist yet |
|
333 | - * http://ca3.php.net/manual/en/function.is-writable.php#73596 |
|
334 | - * |
|
335 | - * @param path Path to check |
|
336 | - */ |
|
332 | + * Writable that checks the folder too, in case the file does not exist yet |
|
333 | + * http://ca3.php.net/manual/en/function.is-writable.php#73596 |
|
334 | + * |
|
335 | + * @param path Path to check |
|
336 | + */ |
|
337 | 337 | private static function is__writable($path) |
338 | 338 | { |
339 | 339 | if ($path{strlen($path)-1}=='/') |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
368 | - * Execute a scheduled import or export |
|
369 | - */ |
|
368 | + * Execute a scheduled import or export |
|
369 | + */ |
|
370 | 370 | public static function exec($data) |
371 | 371 | { |
372 | 372 | ob_start(); |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | public function index($content = array()) |
38 | 38 | { |
39 | 39 | $async = new Api\Asyncservice(); |
40 | - if(is_array($content['scheduled'])) |
|
40 | + if (is_array($content['scheduled'])) |
|
41 | 41 | { |
42 | - foreach($content['scheduled'] as $row) |
|
42 | + foreach ($content['scheduled'] as $row) |
|
43 | 43 | { |
44 | - if($row['delete']) |
|
44 | + if ($row['delete']) |
|
45 | 45 | { |
46 | 46 | $key = urldecode(key($row['delete'])); |
47 | 47 | $async->cancel_timer($key); |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | } |
51 | 51 | $async_list = $async->read('importexport%'); |
52 | 52 | $data = array(); |
53 | - if(is_array($async_list)) |
|
53 | + if (is_array($async_list)) |
|
54 | 54 | { |
55 | - foreach($async_list as $id => $async) |
|
55 | + foreach ($async_list as $id => $async) |
|
56 | 56 | { |
57 | - foreach(array('errors', 'warnings', 'result') as $messages) |
|
57 | + foreach (array('errors', 'warnings', 'result') as $messages) |
|
58 | 58 | { |
59 | - if(is_array($async['data'][$messages])) |
|
59 | + if (is_array($async['data'][$messages])) |
|
60 | 60 | { |
61 | 61 | $list = array(); |
62 | - foreach($async['data'][$messages] as $target => $message) |
|
62 | + foreach ($async['data'][$messages] as $target => $message) |
|
63 | 63 | { |
64 | 64 | $list[] = array( |
65 | 65 | 'target' => (is_numeric($target) ? '' : $target), |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $async['data'][$messages] = $list; |
70 | 70 | } |
71 | 71 | } |
72 | - if(is_numeric($async['data']['record_count'])) |
|
72 | + if (is_numeric($async['data']['record_count'])) |
|
73 | 73 | { |
74 | 74 | $async['data']['record_count'] = lang('%1 records processed', $async['data']['record_count']); |
75 | 75 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $data = $content; |
101 | 101 | |
102 | 102 | // Deal with incoming |
103 | - if($content['save'] && self::check_target($content) === true) |
|
103 | + if ($content['save'] && self::check_target($content) === true) |
|
104 | 104 | { |
105 | 105 | unset($content['save']); |
106 | 106 | $async->cancel_timer($id); |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | unset($content['schedule']); |
112 | 112 | |
113 | 113 | // Remove any left blank |
114 | - foreach($schedule as $key => &$value) |
|
114 | + foreach ($schedule as $key => &$value) |
|
115 | 115 | { |
116 | - if($value == '') unset($schedule[$key]); |
|
116 | + if ($value == '') unset($schedule[$key]); |
|
117 | 117 | } |
118 | 118 | $result = $async->set_timer( |
119 | 119 | $schedule, |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | 'importexport.importexport_schedule_ui.exec', |
122 | 122 | $content |
123 | 123 | ); |
124 | - if($result) |
|
124 | + if ($result) |
|
125 | 125 | { |
126 | - Framework::refresh_opener('', 'admin',$id,'update','admin'); |
|
126 | + Framework::refresh_opener('', 'admin', $id, 'update', 'admin'); |
|
127 | 127 | Framework::window_close(); |
128 | 128 | } |
129 | 129 | else |
@@ -133,19 +133,19 @@ discard block |
||
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | - if($id) |
|
136 | + if ($id) |
|
137 | 137 | { |
138 | 138 | |
139 | 139 | $preserve['id'] = $id; |
140 | 140 | $async = $async->read($id); |
141 | - if(is_array($async[$id]['data'])) |
|
141 | + if (is_array($async[$id]['data'])) |
|
142 | 142 | { |
143 | 143 | $data += $async[$id]['data']; |
144 | 144 | $data['schedule'] = $async[$id]['times']; |
145 | 145 | unset($data['times']); |
146 | 146 | |
147 | 147 | // Async sometimes changes minutes to an array - show user what they typed |
148 | - if(is_array($data['schedule']['min'])) |
|
148 | + if (is_array($data['schedule']['min'])) |
|
149 | 149 | { |
150 | 150 | $data['schedule']['min'] = $data['min']; |
151 | 151 | } |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | { |
160 | 160 | $data['type'] = $content['type'] ? $content['type'] : 'import'; |
161 | 161 | |
162 | - if((int)$definition_id) |
|
162 | + if ((int)$definition_id) |
|
163 | 163 | { |
164 | 164 | $bo = new importexport_definitions_bo(); |
165 | 165 | $definition = $bo->read($definition_id); |
166 | - if($definition['definition_id']) |
|
166 | + if ($definition['definition_id']) |
|
167 | 167 | { |
168 | 168 | $data['type'] = $definition['type']; |
169 | 169 | $data['appname'] = $definition['application']; |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | - if($data['target'] && $data['type']) |
|
176 | + if ($data['target'] && $data['type']) |
|
177 | 177 | { |
178 | 178 | $file_check = self::check_target($data); |
179 | - if($file_check !== true) |
|
179 | + if ($file_check !== true) |
|
180 | 180 | { |
181 | - $data['message'] .= ($data['message'] ? "\n" . $file_check : $file_check); |
|
181 | + $data['message'] .= ($data['message'] ? "\n".$file_check : $file_check); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $data['current_time'] = time(); |
189 | 189 | |
190 | 190 | $sel_options = self::get_select_options($data); |
191 | - Framework::includeJS('.','importexport','importexport'); |
|
191 | + Framework::includeJS('.', 'importexport', 'importexport'); |
|
192 | 192 | |
193 | 193 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Schedule import / export'); |
194 | 194 | $this->template->read('importexport.schedule_edit'); |
@@ -208,21 +208,21 @@ discard block |
||
208 | 208 | ); |
209 | 209 | |
210 | 210 | (array)$apps = importexport_helper_functions::get_apps($data['type'] ? $data['type'] : 'all'); |
211 | - if(count($apps)) |
|
211 | + if (count($apps)) |
|
212 | 212 | { |
213 | - $options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps); |
|
213 | + $options['appname'] = array('' => lang('Select one')) + array_combine($apps, $apps); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | $plugins = importexport_helper_functions::get_plugins($data['appname'] ? $data['appname'] : 'all', $data['type']); |
217 | - if(is_array($plugins)) |
|
217 | + if (is_array($plugins)) |
|
218 | 218 | { |
219 | - foreach($plugins as $types) |
|
219 | + foreach ($plugins as $types) |
|
220 | 220 | { |
221 | - if(!is_array($types[$data['type']])) |
|
221 | + if (!is_array($types[$data['type']])) |
|
222 | 222 | { |
223 | 223 | continue; |
224 | 224 | } |
225 | - foreach($types[$data['type']] as $key => $title) |
|
225 | + foreach ($types[$data['type']] as $key => $title) |
|
226 | 226 | { |
227 | 227 | $options['plugin'][$key] = $title; |
228 | 228 | } |
@@ -285,27 +285,27 @@ discard block |
||
285 | 285 | */ |
286 | 286 | public static function check_target(Array $data) { |
287 | 287 | $scheme = parse_url($data['target'], PHP_URL_SCHEME); |
288 | - if($scheme == '' || $scheme == 'file') |
|
288 | + if ($scheme == '' || $scheme == 'file') |
|
289 | 289 | { |
290 | 290 | return 'Direct file access not allowed'; |
291 | 291 | } |
292 | 292 | |
293 | - if($scheme == Vfs::SCHEME && !in_array(Vfs::SCHEME, stream_get_wrappers())) { |
|
293 | + if ($scheme == Vfs::SCHEME && !in_array(Vfs::SCHEME, stream_get_wrappers())) { |
|
294 | 294 | stream_wrapper_register(Vfs::SCHEME, 'vfs_stream_wrapper', STREAM_IS_URL); |
295 | 295 | } |
296 | 296 | |
297 | 297 | if ($data['type'] == 'import' && ($scheme == Vfs::SCHEME && !Vfs::is_readable($data['target']))) |
298 | 298 | { |
299 | - return lang('%1 is not readable',$data['target']); |
|
299 | + return lang('%1 is not readable', $data['target']); |
|
300 | 300 | } |
301 | - elseif ($data['type'] == 'import' && in_array($scheme, array('http','https'))) |
|
301 | + elseif ($data['type'] == 'import' && in_array($scheme, array('http', 'https'))) |
|
302 | 302 | { |
303 | 303 | // Not supported by is_readable, try headers... |
304 | 304 | stream_context_set_default(array('http'=>array( |
305 | 305 | 'method' => 'HEAD', |
306 | 306 | 'ignore_errors' => 1 |
307 | 307 | ))); |
308 | - $headers = get_headers($data['target'],1); |
|
308 | + $headers = get_headers($data['target'], 1); |
|
309 | 309 | |
310 | 310 | // Reset... |
311 | 311 | stream_context_set_default(array('http'=>array( |
@@ -313,16 +313,16 @@ discard block |
||
313 | 313 | 'ignore_errors' => 0 |
314 | 314 | ))); |
315 | 315 | // Response code has an integer key, but redirects may add more responses |
316 | - for($i = 0; $i < count($headers); $i++) |
|
316 | + for ($i = 0; $i < count($headers); $i++) |
|
317 | 317 | { |
318 | - if(!$headers[$i]) break; |
|
319 | - if(strpos($headers[$i],'200') !== false) return true; |
|
318 | + if (!$headers[$i]) break; |
|
319 | + if (strpos($headers[$i], '200') !== false) return true; |
|
320 | 320 | } |
321 | - return lang('%1 is not readable',$data['target']); |
|
321 | + return lang('%1 is not readable', $data['target']); |
|
322 | 322 | } |
323 | 323 | elseif ($data['type'] == 'export' && !self::is__writable($data['target'])) |
324 | 324 | { |
325 | - return lang('%1 is not writable',$data['target']); |
|
325 | + return lang('%1 is not writable', $data['target']); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | return true; |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | */ |
337 | 337 | private static function is__writable($path) |
338 | 338 | { |
339 | - if ($path{strlen($path)-1}=='/') |
|
339 | + if ($path{strlen($path) - 1} == '/') |
|
340 | 340 | { |
341 | 341 | // recursively return a temporary file path |
342 | 342 | return self::is__writable($path.uniqid(mt_rand()).'.tmp'); |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | $rm = file_exists($path); |
351 | 351 | $f = @fopen($path, 'a'); |
352 | 352 | |
353 | - if ($f===false) |
|
353 | + if ($f === false) |
|
354 | 354 | { |
355 | 355 | return false; |
356 | 356 | } |
@@ -376,10 +376,10 @@ discard block |
||
376 | 376 | unset($data['warnings']); |
377 | 377 | unset($data['result']); |
378 | 378 | |
379 | - if($data['lock']) |
|
379 | + if ($data['lock']) |
|
380 | 380 | { |
381 | 381 | // Lock expires |
382 | - if($data['lock'] < time()) |
|
382 | + if ($data['lock'] < time()) |
|
383 | 383 | { |
384 | 384 | unset($data['lock']); |
385 | 385 | $data['warnings'][][] = lang('Lock expired on previous run'); |
@@ -400,25 +400,25 @@ discard block |
||
400 | 400 | |
401 | 401 | // check file |
402 | 402 | $file_check = self::check_target($data); |
403 | - if($file_check !== true) |
|
403 | + if ($file_check !== true) |
|
404 | 404 | { |
405 | 405 | $data['errors'] = array($file_check=>''); |
406 | 406 | // Update job with results |
407 | 407 | self::update_job($data); |
408 | 408 | |
409 | - error_log('importexport_schedule: ' . date('c') . ": $file_check \n"); |
|
409 | + error_log('importexport_schedule: '.date('c').": $file_check \n"); |
|
410 | 410 | error_log(ob_get_flush()); |
411 | 411 | return; |
412 | 412 | } |
413 | 413 | |
414 | 414 | $definition = new importexport_definition($data['definition']); |
415 | - if( $definition->get_identifier() < 1 ) |
|
415 | + if ($definition->get_identifier() < 1) |
|
416 | 416 | { |
417 | 417 | $data['errors'] = array('Definition not found!'); |
418 | 418 | // Update job with results |
419 | 419 | self::update_job($data); |
420 | 420 | |
421 | - error_log('importexport_schedule: ' . date('c') . ": Definition not found! \n"); |
|
421 | + error_log('importexport_schedule: '.date('c').": Definition not found! \n"); |
|
422 | 422 | return; |
423 | 423 | } |
424 | 424 | $GLOBALS['egw_info']['flags']['currentapp'] = $definition->application; |
@@ -427,30 +427,30 @@ discard block |
||
427 | 427 | |
428 | 428 | $type = $data['type']; |
429 | 429 | |
430 | - if(is_dir($data['target'])) |
|
430 | + if (is_dir($data['target'])) |
|
431 | 431 | { |
432 | - if($data['type'] == 'import') |
|
432 | + if ($data['type'] == 'import') |
|
433 | 433 | { |
434 | 434 | $targets = array(); |
435 | - foreach(scandir($data['target']) as $target) |
|
435 | + foreach (scandir($data['target']) as $target) |
|
436 | 436 | { |
437 | 437 | if ($target == '.' || $target == '..') |
438 | 438 | { |
439 | 439 | continue; |
440 | 440 | } |
441 | - $target = $data['target'].(substr($data['target'],-1) == '/' ? '' : '/').$target; |
|
441 | + $target = $data['target'].(substr($data['target'], -1) == '/' ? '' : '/').$target; |
|
442 | 442 | |
443 | 443 | // Check modification time, make sure it's not currently being written |
444 | 444 | // Skip files modified in the last 10 seconds |
445 | 445 | $mod_time = filemtime($target); |
446 | - if($mod_time >= time() - 10) |
|
446 | + if ($mod_time >= time() - 10) |
|
447 | 447 | { |
448 | 448 | $data['result'][$target] = lang('Skipped'); |
449 | 449 | continue; |
450 | 450 | } |
451 | 451 | $targets[$mod_time.$target] = $target; |
452 | 452 | } |
453 | - if($targets) |
|
453 | + if ($targets) |
|
454 | 454 | { |
455 | 455 | ksort($targets); |
456 | 456 | } |
@@ -466,27 +466,27 @@ discard block |
||
466 | 466 | $targets = array($data['target']); |
467 | 467 | } |
468 | 468 | |
469 | - if($type == 'export') |
|
469 | + if ($type == 'export') |
|
470 | 470 | { |
471 | 471 | // Set to export all or filter, if set |
472 | 472 | $selection = array('selection' => 'all'); |
473 | - if($definition->filter) |
|
473 | + if ($definition->filter) |
|
474 | 474 | { |
475 | 475 | $fields = importexport_helper_functions::get_filter_fields($definition->application, $po); |
476 | 476 | $selection = array('selection' => 'filter'); |
477 | 477 | $filters = array(); |
478 | - foreach($definition->filter as $field => $value) |
|
478 | + foreach ($definition->filter as $field => $value) |
|
479 | 479 | { |
480 | 480 | // Handle multiple values |
481 | - if(!is_array($value) && strpos($value,',') !== false) |
|
481 | + if (!is_array($value) && strpos($value, ',') !== false) |
|
482 | 482 | { |
483 | - $value = explode(',',$value); |
|
483 | + $value = explode(',', $value); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | $filters[$field] = $value; |
487 | 487 | |
488 | 488 | // Process relative dates into the current absolute date |
489 | - if($filters[$field] && strpos($fields[$field]['type'],'date') === 0) |
|
489 | + if ($filters[$field] && strpos($fields[$field]['type'], 'date') === 0) |
|
490 | 490 | { |
491 | 491 | $filters[$field] = importexport_helper_functions::date_rel2abs($value); |
492 | 492 | } |
@@ -494,14 +494,14 @@ discard block |
||
494 | 494 | // Update filter to use current absolute dates |
495 | 495 | $definition->filter = $filters; |
496 | 496 | } |
497 | - if(!is_array($definition->plugin_options)) |
|
497 | + if (!is_array($definition->plugin_options)) |
|
498 | 498 | { |
499 | 499 | $definition->plugin_options = array(); |
500 | 500 | } |
501 | 501 | $definition->plugin_options = array_merge($definition->plugin_options, $selection); |
502 | 502 | } |
503 | 503 | |
504 | - foreach($targets as $target) |
|
504 | + foreach ($targets as $target) |
|
505 | 505 | { |
506 | 506 | // Update lock timeout |
507 | 507 | $data['lock'] = time() + 3600; |
@@ -510,16 +510,16 @@ discard block |
||
510 | 510 | $resource = null; |
511 | 511 | try |
512 | 512 | { |
513 | - if (($resource = @fopen( $target, $data['type'] == 'import' ? 'rb' : 'wb' ))) |
|
513 | + if (($resource = @fopen($target, $data['type'] == 'import' ? 'rb' : 'wb'))) |
|
514 | 514 | { |
515 | - $result = $po->$type( $resource, $definition ); |
|
515 | + $result = $po->$type($resource, $definition); |
|
516 | 516 | |
517 | 517 | fclose($resource); |
518 | 518 | } |
519 | 519 | else |
520 | 520 | { |
521 | - error_log('importexport_schedule: ' . date('c') . ": File $target not readable! \n"); |
|
522 | - $data['errors'][$target][] = lang('%1 is not readable',$target); |
|
521 | + error_log('importexport_schedule: '.date('c').": File $target not readable! \n"); |
|
522 | + $data['errors'][$target][] = lang('%1 is not readable', $target); |
|
523 | 523 | } |
524 | 524 | } |
525 | 525 | catch (Exception $i_ex) |
@@ -529,20 +529,20 @@ discard block |
||
529 | 529 | } |
530 | 530 | |
531 | 531 | |
532 | - if(method_exists($po, 'get_warnings') && $po->get_warnings()) |
|
532 | + if (method_exists($po, 'get_warnings') && $po->get_warnings()) |
|
533 | 533 | { |
534 | - $buffer = 'importexport_schedule: ' . date('c') . ": Import warnings:\n#\tWarning\n"; |
|
535 | - foreach($po->get_warnings() as $record => $msg) |
|
534 | + $buffer = 'importexport_schedule: '.date('c').": Import warnings:\n#\tWarning\n"; |
|
535 | + foreach ($po->get_warnings() as $record => $msg) |
|
536 | 536 | { |
537 | 537 | $data['warnings'][$target][] = "#$record: $msg"; |
538 | 538 | $buffer += "$record\t$msg\n"; |
539 | 539 | } |
540 | 540 | error_log($buffer); |
541 | 541 | } |
542 | - if(method_exists($po, 'get_errors') && $po->get_errors()) |
|
542 | + if (method_exists($po, 'get_errors') && $po->get_errors()) |
|
543 | 543 | { |
544 | - $buffer = 'importexport_schedule: ' . date('c') . ": Import errors:\n#\tError\n"; |
|
545 | - foreach($po->get_errors() as $record => $error) |
|
544 | + $buffer = 'importexport_schedule: '.date('c').": Import errors:\n#\tError\n"; |
|
545 | + foreach ($po->get_errors() as $record => $error) |
|
546 | 546 | { |
547 | 547 | $data['errors'][$target][] = "#$record: $error"; |
548 | 548 | $buffer += "$record\t$error\n"; |
@@ -550,22 +550,22 @@ discard block |
||
550 | 550 | error_log($buffer); |
551 | 551 | } |
552 | 552 | |
553 | - if($po instanceof importexport_iface_import_plugin) |
|
553 | + if ($po instanceof importexport_iface_import_plugin) |
|
554 | 554 | { |
555 | - if(is_numeric($result)) |
|
555 | + if (is_numeric($result)) |
|
556 | 556 | { |
557 | 557 | $data['record_count'] += $result; |
558 | 558 | $data['result'][$target][] = lang('%1 records processed', $result); |
559 | 559 | } |
560 | 560 | $data['result'][$target] = array(); |
561 | - foreach($po->get_results() as $action => $count) |
|
561 | + foreach ($po->get_results() as $action => $count) |
|
562 | 562 | { |
563 | - $data['result'][$target][] = lang($action) . ": $count"; |
|
563 | + $data['result'][$target][] = lang($action).": $count"; |
|
564 | 564 | } |
565 | 565 | } |
566 | 566 | else |
567 | 567 | { |
568 | - if($result instanceof importexport_iface_export_record) |
|
568 | + if ($result instanceof importexport_iface_export_record) |
|
569 | 569 | { |
570 | 570 | $data['record_count'] += $result->get_num_of_records(); |
571 | 571 | $data['result'][$target][] = lang('%1 records processed', $result->get_num_of_records()); |
@@ -574,23 +574,23 @@ discard block |
||
574 | 574 | } |
575 | 575 | |
576 | 576 | // Delete file? |
577 | - if($data['delete_files'] && $type == 'import' && !$data['errors']) |
|
577 | + if ($data['delete_files'] && $type == 'import' && !$data['errors']) |
|
578 | 578 | { |
579 | - foreach($targets as $target) |
|
579 | + foreach ($targets as $target) |
|
580 | 580 | { |
581 | - if(unlink($target)) |
|
581 | + if (unlink($target)) |
|
582 | 582 | { |
583 | - $data['result'][$target][] .= "\n..." . lang('deleted'); |
|
583 | + $data['result'][$target][] .= "\n...".lang('deleted'); |
|
584 | 584 | } |
585 | 585 | else |
586 | 586 | { |
587 | - $data['errors'][$target][] .= "\n..." . lang('Unable to delete'); |
|
587 | + $data['errors'][$target][] .= "\n...".lang('Unable to delete'); |
|
588 | 588 | } |
589 | 589 | } |
590 | 590 | } |
591 | 591 | |
592 | 592 | // Run time in minutes |
593 | - $data['run_time'] = round((time() - $data['last_run']) / 60,1); |
|
593 | + $data['run_time'] = round((time() - $data['last_run']) / 60, 1); |
|
594 | 594 | |
595 | 595 | // Clear lock |
596 | 596 | $data['lock'] = 0; |
@@ -601,9 +601,9 @@ discard block |
||
601 | 601 | $contents = ob_get_contents(); |
602 | 602 | |
603 | 603 | // Log to error log |
604 | - if($contents) |
|
604 | + if ($contents) |
|
605 | 605 | { |
606 | - error_log('importexport_schedule: ' . date('c') . ": \n".$contents); |
|
606 | + error_log('importexport_schedule: '.date('c').": \n".$contents); |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | ob_end_clean(); |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | $jobs = $async->read($id); |
621 | 621 | $job = $jobs[$id]; |
622 | 622 | |
623 | - if(is_array($job)) |
|
623 | + if (is_array($job)) |
|
624 | 624 | { |
625 | 625 | $async->cancel_timer($id); |
626 | 626 | $result = $async->set_timer( |
@@ -630,37 +630,37 @@ discard block |
||
630 | 630 | $data |
631 | 631 | ); |
632 | 632 | } |
633 | - if($no_notification) |
|
633 | + if ($no_notification) |
|
634 | 634 | { |
635 | 635 | return $result; |
636 | 636 | } |
637 | 637 | |
638 | 638 | // Send notification to user |
639 | - if($data['warnings'] || $data['errors']) |
|
639 | + if ($data['warnings'] || $data['errors']) |
|
640 | 640 | { |
641 | 641 | $notify = new notifications(); |
642 | 642 | $notify->set_sender($data['account_id']); |
643 | 643 | $notify->add_receiver($data['account_id']); |
644 | - $notify->set_subject(lang('Schedule import | export'). ' ' . lang('errors')); |
|
644 | + $notify->set_subject(lang('Schedule import | export').' '.lang('errors')); |
|
645 | 645 | $contents = ''; |
646 | 646 | |
647 | - if($data['warnings']) |
|
647 | + if ($data['warnings']) |
|
648 | 648 | { |
649 | - $contents .= lang($data['type']) . ' ' . lang('Warnings') . ' ' . Api\DateTime::to() . ':'; |
|
650 | - foreach($data['warnings'] as $target => $message) |
|
649 | + $contents .= lang($data['type']).' '.lang('Warnings').' '.Api\DateTime::to().':'; |
|
650 | + foreach ($data['warnings'] as $target => $message) |
|
651 | 651 | { |
652 | - $contents .= "\n". (is_numeric($target) ? '' : $target."\n"); |
|
653 | - $contents .= is_array($message) ? implode("\n",$message) : $message; |
|
652 | + $contents .= "\n".(is_numeric($target) ? '' : $target."\n"); |
|
653 | + $contents .= is_array($message) ? implode("\n", $message) : $message; |
|
654 | 654 | } |
655 | 655 | $contents .= "\n"; |
656 | 656 | } |
657 | - if($data['errors']) |
|
657 | + if ($data['errors']) |
|
658 | 658 | { |
659 | - $contents .= lang($data['type']) . ' ' . lang('Errors') . ' ' . Api\DateTime::to() . ':'; |
|
660 | - foreach($data['errors'] as $target => $errors) |
|
659 | + $contents .= lang($data['type']).' '.lang('Errors').' '.Api\DateTime::to().':'; |
|
660 | + foreach ($data['errors'] as $target => $errors) |
|
661 | 661 | { |
662 | - $contents .= "\n". (is_numeric($target) ? '' : $target."\n"); |
|
663 | - $contents .= is_array($errors) ? implode("\n",$errors) : $errors; |
|
662 | + $contents .= "\n".(is_numeric($target) ? '' : $target."\n"); |
|
663 | + $contents .= is_array($errors) ? implode("\n", $errors) : $errors; |
|
664 | 664 | } |
665 | 665 | $contents .= "\n"; |
666 | 666 | } |
@@ -113,7 +113,10 @@ discard block |
||
113 | 113 | // Remove any left blank |
114 | 114 | foreach($schedule as $key => &$value) |
115 | 115 | { |
116 | - if($value == '') unset($schedule[$key]); |
|
116 | + if($value == '') |
|
117 | + { |
|
118 | + unset($schedule[$key]); |
|
119 | + } |
|
117 | 120 | } |
118 | 121 | $result = $async->set_timer( |
119 | 122 | $schedule, |
@@ -283,14 +286,16 @@ discard block |
||
283 | 286 | * |
284 | 287 | * $data should contain target & type |
285 | 288 | */ |
286 | - public static function check_target(Array $data) { |
|
289 | + public static function check_target(Array $data) |
|
290 | + { |
|
287 | 291 | $scheme = parse_url($data['target'], PHP_URL_SCHEME); |
288 | 292 | if($scheme == '' || $scheme == 'file') |
289 | 293 | { |
290 | 294 | return 'Direct file access not allowed'; |
291 | 295 | } |
292 | 296 | |
293 | - if($scheme == Vfs::SCHEME && !in_array(Vfs::SCHEME, stream_get_wrappers())) { |
|
297 | + if($scheme == Vfs::SCHEME && !in_array(Vfs::SCHEME, stream_get_wrappers())) |
|
298 | + { |
|
294 | 299 | stream_wrapper_register(Vfs::SCHEME, 'vfs_stream_wrapper', STREAM_IS_URL); |
295 | 300 | } |
296 | 301 | |
@@ -315,8 +320,14 @@ discard block |
||
315 | 320 | // Response code has an integer key, but redirects may add more responses |
316 | 321 | for($i = 0; $i < count($headers); $i++) |
317 | 322 | { |
318 | - if(!$headers[$i]) break; |
|
319 | - if(strpos($headers[$i],'200') !== false) return true; |
|
323 | + if(!$headers[$i]) |
|
324 | + { |
|
325 | + break; |
|
326 | + } |
|
327 | + if(strpos($headers[$i],'200') !== false) |
|
328 | + { |
|
329 | + return true; |
|
330 | + } |
|
320 | 331 | } |
321 | 332 | return lang('%1 is not readable',$data['target']); |
322 | 333 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | /** |
199 | 199 | * Get options for select boxes |
200 | 200 | */ |
201 | - public static function get_select_options(Array $data) |
|
201 | + public static function get_select_options(array $data) |
|
202 | 202 | { |
203 | 203 | $options = array( |
204 | 204 | 'type' => array( |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * |
284 | 284 | * $data should contain target & type |
285 | 285 | */ |
286 | - public static function check_target(Array $data) { |
|
286 | + public static function check_target(array $data) { |
|
287 | 287 | $scheme = parse_url($data['target'], PHP_URL_SCHEME); |
288 | 288 | if($scheme == '' || $scheme == 'file') |
289 | 289 | { |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | const TEMPLATE_MARKER = '-eTemplate-'; |
24 | 24 | |
25 | 25 | /** |
26 | - * List of steps. Key is the function, value is the translated title. |
|
27 | - */ |
|
26 | + * List of steps. Key is the function, value is the translated title. |
|
27 | + */ |
|
28 | 28 | public $steps; |
29 | 29 | |
30 | 30 | /** |
31 | - * List of eTemplates to use for each step. You can override this with your own etemplates steps. |
|
32 | - */ |
|
31 | + * List of eTemplates to use for each step. You can override this with your own etemplates steps. |
|
32 | + */ |
|
33 | 33 | protected $step_templates = array( |
34 | 34 | 'wizard_step30' => 'importexport.wizard_basic_export_csv.choose_fields', |
35 | 35 | 'wizard_step40' => 'importexport.wizard_basic_export_csv.choosesepncharset', |
@@ -38,19 +38,19 @@ discard block |
||
38 | 38 | |
39 | 39 | |
40 | 40 | /** |
41 | - * Destination fields for the export |
|
42 | - * Key is the field name, value is the human version |
|
43 | - */ |
|
41 | + * Destination fields for the export |
|
42 | + * Key is the field name, value is the human version |
|
43 | + */ |
|
44 | 44 | protected $export_fields = array(); |
45 | 45 | |
46 | 46 | /** |
47 | - * List of conditions your plugin supports |
|
48 | - */ |
|
47 | + * List of conditions your plugin supports |
|
48 | + */ |
|
49 | 49 | protected $conditions = array(); |
50 | 50 | |
51 | 51 | /** |
52 | - * List of actions your plugin supports |
|
53 | - */ |
|
52 | + * List of actions your plugin supports |
|
53 | + */ |
|
54 | 54 | protected $actions = array(); |
55 | 55 | |
56 | 56 | /** |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | - * Choose fields to export |
|
73 | - */ |
|
72 | + * Choose fields to export |
|
73 | + */ |
|
74 | 74 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
75 | 75 | { |
76 | 76 | if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
@@ -206,16 +206,16 @@ discard block |
||
206 | 206 | ); |
207 | 207 | $sel_options['charset'] = Api\Translation::get_installed_charsets()+ |
208 | 208 | array( |
209 | - 'user' => lang('User preference'), |
|
210 | - ); |
|
209 | + 'user' => lang('User preference'), |
|
210 | + ); |
|
211 | 211 | |
212 | - // Add in extra allowed charsets |
|
213 | - $config = Api\Config::read('importexport'); |
|
214 | - $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings()); |
|
215 | - if($extra_charsets) |
|
216 | - { |
|
217 | - $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets)); |
|
218 | - } |
|
212 | + // Add in extra allowed charsets |
|
213 | + $config = Api\Config::read('importexport'); |
|
214 | + $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings()); |
|
215 | + if($extra_charsets) |
|
216 | + { |
|
217 | + $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets)); |
|
218 | + } |
|
219 | 219 | $sel_options['convert'] = array( |
220 | 220 | 0 => lang('Database values'), |
221 | 221 | 1 => lang('Human friendly values') |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | 'wizard_step80' => lang('Filters'), |
65 | 65 | ); |
66 | 66 | list($appname, $part2) = explode('_', get_class($this)); |
67 | - if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= '_'.$part2; // Handle apps with _ in the name |
|
67 | + if (!$GLOBALS['egw_info']['apps'][$appname]) $appname .= '_'.$part2; // Handle apps with _ in the name |
|
68 | 68 | Api\Translation::add_app($appname); |
69 | 69 | } |
70 | 70 | |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | */ |
74 | 74 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
75 | 75 | { |
76 | - if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
76 | + if ($this->debug) error_log(get_class($this).'::wizard_step30->$content '.print_r($content, true)); |
|
77 | 77 | // return from step30 |
78 | 78 | if ($content['step'] == 'wizard_step30') |
79 | 79 | { |
80 | - foreach($content['fields']['export'] as $field_name) |
|
80 | + foreach ($content['fields']['export'] as $field_name) |
|
81 | 81 | { |
82 | 82 | // Preserve original field names, where available |
83 | - if($content['plugin_options']['no_header_translation'] && $content['plugin_options']['mapping'][$field_name]) |
|
83 | + if ($content['plugin_options']['no_header_translation'] && $content['plugin_options']['mapping'][$field_name]) |
|
84 | 84 | { |
85 | 85 | $content['mapping'][$field_name] = $content['plugin_options']['mapping'][$field_name]; |
86 | 86 | } |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | $content['mapping'][$field_name] = $field_name; |
90 | 90 | } |
91 | 91 | } |
92 | - if($content['mapping']['all_custom_fields']) { |
|
92 | + if ($content['mapping']['all_custom_fields']) { |
|
93 | 93 | // Need the appname during actual export, to fetch the fields |
94 | 94 | $parts = explode('_', get_class($this)); |
95 | 95 | $appname = $parts[0]; |
96 | - foreach($parts as $name_part) { |
|
97 | - if($GLOBALS['egw_info']['apps'][$appname]) break; |
|
96 | + foreach ($parts as $name_part) { |
|
97 | + if ($GLOBALS['egw_info']['apps'][$appname]) break; |
|
98 | 98 | $appname .= '_'.$name_part; // Handle apps with _ in the name |
99 | 99 | } |
100 | 100 | $content['mapping']['all_custom_fields'] = $appname; |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | switch (array_search('pressed', $content['button'])) |
106 | 106 | { |
107 | 107 | case 'next': |
108 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
108 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
109 | 109 | case 'previous' : |
110 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
110 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
111 | 111 | case 'finish': |
112 | 112 | return 'wizard_finish'; |
113 | 113 | default : |
114 | - return $this->wizard_step30($content,$sel_options,$readonlys,$preserv); |
|
114 | + return $this->wizard_step30($content, $sel_options, $readonlys, $preserv); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | // init step30 |
@@ -125,15 +125,15 @@ discard block |
||
125 | 125 | unset ($preserv['button']); |
126 | 126 | unset ($preserv['fields']); |
127 | 127 | $content['fields'] = array(''); |
128 | - if(!$content['mapping']) $content['mapping'] = $content['plugin_options']['mapping']; |
|
128 | + if (!$content['mapping']) $content['mapping'] = $content['plugin_options']['mapping']; |
|
129 | 129 | |
130 | 130 | $row = 1; |
131 | - foreach($this->export_fields as $field => $name) { |
|
131 | + foreach ($this->export_fields as $field => $name) { |
|
132 | 132 | $content['fields'][] = array( |
133 | 133 | 'field' => $field, |
134 | 134 | 'name' => lang($name), |
135 | 135 | ); |
136 | - if($content['mapping'][$field]) { |
|
136 | + if ($content['mapping'][$field]) { |
|
137 | 137 | $content['fields']['export'][$row] = $field; |
138 | 138 | } |
139 | 139 | $row++; |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | */ |
156 | 156 | function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) |
157 | 157 | { |
158 | - if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
158 | + if ($this->debug) error_log(get_class($this).'::wizard_step40->$content '.print_r($content, true)); |
|
159 | 159 | // return from step40 |
160 | 160 | if ($content['step'] == 'wizard_step40') { |
161 | - if($content['begin_with_fieldnames'] == 'label') { |
|
162 | - foreach($content['mapping'] as $field => &$label) { |
|
161 | + if ($content['begin_with_fieldnames'] == 'label') { |
|
162 | + foreach ($content['mapping'] as $field => &$label) { |
|
163 | 163 | // Check first, to avoid clearing any pseudo-columns (ex: All custom fields) |
164 | 164 | $label = $this->export_fields[$field] ? $this->export_fields[$field] : $label; |
165 | 165 | } |
@@ -167,13 +167,13 @@ discard block |
||
167 | 167 | switch (array_search('pressed', $content['button'])) |
168 | 168 | { |
169 | 169 | case 'next': |
170 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
170 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
171 | 171 | case 'previous' : |
172 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
172 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
173 | 173 | case 'finish': |
174 | 174 | return 'wizard_finish'; |
175 | 175 | default : |
176 | - return $this->wizard_step40($content,$sel_options,$readonlys,$preserv); |
|
176 | + return $this->wizard_step40($content, $sel_options, $readonlys, $preserv); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | // init step40 |
@@ -183,18 +183,18 @@ discard block |
||
183 | 183 | $content['step'] = 'wizard_step40'; |
184 | 184 | |
185 | 185 | // If editing an existing definition, these will be in plugin_options |
186 | - if(!$content['delimiter'] && $content['plugin_options']['delimiter']) { |
|
186 | + if (!$content['delimiter'] && $content['plugin_options']['delimiter']) { |
|
187 | 187 | $content['delimiter'] = $content['plugin_options']['delimiter']; |
188 | 188 | } elseif (!$content['delimiter']) { |
189 | 189 | $content['delimiter'] = ';'; |
190 | 190 | } |
191 | - if(!$content['charset'] && $content['plugin_options']['charset']) { |
|
191 | + if (!$content['charset'] && $content['plugin_options']['charset']) { |
|
192 | 192 | $content['charset'] = $content['plugin_options']['charset'] ? $content['plugin_options']['charset'] : 'user'; |
193 | 193 | } |
194 | - if(!array_key_exists('begin_with_fieldnames', $content) && array_key_exists('begin_with_fieldnames', $content['plugin_options'])) { |
|
194 | + if (!array_key_exists('begin_with_fieldnames', $content) && array_key_exists('begin_with_fieldnames', $content['plugin_options'])) { |
|
195 | 195 | $content['begin_with_fieldnames'] = $content['plugin_options']['begin_with_fieldnames']; |
196 | 196 | } |
197 | - if(!array_key_exists('convert', $content) && array_key_exists('convert', $content['plugin_options'])) { |
|
197 | + if (!array_key_exists('convert', $content) && array_key_exists('convert', $content['plugin_options'])) { |
|
198 | 198 | $content['convert'] = $content['plugin_options']['convert']; |
199 | 199 | } |
200 | 200 | |
@@ -204,17 +204,17 @@ discard block |
||
204 | 204 | 1 => lang('Field names'), |
205 | 205 | 'label' => lang('Field labels') |
206 | 206 | ); |
207 | - $sel_options['charset'] = Api\Translation::get_installed_charsets()+ |
|
207 | + $sel_options['charset'] = Api\Translation::get_installed_charsets() + |
|
208 | 208 | array( |
209 | 209 | 'user' => lang('User preference'), |
210 | 210 | ); |
211 | 211 | |
212 | 212 | // Add in extra allowed charsets |
213 | 213 | $config = Api\Config::read('importexport'); |
214 | - $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings()); |
|
215 | - if($extra_charsets) |
|
214 | + $extra_charsets = array_intersect(explode(',', $config['import_charsets']), mb_list_encodings()); |
|
215 | + if ($extra_charsets) |
|
216 | 216 | { |
217 | - $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets)); |
|
217 | + $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets, $extra_charsets)); |
|
218 | 218 | } |
219 | 219 | $sel_options['convert'] = array( |
220 | 220 | 0 => lang('Database values'), |
@@ -238,15 +238,15 @@ discard block |
||
238 | 238 | */ |
239 | 239 | function wizard_step80(&$content, &$sel_options, &$readonlys, &$preserv) |
240 | 240 | { |
241 | - if($this->debug) error_log(get_class($this) . '::' . __METHOD__ .'->$content '.print_r($content,true)); |
|
241 | + if ($this->debug) error_log(get_class($this).'::'.__METHOD__.'->$content '.print_r($content, true)); |
|
242 | 242 | // return from submit |
243 | 243 | if ($content['step'] == 'wizard_step80') { |
244 | 244 | // Process submitted |
245 | 245 | unset($content['filter']); |
246 | 246 | unset($content['set_filter']['fields']); |
247 | - foreach($content['set_filter'] as $key => $value) |
|
247 | + foreach ($content['set_filter'] as $key => $value) |
|
248 | 248 | { |
249 | - if($value) { |
|
249 | + if ($value) { |
|
250 | 250 | $content['filter'][$key] = $value; |
251 | 251 | } |
252 | 252 | } |
@@ -256,13 +256,13 @@ discard block |
||
256 | 256 | switch (array_search('pressed', $content['button'])) |
257 | 257 | { |
258 | 258 | case 'next': |
259 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
259 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
260 | 260 | case 'previous' : |
261 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
261 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
262 | 262 | case 'finish': |
263 | 263 | return 'wizard_finish'; |
264 | 264 | default : |
265 | - return $this->wizard_step80($content,$sel_options,$readonlys,$preserv); |
|
265 | + return $this->wizard_step80($content, $sel_options, $readonlys, $preserv); |
|
266 | 266 | } |
267 | 267 | } else { |
268 | 268 | |
@@ -273,15 +273,15 @@ discard block |
||
273 | 273 | unset ($preserv['button']); |
274 | 274 | |
275 | 275 | $content['set_filter']['fields'] = importexport_helper_functions::get_filter_fields( |
276 | - $content['application'],$content['plugin'],$this |
|
276 | + $content['application'], $content['plugin'], $this |
|
277 | 277 | ); |
278 | 278 | // Load existing filter from either content or definition |
279 | - foreach($content['set_filter']['fields'] as $field => $settings) |
|
279 | + foreach ($content['set_filter']['fields'] as $field => $settings) |
|
280 | 280 | { |
281 | 281 | $content['set_filter'][$field] = $content['filter'][$field]; |
282 | 282 | } |
283 | 283 | |
284 | - if(!$content['set_filter']['fields']) |
|
284 | + if (!$content['set_filter']['fields']) |
|
285 | 285 | { |
286 | 286 | // No fields |
287 | 287 | return importexport_definitions_ui::SKIP; |
@@ -64,7 +64,11 @@ discard block |
||
64 | 64 | 'wizard_step80' => lang('Filters'), |
65 | 65 | ); |
66 | 66 | list($appname, $part2) = explode('_', get_class($this)); |
67 | - if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= '_'.$part2; // Handle apps with _ in the name |
|
67 | + if(!$GLOBALS['egw_info']['apps'][$appname]) |
|
68 | + { |
|
69 | + $appname .= '_'.$part2; |
|
70 | + } |
|
71 | + // Handle apps with _ in the name |
|
68 | 72 | Api\Translation::add_app($appname); |
69 | 73 | } |
70 | 74 | |
@@ -73,7 +77,10 @@ discard block |
||
73 | 77 | */ |
74 | 78 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
75 | 79 | { |
76 | - if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
80 | + if($this->debug) |
|
81 | + { |
|
82 | + error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
83 | + } |
|
77 | 84 | // return from step30 |
78 | 85 | if ($content['step'] == 'wizard_step30') |
79 | 86 | { |
@@ -89,12 +96,17 @@ discard block |
||
89 | 96 | $content['mapping'][$field_name] = $field_name; |
90 | 97 | } |
91 | 98 | } |
92 | - if($content['mapping']['all_custom_fields']) { |
|
99 | + if($content['mapping']['all_custom_fields']) |
|
100 | + { |
|
93 | 101 | // Need the appname during actual export, to fetch the fields |
94 | 102 | $parts = explode('_', get_class($this)); |
95 | 103 | $appname = $parts[0]; |
96 | - foreach($parts as $name_part) { |
|
97 | - if($GLOBALS['egw_info']['apps'][$appname]) break; |
|
104 | + foreach($parts as $name_part) |
|
105 | + { |
|
106 | + if($GLOBALS['egw_info']['apps'][$appname]) |
|
107 | + { |
|
108 | + break; |
|
109 | + } |
|
98 | 110 | $appname .= '_'.$name_part; // Handle apps with _ in the name |
99 | 111 | } |
100 | 112 | $content['mapping']['all_custom_fields'] = $appname; |
@@ -125,15 +137,20 @@ discard block |
||
125 | 137 | unset ($preserv['button']); |
126 | 138 | unset ($preserv['fields']); |
127 | 139 | $content['fields'] = array(''); |
128 | - if(!$content['mapping']) $content['mapping'] = $content['plugin_options']['mapping']; |
|
140 | + if(!$content['mapping']) |
|
141 | + { |
|
142 | + $content['mapping'] = $content['plugin_options']['mapping']; |
|
143 | + } |
|
129 | 144 | |
130 | 145 | $row = 1; |
131 | - foreach($this->export_fields as $field => $name) { |
|
146 | + foreach($this->export_fields as $field => $name) |
|
147 | + { |
|
132 | 148 | $content['fields'][] = array( |
133 | 149 | 'field' => $field, |
134 | 150 | 'name' => lang($name), |
135 | 151 | ); |
136 | - if($content['mapping'][$field]) { |
|
152 | + if($content['mapping'][$field]) |
|
153 | + { |
|
137 | 154 | $content['fields']['export'][$row] = $field; |
138 | 155 | } |
139 | 156 | $row++; |
@@ -155,11 +172,17 @@ discard block |
||
155 | 172 | */ |
156 | 173 | function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) |
157 | 174 | { |
158 | - if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
175 | + if($this->debug) |
|
176 | + { |
|
177 | + error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
178 | + } |
|
159 | 179 | // return from step40 |
160 | - if ($content['step'] == 'wizard_step40') { |
|
161 | - if($content['begin_with_fieldnames'] == 'label') { |
|
162 | - foreach($content['mapping'] as $field => &$label) { |
|
180 | + if ($content['step'] == 'wizard_step40') |
|
181 | + { |
|
182 | + if($content['begin_with_fieldnames'] == 'label') |
|
183 | + { |
|
184 | + foreach($content['mapping'] as $field => &$label) |
|
185 | + { |
|
163 | 186 | // Check first, to avoid clearing any pseudo-columns (ex: All custom fields) |
164 | 187 | $label = $this->export_fields[$field] ? $this->export_fields[$field] : $label; |
165 | 188 | } |
@@ -183,18 +206,24 @@ discard block |
||
183 | 206 | $content['step'] = 'wizard_step40'; |
184 | 207 | |
185 | 208 | // If editing an existing definition, these will be in plugin_options |
186 | - if(!$content['delimiter'] && $content['plugin_options']['delimiter']) { |
|
209 | + if(!$content['delimiter'] && $content['plugin_options']['delimiter']) |
|
210 | + { |
|
187 | 211 | $content['delimiter'] = $content['plugin_options']['delimiter']; |
188 | - } elseif (!$content['delimiter']) { |
|
212 | + } |
|
213 | + elseif (!$content['delimiter']) |
|
214 | + { |
|
189 | 215 | $content['delimiter'] = ';'; |
190 | 216 | } |
191 | - if(!$content['charset'] && $content['plugin_options']['charset']) { |
|
217 | + if(!$content['charset'] && $content['plugin_options']['charset']) |
|
218 | + { |
|
192 | 219 | $content['charset'] = $content['plugin_options']['charset'] ? $content['plugin_options']['charset'] : 'user'; |
193 | 220 | } |
194 | - if(!array_key_exists('begin_with_fieldnames', $content) && array_key_exists('begin_with_fieldnames', $content['plugin_options'])) { |
|
221 | + if(!array_key_exists('begin_with_fieldnames', $content) && array_key_exists('begin_with_fieldnames', $content['plugin_options'])) |
|
222 | + { |
|
195 | 223 | $content['begin_with_fieldnames'] = $content['plugin_options']['begin_with_fieldnames']; |
196 | 224 | } |
197 | - if(!array_key_exists('convert', $content) && array_key_exists('convert', $content['plugin_options'])) { |
|
225 | + if(!array_key_exists('convert', $content) && array_key_exists('convert', $content['plugin_options'])) |
|
226 | + { |
|
198 | 227 | $content['convert'] = $content['plugin_options']['convert']; |
199 | 228 | } |
200 | 229 | |
@@ -238,15 +267,20 @@ discard block |
||
238 | 267 | */ |
239 | 268 | function wizard_step80(&$content, &$sel_options, &$readonlys, &$preserv) |
240 | 269 | { |
241 | - if($this->debug) error_log(get_class($this) . '::' . __METHOD__ .'->$content '.print_r($content,true)); |
|
270 | + if($this->debug) |
|
271 | + { |
|
272 | + error_log(get_class($this) . '::' . __METHOD__ .'->$content '.print_r($content,true)); |
|
273 | + } |
|
242 | 274 | // return from submit |
243 | - if ($content['step'] == 'wizard_step80') { |
|
275 | + if ($content['step'] == 'wizard_step80') |
|
276 | + { |
|
244 | 277 | // Process submitted |
245 | 278 | unset($content['filter']); |
246 | 279 | unset($content['set_filter']['fields']); |
247 | 280 | foreach($content['set_filter'] as $key => $value) |
248 | 281 | { |
249 | - if($value) { |
|
282 | + if($value) |
|
283 | + { |
|
250 | 284 | $content['filter'][$key] = $value; |
251 | 285 | } |
252 | 286 | } |
@@ -264,7 +298,9 @@ discard block |
||
264 | 298 | default : |
265 | 299 | return $this->wizard_step80($content,$sel_options,$readonlys,$preserv); |
266 | 300 | } |
267 | - } else { |
|
301 | + } |
|
302 | + else |
|
303 | + { |
|
268 | 304 | |
269 | 305 | // Step 50 - filters |
270 | 306 | $content['text'] = $this->steps['wizard_step80']; |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | const TEMPLATE_MARKER = '-eTemplate-'; |
24 | 24 | |
25 | 25 | /** |
26 | - * List of steps. Key is the function, value is the translated title. |
|
27 | - */ |
|
26 | + * List of steps. Key is the function, value is the translated title. |
|
27 | + */ |
|
28 | 28 | public $steps; |
29 | 29 | |
30 | 30 | /** |
31 | - * List of eTemplates to use for each step. You can override this with your own etemplates steps. |
|
32 | - */ |
|
31 | + * List of eTemplates to use for each step. You can override this with your own etemplates steps. |
|
32 | + */ |
|
33 | 33 | protected $step_templates = array( |
34 | 34 | 'wizard_step30' => 'importexport.wizard_basic_import_csv.sample_file', |
35 | 35 | 'wizard_step40' => 'importexport.wizard_basic_import_csv.choosesepncharset', |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
42 | - * Destination fields for the mapping |
|
43 | - * Key is the field name, value is the human version |
|
44 | - */ |
|
42 | + * Destination fields for the mapping |
|
43 | + * Key is the field name, value is the human version |
|
44 | + */ |
|
45 | 45 | protected $mapping_fields = array(); |
46 | 46 | |
47 | 47 | /** |
48 | - * List of conditions your plugin supports |
|
49 | - */ |
|
48 | + * List of conditions your plugin supports |
|
49 | + */ |
|
50 | 50 | protected $conditions = array(); |
51 | 51 | |
52 | 52 | /** |
53 | - * List of actions your plugin supports |
|
54 | - */ |
|
53 | + * List of actions your plugin supports |
|
54 | + */ |
|
55 | 55 | protected $actions = array(); |
56 | 56 | |
57 | 57 | /** |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | - * Take a sample CSV file. It will be processed in later steps |
|
72 | - */ |
|
71 | + * Take a sample CSV file. It will be processed in later steps |
|
72 | + */ |
|
73 | 73 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
74 | 74 | { |
75 | 75 | if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
266 | - * Process the sample file, get the fields out of it, then allow them to be mapped onto |
|
267 | - * the fields the destination understands. Also, set any translations to be done to the field. |
|
268 | - * |
|
269 | - * You can use the eTemplate |
|
270 | - */ |
|
266 | + * Process the sample file, get the fields out of it, then allow them to be mapped onto |
|
267 | + * the fields the destination understands. Also, set any translations to be done to the field. |
|
268 | + * |
|
269 | + * You can use the eTemplate |
|
270 | + */ |
|
271 | 271 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
272 | 272 | { |
273 | 273 | if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
351 | - * Edit conditions |
|
352 | - */ |
|
351 | + * Edit conditions |
|
352 | + */ |
|
353 | 353 | function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv) |
354 | 354 | { |
355 | 355 | if($this->debug) error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
74 | 74 | { |
75 | - if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
75 | + if ($this->debug) error_log(get_class($this).'::wizard_step30->$content '.print_r($content, true)); |
|
76 | 76 | // return from step30 |
77 | 77 | if ($content['step'] == 'wizard_step30') |
78 | 78 | { |
@@ -80,17 +80,17 @@ discard block |
||
80 | 80 | { |
81 | 81 | case 'next': |
82 | 82 | // Move sample file to temp |
83 | - if($content['file']['tmp_name']) { |
|
84 | - $GLOBALS['egw']->session->appsession('csvfile',$content['application'],$content['file']['tmp_name']); |
|
83 | + if ($content['file']['tmp_name']) { |
|
84 | + $GLOBALS['egw']->session->appsession('csvfile', $content['application'], $content['file']['tmp_name']); |
|
85 | 85 | } |
86 | 86 | unset($content['file']); |
87 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
87 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
88 | 88 | case 'previous' : |
89 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
89 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
90 | 90 | case 'finish': |
91 | 91 | return 'wizard_finish'; |
92 | 92 | default : |
93 | - return $this->wizard_step30($content,$sel_options,$readonlys,$preserv); |
|
93 | + return $this->wizard_step30($content, $sel_options, $readonlys, $preserv); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | // init step30 |
@@ -117,57 +117,57 @@ discard block |
||
117 | 117 | */ |
118 | 118 | function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) |
119 | 119 | { |
120 | - if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
120 | + if ($this->debug) error_log(get_class($this).'::wizard_step40->$content '.print_r($content, true)); |
|
121 | 121 | // return from step40 |
122 | 122 | if ($content['step'] == 'wizard_step40') { |
123 | 123 | switch (array_search('pressed', $content['button'])) |
124 | 124 | { |
125 | 125 | case 'next': |
126 | 126 | // Process sample file for fields |
127 | - if (Api\Cache::getSession($content['application'],'csvfile') && |
|
128 | - ($handle = fopen(Api\Cache::getSession($content['application'],'csvfile'), "rb")) !== FALSE |
|
127 | + if (Api\Cache::getSession($content['application'], 'csvfile') && |
|
128 | + ($handle = fopen(Api\Cache::getSession($content['application'], 'csvfile'), "rb")) !== FALSE |
|
129 | 129 | ) { |
130 | 130 | $data = fgetcsv($handle, 8000, $content['fieldsep']); |
131 | 131 | //error_log(array2string($data)); |
132 | 132 | fclose($handle); |
133 | 133 | |
134 | 134 | // Remove & forget file |
135 | - unlink(Api\Cache::getSession($content['application'],'csvfile')); |
|
135 | + unlink(Api\Cache::getSession($content['application'], 'csvfile')); |
|
136 | 136 | Api\Cache::setSession($content['application'], 'csvfile', ''); |
137 | - $content['csv_fields'] = Api\Translation::convert($data,$content['charset']); |
|
137 | + $content['csv_fields'] = Api\Translation::convert($data, $content['charset']); |
|
138 | 138 | |
139 | 139 | // Reset field mapping for new file |
140 | 140 | $content['field_mapping'] = array(); |
141 | 141 | |
142 | 142 | // Try to match automatically |
143 | 143 | $english = array(); |
144 | - foreach($content['csv_fields'] as $index => $field) { |
|
145 | - if($content['field_mapping'][$index]) continue; |
|
144 | + foreach ($content['csv_fields'] as $index => $field) { |
|
145 | + if ($content['field_mapping'][$index]) continue; |
|
146 | 146 | $best_match = ''; |
147 | 147 | $best_match_value = 0; |
148 | - foreach($this->mapping_fields as $key => $field_name) { |
|
149 | - if(is_array($field_name)) continue; |
|
150 | - if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0) { |
|
148 | + foreach ($this->mapping_fields as $key => $field_name) { |
|
149 | + if (is_array($field_name)) continue; |
|
150 | + if (strcasecmp($field, $field_name) == 0 || strcasecmp($field, $key) == 0) { |
|
151 | 151 | $content['field_mapping'][$index] = $key; |
152 | 152 | continue 2; |
153 | 153 | } |
154 | 154 | // Check english also |
155 | - if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) { |
|
155 | + if ($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) { |
|
156 | 156 | $msg_id = Api\Translation::get_message_id($field_name, $content['application']); |
157 | 157 | } |
158 | - if($msg_id) { |
|
158 | + if ($msg_id) { |
|
159 | 159 | $english[$field_name] = Api\Translation::read('en', $content['application'], $msg_id); |
160 | 160 | } else { |
161 | 161 | $english[$field_name] = false; |
162 | 162 | } |
163 | - if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) { |
|
163 | + if ($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) { |
|
164 | 164 | $content['field_mapping'][$index] = $key; |
165 | 165 | continue 2; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // Check for similar but slightly different |
169 | 169 | $match = 0; |
170 | - if(similar_text(strtolower($field), strtolower($field_name), $match) && |
|
170 | + if (similar_text(strtolower($field), strtolower($field_name), $match) && |
|
171 | 171 | $match > 85 && |
172 | 172 | $match > $best_match_value |
173 | 173 | ) { |
@@ -176,20 +176,20 @@ discard block |
||
176 | 176 | } |
177 | 177 | |
178 | 178 | } |
179 | - if($best_match) { |
|
179 | + if ($best_match) { |
|
180 | 180 | $content['field_mapping'][$index] = $best_match; |
181 | 181 | } |
182 | 182 | } |
183 | - } elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields']) { |
|
183 | + } elseif (!$content['csv_fields'] && $content['plugin_options']['csv_fields']) { |
|
184 | 184 | $content['csv_fields'] = $content['plugin_options']['csv_fields']; |
185 | 185 | } |
186 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
186 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
187 | 187 | case 'previous' : |
188 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
188 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
189 | 189 | case 'finish': |
190 | 190 | return 'wizard_finish'; |
191 | 191 | default : |
192 | - return $this->wizard_step40($content,$sel_options,$readonlys,$preserv); |
|
192 | + return $this->wizard_step40($content, $sel_options, $readonlys, $preserv); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | // init step40 |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | $content['step'] = 'wizard_step40'; |
200 | 200 | |
201 | 201 | // If editing an existing definition, these will be in plugin_options |
202 | - if(!$content['fieldsep'] && $content['plugin_options']['fieldsep']) { |
|
202 | + if (!$content['fieldsep'] && $content['plugin_options']['fieldsep']) { |
|
203 | 203 | $content['fieldsep'] = $content['plugin_options']['fieldsep']; |
204 | 204 | } elseif (!$content['fieldsep']) { |
205 | 205 | $content['fieldsep'] = ';'; |
206 | 206 | } |
207 | - if(!$content['charset'] && $content['plugin_options']['charset']) { |
|
207 | + if (!$content['charset'] && $content['plugin_options']['charset']) { |
|
208 | 208 | $content['charset'] = $content['plugin_options']['charset']; |
209 | 209 | } |
210 | - if(!array_key_exists('num_header_lines', $content)) |
|
210 | + if (!array_key_exists('num_header_lines', $content)) |
|
211 | 211 | { |
212 | - if(is_array($content['plugin_options']) && array_key_exists('num_header_lines', $content['plugin_options'])) |
|
212 | + if (is_array($content['plugin_options']) && array_key_exists('num_header_lines', $content['plugin_options'])) |
|
213 | 213 | { |
214 | 214 | $content['num_header_lines'] = $content['plugin_options']['num_header_lines']; |
215 | 215 | } |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | $content['num_header_lines'] = 1; |
220 | 220 | } |
221 | 221 | } |
222 | - if(!$content['update_cats'] && $content['plugin_options']['update_cats']) { |
|
222 | + if (!$content['update_cats'] && $content['plugin_options']['update_cats']) { |
|
223 | 223 | $content['update_cats'] = $content['plugin_options']['update_cats']; |
224 | 224 | } |
225 | - if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) { |
|
225 | + if (!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) { |
|
226 | 226 | $content['convert'] = $content['plugin_options']['convert']; |
227 | 227 | } |
228 | 228 | else |
@@ -231,24 +231,24 @@ discard block |
||
231 | 231 | $content['convert'] = 1; |
232 | 232 | } |
233 | 233 | |
234 | - $sel_options['charset'] = Api\Translation::get_installed_charsets()+ |
|
234 | + $sel_options['charset'] = Api\Translation::get_installed_charsets() + |
|
235 | 235 | array( |
236 | 236 | 'user' => lang('User preference'), |
237 | 237 | ); |
238 | 238 | |
239 | 239 | // Add in extra allowed charsets |
240 | 240 | $config = Api\Config::read('importexport'); |
241 | - $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings()); |
|
242 | - if($extra_charsets) |
|
241 | + $extra_charsets = array_intersect(explode(',', $config['import_charsets']), mb_list_encodings()); |
|
242 | + if ($extra_charsets) |
|
243 | 243 | { |
244 | - $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets)); |
|
244 | + $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets, $extra_charsets)); |
|
245 | 245 | } |
246 | 246 | $sel_options['convert'] = array( |
247 | 247 | 0 => lang('Database values'), |
248 | 248 | 1 => lang('Human friendly values') |
249 | 249 | ); |
250 | 250 | $preserv = $content; |
251 | - if($this->mapping_fields['cat_id']) { |
|
251 | + if ($this->mapping_fields['cat_id']) { |
|
252 | 252 | $sel_options['update_cats'] = array( |
253 | 253 | 'add' => lang('Add'), |
254 | 254 | 'replace'=> lang('Replace') |
@@ -270,18 +270,18 @@ discard block |
||
270 | 270 | */ |
271 | 271 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
272 | 272 | { |
273 | - if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
273 | + if ($this->debug) error_log(get_class($this).'::wizard_step50->$content '.print_r($content, true)); |
|
274 | 274 | // return from step50 |
275 | 275 | if ($content['step'] == 'wizard_step50') |
276 | 276 | { |
277 | 277 | unset($content['field_mapping']); |
278 | 278 | unset($content['field_conversion']); |
279 | - foreach($content['mapping'] as $field) |
|
279 | + foreach ($content['mapping'] as $field) |
|
280 | 280 | { |
281 | 281 | $index = $field['index']; |
282 | - foreach(array('conversion'=>'field_conversion', 'field' => 'field_mapping') as $id => $dest) |
|
282 | + foreach (array('conversion'=>'field_conversion', 'field' => 'field_mapping') as $id => $dest) |
|
283 | 283 | { |
284 | - if(trim($field[$id]) != '' && $field[$id] !== '--NONE--') |
|
284 | + if (trim($field[$id]) != '' && $field[$id] !== '--NONE--') |
|
285 | 285 | { |
286 | 286 | $content[$dest][$index] = trim($field[$id]); |
287 | 287 | } |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | switch (array_search('pressed', $content['button'])) |
292 | 292 | { |
293 | 293 | case 'next': |
294 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
294 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
295 | 295 | case 'previous' : |
296 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
296 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
297 | 297 | case 'finish': |
298 | 298 | return 'wizard_finish'; |
299 | 299 | default : |
300 | - return $this->wizard_step50($content,$sel_options,$readonlys,$preserv); |
|
300 | + return $this->wizard_step50($content, $sel_options, $readonlys, $preserv); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | // init step50 |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | $content['step'] = 'wizard_step50'; |
308 | 308 | |
309 | 309 | $content['mapping'] = array(false); |
310 | - if(array_key_exists('field_mapping', $content)) |
|
310 | + if (array_key_exists('field_mapping', $content)) |
|
311 | 311 | { |
312 | 312 | $field = $content['field_mapping']; |
313 | 313 | $conversion = $content['field_conversion']; |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | $conversion = $content['plugin_options']['field_conversion']; |
319 | 319 | } |
320 | 320 | $empties = 1; |
321 | - foreach($content['csv_fields'] as $index => $title) |
|
321 | + foreach ($content['csv_fields'] as $index => $title) |
|
322 | 322 | { |
323 | 323 | $content['mapping'][] = array( |
324 | 324 | 'index' => $index, |
@@ -326,15 +326,15 @@ discard block |
||
326 | 326 | 'field' => $field[$index], |
327 | 327 | 'conversion' => $conversion[$index] |
328 | 328 | ); |
329 | - if(strstr($title,lang('Extra %1'))) $empties++; |
|
329 | + if (strstr($title, lang('Extra %1'))) $empties++; |
|
330 | 330 | } |
331 | - while($empties <= 3) |
|
331 | + while ($empties <= 3) |
|
332 | 332 | { |
333 | 333 | $content['mapping'][] = array( |
334 | 334 | 'index' => $index + $empties, |
335 | 335 | 'title' => lang('Extra %1', $empties), |
336 | - 'field' => $field[$index+$empties], |
|
337 | - 'conversion' => $conversion[$index+$empties] |
|
336 | + 'field' => $field[$index + $empties], |
|
337 | + 'conversion' => $conversion[$index + $empties] |
|
338 | 338 | ); |
339 | 339 | $empties++; |
340 | 340 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | */ |
353 | 353 | function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv) |
354 | 354 | { |
355 | - if($this->debug) error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
|
355 | + if ($this->debug) error_log(get_class($this).'::wizard_step55->$content '.print_r($content, true)); |
|
356 | 356 | |
357 | 357 | // return from step55 |
358 | 358 | if ($content['step'] == 'wizard_step55') |
@@ -360,8 +360,8 @@ discard block |
||
360 | 360 | |
361 | 361 | // Clear conditions that don't do anything |
362 | 362 | array_shift($content['conditions']); |
363 | - foreach($content['conditions'] as $key => &$condition) { |
|
364 | - if(($condition['true']['action'] == 'none' || !$condition['true']['action']) |
|
363 | + foreach ($content['conditions'] as $key => &$condition) { |
|
364 | + if (($condition['true']['action'] == 'none' || !$condition['true']['action']) |
|
365 | 365 | && ($condition['false']['action'] == 'none' || !$condition['false']['action']) && |
366 | 366 | !$condition['string'] |
367 | 367 | ) { |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | } |
371 | 371 | |
372 | 372 | // Check for true without false, or false without true - set to 'none' |
373 | - elseif($condition['true']['action'] == '' && $condition['false']['action'] != '' || |
|
373 | + elseif ($condition['true']['action'] == '' && $condition['false']['action'] != '' || |
|
374 | 374 | $condition['true']['action'] != '' && $condition['false']['action'] == '' || |
375 | 375 | !$condition['true'] || !$condition['false'] |
376 | 376 | ) |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | switch (array_search('pressed', $content['button'])) |
383 | 383 | { |
384 | 384 | case 'next': |
385 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
385 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
386 | 386 | case 'previous' : |
387 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
387 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
388 | 388 | case 'finish': |
389 | 389 | return 'wizard_finish'; |
390 | 390 | case 'add': |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | $content['conditions'][] = array('string' => ''); |
394 | 394 | return 'wizard_step55'; |
395 | 395 | default : |
396 | - return $this->wizard_step55($content,$sel_options,$readonlys,$preserv); |
|
396 | + return $this->wizard_step55($content, $sel_options, $readonlys, $preserv); |
|
397 | 397 | break; |
398 | 398 | } |
399 | 399 | } |
@@ -401,18 +401,18 @@ discard block |
||
401 | 401 | $content['text'] = $this->steps['wizard_step55']; |
402 | 402 | $content['step'] = 'wizard_step55'; |
403 | 403 | |
404 | - if(!$content['conditions'] && $content['plugin_options']['conditions']) { |
|
404 | + if (!$content['conditions'] && $content['plugin_options']['conditions']) { |
|
405 | 405 | $content['conditions'] = $content['plugin_options']['conditions']; |
406 | 406 | } |
407 | 407 | $preserv = $content; |
408 | 408 | |
409 | - foreach($content['field_mapping'] as $field) { |
|
409 | + foreach ($content['field_mapping'] as $field) { |
|
410 | 410 | $sel_options['string'][$field] = $this->mapping_fields[$field]; |
411 | - if(!$sel_options['string'][$field]) |
|
411 | + if (!$sel_options['string'][$field]) |
|
412 | 412 | { |
413 | - foreach($this->mapping_fields as $fields) |
|
413 | + foreach ($this->mapping_fields as $fields) |
|
414 | 414 | { |
415 | - if(is_array($fields) && $fields[$field]) |
|
415 | + if (is_array($fields) && $fields[$field]) |
|
416 | 416 | { |
417 | 417 | $sel_options['string'][$field] = $fields[$field]; |
418 | 418 | } |
@@ -72,7 +72,10 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
74 | 74 | { |
75 | - if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
75 | + if($this->debug) |
|
76 | + { |
|
77 | + error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
78 | + } |
|
76 | 79 | // return from step30 |
77 | 80 | if ($content['step'] == 'wizard_step30') |
78 | 81 | { |
@@ -80,7 +83,8 @@ discard block |
||
80 | 83 | { |
81 | 84 | case 'next': |
82 | 85 | // Move sample file to temp |
83 | - if($content['file']['tmp_name']) { |
|
86 | + if($content['file']['tmp_name']) |
|
87 | + { |
|
84 | 88 | $GLOBALS['egw']->session->appsession('csvfile',$content['application'],$content['file']['tmp_name']); |
85 | 89 | } |
86 | 90 | unset($content['file']); |
@@ -117,9 +121,13 @@ discard block |
||
117 | 121 | */ |
118 | 122 | function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) |
119 | 123 | { |
120 | - if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
124 | + if($this->debug) |
|
125 | + { |
|
126 | + error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
127 | + } |
|
121 | 128 | // return from step40 |
122 | - if ($content['step'] == 'wizard_step40') { |
|
129 | + if ($content['step'] == 'wizard_step40') |
|
130 | + { |
|
123 | 131 | switch (array_search('pressed', $content['button'])) |
124 | 132 | { |
125 | 133 | case 'next': |
@@ -141,26 +149,40 @@ discard block |
||
141 | 149 | |
142 | 150 | // Try to match automatically |
143 | 151 | $english = array(); |
144 | - foreach($content['csv_fields'] as $index => $field) { |
|
145 | - if($content['field_mapping'][$index]) continue; |
|
152 | + foreach($content['csv_fields'] as $index => $field) |
|
153 | + { |
|
154 | + if($content['field_mapping'][$index]) |
|
155 | + { |
|
156 | + continue; |
|
157 | + } |
|
146 | 158 | $best_match = ''; |
147 | 159 | $best_match_value = 0; |
148 | - foreach($this->mapping_fields as $key => $field_name) { |
|
149 | - if(is_array($field_name)) continue; |
|
150 | - if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0) { |
|
160 | + foreach($this->mapping_fields as $key => $field_name) |
|
161 | + { |
|
162 | + if(is_array($field_name)) |
|
163 | + { |
|
164 | + continue; |
|
165 | + } |
|
166 | + if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0) |
|
167 | + { |
|
151 | 168 | $content['field_mapping'][$index] = $key; |
152 | 169 | continue 2; |
153 | 170 | } |
154 | 171 | // Check english also |
155 | - if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) { |
|
172 | + if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) |
|
173 | + { |
|
156 | 174 | $msg_id = Api\Translation::get_message_id($field_name, $content['application']); |
157 | 175 | } |
158 | - if($msg_id) { |
|
176 | + if($msg_id) |
|
177 | + { |
|
159 | 178 | $english[$field_name] = Api\Translation::read('en', $content['application'], $msg_id); |
160 | - } else { |
|
179 | + } |
|
180 | + else |
|
181 | + { |
|
161 | 182 | $english[$field_name] = false; |
162 | 183 | } |
163 | - if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) { |
|
184 | + if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) |
|
185 | + { |
|
164 | 186 | $content['field_mapping'][$index] = $key; |
165 | 187 | continue 2; |
166 | 188 | } |
@@ -176,11 +198,14 @@ discard block |
||
176 | 198 | } |
177 | 199 | |
178 | 200 | } |
179 | - if($best_match) { |
|
201 | + if($best_match) |
|
202 | + { |
|
180 | 203 | $content['field_mapping'][$index] = $best_match; |
181 | 204 | } |
182 | 205 | } |
183 | - } elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields']) { |
|
206 | + } |
|
207 | + elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields']) |
|
208 | + { |
|
184 | 209 | $content['csv_fields'] = $content['plugin_options']['csv_fields']; |
185 | 210 | } |
186 | 211 | return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
@@ -199,12 +224,16 @@ discard block |
||
199 | 224 | $content['step'] = 'wizard_step40'; |
200 | 225 | |
201 | 226 | // If editing an existing definition, these will be in plugin_options |
202 | - if(!$content['fieldsep'] && $content['plugin_options']['fieldsep']) { |
|
227 | + if(!$content['fieldsep'] && $content['plugin_options']['fieldsep']) |
|
228 | + { |
|
203 | 229 | $content['fieldsep'] = $content['plugin_options']['fieldsep']; |
204 | - } elseif (!$content['fieldsep']) { |
|
230 | + } |
|
231 | + elseif (!$content['fieldsep']) |
|
232 | + { |
|
205 | 233 | $content['fieldsep'] = ';'; |
206 | 234 | } |
207 | - if(!$content['charset'] && $content['plugin_options']['charset']) { |
|
235 | + if(!$content['charset'] && $content['plugin_options']['charset']) |
|
236 | + { |
|
208 | 237 | $content['charset'] = $content['plugin_options']['charset']; |
209 | 238 | } |
210 | 239 | if(!array_key_exists('num_header_lines', $content)) |
@@ -219,10 +248,12 @@ discard block |
||
219 | 248 | $content['num_header_lines'] = 1; |
220 | 249 | } |
221 | 250 | } |
222 | - if(!$content['update_cats'] && $content['plugin_options']['update_cats']) { |
|
251 | + if(!$content['update_cats'] && $content['plugin_options']['update_cats']) |
|
252 | + { |
|
223 | 253 | $content['update_cats'] = $content['plugin_options']['update_cats']; |
224 | 254 | } |
225 | - if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) { |
|
255 | + if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) |
|
256 | + { |
|
226 | 257 | $content['convert'] = $content['plugin_options']['convert']; |
227 | 258 | } |
228 | 259 | else |
@@ -248,12 +279,15 @@ discard block |
||
248 | 279 | 1 => lang('Human friendly values') |
249 | 280 | ); |
250 | 281 | $preserv = $content; |
251 | - if($this->mapping_fields['cat_id']) { |
|
282 | + if($this->mapping_fields['cat_id']) |
|
283 | + { |
|
252 | 284 | $sel_options['update_cats'] = array( |
253 | 285 | 'add' => lang('Add'), |
254 | 286 | 'replace'=> lang('Replace') |
255 | 287 | ); |
256 | - } else { |
|
288 | + } |
|
289 | + else |
|
290 | + { |
|
257 | 291 | $content['no_cats'] = true; |
258 | 292 | } |
259 | 293 | unset ($preserv['button']); |
@@ -270,7 +304,10 @@ discard block |
||
270 | 304 | */ |
271 | 305 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
272 | 306 | { |
273 | - if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
307 | + if($this->debug) |
|
308 | + { |
|
309 | + error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
310 | + } |
|
274 | 311 | // return from step50 |
275 | 312 | if ($content['step'] == 'wizard_step50') |
276 | 313 | { |
@@ -326,7 +363,10 @@ discard block |
||
326 | 363 | 'field' => $field[$index], |
327 | 364 | 'conversion' => $conversion[$index] |
328 | 365 | ); |
329 | - if(strstr($title,lang('Extra %1'))) $empties++; |
|
366 | + if(strstr($title,lang('Extra %1'))) |
|
367 | + { |
|
368 | + $empties++; |
|
369 | + } |
|
330 | 370 | } |
331 | 371 | while($empties <= 3) |
332 | 372 | { |
@@ -352,7 +392,10 @@ discard block |
||
352 | 392 | */ |
353 | 393 | function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv) |
354 | 394 | { |
355 | - if($this->debug) error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
|
395 | + if($this->debug) |
|
396 | + { |
|
397 | + error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
|
398 | + } |
|
356 | 399 | |
357 | 400 | // return from step55 |
358 | 401 | if ($content['step'] == 'wizard_step55') |
@@ -360,7 +403,8 @@ discard block |
||
360 | 403 | |
361 | 404 | // Clear conditions that don't do anything |
362 | 405 | array_shift($content['conditions']); |
363 | - foreach($content['conditions'] as $key => &$condition) { |
|
406 | + foreach($content['conditions'] as $key => &$condition) |
|
407 | + { |
|
364 | 408 | if(($condition['true']['action'] == 'none' || !$condition['true']['action']) |
365 | 409 | && ($condition['false']['action'] == 'none' || !$condition['false']['action']) && |
366 | 410 | !$condition['string'] |
@@ -373,8 +417,7 @@ discard block |
||
373 | 417 | elseif($condition['true']['action'] == '' && $condition['false']['action'] != '' || |
374 | 418 | $condition['true']['action'] != '' && $condition['false']['action'] == '' || |
375 | 419 | !$condition['true'] || !$condition['false'] |
376 | - ) |
|
377 | - { |
|
420 | + ) { |
|
378 | 421 | $condition[$condition['true']['action'] == '' ? 'true' : 'false']['action'] = "none"; |
379 | 422 | } |
380 | 423 | } |
@@ -401,12 +444,14 @@ discard block |
||
401 | 444 | $content['text'] = $this->steps['wizard_step55']; |
402 | 445 | $content['step'] = 'wizard_step55'; |
403 | 446 | |
404 | - if(!$content['conditions'] && $content['plugin_options']['conditions']) { |
|
447 | + if(!$content['conditions'] && $content['plugin_options']['conditions']) |
|
448 | + { |
|
405 | 449 | $content['conditions'] = $content['plugin_options']['conditions']; |
406 | 450 | } |
407 | 451 | $preserv = $content; |
408 | 452 | |
409 | - foreach($content['field_mapping'] as $field) { |
|
453 | + foreach($content['field_mapping'] as $field) |
|
454 | + { |
|
410 | 455 | $sel_options['string'][$field] = $this->mapping_fields[$field]; |
411 | 456 | if(!$sel_options['string'][$field]) |
412 | 457 | { |
@@ -36,47 +36,47 @@ discard block |
||
36 | 36 | private $export_plugins; |
37 | 37 | |
38 | 38 | public function __construct() { |
39 | - Framework::includeJS('.','export_dialog','importexport'); |
|
40 | - Framework::includeJS('.','importexport','importexport'); |
|
39 | + Framework::includeJS('.', 'export_dialog', 'importexport'); |
|
40 | + Framework::includeJS('.', 'importexport', 'importexport'); |
|
41 | 41 | $this->user = $GLOBALS['egw_info']['user']['user_id']; |
42 | - $this->export_plugins = importexport_helper_functions::get_plugins('all','export'); |
|
42 | + $this->export_plugins = importexport_helper_functions::get_plugins('all', 'export'); |
|
43 | 43 | $GLOBALS['egw_info']['flags']['include_xajax'] = true; |
44 | 44 | |
45 | 45 | } |
46 | 46 | |
47 | - public function export_dialog($_content=array()) { |
|
47 | + public function export_dialog($_content = array()) { |
|
48 | 48 | $tabs = 'general_tab|selection_tab|options_tab'; |
49 | 49 | $sel_options = array(); |
50 | 50 | $readonlys = array(); |
51 | 51 | $preserv = array(); |
52 | 52 | |
53 | - $et = new Etemplate(self::_appname. '.export_dialog'); |
|
53 | + $et = new Etemplate(self::_appname.'.export_dialog'); |
|
54 | 54 | $_appname = $_content['appname'] ? $_content['appname'] : $_GET['appname']; |
55 | 55 | $_definition = $_content['definition'] ? $_content['definition'] : $_GET['definition']; |
56 | 56 | $_plugin = $_content['plugin'] ? $_content['plugin'] : $_GET['plugin']; |
57 | 57 | // Select all from context menu, means use all search results, not just selected |
58 | - if($_GET['select_all'] == 'true') $_GET['selection'] = 'search'; |
|
58 | + if ($_GET['select_all'] == 'true') $_GET['selection'] = 'search'; |
|
59 | 59 | $_selection = $_content['selection'] ? $_content['selection'] : $_GET['selection']; |
60 | - if($_GET['selection'] || $_content['selection_passed']) $content['selection_passed'] = $preserv['selection_passed'] = true; |
|
60 | + if ($_GET['selection'] || $_content['selection_passed']) $content['selection_passed'] = $preserv['selection_passed'] = true; |
|
61 | 61 | |
62 | 62 | // Check global setting |
63 | - if(!Api\Storage\Merge::is_export_limit_excepted()) { |
|
63 | + if (!Api\Storage\Merge::is_export_limit_excepted()) { |
|
64 | 64 | $export_limit = Api\Storage\Merge::getExportLimit($_appname); |
65 | - if($export_limit == 'no') { |
|
65 | + if ($export_limit == 'no') { |
|
66 | 66 | die(lang('Admin disabled exporting')); |
67 | 67 | } |
68 | 68 | } |
69 | 69 | //error_log(__FILE__.__FUNCTION__. '::$_GET[\'appname\']='. $_appname. ',$_GET[\'definition\']='. $_definition. ',$_GET[\'plugin\']='.$_plugin. ',$_GET[\'selection\']='.$_selection); |
70 | 70 | // if appname is given and valid, list available definitions (if no definition is given) |
71 | - $readonlys['appname'] = (!empty($_appname) && $GLOBALS['egw']->acl->check('run',1,$_appname)); |
|
71 | + $readonlys['appname'] = (!empty($_appname) && $GLOBALS['egw']->acl->check('run', 1, $_appname)); |
|
72 | 72 | $content['appname'] = $_appname; |
73 | 73 | $preserv['appname'] = $_appname; |
74 | - if(empty($_appname)) { |
|
75 | - $et->setElementAttribute('select_definition','disabled',true); |
|
74 | + if (empty($_appname)) { |
|
75 | + $et->setElementAttribute('select_definition', 'disabled', true); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | // Check for preferred definition |
79 | - if(!$_definition && $_appname) { |
|
79 | + if (!$_definition && $_appname) { |
|
80 | 80 | $_definition = $GLOBALS['egw_info']['user']['preferences'][$_appname]['nextmatch-export-definition']; |
81 | 81 | } |
82 | 82 | // fill definitions |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | } |
99 | 99 | unset($definition); |
100 | 100 | } |
101 | - if(count($sel_options['definition']) == 2 && !$content['definition']) { |
|
101 | + if (count($sel_options['definition']) == 2 && !$content['definition']) { |
|
102 | 102 | $content['definition'] = end($sel_options['definition']); |
103 | 103 | } |
104 | 104 | unset($definitions); |
105 | 105 | //$sel_options['definition']['expert'] = lang('Expert options'); |
106 | 106 | |
107 | - if(isset($_definition) && array_key_exists($_definition,$sel_options['definition'])) { |
|
107 | + if (isset($_definition) && array_key_exists($_definition, $sel_options['definition'])) { |
|
108 | 108 | $content['definition'] = $_definition; |
109 | 109 | } |
110 | 110 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | $sel_options['plugin'] = $this->export_plugins[$_appname]['export']; |
113 | 113 | |
114 | 114 | // show definitions or plugins in ui? |
115 | - if($content['definition'] == 'expert') { |
|
116 | - if(isset($_plugin) && array_key_exists($_plugin,$sel_options['plugin'])) { |
|
115 | + if ($content['definition'] == 'expert') { |
|
116 | + if (isset($_plugin) && array_key_exists($_plugin, $sel_options['plugin'])) { |
|
117 | 117 | $content['plugin'] = $_plugin; |
118 | 118 | $selected_plugin = $_plugin; |
119 | 119 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $readonlys['save_definition'] = true; |
132 | 132 | |
133 | 133 | $definition = new importexport_definition($content['definition']); |
134 | - if($definition) { |
|
134 | + if ($definition) { |
|
135 | 135 | $content += (array)$definition->plugin_options; |
136 | 136 | $selected_plugin = $definition->plugin; |
137 | 137 | $content['description'] = $definition->description; |
@@ -148,27 +148,27 @@ discard block |
||
148 | 148 | '|' => '|', |
149 | 149 | '' => lang('Other') |
150 | 150 | ); |
151 | - if(!$sel_options['delimiter'][$content['delimiter']]) $sel_options['delimiter'][$content['delimiter']] = $content['delimiter']; |
|
152 | - $sel_options['delimiter'][$content['delimiter']] = lang('Use default') . ' "' . $sel_options['delimiter'][$content['delimiter']] . '"'; |
|
151 | + if (!$sel_options['delimiter'][$content['delimiter']]) $sel_options['delimiter'][$content['delimiter']] = $content['delimiter']; |
|
152 | + $sel_options['delimiter'][$content['delimiter']] = lang('Use default').' "'.$sel_options['delimiter'][$content['delimiter']].'"'; |
|
153 | 153 | |
154 | - if(!$_content['delimiter']) $et->setElementAttribute('other_delimiter','disabled',true); |
|
154 | + if (!$_content['delimiter']) $et->setElementAttribute('other_delimiter', 'disabled', true); |
|
155 | 155 | |
156 | 156 | // Other delimiter (options) |
157 | - if($_content['other_delimiter']) $_content['delimiter'] = $_content['other_delimiter']; |
|
157 | + if ($_content['other_delimiter']) $_content['delimiter'] = $_content['other_delimiter']; |
|
158 | 158 | |
159 | 159 | // handle selector |
160 | - if($selected_plugin) { |
|
160 | + if ($selected_plugin) { |
|
161 | 161 | $content['plugin'] = $selected_plugin; |
162 | 162 | $plugin_object = new $selected_plugin; |
163 | 163 | |
164 | 164 | $content['description'] = $plugin_object->get_description(); |
165 | 165 | |
166 | 166 | // fill options tab |
167 | - if(method_exists($plugin_object, 'get_selectors_html')) { |
|
167 | + if (method_exists($plugin_object, 'get_selectors_html')) { |
|
168 | 168 | $content['plugin_options_html'] = $plugin_object->get_options_html(); |
169 | 169 | } else { |
170 | 170 | $options = $plugin_object->get_options_etpl($definition); |
171 | - if(is_array($options)) { |
|
171 | + if (is_array($options)) { |
|
172 | 172 | $content['plugin_options_template'] = $options['name']; |
173 | 173 | $content += (array)$options['content']; |
174 | 174 | $sel_options += (array)$options['sel_options']; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | // fill selection tab |
184 | - if($definition && is_array($definition->plugin_options) && $definition->plugin_options['selection'] && !$content['selection_passed']) { |
|
184 | + if ($definition && is_array($definition->plugin_options) && $definition->plugin_options['selection'] && !$content['selection_passed']) { |
|
185 | 185 | $_selection = $definition->plugin_options['selection']; |
186 | 186 | } |
187 | 187 | |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | $preserv['selection'] = $_selection; |
192 | 192 | } |
193 | 193 | elseif ($plugin_object) { |
194 | - if(method_exists($plugin_object, 'get_selectors_html')) { |
|
194 | + if (method_exists($plugin_object, 'get_selectors_html')) { |
|
195 | 195 | $content['plugin_selectors_html'] = $plugin_object->get_selectors_html(); |
196 | 196 | } else { |
197 | 197 | $options = $plugin_object->get_selectors_etpl($definition); |
198 | - if(is_array($options)) { |
|
198 | + if (is_array($options)) { |
|
199 | 199 | $content += is_array($options['content']) ? $options['content'] : array('selection' => $options['content']); |
200 | 200 | $sel_options += (array)$options['sel_options']; |
201 | 201 | $readonlys['selection'] = (array)$options['readonlys']; |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | $content['plugin_selectors_template'] = $options; |
206 | 206 | } |
207 | 207 | } |
208 | - if(!$content['plugin_selectors_html'] && !$content['plugin_selectors_template']) { |
|
208 | + if (!$content['plugin_selectors_html'] && !$content['plugin_selectors_template']) { |
|
209 | 209 | $readonlys[$tabs]['selection_tab'] = true; |
210 | 210 | } |
211 | 211 | $content['filter'] = $definition->filter; |
212 | 212 | $content['filter']['fields'] = importexport_helper_functions::get_filter_fields($_appname, $selected_plugin); |
213 | - if(!$content['filter']['fields']) |
|
213 | + if (!$content['filter']['fields']) |
|
214 | 214 | { |
215 | 215 | $content['no_filter'] = true; |
216 | 216 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | { |
229 | 229 | $content['selection'] = 'filter'; |
230 | 230 | } |
231 | - if(!$content['selection']) |
|
231 | + if (!$content['selection']) |
|
232 | 232 | { |
233 | 233 | $content['selection'] = 'search'; |
234 | 234 | } |
@@ -239,33 +239,33 @@ discard block |
||
239 | 239 | //error_log(__METHOD__.__LINE__.array2string($apps)); |
240 | 240 | if (empty($apps)) throw new Exception('Error: no application profiles available for export'); |
241 | 241 | if (!is_array($apps) && $apps) $apps = (array)$apps; |
242 | - $sel_options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps); |
|
243 | - if(!$_application && !$selected_plugin) { |
|
242 | + $sel_options['appname'] = array('' => lang('Select one')) + array_combine($apps, $apps); |
|
243 | + if (!$_application && !$selected_plugin) { |
|
244 | 244 | $content['plugin_selectors_html'] = $content['plugin_options_html'] = |
245 | 245 | lang('You need to select an app and format first!'); |
246 | 246 | $readonlys[$tabs] = array('selection_tab' => true, 'options_tab' => true); |
247 | 247 | } |
248 | 248 | |
249 | - if($_content['preview'] || $_content['export']) |
|
249 | + if ($_content['preview'] || $_content['export']) |
|
250 | 250 | { |
251 | 251 | //error_log(__LINE__.__FILE__.'$_content: '.print_r($_content,true)); |
252 | 252 | $response = Api\Json\Response::get(); |
253 | 253 | |
254 | 254 | if ($_content['definition'] == 'expert') { |
255 | 255 | $definition = new importexport_definition(); |
256 | - $definition->definition_id = $_content['definition_id'] ? $_content['definition_id'] : ''; |
|
256 | + $definition->definition_id = $_content['definition_id'] ? $_content['definition_id'] : ''; |
|
257 | 257 | $definition->name = $_content['name'] ? $_content['name'] : ''; |
258 | - $definition->application = $_content['appname']; |
|
259 | - $definition->plugin = $_content['plugin']; |
|
258 | + $definition->application = $_content['appname']; |
|
259 | + $definition->plugin = $_content['plugin']; |
|
260 | 260 | $definition->type = 'export'; |
261 | - $definition->allowed_users = $_content['allowed_users'] ? $_content['allowed_users'] : $this->user; |
|
262 | - $definition->owner = $_content['owner'] ? $_content['owner'] : $this->user; |
|
261 | + $definition->allowed_users = $_content['allowed_users'] ? $_content['allowed_users'] : $this->user; |
|
262 | + $definition->owner = $_content['owner'] ? $_content['owner'] : $this->user; |
|
263 | 263 | } |
264 | 264 | else { |
265 | 265 | $definition = new importexport_definition($_content['definition']); |
266 | 266 | } |
267 | 267 | |
268 | - if(!is_array($definition->plugin_options)) { |
|
268 | + if (!is_array($definition->plugin_options)) { |
|
269 | 269 | $definition->plugin_options = array( |
270 | 270 | 'mapping' => array() |
271 | 271 | ); |
@@ -275,30 +275,30 @@ discard block |
||
275 | 275 | // Note that because not all dates are DB dates, the plugin has to handle them |
276 | 276 | $filter = array(); |
277 | 277 | $_content['filter'] = $_content['filter_html'] ? $_content['filter_html'] : $_content['filter_tpl']; |
278 | - if(is_array($_content['filter'])) |
|
278 | + if (is_array($_content['filter'])) |
|
279 | 279 | { |
280 | - foreach($_content['filter'] as $key => $value) |
|
280 | + foreach ($_content['filter'] as $key => $value) |
|
281 | 281 | { |
282 | 282 | // Handle multiple values |
283 | - if(!is_array($value) && strpos($value,',') !== false) $value = explode(',',$value); |
|
283 | + if (!is_array($value) && strpos($value, ',') !== false) $value = explode(',', $value); |
|
284 | 284 | |
285 | 285 | $filter[$key] = $value; |
286 | 286 | |
287 | 287 | // Skip empty values or empty ranges |
288 | - if($value == "" || is_null($value) || (is_array($value) && count($value) == 0) || is_array($value) && array_key_exists('from',$value) && !$value['from'] && !$value['to'] ) |
|
288 | + if ($value == "" || is_null($value) || (is_array($value) && count($value) == 0) || is_array($value) && array_key_exists('from', $value) && !$value['from'] && !$value['to']) |
|
289 | 289 | { |
290 | 290 | unset($filter[$key]); |
291 | 291 | } |
292 | - if(is_array($value) && array_key_exists('from', $value) && $value['from']) |
|
292 | + if (is_array($value) && array_key_exists('from', $value) && $value['from']) |
|
293 | 293 | { |
294 | - $filter[$key]['from'] = Api\DateTime::to($value['from'],'ts'); |
|
294 | + $filter[$key]['from'] = Api\DateTime::to($value['from'], 'ts'); |
|
295 | 295 | } |
296 | 296 | // If user selects an end date, they most likely want entries including that date |
297 | - if(is_array($value) && array_key_exists('to',$value) && $value['to'] ) |
|
297 | + if (is_array($value) && array_key_exists('to', $value) && $value['to']) |
|
298 | 298 | { |
299 | 299 | // Adjust time to 23:59:59 |
300 | 300 | $filter[$key]['to'] = new Api\DateTime($value['to']); |
301 | - $filter[$key]['to']->setTime(23,59,59); |
|
301 | + $filter[$key]['to']->setTime(23, 59, 59); |
|
302 | 302 | $filter[$key]['to'] = $filter[$key]['to']->format('ts'); |
303 | 303 | } |
304 | 304 | } |
@@ -312,19 +312,19 @@ discard block |
||
312 | 312 | $_content |
313 | 313 | ); |
314 | 314 | |
315 | - if(!$definition->plugin_options['selection']) { |
|
316 | - $response->alert( lang('No records selected')); |
|
315 | + if (!$definition->plugin_options['selection']) { |
|
316 | + $response->alert(lang('No records selected')); |
|
317 | 317 | return; |
318 | 318 | } |
319 | 319 | |
320 | - $tmpfname = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'export'); |
|
320 | + $tmpfname = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'export'); |
|
321 | 321 | $file = fopen($tmpfname, "w+"); |
322 | - if (! $charset = $definition->plugin_options['charset']) { |
|
322 | + if (!$charset = $definition->plugin_options['charset']) { |
|
323 | 323 | $charset = Api\Translation::charset(); |
324 | 324 | } |
325 | - if($charset == 'user') |
|
325 | + if ($charset == 'user') |
|
326 | 326 | { |
327 | - switch($definition->plugin) |
|
327 | + switch ($definition->plugin) |
|
328 | 328 | { |
329 | 329 | case 'addressbook_export_vcard': |
330 | 330 | $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; |
@@ -334,9 +334,9 @@ discard block |
||
334 | 334 | } |
335 | 335 | } |
336 | 336 | $plugin_object = new $definition->plugin; |
337 | - $result = $plugin_object->export( $file, $definition ); |
|
337 | + $result = $plugin_object->export($file, $definition); |
|
338 | 338 | |
339 | - if(is_object($result) && method_exists($result, 'get_num_of_records')) |
|
339 | + if (is_object($result) && method_exists($result, 'get_num_of_records')) |
|
340 | 340 | { |
341 | 341 | $record_count = $result->get_num_of_records(); |
342 | 342 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | // Store charset to use in header |
345 | 345 | Api\Cache::setSession('importexport', $tmpfname, $charset, 100); |
346 | 346 | |
347 | - if($_content['export'] == 'pressed') { |
|
347 | + if ($_content['export'] == 'pressed') { |
|
348 | 348 | fclose($file); |
349 | 349 | $filename = pathinfo($tmpfname, PATHINFO_FILENAME); |
350 | 350 | $link_query = array( |
@@ -356,25 +356,25 @@ discard block |
||
356 | 356 | ); |
357 | 357 | |
358 | 358 | // Allow plugins to suggest a file name - return false if they have no suggestion |
359 | - if(method_exists($plugin_object, 'get_filename') && $plugin_filename = $plugin_object->get_filename()) |
|
359 | + if (method_exists($plugin_object, 'get_filename') && $plugin_filename = $plugin_object->get_filename()) |
|
360 | 360 | { |
361 | 361 | $link_query['filename'] = $plugin_filename; |
362 | 362 | } |
363 | - $response->redirect( $GLOBALS['egw']->link('/index.php',$link_query),true); |
|
363 | + $response->redirect($GLOBALS['egw']->link('/index.php', $link_query), true); |
|
364 | 364 | Framework::window_close(); |
365 | 365 | return; |
366 | 366 | } |
367 | - elseif($_content['preview'] == 'pressed') { |
|
367 | + elseif ($_content['preview'] == 'pressed') { |
|
368 | 368 | fseek($file, 0); |
369 | 369 | $item_count = 1; |
370 | 370 | $preview = ''; |
371 | - $search = array('[\016]','[\017]', |
|
372 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
373 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
371 | + $search = array('[\016]', '[\017]', |
|
372 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
373 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
374 | 374 | $replace = $preview = ''; |
375 | 375 | |
376 | - while(!feof($file) && $item_count < 30) { |
|
377 | - $preview .= preg_replace($search,$replace,fgets($file,1024)); |
|
376 | + while (!feof($file) && $item_count < 30) { |
|
377 | + $preview .= preg_replace($search, $replace, fgets($file, 1024)); |
|
378 | 378 | $item_count++; |
379 | 379 | } |
380 | 380 | |
@@ -382,12 +382,12 @@ discard block |
||
382 | 382 | unlink($tmpfname); |
383 | 383 | |
384 | 384 | // Convert back to system charset for display |
385 | - $preview = Api\Translation::convert( $preview, |
|
385 | + $preview = Api\Translation::convert($preview, |
|
386 | 386 | $charset, |
387 | 387 | Api\Translation::charset() |
388 | 388 | ); |
389 | 389 | |
390 | - $preview = "<div class='header'>".lang('Preview') . "<span class='count'>".(int)$record_count."</span></div>".$preview; |
|
390 | + $preview = "<div class='header'>".lang('Preview')."<span class='count'>".(int)$record_count."</span></div>".$preview; |
|
391 | 391 | |
392 | 392 | $et->setElementAttribute('preview-box', 'value', nl2br($preview)); |
393 | 393 | return; |
@@ -399,17 +399,17 @@ discard block |
||
399 | 399 | $readonlys[$tabs]['selection'] = false; |
400 | 400 | } |
401 | 401 | //error_log(print_r($content,true)); |
402 | - return $et->exec(self::_appname. '.importexport_export_ui.export_dialog',$content,$sel_options,$readonlys,$preserv,2); |
|
402 | + return $et->exec(self::_appname.'.importexport_export_ui.export_dialog', $content, $sel_options, $readonlys, $preserv, 2); |
|
403 | 403 | } |
404 | 404 | |
405 | - public function ajax_get_definitions($_appname, xajaxResponse &$response = null) { |
|
406 | - if(is_null($response)) { |
|
405 | + public function ajax_get_definitions($_appname, xajaxResponse&$response = null) { |
|
406 | + if (is_null($response)) { |
|
407 | 407 | $response = new xajaxResponse(); |
408 | 408 | } else { |
409 | 409 | $no_return = true; |
410 | 410 | } |
411 | 411 | if (!$_appname) { |
412 | - $response->jquery('tr.select_definition','hide'); |
|
412 | + $response->jquery('tr.select_definition', 'hide'); |
|
413 | 413 | return $no_return ? '' : $response->getXML(); |
414 | 414 | } |
415 | 415 | |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | unset($definition); |
432 | 432 | } |
433 | 433 | unset($definitions); |
434 | - $response->addScript("selectbox_add_option('exec[definition]','" . lang('Expert options') . "', 'expert',".($selected_plugin == $title ? 'true' : 'false').");"); |
|
434 | + $response->addScript("selectbox_add_option('exec[definition]','".lang('Expert options')."', 'expert',".($selected_plugin == $title ? 'true' : 'false').");"); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | public function ajax_get_definition_description($_definition) { |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | } |
447 | 447 | unset ($_object); |
448 | 448 | } |
449 | - $_response->assign('importexport-export_dialog_plugin_description','innerHTML',$description); |
|
449 | + $_response->assign('importexport-export_dialog_plugin_description', 'innerHTML', $description); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | public function ajax_get_plugin_description($_plugin) { |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | if (is_a($plugin_object, 'importexport_iface_export_plugin')) { |
457 | 457 | $description = $plugin_object->get_description(); |
458 | 458 | } |
459 | - $_response->addAssign('importexport-export_dialog_plugin_description','innerHTML',$description); |
|
459 | + $_response->addAssign('importexport-export_dialog_plugin_description', 'innerHTML', $description); |
|
460 | 460 | |
461 | 461 | unset ($plugin_object); |
462 | 462 | } |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | */ |
470 | 470 | public function download($_tmpfname = '') { |
471 | 471 | $tmpfname = $_tmpfname ? $_tmpfname : $_GET['_filename']; |
472 | - $tmpfname = $GLOBALS['egw_info']['server']['temp_dir'] .'/'. $tmpfname; |
|
472 | + $tmpfname = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpfname; |
|
473 | 473 | if (!is_readable($tmpfname)) die(); |
474 | 474 | |
475 | 475 | $appname = $_GET['_appname']; |
@@ -478,13 +478,13 @@ discard block |
||
478 | 478 | // Turn off all output buffering |
479 | 479 | while (@ob_end_clean()); |
480 | 480 | |
481 | - $file = fopen($tmpfname,'rb'); |
|
481 | + $file = fopen($tmpfname, 'rb'); |
|
482 | 482 | |
483 | 483 | // Get charset |
484 | 484 | $charset = Api\Cache::getSession('importexport', $tmpfname); |
485 | 485 | |
486 | 486 | Api\Header\Content::type($nicefname.'.'.$_GET['_suffix'], |
487 | - ($_GET['_type'] ? $_GET['_type'] : 'application/text') . ($charset ? '; charset='.$charset : ''), |
|
487 | + ($_GET['_type'] ? $_GET['_type'] : 'application/text').($charset ? '; charset='.$charset : ''), |
|
488 | 488 | filesize($tmpfname)); |
489 | 489 | fpassthru($file); |
490 | 490 |
@@ -18,7 +18,8 @@ discard block |
||
18 | 18 | * userinterface for exports |
19 | 19 | * |
20 | 20 | */ |
21 | -class importexport_export_ui { |
|
21 | +class importexport_export_ui |
|
22 | +{ |
|
22 | 23 | const _appname = 'importexport'; |
23 | 24 | |
24 | 25 | public $public_functions = array( |
@@ -35,7 +36,8 @@ discard block |
||
35 | 36 | */ |
36 | 37 | private $export_plugins; |
37 | 38 | |
38 | - public function __construct() { |
|
39 | + public function __construct() |
|
40 | + { |
|
39 | 41 | Framework::includeJS('.','export_dialog','importexport'); |
40 | 42 | Framework::includeJS('.','importexport','importexport'); |
41 | 43 | $this->user = $GLOBALS['egw_info']['user']['user_id']; |
@@ -44,7 +46,8 @@ discard block |
||
44 | 46 | |
45 | 47 | } |
46 | 48 | |
47 | - public function export_dialog($_content=array()) { |
|
49 | + public function export_dialog($_content=array()) |
|
50 | + { |
|
48 | 51 | $tabs = 'general_tab|selection_tab|options_tab'; |
49 | 52 | $sel_options = array(); |
50 | 53 | $readonlys = array(); |
@@ -55,14 +58,22 @@ discard block |
||
55 | 58 | $_definition = $_content['definition'] ? $_content['definition'] : $_GET['definition']; |
56 | 59 | $_plugin = $_content['plugin'] ? $_content['plugin'] : $_GET['plugin']; |
57 | 60 | // Select all from context menu, means use all search results, not just selected |
58 | - if($_GET['select_all'] == 'true') $_GET['selection'] = 'search'; |
|
61 | + if($_GET['select_all'] == 'true') |
|
62 | + { |
|
63 | + $_GET['selection'] = 'search'; |
|
64 | + } |
|
59 | 65 | $_selection = $_content['selection'] ? $_content['selection'] : $_GET['selection']; |
60 | - if($_GET['selection'] || $_content['selection_passed']) $content['selection_passed'] = $preserv['selection_passed'] = true; |
|
66 | + if($_GET['selection'] || $_content['selection_passed']) |
|
67 | + { |
|
68 | + $content['selection_passed'] = $preserv['selection_passed'] = true; |
|
69 | + } |
|
61 | 70 | |
62 | 71 | // Check global setting |
63 | - if(!Api\Storage\Merge::is_export_limit_excepted()) { |
|
72 | + if(!Api\Storage\Merge::is_export_limit_excepted()) |
|
73 | + { |
|
64 | 74 | $export_limit = Api\Storage\Merge::getExportLimit($_appname); |
65 | - if($export_limit == 'no') { |
|
75 | + if($export_limit == 'no') |
|
76 | + { |
|
66 | 77 | die(lang('Admin disabled exporting')); |
67 | 78 | } |
68 | 79 | } |
@@ -71,12 +82,14 @@ discard block |
||
71 | 82 | $readonlys['appname'] = (!empty($_appname) && $GLOBALS['egw']->acl->check('run',1,$_appname)); |
72 | 83 | $content['appname'] = $_appname; |
73 | 84 | $preserv['appname'] = $_appname; |
74 | - if(empty($_appname)) { |
|
85 | + if(empty($_appname)) |
|
86 | + { |
|
75 | 87 | $et->setElementAttribute('select_definition','disabled',true); |
76 | 88 | } |
77 | 89 | |
78 | 90 | // Check for preferred definition |
79 | - if(!$_definition && $_appname) { |
|
91 | + if(!$_definition && $_appname) |
|
92 | + { |
|
80 | 93 | $_definition = $GLOBALS['egw_info']['user']['preferences'][$_appname]['nextmatch-export-definition']; |
81 | 94 | } |
82 | 95 | // fill definitions |
@@ -86,25 +99,30 @@ discard block |
||
86 | 99 | 'application' => isset($content['appname']) ? $content['appname'] : '*', |
87 | 100 | 'plugin' => $_plugin ? $_plugin : '*' |
88 | 101 | )); |
89 | - foreach ((array)$definitions->get_definitions() as $identifier) { |
|
102 | + foreach ((array)$definitions->get_definitions() as $identifier) |
|
103 | + { |
|
90 | 104 | try { |
91 | 105 | $definition = new importexport_definition($identifier); |
92 | - } catch (Exception $e) { |
|
106 | + } |
|
107 | + catch (Exception $e) { |
|
93 | 108 | // permission error |
94 | 109 | continue; |
95 | 110 | } |
96 | - if ($title = $definition->get_title()) { |
|
111 | + if ($title = $definition->get_title()) |
|
112 | + { |
|
97 | 113 | $sel_options['definition'][$title] = $title; |
98 | 114 | } |
99 | 115 | unset($definition); |
100 | 116 | } |
101 | - if(count($sel_options['definition']) == 2 && !$content['definition']) { |
|
117 | + if(count($sel_options['definition']) == 2 && !$content['definition']) |
|
118 | + { |
|
102 | 119 | $content['definition'] = end($sel_options['definition']); |
103 | 120 | } |
104 | 121 | unset($definitions); |
105 | 122 | //$sel_options['definition']['expert'] = lang('Expert options'); |
106 | 123 | |
107 | - if(isset($_definition) && array_key_exists($_definition,$sel_options['definition'])) { |
|
124 | + if(isset($_definition) && array_key_exists($_definition,$sel_options['definition'])) |
|
125 | + { |
|
108 | 126 | $content['definition'] = $_definition; |
109 | 127 | } |
110 | 128 | |
@@ -112,8 +130,10 @@ discard block |
||
112 | 130 | $sel_options['plugin'] = $this->export_plugins[$_appname]['export']; |
113 | 131 | |
114 | 132 | // show definitions or plugins in ui? |
115 | - if($content['definition'] == 'expert') { |
|
116 | - if(isset($_plugin) && array_key_exists($_plugin,$sel_options['plugin'])) { |
|
133 | + if($content['definition'] == 'expert') |
|
134 | + { |
|
135 | + if(isset($_plugin) && array_key_exists($_plugin,$sel_options['plugin'])) |
|
136 | + { |
|
117 | 137 | $content['plugin'] = $_plugin; |
118 | 138 | $selected_plugin = $_plugin; |
119 | 139 | } |
@@ -126,12 +146,14 @@ discard block |
||
126 | 146 | */ |
127 | 147 | } |
128 | 148 | } |
129 | - else { |
|
149 | + else |
|
150 | + { |
|
130 | 151 | $readonlys['plugin'] = true; |
131 | 152 | $readonlys['save_definition'] = true; |
132 | 153 | |
133 | 154 | $definition = new importexport_definition($content['definition']); |
134 | - if($definition) { |
|
155 | + if($definition) |
|
156 | + { |
|
135 | 157 | $content += (array)$definition->plugin_options; |
136 | 158 | $selected_plugin = $definition->plugin; |
137 | 159 | $content['description'] = $definition->description; |
@@ -148,64 +170,90 @@ discard block |
||
148 | 170 | '|' => '|', |
149 | 171 | '' => lang('Other') |
150 | 172 | ); |
151 | - if(!$sel_options['delimiter'][$content['delimiter']]) $sel_options['delimiter'][$content['delimiter']] = $content['delimiter']; |
|
173 | + if(!$sel_options['delimiter'][$content['delimiter']]) |
|
174 | + { |
|
175 | + $sel_options['delimiter'][$content['delimiter']] = $content['delimiter']; |
|
176 | + } |
|
152 | 177 | $sel_options['delimiter'][$content['delimiter']] = lang('Use default') . ' "' . $sel_options['delimiter'][$content['delimiter']] . '"'; |
153 | 178 | |
154 | - if(!$_content['delimiter']) $et->setElementAttribute('other_delimiter','disabled',true); |
|
179 | + if(!$_content['delimiter']) |
|
180 | + { |
|
181 | + $et->setElementAttribute('other_delimiter','disabled',true); |
|
182 | + } |
|
155 | 183 | |
156 | 184 | // Other delimiter (options) |
157 | - if($_content['other_delimiter']) $_content['delimiter'] = $_content['other_delimiter']; |
|
185 | + if($_content['other_delimiter']) |
|
186 | + { |
|
187 | + $_content['delimiter'] = $_content['other_delimiter']; |
|
188 | + } |
|
158 | 189 | |
159 | 190 | // handle selector |
160 | - if($selected_plugin) { |
|
191 | + if($selected_plugin) |
|
192 | + { |
|
161 | 193 | $content['plugin'] = $selected_plugin; |
162 | 194 | $plugin_object = new $selected_plugin; |
163 | 195 | |
164 | 196 | $content['description'] = $plugin_object->get_description(); |
165 | 197 | |
166 | 198 | // fill options tab |
167 | - if(method_exists($plugin_object, 'get_selectors_html')) { |
|
199 | + if(method_exists($plugin_object, 'get_selectors_html')) |
|
200 | + { |
|
168 | 201 | $content['plugin_options_html'] = $plugin_object->get_options_html(); |
169 | - } else { |
|
202 | + } |
|
203 | + else |
|
204 | + { |
|
170 | 205 | $options = $plugin_object->get_options_etpl($definition); |
171 | - if(is_array($options)) { |
|
206 | + if(is_array($options)) |
|
207 | + { |
|
172 | 208 | $content['plugin_options_template'] = $options['name']; |
173 | 209 | $content += (array)$options['content']; |
174 | 210 | $sel_options += (array)$options['sel_options']; |
175 | 211 | $readonlys += (array)$options['readonlys']; |
176 | 212 | $preserv += (array)$options['preserv']; |
177 | - } else { |
|
213 | + } |
|
214 | + else |
|
215 | + { |
|
178 | 216 | $content['plugin_options_template'] = $options; |
179 | 217 | } |
180 | 218 | } |
181 | 219 | } |
182 | 220 | |
183 | 221 | // fill selection tab |
184 | - if($definition && is_array($definition->plugin_options) && $definition->plugin_options['selection'] && !$content['selection_passed']) { |
|
222 | + if($definition && is_array($definition->plugin_options) && $definition->plugin_options['selection'] && !$content['selection_passed']) |
|
223 | + { |
|
185 | 224 | $_selection = $definition->plugin_options['selection']; |
186 | 225 | } |
187 | 226 | |
188 | - if ($_selection && ($content['old_definition'] == $content['definition'] || $content['selection_passed'])) { |
|
227 | + if ($_selection && ($content['old_definition'] == $content['definition'] || $content['selection_passed'])) |
|
228 | + { |
|
189 | 229 | $readonlys[$tabs]['selection_tab'] = true; |
190 | 230 | $content['selection'] = $_selection; |
191 | 231 | $preserv['selection'] = $_selection; |
192 | 232 | } |
193 | - elseif ($plugin_object) { |
|
194 | - if(method_exists($plugin_object, 'get_selectors_html')) { |
|
233 | + elseif ($plugin_object) |
|
234 | + { |
|
235 | + if(method_exists($plugin_object, 'get_selectors_html')) |
|
236 | + { |
|
195 | 237 | $content['plugin_selectors_html'] = $plugin_object->get_selectors_html(); |
196 | - } else { |
|
238 | + } |
|
239 | + else |
|
240 | + { |
|
197 | 241 | $options = $plugin_object->get_selectors_etpl($definition); |
198 | - if(is_array($options)) { |
|
242 | + if(is_array($options)) |
|
243 | + { |
|
199 | 244 | $content += is_array($options['content']) ? $options['content'] : array('selection' => $options['content']); |
200 | 245 | $sel_options += (array)$options['sel_options']; |
201 | 246 | $readonlys['selection'] = (array)$options['readonlys']; |
202 | 247 | $preserv['selection'] = (array)$options['preserv']; |
203 | 248 | $content['plugin_selectors_template'] = $options['name']; |
204 | - } else { |
|
249 | + } |
|
250 | + else |
|
251 | + { |
|
205 | 252 | $content['plugin_selectors_template'] = $options; |
206 | 253 | } |
207 | 254 | } |
208 | - if(!$content['plugin_selectors_html'] && !$content['plugin_selectors_template']) { |
|
255 | + if(!$content['plugin_selectors_html'] && !$content['plugin_selectors_template']) |
|
256 | + { |
|
209 | 257 | $readonlys[$tabs]['selection_tab'] = true; |
210 | 258 | } |
211 | 259 | $content['filter'] = $definition->filter; |
@@ -237,10 +285,17 @@ discard block |
||
237 | 285 | unset ($plugin_object); |
238 | 286 | $apps = importexport_helper_functions::get_apps('export'); |
239 | 287 | //error_log(__METHOD__.__LINE__.array2string($apps)); |
240 | - if (empty($apps)) throw new Exception('Error: no application profiles available for export'); |
|
241 | - if (!is_array($apps) && $apps) $apps = (array)$apps; |
|
288 | + if (empty($apps)) |
|
289 | + { |
|
290 | + throw new Exception('Error: no application profiles available for export'); |
|
291 | + } |
|
292 | + if (!is_array($apps) && $apps) |
|
293 | + { |
|
294 | + $apps = (array)$apps; |
|
295 | + } |
|
242 | 296 | $sel_options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps); |
243 | - if(!$_application && !$selected_plugin) { |
|
297 | + if(!$_application && !$selected_plugin) |
|
298 | + { |
|
244 | 299 | $content['plugin_selectors_html'] = $content['plugin_options_html'] = |
245 | 300 | lang('You need to select an app and format first!'); |
246 | 301 | $readonlys[$tabs] = array('selection_tab' => true, 'options_tab' => true); |
@@ -251,7 +306,8 @@ discard block |
||
251 | 306 | //error_log(__LINE__.__FILE__.'$_content: '.print_r($_content,true)); |
252 | 307 | $response = Api\Json\Response::get(); |
253 | 308 | |
254 | - if ($_content['definition'] == 'expert') { |
|
309 | + if ($_content['definition'] == 'expert') |
|
310 | + { |
|
255 | 311 | $definition = new importexport_definition(); |
256 | 312 | $definition->definition_id = $_content['definition_id'] ? $_content['definition_id'] : ''; |
257 | 313 | $definition->name = $_content['name'] ? $_content['name'] : ''; |
@@ -261,11 +317,13 @@ discard block |
||
261 | 317 | $definition->allowed_users = $_content['allowed_users'] ? $_content['allowed_users'] : $this->user; |
262 | 318 | $definition->owner = $_content['owner'] ? $_content['owner'] : $this->user; |
263 | 319 | } |
264 | - else { |
|
320 | + else |
|
321 | + { |
|
265 | 322 | $definition = new importexport_definition($_content['definition']); |
266 | 323 | } |
267 | 324 | |
268 | - if(!is_array($definition->plugin_options)) { |
|
325 | + if(!is_array($definition->plugin_options)) |
|
326 | + { |
|
269 | 327 | $definition->plugin_options = array( |
270 | 328 | 'mapping' => array() |
271 | 329 | ); |
@@ -280,7 +338,10 @@ discard block |
||
280 | 338 | foreach($_content['filter'] as $key => $value) |
281 | 339 | { |
282 | 340 | // Handle multiple values |
283 | - if(!is_array($value) && strpos($value,',') !== false) $value = explode(',',$value); |
|
341 | + if(!is_array($value) && strpos($value,',') !== false) |
|
342 | + { |
|
343 | + $value = explode(',',$value); |
|
344 | + } |
|
284 | 345 | |
285 | 346 | $filter[$key] = $value; |
286 | 347 | |
@@ -312,14 +373,16 @@ discard block |
||
312 | 373 | $_content |
313 | 374 | ); |
314 | 375 | |
315 | - if(!$definition->plugin_options['selection']) { |
|
376 | + if(!$definition->plugin_options['selection']) |
|
377 | + { |
|
316 | 378 | $response->alert( lang('No records selected')); |
317 | 379 | return; |
318 | 380 | } |
319 | 381 | |
320 | 382 | $tmpfname = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'export'); |
321 | 383 | $file = fopen($tmpfname, "w+"); |
322 | - if (! $charset = $definition->plugin_options['charset']) { |
|
384 | + if (! $charset = $definition->plugin_options['charset']) |
|
385 | + { |
|
323 | 386 | $charset = Api\Translation::charset(); |
324 | 387 | } |
325 | 388 | if($charset == 'user') |
@@ -344,7 +407,8 @@ discard block |
||
344 | 407 | // Store charset to use in header |
345 | 408 | Api\Cache::setSession('importexport', $tmpfname, $charset, 100); |
346 | 409 | |
347 | - if($_content['export'] == 'pressed') { |
|
410 | + if($_content['export'] == 'pressed') |
|
411 | + { |
|
348 | 412 | fclose($file); |
349 | 413 | $filename = pathinfo($tmpfname, PATHINFO_FILENAME); |
350 | 414 | $link_query = array( |
@@ -364,7 +428,8 @@ discard block |
||
364 | 428 | Framework::window_close(); |
365 | 429 | return; |
366 | 430 | } |
367 | - elseif($_content['preview'] == 'pressed') { |
|
431 | + elseif($_content['preview'] == 'pressed') |
|
432 | + { |
|
368 | 433 | fseek($file, 0); |
369 | 434 | $item_count = 1; |
370 | 435 | $preview = ''; |
@@ -373,7 +438,8 @@ discard block |
||
373 | 438 | '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
374 | 439 | $replace = $preview = ''; |
375 | 440 | |
376 | - while(!feof($file) && $item_count < 30) { |
|
441 | + while(!feof($file) && $item_count < 30) |
|
442 | + { |
|
377 | 443 | $preview .= preg_replace($search,$replace,fgets($file,1024)); |
378 | 444 | $item_count++; |
379 | 445 | } |
@@ -394,7 +460,9 @@ discard block |
||
394 | 460 | } |
395 | 461 | //nothing else expected! |
396 | 462 | throw new Exception('Error: unexpected submit in export_dialog!'); |
397 | - } else { |
|
463 | + } |
|
464 | + else |
|
465 | + { |
|
398 | 466 | $readonlys[$tabs]['selection'] = true; |
399 | 467 | $readonlys[$tabs]['selection'] = false; |
400 | 468 | } |
@@ -402,13 +470,18 @@ discard block |
||
402 | 470 | return $et->exec(self::_appname. '.importexport_export_ui.export_dialog',$content,$sel_options,$readonlys,$preserv,2); |
403 | 471 | } |
404 | 472 | |
405 | - public function ajax_get_definitions($_appname, xajaxResponse &$response = null) { |
|
406 | - if(is_null($response)) { |
|
473 | + public function ajax_get_definitions($_appname, xajaxResponse &$response = null) |
|
474 | + { |
|
475 | + if(is_null($response)) |
|
476 | + { |
|
407 | 477 | $response = new xajaxResponse(); |
408 | - } else { |
|
478 | + } |
|
479 | + else |
|
480 | + { |
|
409 | 481 | $no_return = true; |
410 | 482 | } |
411 | - if (!$_appname) { |
|
483 | + if (!$_appname) |
|
484 | + { |
|
412 | 485 | $response->jquery('tr.select_definition','hide'); |
413 | 486 | return $no_return ? '' : $response->getXML(); |
414 | 487 | } |
@@ -417,15 +490,21 @@ discard block |
||
417 | 490 | 'type' => 'export', |
418 | 491 | 'application' => $_appname |
419 | 492 | )); |
420 | - foreach ((array)$definitions->get_definitions() as $identifier) { |
|
493 | + foreach ((array)$definitions->get_definitions() as $identifier) |
|
494 | + { |
|
421 | 495 | try { |
422 | 496 | $definition = new importexport_definition($identifier); |
423 | - } catch (Exception $e) { |
|
497 | + } |
|
498 | + catch (Exception $e) { |
|
424 | 499 | // Permission error |
425 | 500 | continue; |
426 | 501 | } |
427 | - if ($title = $definition->get_title()) { |
|
428 | - if (!$selected_plugin) $selected_plugin = $title; |
|
502 | + if ($title = $definition->get_title()) |
|
503 | + { |
|
504 | + if (!$selected_plugin) |
|
505 | + { |
|
506 | + $selected_plugin = $title; |
|
507 | + } |
|
429 | 508 | $response->addScript("selectbox_add_option('exec[definition]','$title', '$value',".($selected_plugin == $title ? 'true' : 'false').");"); |
430 | 509 | } |
431 | 510 | unset($definition); |
@@ -434,14 +513,16 @@ discard block |
||
434 | 513 | $response->addScript("selectbox_add_option('exec[definition]','" . lang('Expert options') . "', 'expert',".($selected_plugin == $title ? 'true' : 'false').");"); |
435 | 514 | } |
436 | 515 | |
437 | - public function ajax_get_definition_description($_definition) { |
|
516 | + public function ajax_get_definition_description($_definition) |
|
517 | + { |
|
438 | 518 | |
439 | 519 | $_response = Api\Json\Response::get(); |
440 | 520 | $description = ''; |
441 | 521 | if ($_definition) |
442 | 522 | { |
443 | 523 | $_object = new importexport_definition($_definition); |
444 | - if (is_a($_object, 'importexport_definition')) { |
|
524 | + if (is_a($_object, 'importexport_definition')) |
|
525 | + { |
|
445 | 526 | $description = $_object->description; |
446 | 527 | } |
447 | 528 | unset ($_object); |
@@ -449,11 +530,13 @@ discard block |
||
449 | 530 | $_response->assign('importexport-export_dialog_plugin_description','innerHTML',$description); |
450 | 531 | } |
451 | 532 | |
452 | - public function ajax_get_plugin_description($_plugin) { |
|
533 | + public function ajax_get_plugin_description($_plugin) |
|
534 | + { |
|
453 | 535 | $_respone = Api\Json\Response::get(); |
454 | 536 | |
455 | 537 | $plugin_object = new $_plugin; |
456 | - if (is_a($plugin_object, 'importexport_iface_export_plugin')) { |
|
538 | + if (is_a($plugin_object, 'importexport_iface_export_plugin')) |
|
539 | + { |
|
457 | 540 | $description = $plugin_object->get_description(); |
458 | 541 | } |
459 | 542 | $_response->addAssign('importexport-export_dialog_plugin_description','innerHTML',$description); |
@@ -467,10 +550,14 @@ discard block |
||
467 | 550 | * @param sting $_tmpfname |
468 | 551 | * @todo we need a suffix atibute in plugins e.g. .csv |
469 | 552 | */ |
470 | - public function download($_tmpfname = '') { |
|
553 | + public function download($_tmpfname = '') |
|
554 | + { |
|
471 | 555 | $tmpfname = $_tmpfname ? $_tmpfname : $_GET['_filename']; |
472 | 556 | $tmpfname = $GLOBALS['egw_info']['server']['temp_dir'] .'/'. $tmpfname; |
473 | - if (!is_readable($tmpfname)) die(); |
|
557 | + if (!is_readable($tmpfname)) |
|
558 | + { |
|
559 | + die(); |
|
560 | + } |
|
474 | 561 | |
475 | 562 | $appname = $_GET['_appname']; |
476 | 563 | $nicefname = $_GET['filename'] ? $_GET['filename'] : 'egw_export_'.$appname.'-'.date('Y-m-d'); |