Completed
Push — 14.2 ( 7153cd...f2fc75 )
by Nathan
28:08
created
importexport/inc/class.importexport_export_ui.inc.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -34,47 +34,47 @@  discard block
 block discarded – undo
34 34
 
35 35
 	public function __construct() {
36 36
 		$this->js = $GLOBALS['egw']->js = is_object($GLOBALS['egw']->js) ? $GLOBALS['egw']->js : CreateObject('phpgwapi.javascript');
37
-		$this->js->validate_file('.','export_dialog','importexport');
38
-		$this->js->validate_file('.','importexport','importexport');
37
+		$this->js->validate_file('.', 'export_dialog', 'importexport');
38
+		$this->js->validate_file('.', 'importexport', 'importexport');
39 39
 		$this->user = $GLOBALS['egw_info']['user']['user_id'];
40
-		$this->export_plugins = importexport_helper_functions::get_plugins('all','export');
40
+		$this->export_plugins = importexport_helper_functions::get_plugins('all', 'export');
41 41
 		$GLOBALS['egw_info']['flags']['include_xajax'] = true;
42 42
 
43 43
 	}
44 44
 
45
-	public function export_dialog($_content=array()) {
45
+	public function export_dialog($_content = array()) {
46 46
 		$tabs = 'general_tab|selection_tab|options_tab';
47 47
 		$sel_options = array();
48 48
 		$readonlys = array();
49 49
 		$preserv = array();
50 50
 
51
-		$et = new etemplate_new(self::_appname. '.export_dialog');
51
+		$et = new etemplate_new(self::_appname.'.export_dialog');
52 52
 		$_appname = $_content['appname'] ? $_content['appname'] : $_GET['appname'];
53 53
 		$_definition = $_content['definition'] ? $_content['definition'] : $_GET['definition'];
54 54
 		$_plugin = $_content['plugin'] ? $_content['plugin'] : $_GET['plugin'];
55 55
 		// Select all from context menu, means use all search results, not just selected
56
-		if($_GET['select_all'] == 'true') $_GET['selection'] = 'search';
56
+		if ($_GET['select_all'] == 'true') $_GET['selection'] = 'search';
57 57
 		$_selection = $_content['selection'] ? $_content['selection'] : $_GET['selection'];
58
-		if($_GET['selection'] || $_content['selection_passed']) $content['selection_passed'] = $preserv['selection_passed'] = true;
58
+		if ($_GET['selection'] || $_content['selection_passed']) $content['selection_passed'] = $preserv['selection_passed'] = true;
59 59
 
60 60
 		// Check global setting
61
-		if(!bo_merge::is_export_limit_excepted()) {
61
+		if (!bo_merge::is_export_limit_excepted()) {
62 62
 			$export_limit = bo_merge::getExportLimit($_appname);
63
-			if($export_limit == 'no') {
63
+			if ($export_limit == 'no') {
64 64
 				die(lang('Admin disabled exporting'));
65 65
 			}
66 66
 		}
67 67
 			//error_log(__FILE__.__FUNCTION__. '::$_GET[\'appname\']='. $_appname. ',$_GET[\'definition\']='. $_definition. ',$_GET[\'plugin\']='.$_plugin. ',$_GET[\'selection\']='.$_selection);
68 68
 		// if appname is given and valid, list available definitions (if no definition is given)
69
-		$readonlys['appname'] = (!empty($_appname) && $GLOBALS['egw']->acl->check('run',1,$_appname));
69
+		$readonlys['appname'] = (!empty($_appname) && $GLOBALS['egw']->acl->check('run', 1, $_appname));
70 70
 		$content['appname'] = $_appname;
71 71
 		$preserv['appname'] = $_appname;
72
-		if(empty($_appname)) {
73
-			$et->setElementAttribute('select_definition','disabled',true);
72
+		if (empty($_appname)) {
73
+			$et->setElementAttribute('select_definition', 'disabled', true);
74 74
 		}
75 75
 
76 76
 		// Check for preferred definition
77
-		if(!$_definition && $_appname) {
77
+		if (!$_definition && $_appname) {
78 78
 			$_definition = $GLOBALS['egw_info']['user']['preferences'][$_appname]['nextmatch-export-definition'];
79 79
 		}
80 80
 		// fill definitions
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
 			}
97 97
 			unset($definition);
98 98
 		}
99
-		if(count($sel_options['definition']) == 2 && !$content['definition']) {
99
+		if (count($sel_options['definition']) == 2 && !$content['definition']) {
100 100
 			$content['definition'] = end($sel_options['definition']);
101 101
 		}
102 102
 		unset($definitions);
103 103
 		//$sel_options['definition']['expert'] = lang('Expert options');
104 104
 
105
-		if(isset($_definition) && array_key_exists($_definition,$sel_options['definition'])) {
105
+		if (isset($_definition) && array_key_exists($_definition, $sel_options['definition'])) {
106 106
 			$content['definition'] = $_definition;
107 107
 		}
108 108
 
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 		$sel_options['plugin'] = $this->export_plugins[$_appname]['export'];
111 111
 
112 112
 		// show definitions or plugins in ui?
113
-		if($content['definition'] == 'expert') {
114
-			if(isset($_plugin) && array_key_exists($_plugin,$sel_options['plugin'])) {
113
+		if ($content['definition'] == 'expert') {
114
+			if (isset($_plugin) && array_key_exists($_plugin, $sel_options['plugin'])) {
115 115
 				$content['plugin'] = $_plugin;
116 116
 				$selected_plugin = $_plugin;
117 117
 			}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 			$readonlys['save_definition'] = true;
131 131
 
132 132
 			$definition = new importexport_definition($content['definition']);
133
-			if($definition) {
133
+			if ($definition) {
134 134
 				$content += (array)$definition->plugin_options;
135 135
 				$selected_plugin = $definition->plugin;
136 136
 				$content['description'] = $definition->description;
@@ -147,27 +147,27 @@  discard block
 block discarded – undo
147 147
 			'|'	=>	'|',
148 148
 			''	=>	lang('Other')
149 149
 		);
150
-		if(!$sel_options['delimiter'][$content['delimiter']]) $sel_options['delimiter'][$content['delimiter']] = $content['delimiter'];
151
-		$sel_options['delimiter'][$content['delimiter']] = lang('Use default') . ' "' . $sel_options['delimiter'][$content['delimiter']] . '"';
150
+		if (!$sel_options['delimiter'][$content['delimiter']]) $sel_options['delimiter'][$content['delimiter']] = $content['delimiter'];
151
+		$sel_options['delimiter'][$content['delimiter']] = lang('Use default').' "'.$sel_options['delimiter'][$content['delimiter']].'"';
152 152
 
153
-		if(!$_content['delimiter']) $et->setElementAttribute('other_delimiter','disabled',true);
153
+		if (!$_content['delimiter']) $et->setElementAttribute('other_delimiter', 'disabled', true);
154 154
 
155 155
 		// Other delimiter (options)
156
-		if($_content['other_delimiter']) $_content['delimiter'] = $_content['other_delimiter'];
156
+		if ($_content['other_delimiter']) $_content['delimiter'] = $_content['other_delimiter'];
157 157
 
158 158
 		// handle selector
159
-		if($selected_plugin) {
159
+		if ($selected_plugin) {
160 160
 			$content['plugin'] = $selected_plugin;
161 161
 			$plugin_object = new $selected_plugin;
162 162
 
163 163
 			$content['description'] = $plugin_object->get_description();
164 164
 
165 165
 			// fill options tab
166
- 			if(method_exists($plugin_object, 'get_selectors_html')) {
166
+ 			if (method_exists($plugin_object, 'get_selectors_html')) {
167 167
 				$content['plugin_options_html'] = $plugin_object->get_options_html();
168 168
 			} else {
169 169
 				$options = $plugin_object->get_options_etpl($definition);
170
-				if(is_array($options)) {
170
+				if (is_array($options)) {
171 171
 					$content['plugin_options_template'] = $options['name'];
172 172
 					$content += (array)$options['content'];
173 173
 					$sel_options += (array)$options['sel_options'];
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		}
181 181
 
182 182
 		// fill selection tab
183
-		if($definition && is_array($definition->plugin_options) && $definition->plugin_options['selection'] && !$content['selection_passed']) {
183
+		if ($definition && is_array($definition->plugin_options) && $definition->plugin_options['selection'] && !$content['selection_passed']) {
184 184
 			$_selection = $definition->plugin_options['selection'];
185 185
 		}
186 186
 		
@@ -190,11 +190,11 @@  discard block
 block discarded – undo
190 190
 			$preserv['selection'] = $_selection;
191 191
 		}
192 192
 		elseif ($plugin_object) {
193
- 			if(method_exists($plugin_object, 'get_selectors_html')) {
193
+ 			if (method_exists($plugin_object, 'get_selectors_html')) {
194 194
 				$content['plugin_selectors_html'] = $plugin_object->get_selectors_html();
195 195
 			} else {
196 196
 				$options = $plugin_object->get_selectors_etpl($definition);
197
-				if(is_array($options)) {
197
+				if (is_array($options)) {
198 198
 					$content += is_array($options['content']) ? $options['content'] : array('selection' => $options['content']);
199 199
 					$sel_options += (array)$options['sel_options'];
200 200
 					$readonlys['selection'] = (array)$options['readonlys'];
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
 					$content['plugin_selectors_template'] = $options;
205 205
 				}
206 206
 			}
207
-			if(!$content['plugin_selectors_html'] && !$content['plugin_selectors_template']) {
207
+			if (!$content['plugin_selectors_html'] && !$content['plugin_selectors_template']) {
208 208
 				$readonlys[$tabs]['selection_tab'] = true;
209 209
 			}
210 210
 			$content['filter'] = $definition->filter;
211 211
 			$content['filter']['fields'] = importexport_helper_functions::get_filter_fields($_appname, $selected_plugin);
212
-			if(!$content['filter']['fields'])
212
+			if (!$content['filter']['fields'])
213 213
 			{
214 214
 				$this->js->set_onload("\$j('input[value=\"filter\"]').parent().hide();");
215 215
 				$content['no_filter'] = true;
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
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
 		}
235 235
 
236 236
 		// Disable / hide definition filter if not selected
237
-		if($content['selection'] != 'filter')
237
+		if ($content['selection'] != 'filter')
238 238
 		{
239 239
 			$this->js->set_onload("
240 240
 				\$j('div.filters').hide();
@@ -245,33 +245,33 @@  discard block
 block discarded – undo
245 245
 		//error_log(__METHOD__.__LINE__.array2string($apps));
246 246
 		if (empty($apps)) throw new Exception('Error: no application profiles available for export');
247 247
 		if (!is_array($apps) && $apps) $apps = (array)$apps;
248
-		$sel_options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps);
249
-		if(!$_application && !$selected_plugin) {
248
+		$sel_options['appname'] = array('' => lang('Select one')) + array_combine($apps, $apps);
249
+		if (!$_application && !$selected_plugin) {
250 250
 			$content['plugin_selectors_html'] = $content['plugin_options_html'] =
251 251
 			lang('You need to select an app and format first!');
252 252
 			$readonlys[$tabs] = array('selection_tab' => true, 'options_tab' => true);
253 253
 		}
254 254
 
255
-		if($_content['preview'] || $_content['export'])
255
+		if ($_content['preview'] || $_content['export'])
256 256
 		{
257 257
 			//error_log(__LINE__.__FILE__.'$_content: '.print_r($_content,true));
258 258
 			$response = egw_json_response::get();
259 259
 
260 260
 			if ($_content['definition'] == 'expert') {
261 261
 				$definition = new importexport_definition();
262
-				$definition->definition_id	= $_content['definition_id'] ? $_content['definition_id'] : '';
262
+				$definition->definition_id = $_content['definition_id'] ? $_content['definition_id'] : '';
263 263
 				$definition->name		= $_content['name'] ? $_content['name'] : '';
264
-				$definition->application	= $_content['appname'];
265
-				$definition->plugin		= $_content['plugin'];
264
+				$definition->application = $_content['appname'];
265
+				$definition->plugin = $_content['plugin'];
266 266
 				$definition->type		= 'export';
267
-				$definition->allowed_users	= $_content['allowed_users'] ? $_content['allowed_users'] : $this->user;
268
-				$definition->owner		= $_content['owner'] ? $_content['owner'] : $this->user;
267
+				$definition->allowed_users = $_content['allowed_users'] ? $_content['allowed_users'] : $this->user;
268
+				$definition->owner = $_content['owner'] ? $_content['owner'] : $this->user;
269 269
 			}
270 270
 			else {
271 271
 				$definition = new importexport_definition($_content['definition']);
272 272
 			}
273 273
 
274
-			if(!is_array($definition->plugin_options)) {
274
+			if (!is_array($definition->plugin_options)) {
275 275
 				$definition->plugin_options = array(
276 276
 					'mapping'	=>	array()
277 277
 				);
@@ -281,30 +281,30 @@  discard block
 block discarded – undo
281 281
 			// Note that because not all dates are DB dates, the plugin has to handle them
282 282
 			$filter = array();
283 283
 			$_content['filter'] = $_content['filter_html'] ? $_content['filter_html'] : $_content['filter_tpl'];
284
-			if(is_array($_content['filter']))
284
+			if (is_array($_content['filter']))
285 285
 			{
286
-				foreach($_content['filter'] as $key => $value)
286
+				foreach ($_content['filter'] as $key => $value)
287 287
 				{
288 288
 					// Handle multiple values
289
-					if(!is_array($value) && strpos($value,',') !== false) $value = explode(',',$value);
289
+					if (!is_array($value) && strpos($value, ',') !== false) $value = explode(',', $value);
290 290
 
291 291
 					$filter[$key] = $value;
292 292
 
293 293
 					// Skip empty values or empty ranges
294
-					if($value == "" || is_null($value) || (is_array($value) && count($value) == 0) || is_array($value) && array_key_exists('from',$value) && !$value['from'] && !$value['to'] )
294
+					if ($value == "" || is_null($value) || (is_array($value) && count($value) == 0) || is_array($value) && array_key_exists('from', $value) && !$value['from'] && !$value['to'])
295 295
 					{
296 296
 						unset($filter[$key]);
297 297
 					}
298
-					if(is_array($value) && array_key_exists('from', $value) && $value['from'])
298
+					if (is_array($value) && array_key_exists('from', $value) && $value['from'])
299 299
 					{
300
-						$filter[$key]['from'] = egw_time::to($value['from'],'ts');
300
+						$filter[$key]['from'] = egw_time::to($value['from'], 'ts');
301 301
 					}
302 302
 					// If user selects an end date, they most likely want entries including that date
303
-					if(is_array($value) && array_key_exists('to',$value) && $value['to'] )
303
+					if (is_array($value) && array_key_exists('to', $value) && $value['to'])
304 304
 					{
305 305
 						// Adjust time to 23:59:59
306 306
 						$filter[$key]['to'] = new egw_time($value['to']);
307
-						$filter[$key]['to']->setTime(23,59,59);
307
+						$filter[$key]['to']->setTime(23, 59, 59);
308 308
 						$filter[$key]['to'] = $filter[$key]['to']->format('ts');
309 309
 					}
310 310
 				}
@@ -319,19 +319,19 @@  discard block
 block discarded – undo
319 319
 				$_content
320 320
 			);
321 321
 
322
-			if(!$definition->plugin_options['selection']) {
323
-				$response->alert( lang('No records selected'));
322
+			if (!$definition->plugin_options['selection']) {
323
+				$response->alert(lang('No records selected'));
324 324
 				return;
325 325
 			}
326 326
 
327
-			$tmpfname = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'export');
327
+			$tmpfname = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'export');
328 328
 			$file = fopen($tmpfname, "w+");
329
-			if (! $charset = $definition->plugin_options['charset']) {
329
+			if (!$charset = $definition->plugin_options['charset']) {
330 330
 				$charset = $GLOBALS['egw']->translation->charset();
331 331
 			}
332
-			if($charset == 'user')
332
+			if ($charset == 'user')
333 333
 			{
334
-				switch($definition->plugin)
334
+				switch ($definition->plugin)
335 335
 				{
336 336
 					case 'addressbook_export_vcard':
337 337
 						$charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
 				}
342 342
 			}
343 343
 			$plugin_object = new $definition->plugin;
344
-			$result = $plugin_object->export( $file, $definition );
344
+			$result = $plugin_object->export($file, $definition);
345 345
 
346
-			if(is_object($result) && method_exists($result, 'get_num_of_records'))
346
+			if (is_object($result) && method_exists($result, 'get_num_of_records'))
347 347
 			{
348 348
 				$record_count = $result->get_num_of_records();
349 349
 			}
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 			// Store charset to use in header
352 352
 			egw_cache::setSession('importexport', $tmpfname, $charset, 100);
353 353
 
354
-			if($_content['export'] == 'pressed') {
354
+			if ($_content['export'] == 'pressed') {
355 355
 				fclose($file);
356 356
 				$filename = pathinfo($tmpfname, PATHINFO_FILENAME);
357 357
 				$link_query = array(
@@ -363,25 +363,25 @@  discard block
 block discarded – undo
363 363
 				);
364 364
 
365 365
 				// Allow plugins to suggest a file name - return false if they have no suggestion
366
-				if(method_exists($plugin_object, 'get_filename') && $plugin_filename = $plugin_object->get_filename())
366
+				if (method_exists($plugin_object, 'get_filename') && $plugin_filename = $plugin_object->get_filename())
367 367
 				{
368 368
 					$link_query['filename'] = $plugin_filename;
369 369
 				}
370
-				$response->redirect( $GLOBALS['egw']->link('/index.php',$link_query),true);
370
+				$response->redirect($GLOBALS['egw']->link('/index.php', $link_query), true);
371 371
 				egw_framework::window_close();
372 372
 				return;
373 373
 			}
374
-			elseif($_content['preview'] == 'pressed') {
374
+			elseif ($_content['preview'] == 'pressed') {
375 375
 				fseek($file, 0);
376 376
 				$item_count = 1;
377 377
 				$preview = '';
378
-				$search = array('[\016]','[\017]',
379
-								'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
380
-								'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
378
+				$search = array('[\016]', '[\017]',
379
+								'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
380
+								'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
381 381
 				$replace = $preview = '';
382 382
 
383
-				while(!feof($file) && $item_count < 30) {
384
-					$preview .= preg_replace($search,$replace,fgets($file,1024));
383
+				while (!feof($file) && $item_count < 30) {
384
+					$preview .= preg_replace($search, $replace, fgets($file, 1024));
385 385
 					$item_count++;
386 386
 				}
387 387
 
@@ -389,12 +389,12 @@  discard block
 block discarded – undo
389 389
 				unlink($tmpfname);
390 390
 
391 391
 				// Convert back to system charset for display
392
-				$preview = $GLOBALS['egw']->translation->convert( $preview,
392
+				$preview = $GLOBALS['egw']->translation->convert($preview,
393 393
 					$charset,
394 394
 					$GLOBALS['egw']->translation->charset()
395 395
 				);
396 396
 
397
-				$preview = "<div class='header'>".lang('Preview') . "<span class='count'>".(int)$record_count."</span></div>".$preview;
397
+				$preview = "<div class='header'>".lang('Preview')."<span class='count'>".(int)$record_count."</span></div>".$preview;
398 398
 				
399 399
 				$et->setElementAttribute('preview-box', 'value', nl2br($preview));
400 400
 				return;
@@ -406,17 +406,17 @@  discard block
 block discarded – undo
406 406
 			$readonlys[$tabs]['selection'] = false;
407 407
 		}
408 408
 		//error_log(print_r($content,true));
409
-		return $et->exec(self::_appname. '.importexport_export_ui.export_dialog',$content,$sel_options,$readonlys,$preserv,2);
409
+		return $et->exec(self::_appname.'.importexport_export_ui.export_dialog', $content, $sel_options, $readonlys, $preserv, 2);
410 410
 	}
411 411
 
412
-	public function ajax_get_definitions($_appname, xajaxResponse &$response = null) {
413
-		if(is_null($response)) {
412
+	public function ajax_get_definitions($_appname, xajaxResponse&$response = null) {
413
+		if (is_null($response)) {
414 414
 			$response = new xajaxResponse();
415 415
 		} else {
416 416
 			$no_return = true;
417 417
 		}
418 418
 		if (!$_appname) {
419
-			$response->jquery('tr.select_definition','hide');
419
+			$response->jquery('tr.select_definition', 'hide');
420 420
 			return $no_return ? '' : $response->getXML();
421 421
 		}
422 422
 
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 				unset($definition);
439 439
 		}
440 440
 		unset($definitions);
441
-		$response->addScript("selectbox_add_option('exec[definition]','" . lang('Expert options') . "', 'expert',".($selected_plugin == $title ? 'true' : 'false').");");
441
+		$response->addScript("selectbox_add_option('exec[definition]','".lang('Expert options')."', 'expert',".($selected_plugin == $title ? 'true' : 'false').");");
442 442
 	}
443 443
 
444 444
 	public function ajax_get_definition_description($_definition) {
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 			}
454 454
 			unset ($_object);
455 455
 		}
456
-		$_response->assign('importexport-export_dialog_plugin_description','innerHTML',$description);
456
+		$_response->assign('importexport-export_dialog_plugin_description', 'innerHTML', $description);
457 457
 	}
458 458
 
459 459
 	public function ajax_get_plugin_description($_plugin) {
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 		if (is_a($plugin_object, 'importexport_iface_export_plugin')) {
464 464
 			$description = $plugin_object->get_description();
465 465
 		}
466
-		$_response->addAssign('importexport-export_dialog_plugin_description','innerHTML',$description);
466
+		$_response->addAssign('importexport-export_dialog_plugin_description', 'innerHTML', $description);
467 467
 		
468 468
 		unset ($plugin_object);
469 469
 	}
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	 */
477 477
 	public function download($_tmpfname = '') {
478 478
 		$tmpfname = $_tmpfname ? $_tmpfname : $_GET['_filename'];
479
-		$tmpfname = $GLOBALS['egw_info']['server']['temp_dir'] .'/'. $tmpfname;
479
+		$tmpfname = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpfname;
480 480
 		if (!is_readable($tmpfname)) die();
481 481
 
482 482
 		$appname = $_GET['_appname'];
@@ -485,13 +485,13 @@  discard block
 block discarded – undo
485 485
 		// Turn off all output buffering
486 486
 		while (@ob_end_clean());
487 487
 
488
-		$file = fopen($tmpfname,'rb');
488
+		$file = fopen($tmpfname, 'rb');
489 489
 
490 490
 		// Get charset
491 491
 		$charset = egw_cache::getSession('importexport', $tmpfname);
492 492
 
493 493
 		html::content_header($nicefname.'.'.$_GET['_suffix'],
494
-			($_GET['_type'] ? $_GET['_type'] : 'application/text') . ($charset ? '; charset='.$charset : ''),
494
+			($_GET['_type'] ? $_GET['_type'] : 'application/text').($charset ? '; charset='.$charset : ''),
495 495
 			filesize($tmpfname));
496 496
 		fpassthru($file);
497 497
 
Please login to merge, or discard this patch.
importexport/inc/class.importexport_widget_filter.inc.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -38,18 +38,18 @@  discard block
 block discarded – undo
38 38
 	public function beforeSendToClient($cname, Array $expand = Array())
39 39
 	{
40 40
 		$form_name = self::form_name($cname, $this->id);
41
-		if($this->getElementAttribute($form_name, 'customfields'))
41
+		if ($this->getElementAttribute($form_name, 'customfields'))
42 42
 		{
43 43
 			// Already done?  Still need to process, or sel_options may be missing
44 44
 			unset(self::$request->modifications[$form_name]);
45 45
 		}
46
-		$value =& self::get_array(self::$request->content, $form_name, true);
46
+		$value = & self::get_array(self::$request->content, $form_name, true);
47 47
 		$fields = $value['fields'];
48 48
 		unset($value['fields']);
49 49
 		$relative_dates = $this->attrs['relative_dates'];
50 50
 
51 51
 		// Fallback, so there's something there...
52
-		if(!is_array($fields))
52
+		if (!is_array($fields))
53 53
 		{
54 54
 			error_log("$this has no fields");
55 55
 			self::$transformation = array(
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
 		$this->setElementAttribute($form_name, 'prefix', self::$prefix);
67 67
 
68 68
 		$n = 1;
69
-		foreach($fields as $lname => &$field)
69
+		foreach ($fields as $lname => &$field)
70 70
 		{
71
-			$type =& $field['type'];
71
+			$type = & $field['type'];
72 72
 
73 73
 			// No filters are required
74 74
 			$field['needed'] = false;
75 75
 
76
-			switch($type)
76
+			switch ($type)
77 77
 			{
78 78
 				case 'date':
79 79
 				case 'date-time':
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 						'get_rows'      => 'etemplate.ajax_select_widget.array_rows',
91 91
 						'id_field'      => ajax_select_widget::ARRAY_KEY,
92 92
 					);
93
-					if($field['rows']) {
93
+					if ($field['rows']) {
94 94
 						$options['num_rows'] = $field['rows'];
95 95
 					}
96 96
 
@@ -109,15 +109,15 @@  discard block
 block discarded – undo
109 109
 					break;
110 110
 				case 'select':
111 111
 				default:
112
-					if(strpos($field['type'],'select') === 0)
112
+					if (strpos($field['type'], 'select') === 0)
113 113
 					{
114 114
 						if (count($field['values']) == 1 && isset($field['values']['@']))
115 115
 						{
116 116
 							$field['values'] = egw_customfields::get_options_from_file($field['values']['@']);
117 117
 						}
118
-						foreach((array)$field['values'] as $key => $val)
118
+						foreach ((array)$field['values'] as $key => $val)
119 119
 						{
120
-							if (substr($val = lang($val),-1) != '*')
120
+							if (substr($val = lang($val), -1) != '*')
121 121
 							{
122 122
 								$field['values'][$key] = $val;
123 123
 							}
@@ -129,27 +129,27 @@  discard block
 block discarded – undo
129 129
 						$this->setElementAttribute($form_name.'['.self::$prefix.$lname.']', 'tags', TRUE);
130 130
 						$this->setElementAttribute($form_name.'['.self::$prefix.$lname.']', 'multiple', TRUE);
131 131
 					}
132
-					else if( $GLOBALS['egw_info']['apps'][$field['type']])
132
+					else if ($GLOBALS['egw_info']['apps'][$field['type']])
133 133
 					{
134 134
 						// Links
135 135
 					}
136 136
 					else
137 137
 					{
138
-						error_log('Trying to filter with unsupported field type ' . $lname . ': ' . $field['type']);
138
+						error_log('Trying to filter with unsupported field type '.$lname.': '.$field['type']);
139 139
 					}
140 140
 			}
141 141
 
142 142
 			// Send select options
143
-			if($field['values'])
143
+			if ($field['values'])
144 144
 			{
145 145
 				self::$request->sel_options[self::$prefix.$lname] = $field['values'];
146 146
 			}
147 147
 			$widget = self::factory($type, '<'.$type.' type="'.$type.'" id="'.self::$prefix.$lname.'"/>', self::$prefix.$lname);
148
-			if(method_exists($widget, 'beforeSendToClient'))
148
+			if (method_exists($widget, 'beforeSendToClient'))
149 149
 			{
150 150
 				$widget->id = self::$prefix.$lname;
151 151
 				$widget->attrs['type'] = $type;
152
-				if($type == 'link-to')
152
+				if ($type == 'link-to')
153 153
 				{
154 154
 					$widget->attrs['only_app'] = $field['type'];
155 155
 				}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		parent::beforeSendToClient($cname, $expand);
162 162
 
163 163
 		$this->setElementAttribute($form_name, 'customfields', $fields);
164
-		$this->setElementAttribute($form_name, 'fields',array_fill_keys(array_keys($fields), true));
164
+		$this->setElementAttribute($form_name, 'fields', array_fill_keys(array_keys($fields), true));
165 165
 		return false;
166 166
 	}
167 167
 
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
 	protected static function do_relative_date($lname, Array &$value, $options, $readonly)
178 178
 	{
179 179
 		// Maybe this could be moved to date widget
180
-		$input = boetemplate::empty_cell('select',$lname, array(
180
+		$input = boetemplate::empty_cell('select', $lname, array(
181 181
 			'readonly'	=> $readonly,
182 182
 			'no_lang'	=> true,
183 183
 			'options'	=> $options,
184 184
 			'sel_options'	=> array('' => lang('all'))
185 185
 		));
186
-		foreach(importexport_helper_functions::$relative_dates as $label => $values)
186
+		foreach (importexport_helper_functions::$relative_dates as $label => $values)
187 187
 		{
188 188
 			$input['sel_options'][$label] = lang($label);
189 189
 		}
@@ -202,10 +202,10 @@  discard block
 block discarded – undo
202 202
 	 */
203 203
 	protected static function do_absolute_date($lname, Array &$value, $options, $readonly)
204 204
 	{
205
-		$input = boetemplate::empty_cell('hbox',$lname);
205
+		$input = boetemplate::empty_cell('hbox', $lname);
206 206
 
207 207
 		$type = 'date';
208
-		$from = boetemplate::empty_cell($type, $lname.'[from]',array(
208
+		$from = boetemplate::empty_cell($type, $lname.'[from]', array(
209 209
 			'readonly'      => $readonly,
210 210
 			'no_lang'       => True,
211 211
 			'size'          => $options
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			'size'          => $options
218 218
 		));
219 219
 		boetemplate::add_child($input, $from);
220
-		boetemplate::add_child($input,boetemplate::empty_cell('label','',array(
220
+		boetemplate::add_child($input, boetemplate::empty_cell('label', '', array(
221 221
 			'label' => lang('to'),
222 222
 			'no_lang' => true
223 223
 		)));
@@ -226,18 +226,18 @@  discard block
 block discarded – undo
226 226
 	}
227 227
 
228 228
 
229
-	public function validate($cname, array $expand, array $content, &$validated=array())
229
+	public function validate($cname, array $expand, array $content, &$validated = array())
230 230
 	{
231 231
 		$form_name = self::form_name($cname, $this->id, $expand);
232 232
 		if (!$this->is_readonly($cname, $form_name))
233 233
 		{
234 234
 			$value_in = (array)self::get_array($content, $form_name);
235
-			$valid =& self::get_array($validated, $this->id ? $form_name : $field, true);
235
+			$valid = & self::get_array($validated, $this->id ? $form_name : $field, true);
236 236
 
237
-			foreach($value_in as $key => $value)
237
+			foreach ($value_in as $key => $value)
238 238
 			{
239 239
 				// Client side cf widget automatically prefixes #
240
-				$valid[substr($key,strlen(self::$prefix))] = $value;
240
+				$valid[substr($key, strlen(self::$prefix))] = $value;
241 241
 			}
242 242
 		}
243 243
 	}
Please login to merge, or discard this patch.