Completed
Push — 16.1 ( 5454d8...fe7837 )
by Hadi
15:34
created
filemanager/inc/class.filemanager_ui.inc.php 2 patches
Braces   +142 added lines, -36 removed lines patch added patch discarded remove patch
@@ -88,7 +88,10 @@  discard block
 block discarded – undo
88 88
 			// search for plugins with additional filemanager views
89 89
 			foreach(Api\Hooks::process('filemanager_views') as $views)
90 90
 			{
91
-				if (is_array($views)) static::$views += $views;
91
+				if (is_array($views))
92
+				{
93
+					static::$views += $views;
94
+				}
92 95
 			}
93 96
 			static::$views_init = true;
94 97
 		}
@@ -405,7 +408,10 @@  discard block
 block discarded – undo
405 408
 			$content['nm']['home_dir'] = static::get_home_dir();
406 409
 			$content['nm']['view'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['nm_view'];
407 410
 
408
-			if (isset($_GET['msg'])) $msg = $_GET['msg'];
411
+			if (isset($_GET['msg']))
412
+			{
413
+				$msg = $_GET['msg'];
414
+			}
409 415
 
410 416
 			// Blank favorite set via GET needs special handling for path
411 417
 			if (isset($_GET['favorite']) && $_GET['favorite'] == 'blank')
@@ -439,7 +445,10 @@  discard block
 block discarded – undo
439 445
 				// reset lettersearch as it confuses users (they think the dir is empty)
440 446
 				$content['nm']['searchletter'] = false;
441 447
 				// switch recusive display off
442
-				if (!$content['nm']['filter']) $content['nm']['filter'] = '';
448
+				if (!$content['nm']['filter'])
449
+				{
450
+					$content['nm']['filter'] = '';
451
+				}
443 452
 			}
444 453
 		}
445 454
 		$view = static::get_view();
@@ -488,37 +497,70 @@  discard block
 block discarded – undo
488 497
 	{
489 498
 		$tpl = new Etemplate('filemanager.index');
490 499
 
491
-		if($msg) Framework::message($msg);
500
+		if($msg)
501
+		{
502
+			Framework::message($msg);
503
+		}
492 504
 
493 505
 		if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button'])))
494 506
 		{
495 507
 			if ($content['nm']['action'])
496 508
 			{
497 509
 				$msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
498
-				if($msg) Framework::message($msg);
510
+				if($msg)
511
+				{
512
+					Framework::message($msg);
513
+				}
499 514
 
500 515
 				// clean up after action
501 516
 				unset($content['nm']['selected']);
502 517
 				// reset any occasion where action may be stored, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete
503
-				if (isset($content['nm']['action'])) unset($content['nm']['action']);
504
-				if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']);
505
-				if (isset($content['nm_action'])) unset($content['nm_action']);
518
+				if (isset($content['nm']['action']))
519
+				{
520
+					unset($content['nm']['action']);
521
+				}
522
+				if (isset($content['nm']['nm_action']))
523
+				{
524
+					unset($content['nm']['nm_action']);
525
+				}
526
+				if (isset($content['nm_action']))
527
+				{
528
+					unset($content['nm_action']);
529
+				}
506 530
 				// we dont use ['nm']['rows']['delete'], so unset it, if it is present
507
-				if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']);
531
+				if (isset($content['nm']['rows']['delete']))
532
+				{
533
+					unset($content['nm']['rows']['delete']);
534
+				}
508 535
 			}
509 536
 			elseif($content['nm']['rows']['delete'])
510 537
 			{
511 538
 				$msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']);
512
-				if($msg) Framework::message($msg);
539
+				if($msg)
540
+				{
541
+					Framework::message($msg);
542
+				}
513 543
 
514 544
 				// clean up after action
515 545
 				unset($content['nm']['rows']['delete']);
516 546
 				// reset any occasion where action may be stored, as we use ['nm']['rows']['delete'] anyhow
517 547
 				// we clean this up, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete
518
-				if (isset($content['nm']['action'])) unset($content['nm']['action']);
519
-				if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']);
520
-				if (isset($content['nm_action'])) unset($content['nm_action']);
521
-				if (isset($content['nm']['selected'])) unset($content['nm']['selected']);
548
+				if (isset($content['nm']['action']))
549
+				{
550
+					unset($content['nm']['action']);
551
+				}
552
+				if (isset($content['nm']['nm_action']))
553
+				{
554
+					unset($content['nm']['nm_action']);
555
+				}
556
+				if (isset($content['nm_action']))
557
+				{
558
+					unset($content['nm_action']);
559
+				}
560
+				if (isset($content['nm']['selected']))
561
+				{
562
+					unset($content['nm']['selected']);
563
+				}
522 564
 			}
523 565
 			unset($content['nm']['rows']);
524 566
 			Api\Cache::setSession('filemanager', 'index',$content['nm']);
@@ -685,9 +727,12 @@  discard block
 block discarded – undo
685 727
 						foreach(Vfs::find($path) as $p)
686 728
 						{
687 729
 							$to = $dir.substr($p,$len);
688
-							if ($to == $p)	// cant copy into itself!
730
+							if ($to == $p)
731
+							{
732
+								// cant copy into itself!
689 733
 							{
690 734
 								++$errs;
735
+							}
691 736
 								continue;
692 737
 							}
693 738
 							if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE))
@@ -742,7 +787,10 @@  discard block
 block discarded – undo
742 787
 							continue;
743 788
 						}
744 789
 					}
745
-					if ($target[0] != '/') $target = Vfs::concat($dir, $target);
790
+					if ($target[0] != '/')
791
+					{
792
+						$target = Vfs::concat($dir, $target);
793
+					}
746 794
 					if (!Vfs::stat($target))
747 795
 					{
748 796
 						return lang('Link target %1 not found!', Vfs::decodePath($target));
@@ -785,10 +833,16 @@  discard block
 block discarded – undo
785 833
 				switch($action)
786 834
 				{
787 835
 					case 'document':
788
-						if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
836
+						if (!$settings)
837
+						{
838
+							$settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
839
+						}
789 840
 						$document_merge = new filemanager_merge(Vfs::decodePath($dir));
790 841
 						$msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']);
791
-						if($msg) return $msg;
842
+						if($msg)
843
+						{
844
+							return $msg;
845
+						}
792 846
 						$errs = count($selected);
793 847
 						return false;
794 848
 				}
@@ -825,7 +879,9 @@  discard block
 block discarded – undo
825 879
 				unset($selected[$key]);
826 880
 			}
827 881
 		}
828
-		if ($selected)	// somethings left to delete
882
+		if ($selected)
883
+		{
884
+			// somethings left to delete
829 885
 		{
830 886
 			// some precaution to never allow to (recursivly) remove /, /apps or /home
831 887
 			foreach((array)$selected as $path)
@@ -833,6 +889,7 @@  discard block
 block discarded – undo
833 889
 				if (Vfs::isProtectedDir($path))
834 890
 				{
835 891
 					$errs++;
892
+		}
836 893
 					return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path));
837 894
 				}
838 895
 			}
@@ -881,7 +938,10 @@  discard block
 block discarded – undo
881 938
 			Api\Cache::setSession('filemanager', 'index',
882 939
 				array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions'))));
883 940
 		}
884
-		if(!$query['path']) $query['path'] = static::get_home_dir();
941
+		if(!$query['path'])
942
+		{
943
+			$query['path'] = static::get_home_dir();
944
+		}
885 945
 
886 946
 		// Change template to match selected view
887 947
 		if($query['view'])
@@ -939,7 +999,10 @@  discard block
 block discarded – undo
939 999
 		$filter = $query['filter'] === '' ? 1 : $query['filter'];
940 1000
 
941 1001
 		$maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null;
942
-		if($filter == 5) $maxdepth = 2;
1002
+		if($filter == 5)
1003
+		{
1004
+			$maxdepth = 2;
1005
+		}
943 1006
 		$n = 0;
944 1007
 		$vfs_options = array(
945 1008
 			'mindepth' => 1,
@@ -1002,10 +1065,16 @@  discard block
 block discarded – undo
1002 1065
 			{
1003 1066
 				unset($row);	// fixes a weird problem with php5.1, does NOT happen with php5.2
1004 1067
 				$row =& $rows[$path2n[$path]];
1005
-				if ( !is_array($props) ) continue;
1068
+				if ( !is_array($props) )
1069
+				{
1070
+					continue;
1071
+				}
1006 1072
 				foreach($props as $prop)
1007 1073
 				{
1008
-					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue;
1074
+					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show))
1075
+					{
1076
+						continue;
1077
+					}
1009 1078
 					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...';
1010 1079
 				}
1011 1080
 			}
@@ -1130,7 +1199,10 @@  discard block
 block discarded – undo
1130 1199
 							if (!($dir = Vfs::dirname($path)))
1131 1200
 							{
1132 1201
 								$msg .= lang('File or directory not found!')." Vfs::dirname('$path')===false";
1133
-								if ($button == 'save') $button = 'apply';
1202
+								if ($button == 'save')
1203
+								{
1204
+									$button = 'apply';
1205
+								}
1134 1206
 								continue;
1135 1207
 							}
1136 1208
 							$to = Vfs::concat($dir, $content['name']);
@@ -1139,7 +1211,10 @@  discard block
 block discarded – undo
1139 1211
 								$tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'.
1140 1212
 									lang('To overwrite the existing file store again.',lang($button)));
1141 1213
 								$content['confirm_overwrite'] = $to;
1142
-								if ($button == 'save') $button = 'apply';
1214
+								if ($button == 'save')
1215
+								{
1216
+									$button = 'apply';
1217
+								}
1143 1218
 								continue;
1144 1219
 							}
1145 1220
 							if (Vfs::rename($path,$to))
@@ -1212,13 +1287,19 @@  discard block
 block discarded – undo
1212 1287
 								}
1213 1288
 								if ($ok && !$failed)
1214 1289
 								{
1215
-									if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1290
+									if(!$perm_changed++)
1291
+									{
1292
+										$msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1293
+									}
1216 1294
 									$content['old'][$name] = $content[$name];
1217 1295
 								}
1218 1296
 								elseif($failed)
1219 1297
 								{
1220
-									if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1298
+									if(!$perm_failed++)
1299
+									{
1300
+										$msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1221 1301
 										($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : ''));
1302
+									}
1222 1303
 								}
1223 1304
 							}
1224 1305
 							elseif (call_user_func_array($cmd,array($path,$value)))
@@ -1271,7 +1352,10 @@  discard block
 block discarded – undo
1271 1352
 				}
1272 1353
 			}
1273 1354
 			Framework::refresh_opener($msg, 'filemanager', $refresh_path ? $refresh_path : $path, 'edit', null, '&path=[^&]*');
1274
-			if ($button == 'save') Framework::window_close();
1355
+			if ($button == 'save')
1356
+			{
1357
+				Framework::window_close();
1358
+			}
1275 1359
 		}
1276 1360
 		if ($content['is_link'] && !Vfs::stat($path))
1277 1361
 		{
@@ -1281,13 +1365,19 @@  discard block
 block discarded – undo
1281 1365
 		$content['icon'] = Vfs::mime_icon($content['mime']);
1282 1366
 		$content['msg'] = $msg;
1283 1367
 
1284
-		if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root';
1368
+		if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid'])
1369
+		{
1370
+			$content['ro_uid_root'] = 'root';
1371
+		}
1285 1372
 		// only owner can change group & perms
1286 1373
 		if (($readonlys['gid'] = !$content['is_owner'] ||
1287 1374
 			Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs') ||// no uid, gid or perms in oldvfs
1288 1375
 				 !Vfs::is_writable($path))
1289 1376
 		{
1290
-			if (!$content['gid']) $content['ro_gid_root'] = 'root';
1377
+			if (!$content['gid'])
1378
+			{
1379
+				$content['ro_gid_root'] = 'root';
1380
+			}
1291 1381
 			foreach($content['perms'] as $name => $value)
1292 1382
 			{
1293 1383
 				$readonlys['perms['.$name.']'] = true;
@@ -1322,9 +1412,13 @@  discard block
 block discarded – undo
1322 1412
 				0 => lang('No access'),
1323 1413
 			);
1324 1414
 			if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false &&	// backend supports eacl
1325
-				$GLOBALS['egw_info']['user']['account_id'] == Vfs::$user)	// leave eACL tab disabled for sharing
1415
+				$GLOBALS['egw_info']['user']['account_id'] == Vfs::$user)
1326 1416
 			{
1327
-				unset($readonlys['tabs']['filemanager.file.eacl']);	// --> switch the tab on again
1417
+				// leave eACL tab disabled for sharing
1418
+			{
1419
+				unset($readonlys['tabs']['filemanager.file.eacl']);
1420
+			}
1421
+			// --> switch the tab on again
1328 1422
 				foreach($content['eacl'] as &$eacl)
1329 1423
 				{
1330 1424
 					$eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/');
@@ -1381,10 +1475,13 @@  discard block
 block discarded – undo
1381 1475
 				'comment' => (string)$content['comment'],
1382 1476
 				'mergeapp' => $content['mergeapp']
1383 1477
 			);
1384
-			if ($cfs) foreach($cfs as $name => $data)
1478
+			if ($cfs)
1479
+			{
1480
+				foreach($cfs as $name => $data)
1385 1481
 			{
1386 1482
 				$preserve['old']['#'.$name] = (string)$content['#'.$name];
1387 1483
 			}
1484
+			}
1388 1485
 		}
1389 1486
 		if (Vfs::$is_root)
1390 1487
 		{
@@ -1411,7 +1508,10 @@  discard block
 block discarded – undo
1411 1508
 			$tpl->setElementAttribute('tabs', 'add_tabs', true);
1412 1509
 
1413 1510
 			$tabs =& $tpl->getElementAttribute('tabs','tabs');
1414
-			if (true) $tabs = array();
1511
+			if (true)
1512
+			{
1513
+				$tabs = array();
1514
+			}
1415 1515
 
1416 1516
 			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1417 1517
 			{
@@ -1490,7 +1590,10 @@  discard block
 block discarded – undo
1490 1590
 			'files' => 0,
1491 1591
 		);
1492 1592
 
1493
-		if (!isset($dir)) $dir = array_pop($selected);
1593
+		if (!isset($dir))
1594
+		{
1595
+			$dir = array_pop($selected);
1596
+		}
1494 1597
 
1495 1598
 		switch($action)
1496 1599
 		{
@@ -1588,7 +1691,10 @@  discard block
 block discarded – undo
1588 1691
 					$target=Vfs::concat($dir,Vfs::encodePathComponent($file['name']));
1589 1692
 					if (Vfs::file_exists($target) && $app_dir)
1590 1693
 					{
1591
-						if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir);
1694
+						if (!Vfs::file_exists($app_dir))
1695
+						{
1696
+							Vfs::mkdir($app_dir);
1697
+						}
1592 1698
 						error_log("Symlinking $target to $app_dir");
1593 1699
 						Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name'])));
1594 1700
 					}
Please login to merge, or discard this patch.
Spacing   +203 added lines, -205 removed lines patch added patch discarded remove patch
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 		if (!static::$views_init)
81 81
 		{
82 82
 			// translate our labels
83
-			foreach(static::$views as &$label)
83
+			foreach (static::$views as &$label)
84 84
 			{
85 85
 				$label = lang($label);
86 86
 			}
87 87
 			// search for plugins with additional filemanager views
88
-			foreach(Api\Hooks::process('filemanager_views') as $views)
88
+			foreach (Api\Hooks::process('filemanager_views') as $views)
89 89
 			{
90 90
 				if (is_array($views)) static::$views += $views;
91 91
 			}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public static function get_view()
103 103
 	{
104
-		$view =& Api\Cache::getSession('filemanager', 'view');
104
+		$view = & Api\Cache::getSession('filemanager', 'view');
105 105
 		if (isset($_GET['view']))
106 106
 		{
107 107
 			$view = $_GET['view'];
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 			'open' => array(
126 126
 				'caption' => lang('Open'),
127 127
 				'icon' => '',
128
-				'group' => $group=1,
128
+				'group' => $group = 1,
129 129
 				'allowOnMultiple' => false,
130 130
 				'onExecute' => 'javaScript:app.filemanager.open',
131 131
 				'default' => true
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 				'caption' => lang('Edit settings'),
151 151
 				'group' => $group,
152 152
 				'allowOnMultiple' => false,
153
-				'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.filemanager.viewEntry':'javaScript:app.filemanager.editprefs',
153
+				'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.filemanager.viewEntry' : 'javaScript:app.filemanager.editprefs',
154 154
 				'mobileViewTemplate' => 'file?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/filemanager/templates/mobile/file.xet'))
155 155
 			),
156 156
 			'mkdir' => array(
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			),
210 210
 			// DRAG and DROP events
211 211
 			'file_drag' => array(
212
-				'dragType' => array('file','link'),
212
+				'dragType' => array('file', 'link'),
213 213
 				'type' => 'drag',
214 214
 				'onExecute' => 'javaScript:app.filemanager.drag'
215 215
 			),
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 		}
249 249
 		else
250 250
 		{
251
-			foreach(Vfs\Sharing::$modes as $mode => $data)
251
+			foreach (Vfs\Sharing::$modes as $mode => $data)
252 252
 			{
253 253
 				$actions['mail']['children']['mail_'.$mode] = array(
254 254
 					'caption' => $data['label'],
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
 			}
260 260
 		}
261 261
 		// This would be done automatically, but we're overriding
262
-		foreach($actions as $action_id => $action)
262
+		foreach ($actions as $action_id => $action)
263 263
 		{
264
-			if($action['type'] == 'drop' && $action['caption'])
264
+			if ($action['type'] == 'drop' && $action['caption'])
265 265
 			{
266 266
 				$action['type'] = 'popup';
267
-				if($action['acceptedTypes'] == 'file')
267
+				if ($action['acceptedTypes'] == 'file')
268 268
 				{
269 269
 					$action['enabled'] = 'javaScript:app.filemanager.paste_enabled';
270 270
 				}
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 		}
274 274
 
275 275
 		// Anonymous users have limited actions
276
-		if(self::is_anonymous($GLOBALS['egw_info']['user']['account_id']))
276
+		if (self::is_anonymous($GLOBALS['egw_info']['user']['account_id']))
277 277
 		{
278 278
 			self::restrict_anonymous_actions($actions);
279 279
 		}
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 	 *
291 291
 	 * @return string merge application or NULL if no property found
292 292
 	 */
293
-	private static function get_mergeapp($path, $scope='self')
293
+	private static function get_mergeapp($path, $scope = 'self')
294 294
 	{
295 295
 		$app = null;
296
-		switch($scope)
296
+		switch ($scope)
297 297
 		{
298 298
 			case 'self':
299 299
 				$props = Vfs::propfind($path, static::$merge_prop_namespace);
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 			case 'parents':
303 303
 				// search for props in parent directories
304 304
 				$currentpath = $path;
305
-				while($dir = Vfs::dirname($currentpath))
305
+				while ($dir = Vfs::dirname($currentpath))
306 306
 				{
307 307
 					$props = Vfs::propfind($dir, static::$merge_prop_namespace);
308
-					if(!empty($props))
308
+					if (!empty($props))
309 309
 					{
310 310
 						// found prop in parent directory
311 311
 						return $app = $props[0]['val'];
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 * @param array $content
325 325
 	 * @param string $msg
326 326
 	 */
327
-	function index(array $content=null,$msg=null)
327
+	function index(array $content = null, $msg = null)
328 328
 	{
329 329
 		if (!is_array($content))
330 330
 		{
@@ -334,16 +334,16 @@  discard block
 block discarded – undo
334 334
 			if (!is_array($content['nm']))
335 335
 			{
336 336
 				$content['nm'] = array(
337
-					'get_rows'       =>	'filemanager.filemanager_ui.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
338
-					'filter'         => '',	// current dir only
339
-					'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
340
-					'no_cat'         => True,	// I  disable the cat-selectbox
341
-					'lettersearch'   => True,	// I  show a lettersearch
342
-					'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
343
-					'start'          =>	0,		// IO position in list
344
-					'order'          =>	'name',	// IO name of the column to sort after (optional for the sortheaders)
345
-					'sort'           =>	'ASC',	// IO direction of the sort: 'ASC' or 'DESC'
346
-					'default_cols'   => '!comment,ctime',	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
337
+					'get_rows'       =>	'filemanager.filemanager_ui.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
338
+					'filter'         => '', // current dir only
339
+					'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
340
+					'no_cat'         => True, // I  disable the cat-selectbox
341
+					'lettersearch'   => True, // I  show a lettersearch
342
+					'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
343
+					'start'          =>	0, // IO position in list
344
+					'order'          =>	'name', // IO name of the column to sort after (optional for the sortheaders)
345
+					'sort'           =>	'ASC', // IO direction of the sort: 'ASC' or 'DESC'
346
+					'default_cols'   => '!comment,ctime', // I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
347 347
 					'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
348 348
 									//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
349 349
 					'row_id'         => 'path',
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 					'parent_id'      => 'dir',
352 352
 					'is_parent'      => 'is_dir',
353 353
 					'favorites'      => true,
354
-					'placeholder_actions' => array('mkdir','paste','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink')
354
+					'placeholder_actions' => array('mkdir', 'paste', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink')
355 355
 				);
356 356
 				$content['nm']['path'] = static::get_home_dir();
357 357
 			}
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 			}
374 374
 			if (isset($_GET['path']) && ($path = $_GET['path']))
375 375
 			{
376
-				switch($path)
376
+				switch ($path)
377 377
 				{
378 378
 					case '..':
379 379
 						$path = Vfs::dirname($content['nm']['path']);
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 						$path = static::get_home_dir();
383 383
 						break;
384 384
 				}
385
-				if ($path && $path[0] == '/' && Vfs::stat($path,true) && Vfs::is_dir($path) && Vfs::check_access($path,Vfs::READABLE))
385
+				if ($path && $path[0] == '/' && Vfs::stat($path, true) && Vfs::is_dir($path) && Vfs::check_access($path, Vfs::READABLE))
386 386
 				{
387 387
 					$content['nm']['path'] = $path;
388 388
 				}
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 		}
399 399
 		$view = static::get_view();
400 400
 
401
-		call_user_func($view,$content,$msg);
401
+		call_user_func($view, $content, $msg);
402 402
 	}
403 403
 
404 404
 	/**
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 	 * @param boolean &$is_setup=null on return true if authenticated user is setup config user, false otherwise
412 412
 	 * @return boolean true is root user given, false otherwise (including logout / empty $user)
413 413
 	 */
414
-	protected function sudo($user='',$password=null,&$is_setup=null)
414
+	protected function sudo($user = '', $password = null, &$is_setup = null)
415 415
 	{
416 416
 		if (!$user)
417 417
 		{
@@ -420,15 +420,15 @@  discard block
 block discarded – undo
420 420
 		else
421 421
 		{
422 422
 			// config user & password
423
-			$is_setup = Api\Session::user_pw_hash($user,$password) === $GLOBALS['egw_info']['server']['config_hash'];
423
+			$is_setup = Api\Session::user_pw_hash($user, $password) === $GLOBALS['egw_info']['server']['config_hash'];
424 424
 			// or vfs root user from setup >> configuration
425
-			$is_root = $is_setup ||	$GLOBALS['egw_info']['server']['vfs_root_user'] &&
426
-				in_array($user,preg_split('/, */',$GLOBALS['egw_info']['server']['vfs_root_user'])) &&
425
+			$is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] &&
426
+				in_array($user, preg_split('/, */', $GLOBALS['egw_info']['server']['vfs_root_user'])) &&
427 427
 				$GLOBALS['egw']->auth->authenticate($user, $password, 'text');
428 428
 		}
429 429
 		//error_log(__METHOD__."('$user','$password',$is_setup) user_pw_hash(...)='".Api\Session::user_pw_hash($user,$password)."', config_hash='{$GLOBALS['egw_info']['server']['config_hash']}' --> returning ".array2string($is_root));
430
-		Api\Cache::setSession('filemanager', 'is_setup',$is_setup);
431
-		Api\Cache::setSession('filemanager', 'is_root',Vfs::$is_root = $is_root);
430
+		Api\Cache::setSession('filemanager', 'is_setup', $is_setup);
431
+		Api\Cache::setSession('filemanager', 'is_root', Vfs::$is_root = $is_root);
432 432
 		return Vfs::$is_root;
433 433
 	}
434 434
 
@@ -438,18 +438,18 @@  discard block
 block discarded – undo
438 438
 	 * @param array $content
439 439
 	 * @param string $msg
440 440
 	 */
441
-	function listview(array $content=null,$msg=null)
441
+	function listview(array $content = null, $msg = null)
442 442
 	{
443 443
 		$tpl = new Etemplate('filemanager.index');
444 444
 
445
-		if($msg) Framework::message($msg);
445
+		if ($msg) Framework::message($msg);
446 446
 
447 447
 		if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button'])))
448 448
 		{
449 449
 			if ($content['nm']['action'])
450 450
 			{
451
-				$msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
452
-				if($msg) Framework::message($msg);
451
+				$msg = static::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']);
452
+				if ($msg) Framework::message($msg);
453 453
 
454 454
 				// clean up after action
455 455
 				unset($content['nm']['selected']);
@@ -460,10 +460,10 @@  discard block
 block discarded – undo
460 460
 				// we dont use ['nm']['rows']['delete'], so unset it, if it is present
461 461
 				if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']);
462 462
 			}
463
-			elseif($content['nm']['rows']['delete'])
463
+			elseif ($content['nm']['rows']['delete'])
464 464
 			{
465
-				$msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']);
466
-				if($msg) Framework::message($msg);
465
+				$msg = static::action('delete', array_keys($content['nm']['rows']['delete']), $content['nm']['path']);
466
+				if ($msg) Framework::message($msg);
467 467
 
468 468
 				// clean up after action
469 469
 				unset($content['nm']['rows']['delete']);
@@ -475,11 +475,11 @@  discard block
 block discarded – undo
475 475
 				if (isset($content['nm']['selected'])) unset($content['nm']['selected']);
476 476
 			}
477 477
 			unset($content['nm']['rows']);
478
-			Api\Cache::setSession('filemanager', 'index',$content['nm']);
478
+			Api\Cache::setSession('filemanager', 'index', $content['nm']);
479 479
 		}
480 480
 
481 481
 		// be tolerant with (in previous versions) not correct urlencoded pathes
482
-		if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'],true) && Vfs::stat(urldecode($content['nm']['path'])))
482
+		if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'], true) && Vfs::stat(urldecode($content['nm']['path'])))
483 483
 		{
484 484
 			$content['nm']['path'] = urldecode($content['nm']['path']);
485 485
 		}
@@ -490,22 +490,22 @@  discard block
 block discarded – undo
490 490
 				list($button) = each($content['button']);
491 491
 				unset($content['button']);
492 492
 			}
493
-			switch($button)
493
+			switch ($button)
494 494
 			{
495 495
 				case 'upload':
496 496
 					if (!$content['upload'])
497 497
 					{
498
-						Framework::message(lang('You need to select some files first!'),'error');
498
+						Framework::message(lang('You need to select some files first!'), 'error');
499 499
 						break;
500 500
 					}
501 501
 					$upload_success = $upload_failure = array();
502
-					foreach(isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload)
502
+					foreach (isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload)
503 503
 					{
504 504
 						// encode chars which special meaning in url/vfs (some like / get removed!)
505
-						$to = Vfs::concat($content['nm']['path'],Vfs::encodePathComponent($upload['name']));
505
+						$to = Vfs::concat($content['nm']['path'], Vfs::encodePathComponent($upload['name']));
506 506
 						if ($upload &&
507 507
 							(Vfs::is_writable($content['nm']['path']) || Vfs::is_writable($to)) &&
508
-							copy($upload['tmp_name'],Vfs::PREFIX.$to))
508
+							copy($upload['tmp_name'], Vfs::PREFIX.$to))
509 509
 						{
510 510
 							$upload_success[] = $upload['name'];
511 511
 						}
@@ -517,12 +517,11 @@  discard block
 block discarded – undo
517 517
 					$content['nm']['msg'] = '';
518 518
 					if ($upload_success)
519 519
 					{
520
-						Framework::message( count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') :
521
-							lang('%1 successful uploaded.',implode(', ',$upload_success)));
520
+						Framework::message(count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : lang('%1 successful uploaded.', implode(', ', $upload_success)));
522 521
 					}
523 522
 					if ($upload_failure)
524 523
 					{
525
-						Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(),'error');
524
+						Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(), 'error');
526 525
 					}
527 526
 					break;
528 527
 			}
@@ -543,16 +542,16 @@  discard block
 block discarded – undo
543 542
 			$tpl->setElementAttribute('nm[buttons][upload]', 'drop_target', 'popupMainDiv');
544 543
 		}
545 544
 		// Set view button to match current settings
546
-		if($content['nm']['view'] == 'tile')
545
+		if ($content['nm']['view'] == 'tile')
547 546
 		{
548
-			$tpl->setElementAttribute('nm[button][change_view]','statustext',lang('List view'));
549
-			$tpl->setElementAttribute('nm[button][change_view]','image','list_row');
547
+			$tpl->setElementAttribute('nm[button][change_view]', 'statustext', lang('List view'));
548
+			$tpl->setElementAttribute('nm[button][change_view]', 'image', 'list_row');
550 549
 		}
551 550
 		// if initial load is done via GET request (idots template or share.php)
552 551
 		// get_rows cant call app.filemanager.set_readonly, so we need to do that here
553 552
 		$content['initial_path_readonly'] = !Vfs::is_writable($content['nm']['path']);
554 553
 
555
-		$tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm']));
554
+		$tpl->exec('filemanager.filemanager_ui.index', $content, $sel_options, $readonlys, array('nm' => $content['nm']));
556 555
 	}
557 556
 
558 557
 	/**
@@ -588,7 +587,7 @@  discard block
 block discarded – undo
588 587
 	 * @param int &$files=null on return number of files deleted
589 588
 	 * @return string success or failure message displayed to the user
590 589
 	 */
591
-	static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null)
590
+	static public function action($action, $selected, $dir = null, &$errs = null, &$files = null, &$dirs = null)
592 591
 	{
593 592
 		if (!count($selected))
594 593
 		{
@@ -596,20 +595,20 @@  discard block
 block discarded – undo
596 595
 		}
597 596
 		$errs = $dirs = $files = 0;
598 597
 
599
-		switch($action)
598
+		switch ($action)
600 599
 		{
601 600
 
602 601
 			case 'delete':
603
-				return static::do_delete($selected,$errs,$files,$dirs);
602
+				return static::do_delete($selected, $errs, $files, $dirs);
604 603
 
605 604
 			case 'mail':
606 605
 			case 'copy':
607
-				foreach($selected as $path)
606
+				foreach ($selected as $path)
608 607
 				{
609 608
 					if (strpos($path, 'mail::') === 0 && $path = substr($path, 6))
610 609
 					{
611 610
 						// Support for dropping mail in filemanager - Pass mail back to mail app
612
-						if(ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false))
611
+						if (ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false))
613 612
 						{
614 613
 							++$files;
615 614
 						}
@@ -620,8 +619,8 @@  discard block
 block discarded – undo
620 619
 					}
621 620
 					elseif (!Vfs::is_dir($path))
622 621
 					{
623
-						$to = Vfs::concat($dir,Vfs::basename($path));
624
-						if ($path != $to && Vfs::copy($path,$to))
622
+						$to = Vfs::concat($dir, Vfs::basename($path));
623
+						if ($path != $to && Vfs::copy($path, $to))
625 624
 						{
626 625
 							++$files;
627 626
 						}
@@ -633,19 +632,19 @@  discard block
 block discarded – undo
633 632
 					else
634 633
 					{
635 634
 						$len = strlen(dirname($path));
636
-						foreach(Vfs::find($path) as $p)
635
+						foreach (Vfs::find($path) as $p)
637 636
 						{
638
-							$to = $dir.substr($p,$len);
637
+							$to = $dir.substr($p, $len);
639 638
 							if ($to == $p)	// cant copy into itself!
640 639
 							{
641 640
 								++$errs;
642 641
 								continue;
643 642
 							}
644
-							if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE))
643
+							if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to, null, STREAM_MKDIR_RECURSIVE))
645 644
 							{
646 645
 								++$dirs;
647 646
 							}
648
-							elseif(!$is_dir && Vfs::copy($p,$to))
647
+							elseif (!$is_dir && Vfs::copy($p, $to))
649 648
 							{
650 649
 								++$files;
651 650
 							}
@@ -658,15 +657,15 @@  discard block
 block discarded – undo
658 657
 				}
659 658
 				if ($errs)
660 659
 				{
661
-					return lang('%1 errors copying (%2 diretories and %3 files copied)!',$errs,$dirs,$files);
660
+					return lang('%1 errors copying (%2 diretories and %3 files copied)!', $errs, $dirs, $files);
662 661
 				}
663
-				return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files);
662
+				return $dirs ? lang('%1 directories and %2 files copied.', $dirs, $files) : lang('%1 files copied.', $files);
664 663
 
665 664
 			case 'move':
666
-				foreach($selected as $path)
665
+				foreach ($selected as $path)
667 666
 				{
668
-					$to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir,Vfs::basename($path)) : $dir;
669
-					if ($path != $to && Vfs::rename($path,$to))
667
+					$to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir, Vfs::basename($path)) : $dir;
668
+					if ($path != $to && Vfs::rename($path, $to))
670 669
 					{
671 670
 						++$files;
672 671
 					}
@@ -677,17 +676,17 @@  discard block
 block discarded – undo
677 676
 				}
678 677
 				if ($errs)
679 678
 				{
680
-					return lang('%1 errors moving (%2 files moved)!',$errs,$files);
679
+					return lang('%1 errors moving (%2 files moved)!', $errs, $files);
681 680
 				}
682
-				return lang('%1 files moved.',$files);
681
+				return lang('%1 files moved.', $files);
683 682
 
684 683
 			case 'symlink':	// symlink given files to $dir
685
-				foreach((array)$selected as $target)
684
+				foreach ((array)$selected as $target)
686 685
 				{
687 686
 					$link = Vfs::concat($dir, Vfs::basename($target));
688
-					if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir,0,true)))
687
+					if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir, 0, true)))
689 688
 					{
690
-						if(!$ok)
689
+						if (!$ok)
691 690
 						{
692 691
 							$errs++;
693 692
 							continue;
@@ -709,15 +708,14 @@  discard block
 block discarded – undo
709 708
 				}
710 709
 				if (count((array)$selected) == 1)
711 710
 				{
712
-					return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) :
713
-						lang('Error creating symlink to target %1!', Vfs::decodePath($target));
711
+					return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : lang('Error creating symlink to target %1!', Vfs::decodePath($target));
714 712
 				}
715 713
 				$ret = lang('%1 elements linked.', $files);
716 714
 				if ($errs)
717 715
 				{
718
-					$ret = lang('%1 errors linking (%2)!',$errs, $ret);
716
+					$ret = lang('%1 errors linking (%2)!', $errs, $ret);
719 717
 				}
720
-				return $ret;//." Vfs::symlink('$target', '$link')";
718
+				return $ret; //." Vfs::symlink('$target', '$link')";
721 719
 
722 720
 			case 'createdir':
723 721
 				$dst = Vfs::concat($dir, is_array($selected) ? $selected[0] : $selected);
@@ -733,13 +731,13 @@  discard block
 block discarded – undo
733 731
 
734 732
 			default:
735 733
 				list($action, $settings) = explode('_', $action, 2);
736
-				switch($action)
734
+				switch ($action)
737 735
 				{
738 736
 					case 'document':
739 737
 						if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
740 738
 						$document_merge = new filemanager_merge(Vfs::decodePath($dir));
741 739
 						$msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']);
742
-						if($msg) return $msg;
740
+						if ($msg) return $msg;
743 741
 						$errs = count($selected);
744 742
 						return false;
745 743
 				}
@@ -756,12 +754,12 @@  discard block
 block discarded – undo
756 754
 	 * @param int &$files=null on return number of files deleted
757 755
 	 * @return string
758 756
 	 */
759
-	public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null)
757
+	public static function do_delete(array $selected, &$errs = null, &$dirs = null, &$files = null)
760 758
 	{
761 759
 		$dirs = $files = $errs = 0;
762 760
 		// we first delete all selected links (and files)
763 761
 		// feeding the links to dirs to Vfs::find() deletes the content of the dirs, not just the link!
764
-		foreach($selected as $key => $path)
762
+		foreach ($selected as $key => $path)
765 763
 		{
766 764
 			if (!Vfs::is_dir($path) || Vfs::is_link($path))
767 765
 			{
@@ -779,21 +777,21 @@  discard block
 block discarded – undo
779 777
 		if ($selected)	// somethings left to delete
780 778
 		{
781 779
 			// some precaution to never allow to (recursivly) remove /, /apps or /home
782
-			foreach((array)$selected as $path)
780
+			foreach ((array)$selected as $path)
783 781
 			{
784 782
 				if (Vfs::isProtectedDir($path))
785 783
 				{
786 784
 					$errs++;
787
-					return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path));
785
+					return lang("Cautiously rejecting to remove folder '%1'!", Vfs::decodePath($path));
788 786
 				}
789 787
 			}
790 788
 			// now we use find to loop through all files and dirs: (selected only contains dirs now)
791 789
 			// - depth=true to get first the files and then the dir containing it
792 790
 			// - hidden=true to also return hidden files (eg. Thumbs.db), as we cant delete non-empty dirs
793 791
 			// - show-deleted=false to not (finally) deleted versioned files
794
-			foreach(Vfs::find($selected,array('depth'=>true,'hidden'=>true,'show-deleted'=>false)) as $path)
792
+			foreach (Vfs::find($selected, array('depth'=>true, 'hidden'=>true, 'show-deleted'=>false)) as $path)
795 793
 			{
796
-				if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path,0))
794
+				if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path, 0))
797 795
 				{
798 796
 					++$dirs;
799 797
 				}
@@ -809,13 +807,13 @@  discard block
 block discarded – undo
809 807
 		}
810 808
 		if ($errs)
811 809
 		{
812
-			return lang('%1 errors deleteting (%2 directories and %3 files deleted)!',$errs,$dirs,$files);
810
+			return lang('%1 errors deleteting (%2 directories and %3 files deleted)!', $errs, $dirs, $files);
813 811
 		}
814 812
 		if ($dirs)
815 813
 		{
816
-			return lang('%1 directories and %2 files deleted.',$dirs,$files);
814
+			return lang('%1 directories and %2 files deleted.', $dirs, $files);
817 815
 		}
818
-		return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.',$files);
816
+		return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.', $files);
819 817
 	}
820 818
 
821 819
 	/**
@@ -830,37 +828,37 @@  discard block
 block discarded – undo
830 828
 		if (!$query['csv_export'])
831 829
 		{
832 830
 			Api\Cache::setSession('filemanager', 'index',
833
-				array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions'))));
831
+				array_diff_key($query, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions'))));
834 832
 		}
835
-		if(!$query['path']) $query['path'] = static::get_home_dir();
833
+		if (!$query['path']) $query['path'] = static::get_home_dir();
836 834
 
837 835
 		// Change template to match selected view
838
-		if($query['view'])
836
+		if ($query['view'])
839 837
 		{
840 838
 			$query['template'] = ($query['view'] == 'row' ? 'filemanager.index.rows' : 'filemanager.tile');
841 839
 
842 840
 			// Store as preference but only for index, not home
843
-			if($query['get_rows'] == 'filemanager.filemanager_ui.get_rows')
841
+			if ($query['get_rows'] == 'filemanager.filemanager_ui.get_rows')
844 842
 			{
845
-				$GLOBALS['egw']->preferences->add('filemanager','nm_view',$query['view']);
843
+				$GLOBALS['egw']->preferences->add('filemanager', 'nm_view', $query['view']);
846 844
 				$GLOBALS['egw']->preferences->save_repository();
847 845
 			}
848 846
 		}
849 847
 		// be tolerant with (in previous versions) not correct urlencoded pathes
850
-		if (!Vfs::stat($query['path'],true) && Vfs::stat(urldecode($query['path'])))
848
+		if (!Vfs::stat($query['path'], true) && Vfs::stat(urldecode($query['path'])))
851 849
 		{
852 850
 			$query['path'] = urldecode($query['path']);
853 851
 		}
854
-		if (!Vfs::stat($query['path'],true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'],Vfs::READABLE))
852
+		if (!Vfs::stat($query['path'], true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'], Vfs::READABLE))
855 853
 		{
856 854
 			// only redirect, if it would be to some other location, gives redirect-loop otherwise
857 855
 			if ($query['path'] != ($path = static::get_home_dir()))
858 856
 			{
859 857
 				// we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give
860 858
 				// an appropriate message
861
-				Egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index',
859
+				Egw::redirect_link('/index.php', array('menuaction'=>'filemanager.filemanager_ui.index',
862 860
 					'path' => $path,
863
-					'msg' => lang('The requested path %1 is not available.',Vfs::decodePath($query['path'])),
861
+					'msg' => lang('The requested path %1 is not available.', Vfs::decodePath($query['path'])),
864 862
 					'ajax' => 'true'
865 863
 				));
866 864
 			}
@@ -868,35 +866,35 @@  discard block
 block discarded – undo
868 866
 			return 0;
869 867
 		}
870 868
 		$rows = $dir_is_writable = array();
871
-		if($query['searchletter'] && !empty($query['search']))
869
+		if ($query['searchletter'] && !empty($query['search']))
872 870
 		{
873
-			$namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i';
871
+			$namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i';
874 872
 			if ($query['searchletter'] == strtolower($query['search'][0]))
875 873
 			{
876
-				$namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'|'.
877
-					str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).')/i';
874
+				$namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'|'.
875
+					str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).')/i';
878 876
 			}
879 877
 		}
880 878
 		elseif ($query['searchletter'])
881 879
 		{
882 880
 			$namefilter = '/^'.$query['searchletter'].'/i';
883 881
 		}
884
-		elseif(!empty($query['search']))
882
+		elseif (!empty($query['search']))
885 883
 		{
886
-			$namefilter = '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i';
884
+			$namefilter = '/'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i';
887 885
 		}
888 886
 
889 887
 		// Re-map so 'No filters' favorite ('') is depth 1
890 888
 		$filter = $query['filter'] === '' ? 1 : $query['filter'];
891 889
 
892 890
 		$maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null;
893
-		if($filter == 5) $maxdepth = 2;
891
+		if ($filter == 5) $maxdepth = 2;
894 892
 		$n = 0;
895 893
 		$vfs_options = array(
896 894
 			'mindepth' => 1,
897 895
 			'maxdepth' => $maxdepth,
898 896
 			'dirsontop' => $filter <= 1,
899
-			'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F':'f'),
897
+			'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F' : 'f'),
900 898
 			'order' => $query['order'], 'sort' => $query['sort'],
901 899
 			'limit' => (int)$query['num_rows'].','.(int)$query['start'],
902 900
 			'need_mime' => true,
@@ -904,11 +902,11 @@  discard block
 block discarded – undo
904 902
 			'hidden' => $filter == 3,
905 903
 			'follow' => $filter == 5,
906 904
 		);
907
-		if($query['col_filter']['mime'])
905
+		if ($query['col_filter']['mime'])
908 906
 		{
909 907
 			$vfs_options['mime'] = $query['col_filter']['mime'];
910 908
 		}
911
-		foreach(Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],$vfs_options,true) as $path => $row)
909
+		foreach (Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'], $vfs_options, true) as $path => $row)
912 910
 		{
913 911
 			//echo $path; _debug_array($row);
914 912
 
@@ -927,37 +925,37 @@  discard block
 block discarded – undo
927 925
 				$row['class'] .= 'isDir ';
928 926
 				$row['is_dir'] = 1;
929 927
 			}
930
-			if(!$dir_is_writable[$path])
928
+			if (!$dir_is_writable[$path])
931 929
 			{
932 930
 				$row['class'] .= 'noEdit ';
933 931
 			}
934 932
 			$row['download_url'] = Vfs::download_url($path);
935
-			$row['gid'] = -abs($row['gid']);	// gid are positive, but we use negagive account_id for groups internal
933
+			$row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal
936 934
 
937 935
 			$rows[++$n] = $row;
938 936
 			$path2n[$path] = $n;
939 937
 		}
940 938
 		// query comments and cf's for the displayed rows
941
-		$cols_to_show = explode(',',$GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']);
939
+		$cols_to_show = explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']);
942 940
 
943 941
 		// Always include comment in tiles
944
-		if($query['view'] == 'tile')
942
+		if ($query['view'] == 'tile')
945 943
 		{
946 944
 			$cols_to_show[] = 'comment';
947 945
 		}
948
-		$all_cfs = in_array('customfields',$cols_to_show) && $cols_to_show[count($cols_to_show)-1][0] != '#';
949
-		if ($path2n && (in_array('comment',$cols_to_show) || in_array('customfields',$cols_to_show)) &&
946
+		$all_cfs = in_array('customfields', $cols_to_show) && $cols_to_show[count($cols_to_show) - 1][0] != '#';
947
+		if ($path2n && (in_array('comment', $cols_to_show) || in_array('customfields', $cols_to_show)) &&
950 948
 			($path2props = Vfs::propfind(array_keys($path2n))))
951 949
 		{
952
-			foreach($path2props as $path => $props)
950
+			foreach ($path2props as $path => $props)
953 951
 			{
954
-				unset($row);	// fixes a weird problem with php5.1, does NOT happen with php5.2
955
-				$row =& $rows[$path2n[$path]];
956
-				if ( !is_array($props) ) continue;
957
-				foreach($props as $prop)
952
+				unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2
953
+				$row = & $rows[$path2n[$path]];
954
+				if (!is_array($props)) continue;
955
+				foreach ($props as $prop)
958 956
 				{
959
-					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue;
960
-					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...';
957
+					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'], $cols_to_show)) continue;
958
+					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'], 0, 64).' ...';
961 959
 				}
962 960
 			}
963 961
 		}
@@ -969,7 +967,7 @@  discard block
 block discarded – undo
969 967
 		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'projectmanager')
970 968
 		{
971 969
 			// we need our app.css file
972
-			if (!file_exists(EGW_SERVER_ROOT.($css_file='/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css')))
970
+			if (!file_exists(EGW_SERVER_ROOT.($css_file = '/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css')))
973 971
 			{
974 972
 				$css_file = '/filemanager/templates/default/app.css';
975 973
 			}
@@ -985,7 +983,7 @@  discard block
 block discarded – undo
985 983
 	 * @param array $content
986 984
 	 * @param string $msg
987 985
 	 */
988
-	function file(array $content=null,$msg='')
986
+	function file(array $content = null, $msg = '')
989 987
 	{
990 988
 		$tpl = new Etemplate('filemanager.file');
991 989
 
@@ -995,9 +993,9 @@  discard block
 block discarded – undo
995 993
 			{
996 994
 				$msg .= $_GET['msg'];
997 995
 			}
998
-			if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) ||	// ?, # need to stay encoded!
996
+			if (!($path = str_replace(array('#', '?'), array('%23', '%3F'), $_GET['path'])) || // ?, # need to stay encoded!
999 997
 				// actions enclose pathes containing comma with "
1000
-				($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) ||
998
+				($path[0] == '"' && substr($path, -1) == '"' && !($path = substr(str_replace('""', '"', $path), 1, -1))) ||
1001 999
 				!($stat = Vfs::lstat($path)))
1002 1000
 			{
1003 1001
 				$msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat);
@@ -1010,10 +1008,10 @@  discard block
 block discarded – undo
1010 1008
 				$content['path'] = $path;
1011 1009
 				$content['hsize'] = Vfs::hsize($stat['size']);
1012 1010
 				$content['mime'] = Vfs::mime_content_type($path);
1013
-				$content['gid'] *= -1;	// our widgets use negative gid's
1011
+				$content['gid'] *= -1; // our widgets use negative gid's
1014 1012
 				if (($props = Vfs::propfind($path)))
1015 1013
 				{
1016
-					foreach($props as $prop)
1014
+					foreach ($props as $prop)
1017 1015
 					{
1018 1016
 						$content[$prop['name']] = $prop['val'];
1019 1017
 					}
@@ -1026,9 +1024,9 @@  discard block
 block discarded – undo
1026 1024
 			$content['tabs'] = $_GET['tabs'];
1027 1025
 			if (!($content['is_dir'] = Vfs::is_dir($path) && !Vfs::is_link($path)))
1028 1026
 			{
1029
-				$content['perms']['executable'] = (int)!!($content['mode'] & 0111);
1027
+				$content['perms']['executable'] = (int)!!($content['mode']&0111);
1030 1028
 				$mask = 6;
1031
-				if (preg_match('/^text/',$content['mime']) && $content['size'] < 100000)
1029
+				if (preg_match('/^text/', $content['mime']) && $content['size'] < 100000)
1032 1030
 				{
1033 1031
 					$content['text_content'] = file_get_contents(Vfs::PREFIX.$path);
1034 1032
 				}
@@ -1038,19 +1036,19 @@  discard block
 block discarded – undo
1038 1036
 				//currently not implemented in backend $content['perms']['sticky'] = (int)!!($content['mode'] & 0x201);
1039 1037
 				$mask = 7;
1040 1038
 			}
1041
-			foreach(array('owner' => 6,'group' => 3,'other' => 0) as $name => $shift)
1039
+			foreach (array('owner' => 6, 'group' => 3, 'other' => 0) as $name => $shift)
1042 1040
 			{
1043
-				$content['perms'][$name] = ($content['mode'] >> $shift) & $mask;
1041
+				$content['perms'][$name] = ($content['mode'] >> $shift)&$mask;
1044 1042
 			}
1045
-			$content['is_owner'] = Vfs::has_owner_rights($path,$content);
1043
+			$content['is_owner'] = Vfs::has_owner_rights($path, $content);
1046 1044
 		}
1047 1045
 		else
1048 1046
 		{
1049 1047
 			//_debug_array($content);
1050
-			$path =& $content['path'];
1048
+			$path = & $content['path'];
1051 1049
 
1052 1050
 			list($button) = @each($content['button']); unset($content['button']);
1053
-			if(!$button && $content['sudo'])
1051
+			if (!$button && $content['sudo'])
1054 1052
 			{
1055 1053
 				// Button to stop sudo is not in button namespace
1056 1054
 				$button = 'sudo';
@@ -1059,21 +1057,21 @@  discard block
 block discarded – undo
1059 1057
 			// need to check 'setup' button (submit button in sudo popup), as some browsers (eg. chrome) also fill the hidden field
1060 1058
 			if ($button == 'sudo' && Vfs::$is_root || $button == 'setup' && $content['sudo']['user'])
1061 1059
 			{
1062
-				$msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '',$content['sudo']['passwd']) ?
1060
+				$msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '', $content['sudo']['passwd']) ?
1063 1061
 					lang('Root access granted.') : ($button == 'setup' && $content['sudo']['user'] ?
1064 1062
 					lang('Wrong username or password!') : lang('Root access stopped.'));
1065 1063
 				unset($content['sudo']);
1066 1064
 				$content['is_owner'] = Vfs::has_owner_rights($path);
1067 1065
 			}
1068
-			if (in_array($button,array('save','apply')))
1066
+			if (in_array($button, array('save', 'apply')))
1069 1067
 			{
1070 1068
 				$props = array();
1071 1069
 				$perm_changed = $perm_failed = 0;
1072
-				foreach($content['old'] as $name => $old_value)
1070
+				foreach ($content['old'] as $name => $old_value)
1073 1071
 				{
1074 1072
 					if (isset($content[$name]) && ($old_value != $content[$name] ||
1075 1073
 						// do not check for modification, if modify_subs is checked!
1076
-						$content['modify_subs'] && in_array($name,array('uid','gid','perms'))) &&
1074
+						$content['modify_subs'] && in_array($name, array('uid', 'gid', 'perms'))) &&
1077 1075
 						($name != 'uid' || Vfs::$is_root))
1078 1076
 					{
1079 1077
 						if ($name == 'name')
@@ -1087,23 +1085,23 @@  discard block
 block discarded – undo
1087 1085
 							$to = Vfs::concat($dir, $content['name']);
1088 1086
 							if (file_exists(Vfs::PREFIX.$to) && $content['confirm_overwrite'] !== $to)
1089 1087
 							{
1090
-								$tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'.
1091
-									lang('To overwrite the existing file store again.',lang($button)));
1088
+								$tpl->set_validation_error('name', lang("There's already a file with that name!").'<br />'.
1089
+									lang('To overwrite the existing file store again.', lang($button)));
1092 1090
 								$content['confirm_overwrite'] = $to;
1093 1091
 								if ($button == 'save') $button = 'apply';
1094 1092
 								continue;
1095 1093
 							}
1096
-							if (Vfs::rename($path,$to))
1094
+							if (Vfs::rename($path, $to))
1097 1095
 							{
1098
-								$msg .= lang('Renamed %1 to %2.',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' ';
1096
+								$msg .= lang('Renamed %1 to %2.', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' ';
1099 1097
 								$content['old']['name'] = $content[$name];
1100 1098
 								$path = $to;
1101
-								$content['mime'] = Api\MimeMagic::filename2mime($path);	// recheck mime type
1102
-								$refresh_path = Vfs::dirname($path);	// for renames, we have to refresh the parent
1099
+								$content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type
1100
+								$refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent
1103 1101
 							}
1104 1102
 							else
1105 1103
 							{
1106
-								$msg .= lang('Rename of %1 to %2 failed!',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' ';
1104
+								$msg .= lang('Rename of %1 to %2 failed!', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' ';
1107 1105
 								if (Vfs::deny_script($to))
1108 1106
 								{
1109 1107
 									$msg .= lang('You are NOT allowed to upload a script!').' ';
@@ -1123,7 +1121,7 @@  discard block
 block discarded – undo
1123 1121
 									'val'	=> (!empty($content[$name]) ? $content[$name] : null),
1124 1122
 								),
1125 1123
 							);
1126
-							if (Vfs::proppatch($path,$mergeprop))
1124
+							if (Vfs::proppatch($path, $mergeprop))
1127 1125
 							{
1128 1126
 								$content['old'][$name] = $content[$name];
1129 1127
 								$msg .= lang('Setting for document merge saved.');
@@ -1135,22 +1133,22 @@  discard block
 block discarded – undo
1135 1133
 						}
1136 1134
 						else
1137 1135
 						{
1138
-							static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod');
1139
-							$cmd = array('EGroupware\\Api\\Vfs',$name2cmd[$name]);
1136
+							static $name2cmd = array('uid' => 'chown', 'gid' => 'chgrp', 'perms' => 'chmod');
1137
+							$cmd = array('EGroupware\\Api\\Vfs', $name2cmd[$name]);
1140 1138
 							$value = $name == 'perms' ? static::perms2mode($content['perms']) : $content[$name];
1141 1139
 							if ($content['modify_subs'])
1142 1140
 							{
1143 1141
 								if ($name == 'perms')
1144 1142
 								{
1145
-									$changed = Vfs::find($path,array('type'=>'d'),$cmd,array($value));
1146
-									$changed += Vfs::find($path,array('type'=>'f'),$cmd,array($value & 0666));	// no execute for files
1143
+									$changed = Vfs::find($path, array('type'=>'d'), $cmd, array($value));
1144
+									$changed += Vfs::find($path, array('type'=>'f'), $cmd, array($value&0666)); // no execute for files
1147 1145
 								}
1148 1146
 								else
1149 1147
 								{
1150
-									$changed = Vfs::find($path,null,$cmd,array($value));
1148
+									$changed = Vfs::find($path, null, $cmd, array($value));
1151 1149
 								}
1152 1150
 								$ok = $failed = 0;
1153
-								foreach($changed as &$r)
1151
+								foreach ($changed as &$r)
1154 1152
 								{
1155 1153
 									if ($r)
1156 1154
 									{
@@ -1163,32 +1161,32 @@  discard block
 block discarded – undo
1163 1161
 								}
1164 1162
 								if ($ok && !$failed)
1165 1163
 								{
1166
-									if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1164
+									if (!$perm_changed++) $msg .= lang('Permissions of %1 changed.', $path.' '.lang('and all it\'s childeren'));
1167 1165
 									$content['old'][$name] = $content[$name];
1168 1166
 								}
1169
-								elseif($failed)
1167
+								elseif ($failed)
1170 1168
 								{
1171
-									if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1172
-										($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : ''));
1169
+									if (!$perm_failed++) $msg .= lang('Failed to change permissions of %1!', $path.lang('and all it\'s childeren').
1170
+										($ok ? ' ('.lang('%1 failed, %2 succeded', $failed, $ok).')' : ''));
1173 1171
 								}
1174 1172
 							}
1175
-							elseif (call_user_func_array($cmd,array($path,$value)))
1173
+							elseif (call_user_func_array($cmd, array($path, $value)))
1176 1174
 							{
1177
-								$msg .= lang('Permissions of %1 changed.',$path);
1175
+								$msg .= lang('Permissions of %1 changed.', $path);
1178 1176
 								$content['old'][$name] = $content[$name];
1179 1177
 							}
1180 1178
 							else
1181 1179
 							{
1182
-								$msg .= lang('Failed to change permissions of %1!',$path);
1180
+								$msg .= lang('Failed to change permissions of %1!', $path);
1183 1181
 							}
1184 1182
 						}
1185 1183
 					}
1186 1184
 				}
1187 1185
 				if ($props)
1188 1186
 				{
1189
-					if (Vfs::proppatch($path,$props))
1187
+					if (Vfs::proppatch($path, $props))
1190 1188
 					{
1191
-						foreach($props as $prop)
1189
+						foreach ($props as $prop)
1192 1190
 						{
1193 1191
 							$content['old'][$prop['name']] = $prop['val'];
1194 1192
 						}
@@ -1205,8 +1203,8 @@  discard block
 block discarded – undo
1205 1203
 				if ($content['eacl']['delete'])
1206 1204
 				{
1207 1205
 					list($ino_owner) = each($content['eacl']['delete']);
1208
-					list(, $owner) = explode('-',$ino_owner,2);	// $owner is a group and starts with a minus!
1209
-					$msg .= Vfs::eacl($path,null,$owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!');
1206
+					list(, $owner) = explode('-', $ino_owner, 2); // $owner is a group and starts with a minus!
1207
+					$msg .= Vfs::eacl($path, null, $owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!');
1210 1208
 				}
1211 1209
 				elseif ($button == 'eacl')
1212 1210
 				{
@@ -1216,7 +1214,7 @@  discard block
 block discarded – undo
1216 1214
 					}
1217 1215
 					else
1218 1216
 					{
1219
-						$msg .= Vfs::eacl($path,$content['eacl']['rights'],$content['eacl_owner']) ?
1217
+						$msg .= Vfs::eacl($path, $content['eacl']['rights'], $content['eacl_owner']) ?
1220 1218
 							lang('ACL added.') : lang('Error adding the ACL!');
1221 1219
 					}
1222 1220
 				}
@@ -1226,7 +1224,7 @@  discard block
 block discarded – undo
1226 1224
 		}
1227 1225
 		if ($content['is_link'] && !Vfs::stat($path))
1228 1226
 		{
1229
-			$msg .= ($msg ? "\n" : '').lang('Link target %1 not found!',$content['symlink']);
1227
+			$msg .= ($msg ? "\n" : '').lang('Link target %1 not found!', $content['symlink']);
1230 1228
 		}
1231 1229
 		$content['link'] = Egw::link(Vfs::download_url($path));
1232 1230
 		$content['icon'] = Vfs::mime_icon($content['mime']);
@@ -1235,11 +1233,11 @@  discard block
 block discarded – undo
1235 1233
 		if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root';
1236 1234
 		// only owner can change group & perms
1237 1235
 		if (($readonlys['gid'] = !$content['is_owner'] ||
1238
-			Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs') ||// no uid, gid or perms in oldvfs
1236
+			Vfs::parse_url(Vfs::resolve_url($content['path']), PHP_URL_SCHEME) == 'oldvfs') || // no uid, gid or perms in oldvfs
1239 1237
 				 !Vfs::is_writable($path))
1240 1238
 		{
1241 1239
 			if (!$content['gid']) $content['ro_gid_root'] = 'root';
1242
-			foreach($content['perms'] as $name => $value)
1240
+			foreach ($content['perms'] as $name => $value)
1243 1241
 			{
1244 1242
 				$readonlys['perms['.$name.']'] = true;
1245 1243
 			}
@@ -1258,38 +1256,38 @@  discard block
 block discarded – undo
1258 1256
 		}
1259 1257
 		elseif (!Vfs::is_writable($path))
1260 1258
 		{
1261
-			foreach($cfs as $name => $data)
1259
+			foreach ($cfs as $name => $data)
1262 1260
 			{
1263 1261
 				$readonlys['#'.$name] = true;
1264 1262
 			}
1265 1263
 		}
1266
-		$readonlys['tabs']['filemanager.file.eacl'] = true;	// eacl off by default
1264
+		$readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default
1267 1265
 		if ($content['is_dir'])
1268 1266
 		{
1269
-			$readonlys['tabs']['filemanager.file.preview'] = true;	// no preview tab for dirs
1270
-			$sel_options['rights']=$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array(
1267
+			$readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs
1268
+			$sel_options['rights'] = $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array(
1271 1269
 				7 => lang('Display and modification of content'),
1272 1270
 				5 => lang('Display of content'),
1273 1271
 				0 => lang('No access'),
1274 1272
 			);
1275
-			if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false &&	// backend supports eacl
1273
+			if (($content['eacl'] = Vfs::get_eacl($content['path'])) !== false && // backend supports eacl
1276 1274
 				$GLOBALS['egw_info']['user']['account_id'] == Vfs::$user)	// leave eACL tab disabled for sharing
1277 1275
 			{
1278
-				unset($readonlys['tabs']['filemanager.file.eacl']);	// --> switch the tab on again
1279
-				foreach($content['eacl'] as &$eacl)
1276
+				unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again
1277
+				foreach ($content['eacl'] as &$eacl)
1280 1278
 				{
1281
-					$eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/');
1279
+					$eacl['path'] = rtrim(Vfs::parse_url($eacl['path'], PHP_URL_PATH), '/');
1282 1280
 					$readonlys['delete['.$eacl['ino'].'-'.$eacl['owner'].']'] = $eacl['ino'] != $content['ino'] ||
1283 1281
 						$eacl['path'] != $content['path'] || !$content['is_owner'];
1284 1282
 				}
1285
-				array_unshift($content['eacl'],false);	// make the keys start with 1, not 0
1283
+				array_unshift($content['eacl'], false); // make the keys start with 1, not 0
1286 1284
 				$content['eacl']['owner'] = 0;
1287 1285
 				$content['eacl']['rights'] = 5;
1288 1286
 			}
1289 1287
 		}
1290 1288
 		else
1291 1289
 		{
1292
-			$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array(
1290
+			$sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array(
1293 1291
 				6 => lang('Read & write access'),
1294 1292
 				4 => lang('Read access only'),
1295 1293
 				0 => lang('No access'),
@@ -1299,11 +1297,11 @@  discard block
 block discarded – undo
1299 1297
 		// mergeapp
1300 1298
 		$content['mergeapp'] = static::get_mergeapp($path, 'self');
1301 1299
 		$content['mergeapp_parent'] = static::get_mergeapp($path, 'parents');
1302
-		if(!empty($content['mergeapp']))
1300
+		if (!empty($content['mergeapp']))
1303 1301
 		{
1304 1302
 			$content['mergeapp_effective'] = $content['mergeapp'];
1305 1303
 		}
1306
-		elseif(!empty($content['mergeapp_parent']))
1304
+		elseif (!empty($content['mergeapp_parent']))
1307 1305
 		{
1308 1306
 			$content['mergeapp_effective'] = $content['mergeapp_parent'];
1309 1307
 		}
@@ -1315,7 +1313,7 @@  discard block
 block discarded – undo
1315 1313
 		$mergeapp_list = Link::app_list('merge');
1316 1314
 		unset($mergeapp_list[$GLOBALS['egw_info']['flags']['currentapp']]); // exclude filemanager from list
1317 1315
 		$mergeapp_empty = !empty($content['mergeapp_parent'])
1318
-			? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : '';
1316
+			? $mergeapp_list[$content['mergeapp_parent']].' (parent setting)' : '';
1319 1317
 		$sel_options['mergeapp'] = array(''	=> $mergeapp_empty);
1320 1318
 		$sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list;
1321 1319
 		// mergeapp other gui options
@@ -1332,7 +1330,7 @@  discard block
 block discarded – undo
1332 1330
 				'comment' => (string)$content['comment'],
1333 1331
 				'mergeapp' => $content['mergeapp']
1334 1332
 			);
1335
-			if ($cfs) foreach($cfs as $name => $data)
1333
+			if ($cfs) foreach ($cfs as $name => $data)
1336 1334
 			{
1337 1335
 				$preserve['old']['#'.$name] = (string)$content['#'.$name];
1338 1336
 			}
@@ -1340,31 +1338,31 @@  discard block
 block discarded – undo
1340 1338
 		if (Vfs::$is_root)
1341 1339
 		{
1342 1340
 			$tpl->setElementAttribute('sudouser', 'label', 'Logout');
1343
-			$tpl->setElementAttribute('sudouser', 'help','Log out as superuser');
1341
+			$tpl->setElementAttribute('sudouser', 'help', 'Log out as superuser');
1344 1342
 			// Need a more complex submit because button type is buttononly, which doesn't submit
1345
-			$tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")');
1343
+			$tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"login")');
1346 1344
 
1347 1345
 		}
1348 1346
 		elseif ($button == 'sudo')
1349 1347
 		{
1350 1348
 			$tpl->setElementAttribute('sudouser', 'label', 'Superuser');
1351
-			$tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights');
1352
-			$tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")');
1349
+			$tpl->setElementAttribute('sudouser', 'help', 'Enter setup user and password to get root rights');
1350
+			$tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"logout")');
1353 1351
 		}
1354 1352
 		else if (self::is_anonymous($GLOBALS['egw_info']['user']['account_id']))
1355 1353
 		{
1356 1354
 			// Just hide sudo for anonymous users
1357 1355
 			$readonlys['sudouser'] = true;
1358 1356
 		}
1359
-		if (($extra_tabs = Vfs::getExtraInfo($path,$content)))
1357
+		if (($extra_tabs = Vfs::getExtraInfo($path, $content)))
1360 1358
 		{
1361 1359
 			// add to existing tabs in template
1362 1360
 			$tpl->setElementAttribute('tabs', 'add_tabs', true);
1363 1361
 
1364
-			$tabs =& $tpl->getElementAttribute('tabs','tabs');
1362
+			$tabs = & $tpl->getElementAttribute('tabs', 'tabs');
1365 1363
 			if (true) $tabs = array();
1366 1364
 
1367
-			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1365
+			foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1368 1366
 			{
1369 1367
 				$tabs[] = array(
1370 1368
 					'label' =>	$extra_tab['label'],
@@ -1387,7 +1385,7 @@  discard block
 block discarded – undo
1387 1385
 		Framework::window_focus();
1388 1386
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.Vfs::decodePath($path);
1389 1387
 
1390
-		$tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2);
1388
+		$tpl->exec('filemanager.filemanager_ui.file', $content, $sel_options, $readonlys, $preserve, 2);
1391 1389
 	}
1392 1390
 
1393 1391
 	/**
@@ -1410,7 +1408,7 @@  discard block
 block discarded – undo
1410 1408
 		$remove = array(
1411 1409
 			'delete'
1412 1410
 		);
1413
-		foreach($remove as $key)
1411
+		foreach ($remove as $key)
1414 1412
 		{
1415 1413
 			unset($actions[$key]);
1416 1414
 		}
@@ -1424,7 +1422,7 @@  discard block
 block discarded – undo
1424 1422
 	 * @param string $dir=null current directory
1425 1423
 	 * @see static::action()
1426 1424
 	 */
1427
-	public static function ajax_action($action, $selected, $dir=null, $props=null)
1425
+	public static function ajax_action($action, $selected, $dir = null, $props = null)
1428 1426
 	{
1429 1427
 		// do we have root rights, need to run here too, as method is static and therefore does NOT run __construct
1430 1428
 		if (Api\Cache::getSession('filemanager', 'is_root'))
@@ -1443,15 +1441,15 @@  discard block
 block discarded – undo
1443 1441
 
1444 1442
 		if (!isset($dir)) $dir = array_pop($selected);
1445 1443
 
1446
-		switch($action)
1444
+		switch ($action)
1447 1445
 		{
1448 1446
 			case 'upload':
1449 1447
 				$script_error = 0;
1450
-				foreach($selected as $tmp_name => &$data)
1448
+				foreach ($selected as $tmp_name => &$data)
1451 1449
 				{
1452 1450
 					$path = Vfs::concat($dir, Vfs::encodePathComponent($data['name']));
1453 1451
 
1454
-					if(Vfs::deny_script($path))
1452
+					if (Vfs::deny_script($path))
1455 1453
 					{
1456 1454
 						if (!isset($script_error))
1457 1455
 						{
@@ -1473,7 +1471,7 @@  discard block
 block discarded – undo
1473 1471
 					{
1474 1472
 						if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
1475 1473
 						{
1476
-							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name);
1474
+							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmp_name);
1477 1475
 						}
1478 1476
 						else
1479 1477
 						{
@@ -1505,7 +1503,7 @@  discard block
 block discarded – undo
1505 1503
 				break;
1506 1504
 
1507 1505
 			case 'sharelink':
1508
-				$share = Vfs\Sharing::create($selected, Vfs\Sharing::READONLY, basename($selected), array() );
1506
+				$share = Vfs\Sharing::create($selected, Vfs\Sharing::READONLY, basename($selected), array());
1509 1507
 				$arr["share_link"] = $link = Vfs\Sharing::share2link($share);
1510 1508
 				$arr["template"] = Api\Etemplate\Widget\Template::rel2url('/filemanager/templates/default/share_dialog.xet');
1511 1509
 				break;
@@ -1514,16 +1512,16 @@  discard block
 block discarded – undo
1514 1512
 			case 'link':
1515 1513
 				// First upload
1516 1514
 				$arr = static::ajax_action('upload', $selected, $dir, $props);
1517
-				$app_dir = Link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true);
1515
+				$app_dir = Link::vfs_path($props['entry']['app'], $props['entry']['id'], '', true);
1518 1516
 
1519
-				foreach($arr['uploaded'] as $file)
1517
+				foreach ($arr['uploaded'] as $file)
1520 1518
 				{
1521
-					$target=Vfs::concat($dir,Vfs::encodePathComponent($file['name']));
1519
+					$target = Vfs::concat($dir, Vfs::encodePathComponent($file['name']));
1522 1520
 					if (Vfs::file_exists($target) && $app_dir)
1523 1521
 					{
1524 1522
 						if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir);
1525 1523
 						error_log("Symlinking $target to $app_dir");
1526
-						Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name'])));
1524
+						Vfs::symlink($target, Vfs::concat($app_dir, Vfs::encodePathComponent($file['name'])));
1527 1525
 					}
1528 1526
 				}
1529 1527
 				// Must return to avoid adding to $response again
@@ -1545,7 +1543,7 @@  discard block
 block discarded – undo
1545 1543
 	 */
1546 1544
 	private function perms2mode(array $perms)
1547 1545
 	{
1548
-		$mode = $perms['owner'] << 6 | $perms['group'] << 3 | $perms['other'];
1546
+		$mode = $perms['owner'] << 6|$perms['group'] << 3|$perms['other'];
1549 1547
 		if ($mode['executable'])
1550 1548
 		{
1551 1549
 			$mode |= 0111;
Please login to merge, or discard this patch.
api/src/Vfs.php 1 patch
Spacing   +289 added lines, -294 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @param resource $context =null context to pass to stream-wrapper
146 146
 	 * @return resource
147 147
 	 */
148
-	static function fopen($path, $mode, $context=null)
148
+	static function fopen($path, $mode, $context = null)
149 149
 	{
150 150
 		if ($path[0] != '/')
151 151
 		{
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @param resource $context =null context to pass to stream-wrapper
162 162
 	 * @return resource
163 163
 	 */
164
-	static function opendir($path, $context=null)
164
+	static function opendir($path, $context = null)
165 165
 	{
166 166
 		if ($path[0] != '/')
167 167
 		{
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
 	 * @param int $sorting_order =0 !$sorting_order (default) alphabetical in ascending order, $sorting_order alphabetical in descending order.
193 193
 	 * @return array
194 194
 	 */
195
-	static function scandir($path,$sorting_order=0)
195
+	static function scandir($path, $sorting_order = 0)
196 196
 	{
197 197
 		if ($path[0] != '/')
198 198
 		{
199 199
 			throw new Exception\AssertionFailed("Directory '$path' is not an absolute path!");
200 200
 		}
201
-		return scandir(self::PREFIX.$path,$sorting_order);
201
+		return scandir(self::PREFIX.$path, $sorting_order);
202 202
 	}
203 203
 
204 204
 	/**
@@ -208,25 +208,25 @@  discard block
 block discarded – undo
208 208
 	 * @param string $to
209 209
 	 * @return boolean
210 210
 	 */
211
-	static function copy($from,$to)
211
+	static function copy($from, $to)
212 212
 	{
213
-		$old_props = self::file_exists($to) ? self::propfind($to,null) : array();
213
+		$old_props = self::file_exists($to) ? self::propfind($to, null) : array();
214 214
 		// copy properties (eg. file comment), if there are any and evtl. existing old properties
215
-		$props = self::propfind($from,null);
216
-		if(!$props)
215
+		$props = self::propfind($from, null);
216
+		if (!$props)
217 217
 		{
218 218
 			$props = array();
219 219
 		}
220
-		foreach($old_props as $prop)
220
+		foreach ($old_props as $prop)
221 221
 		{
222
-			if (!self::find_prop($props,$prop))
222
+			if (!self::find_prop($props, $prop))
223 223
 			{
224
-				$prop['val'] = null;	// null = delete prop
224
+				$prop['val'] = null; // null = delete prop
225 225
 				$props[] = $prop;
226 226
 			}
227 227
 		}
228 228
 		// using self::copy_uploaded() to treat copying incl. properties as atomar operation in respect of notifications
229
-		return self::copy_uploaded(self::PREFIX.$from,$to,$props,false);	// false = no is_uploaded_file check!
229
+		return self::copy_uploaded(self::PREFIX.$from, $to, $props, false); // false = no is_uploaded_file check!
230 230
 	}
231 231
 
232 232
 	/**
@@ -237,14 +237,14 @@  discard block
 block discarded – undo
237 237
 	 * @param string $ns =self::DEFAULT_PROP_NAMESPACE namespace, only if $prop is no array
238 238
 	 * @return &array reference to property in $props or null if not found
239 239
 	 */
240
-	static function &find_prop(array &$props,$name,$ns=self::DEFAULT_PROP_NAMESPACE)
240
+	static function &find_prop(array &$props, $name, $ns = self::DEFAULT_PROP_NAMESPACE)
241 241
 	{
242 242
 		if (is_array($name))
243 243
 		{
244 244
 			$ns = $name['ns'];
245 245
 			$name = $name['name'];
246 246
 		}
247
-		foreach($props as &$prop)
247
+		foreach ($props as &$prop)
248 248
 		{
249 249
 			if ($prop['name'] == $name && $prop['ns'] == $ns) return $prop;
250 250
 		}
@@ -258,16 +258,16 @@  discard block
 block discarded – undo
258 258
 	 * @param boolean $try_create_home =false should a non-existing home-directory be automatically created
259 259
 	 * @return array
260 260
 	 */
261
-	static function stat($path,$try_create_home=false)
261
+	static function stat($path, $try_create_home = false)
262 262
 	{
263 263
 		if ($path[0] != '/' && strpos($path, self::PREFIX.'/') !== 0)
264 264
 		{
265 265
 			throw new Exception\AssertionFailed("File '$path' is not an absolute path!");
266 266
 		}
267 267
 		$vfs = new Vfs\StreamWrapper();
268
-		if (($stat = $vfs->url_stat($path,0,$try_create_home)))
268
+		if (($stat = $vfs->url_stat($path, 0, $try_create_home)))
269 269
 		{
270
-			$stat = array_slice($stat,13);	// remove numerical indices 0-12
270
+			$stat = array_slice($stat, 13); // remove numerical indices 0-12
271 271
 		}
272 272
 		return $stat;
273 273
 	}
@@ -279,16 +279,16 @@  discard block
 block discarded – undo
279 279
 	 * @param boolean $try_create_home =false should a non-existing home-directory be automatically created
280 280
 	 * @return array
281 281
 	 */
282
-	static function lstat($path,$try_create_home=false)
282
+	static function lstat($path, $try_create_home = false)
283 283
 	{
284 284
 		if ($path[0] != '/' && strpos($path, self::PREFIX.'/') !== 0)
285 285
 		{
286 286
 			throw new Exception\AssertionFailed("File '$path' is not an absolute path!");
287 287
 		}
288 288
 		$vfs = new Vfs\StreamWrapper();
289
-		if (($stat = $vfs->url_stat($path,STREAM_URL_STAT_LINK,$try_create_home)))
289
+		if (($stat = $vfs->url_stat($path, STREAM_URL_STAT_LINK, $try_create_home)))
290 290
 		{
291
-			$stat = array_slice($stat,13);	// remove numerical indices 0-12
291
+			$stat = array_slice($stat, 13); // remove numerical indices 0-12
292 292
 		}
293 293
 		return $stat;
294 294
 	}
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	 * @param boolean $clear_fstab =false true clear current fstab, false (default) only add given mount
340 340
 	 * @return array|boolean array with fstab, if called without parameter or true on successful mount
341 341
 	 */
342
-	static function mount($url=null,$path=null,$check_url=null,$persitent_mount=true,$clear_fstab=false)
342
+	static function mount($url = null, $path = null, $check_url = null, $persitent_mount = true, $clear_fstab = false)
343 343
 	{
344 344
 		return Vfs\StreamWrapper::mount($url, $path, $check_url, $persitent_mount, $clear_fstab);
345 345
 	}
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 	 * @param boolean $allow_versions =false allow .versions or .attic
373 373
 	 * @return boolean
374 374
 	 */
375
-	public static function is_hidden($path, $allow_versions=false)
375
+	public static function is_hidden($path, $allow_versions = false)
376 376
 	{
377 377
 		$file = self::basename($path);
378 378
 
@@ -408,30 +408,30 @@  discard block
 block discarded – undo
408 408
 	 * @param array $exec_params =null further params for exec as array, path is always the first param and stat the last!
409 409
 	 * @return array of pathes if no $exec, otherwise path => stat pairs
410 410
 	 */
411
-	static function find($base,$options=null,$exec=null,$exec_params=null)
411
+	static function find($base, $options = null, $exec = null, $exec_params = null)
412 412
 	{
413 413
 		//error_log(__METHOD__."(".print_r($base,true).",".print_r($options,true).",".print_r($exec,true).",".print_r($exec_params,true).")\n");
414 414
 
415
-		$type = $options['type'];	// 'd', 'f' or 'F'
416
-		$dirs_last = $options['depth'];	// put content of dirs before the dir itself
415
+		$type = $options['type']; // 'd', 'f' or 'F'
416
+		$dirs_last = $options['depth']; // put content of dirs before the dir itself
417 417
 		// show dirs on top by default, if no recursive listing (allways disabled if $type specified, as unnecessary)
418
-		$dirsontop = !$type && (isset($options['dirsontop']) ? (boolean)$options['dirsontop'] : isset($options['maxdepth'])&&$options['maxdepth']>0);
419
-		if ($dirsontop) $options['need_mime'] = true;	// otherwise dirsontop can NOT work
418
+		$dirsontop = !$type && (isset($options['dirsontop']) ? (boolean)$options['dirsontop'] : isset($options['maxdepth']) && $options['maxdepth'] > 0);
419
+		if ($dirsontop) $options['need_mime'] = true; // otherwise dirsontop can NOT work
420 420
 
421 421
 		// process some of the options (need to be done only once)
422 422
 		if (isset($options['name']) && !isset($options['name_preg']))	// change from simple *,? wildcards to preg regular expression once
423 423
 		{
424
-			$options['name_preg'] = '/^'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($options['name'])).'$/i';
424
+			$options['name_preg'] = '/^'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($options['name'])).'$/i';
425 425
 		}
426 426
 		if (isset($options['path']) && !isset($options['preg_path']))	// change from simple *,? wildcards to preg regular expression once
427 427
 		{
428
-			$options['path_preg'] = '/^'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($options['path'])).'$/i';
428
+			$options['path_preg'] = '/^'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($options['path'])).'$/i';
429 429
 		}
430 430
 		if (!isset($options['uid']))
431 431
 		{
432 432
 			if (isset($options['user']))
433 433
 			{
434
-				$options['uid'] = $GLOBALS['egw']->accounts->name2id($options['user'],'account_lid','u');
434
+				$options['uid'] = $GLOBALS['egw']->accounts->name2id($options['user'], 'account_lid', 'u');
435 435
 			}
436 436
 			elseif (isset($options['nouser']))
437 437
 			{
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 		{
443 443
 			if (isset($options['group']))
444 444
 			{
445
-				$options['gid'] = abs($GLOBALS['egw']->accounts->name2id($options['group'],'account_lid','g'));
445
+				$options['gid'] = abs($GLOBALS['egw']->accounts->name2id($options['group'], 'account_lid', 'g'));
446 446
 			}
447 447
 			elseif (isset($options['nogroup']))
448 448
 			{
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 		}
452 452
 		if ($options['order'] == 'mime')
453 453
 		{
454
-			$options['need_mime'] = true;	// we need to return the mime colum
454
+			$options['need_mime'] = true; // we need to return the mime colum
455 455
 		}
456 456
 		// implicit show deleted files, if hidden is enabled (requires versioning!)
457 457
 		if (!empty($options['hidden']) && !isset($options['show-deleted']))
@@ -469,37 +469,37 @@  discard block
 block discarded – undo
469 469
 			$base = array($base);
470 470
 		}
471 471
 		$result = array();
472
-		foreach($base as $path)
472
+		foreach ($base as $path)
473 473
 		{
474 474
 			if (!$url)
475 475
 			{
476 476
 				if ($path[0] != '/' || !self::stat($path)) continue;
477
-				$path = self::PREFIX . $path;
477
+				$path = self::PREFIX.$path;
478 478
 			}
479 479
 			if (!isset($options['remove']))
480 480
 			{
481
-				$options['remove'] = count($base) == 1 ? count(explode('/',$path))-3+(int)(substr($path,-1)!='/') : 0;
481
+				$options['remove'] = count($base) == 1 ? count(explode('/', $path)) - 3 + (int)(substr($path, -1) != '/') : 0;
482 482
 			}
483 483
 			$is_dir = is_dir($path);
484 484
 			if ((int)$options['mindepth'] == 0 && (!$dirs_last || !$is_dir))
485 485
 			{
486
-				self::_check_add($options,$path,$result);
486
+				self::_check_add($options, $path, $result);
487 487
 			}
488 488
 			if ($is_dir && (!isset($options['maxdepth']) || ($options['maxdepth'] > 0 &&
489 489
 				$options['depth'] < $options['maxdepth'])) &&
490 490
 				($dir = @opendir($path, $context)))
491 491
 			{
492
-				while(($fname = readdir($dir)) !== false)
492
+				while (($fname = readdir($dir)) !== false)
493 493
 				{
494
-					if ($fname == '.' || $fname == '..') continue;	// ignore current and parent dir!
494
+					if ($fname == '.' || $fname == '..') continue; // ignore current and parent dir!
495 495
 
496
-					if (self::is_hidden($fname, $options['show-deleted']) && !$options['hidden']) continue;	// ignore hidden files
496
+					if (self::is_hidden($fname, $options['show-deleted']) && !$options['hidden']) continue; // ignore hidden files
497 497
 
498 498
 					$file = self::concat($path, $fname);
499 499
 
500 500
 					if ((int)$options['mindepth'] <= 1)
501 501
 					{
502
-						self::_check_add($options,$file,$result);
502
+						self::_check_add($options, $file, $result);
503 503
 					}
504 504
 					// only descend into subdirs, if it's a real dir (no link to a dir) or we should follow symlinks
505 505
 					if (is_dir($file) && ($options['follow'] || !is_link($file)) && (!isset($options['maxdepth']) || $options['maxdepth'] > 1))
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 						if ($opts['maxdepth']) $opts['depth']++;
510 510
 						unset($opts['order']);
511 511
 						unset($opts['limit']);
512
-						foreach(self::find($options['url']?$file:self::parse_url($file,PHP_URL_PATH),$opts,true) as $p => $s)
512
+						foreach (self::find($options['url'] ? $file : self::parse_url($file, PHP_URL_PATH), $opts, true) as $p => $s)
513 513
 						{
514 514
 							unset($result[$p]);
515 515
 							$result[$p] = $s;
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 			}
521 521
 			if ($is_dir && (int)$options['mindepth'] == 0 && $dirs_last)
522 522
 			{
523
-				self::_check_add($options,$path,$result);
523
+				self::_check_add($options, $path, $result);
524 524
 			}
525 525
 		}
526 526
 		// sort code, to place directories before files, if $dirsontop enabled
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 		if (isset($options['order']))
531 531
 		{
532 532
 			$sort = strtolower($options['sort']) == 'desc' ? '-' : '';
533
-			switch($options['order'])
533
+			switch ($options['order'])
534 534
 			{
535 535
 				// sort numerical
536 536
 				case 'size':
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 					$code = $dirsfirst.$sort.'($a[\''.$options['order'].'\']-$b[\''.$options['order'].'\']);';
543 543
 					// always use name as second sort criteria
544 544
 					$code = '$cmp = '.$code.' return $cmp ? $cmp : strcasecmp($a[\'name\'],$b[\'name\']);';
545
-					$ok = uasort($result,create_function('$a,$b',$code));
545
+					$ok = uasort($result, create_function('$a,$b', $code));
546 546
 					break;
547 547
 
548 548
 				// sort alphanumerical
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 					{
562 562
 						$code = 'return '.$code;
563 563
 					}
564
-					$ok = uasort($result,create_function('$a,$b',$code));
564
+					$ok = uasort($result, create_function('$a,$b', $code));
565 565
 					break;
566 566
 			}
567 567
 			//echo "<p>order='$options[order]', sort='$options[sort]' --> uasort($result,create_function(,'$code'))=".array2string($ok)."</p>>\n";
@@ -570,13 +570,13 @@  discard block
 block discarded – undo
570 570
 		self::$find_total = count($result);
571 571
 		if (isset($options['limit']))
572 572
 		{
573
-			list($limit,$start) = explode(',',$options['limit']);
573
+			list($limit, $start) = explode(',', $options['limit']);
574 574
 			if (!$limit && !($limit = $GLOBALS['egw_info']['user']['preferences']['comman']['maxmatches'])) $limit = 15;
575 575
 			//echo "total=".self::$find_total.", limit=$options[limit] --> start=$start, limit=$limit<br>\n";
576 576
 
577 577
 			if ((int)$start || self::$find_total > $limit)
578 578
 			{
579
-				$result = array_slice($result,(int)$start,(int)$limit,true);
579
+				$result = array_slice($result, (int)$start, (int)$limit, true);
580 580
 			}
581 581
 		}
582 582
 		//echo $path; _debug_array($result);
@@ -586,13 +586,13 @@  discard block
 block discarded – undo
586 586
 			{
587 587
 				$exec_params = is_null($exec_params) ? array() : array($exec_params);
588 588
 			}
589
-			foreach($result as $path => &$stat)
589
+			foreach ($result as $path => &$stat)
590 590
 			{
591 591
 				$options = $exec_params;
592
-				array_unshift($options,$path);
593
-				array_push($options,$stat);
592
+				array_unshift($options, $path);
593
+				array_push($options, $stat);
594 594
 				//echo "calling ".print_r($exec,true).print_r($options,true)."\n";
595
-				$stat = call_user_func_array($exec,$options);
595
+				$stat = call_user_func_array($exec, $options);
596 596
 			}
597 597
 			return $result;
598 598
 		}
@@ -611,15 +611,15 @@  discard block
 block discarded – undo
611 611
 	 * @param string $path name of path to add
612 612
 	 * @param array &$result here we add the stat for the key $path, if the checks are successful
613 613
 	 */
614
-	private static function _check_add($options,$path,&$result)
614
+	private static function _check_add($options, $path, &$result)
615 615
 	{
616
-		$type = $options['type'];	// 'd' or 'f'
616
+		$type = $options['type']; // 'd' or 'f'
617 617
 
618 618
 		if ($options['url'])
619 619
 		{
620 620
 			if (($stat = @lstat($path)))
621 621
 			{
622
-				$stat = array_slice($stat,13);	// remove numerical indices 0-12
622
+				$stat = array_slice($stat, 13); // remove numerical indices 0-12
623 623
 			}
624 624
 		}
625 625
 		else
@@ -628,30 +628,30 @@  discard block
 block discarded – undo
628 628
 		}
629 629
 		if (!$stat)
630 630
 		{
631
-			return;	// not found, should not happen
631
+			return; // not found, should not happen
632 632
 		}
633
-		if ($type && (($type == 'd') == !($stat['mode'] & Vfs\Sqlfs\StreamWrapper::MODE_DIR) ||	// != is_dir() which can be true for symlinks
633
+		if ($type && (($type == 'd') == !($stat['mode']&Vfs\Sqlfs\StreamWrapper::MODE_DIR) || // != is_dir() which can be true for symlinks
634 634
 		    $type == 'F' && is_dir($path)))	// symlink to a directory
635 635
 		{
636
-			return;	// wrong type
636
+			return; // wrong type
637 637
 		}
638
-		$stat['path'] = self::parse_url($path,PHP_URL_PATH);
639
-		$stat['name'] = $options['remove'] > 0 ? implode('/',array_slice(explode('/',$stat['path']),$options['remove'])) : self::basename($path);
638
+		$stat['path'] = self::parse_url($path, PHP_URL_PATH);
639
+		$stat['name'] = $options['remove'] > 0 ? implode('/', array_slice(explode('/', $stat['path']), $options['remove'])) : self::basename($path);
640 640
 
641 641
 		if ($options['mime'] || $options['need_mime'])
642 642
 		{
643 643
 			$stat['mime'] = self::mime_content_type($path);
644 644
 		}
645
-		if (isset($options['name_preg']) && !preg_match($options['name_preg'],$stat['name']) ||
646
-			isset($options['path_preg']) && !preg_match($options['path_preg'],$path))
645
+		if (isset($options['name_preg']) && !preg_match($options['name_preg'], $stat['name']) ||
646
+			isset($options['path_preg']) && !preg_match($options['path_preg'], $path))
647 647
 		{
648 648
 			//echo "<p>!preg_match('{$options['name_preg']}','{$stat['name']}')</p>\n";
649
-			return;	// wrong name or path
649
+			return; // wrong name or path
650 650
 		}
651 651
 		if (isset($options['gid']) && $stat['gid'] != $options['gid'] ||
652 652
 			isset($options['uid']) && $stat['uid'] != $options['uid'])
653 653
 		{
654
-			return;	// wrong user or group
654
+			return; // wrong user or group
655 655
 		}
656 656
 		if (isset($options['mime']) && $options['mime'] != $stat['mime'])
657 657
 		{
@@ -659,40 +659,40 @@  discard block
 block discarded – undo
659 659
 			{
660 660
 				if (!preg_match($options['mime'], $stat['mime']))
661 661
 				{
662
-					return;	// wrong mime-type
662
+					return; // wrong mime-type
663 663
 				}
664 664
 			}
665 665
 			else
666 666
 			{
667
-				list($type,$subtype) = explode('/',$options['mime']);
667
+				list($type, $subtype) = explode('/', $options['mime']);
668 668
 				// no subtype (eg. 'image') --> check only the main type
669
-				if ($subtype || substr($stat['mime'],0,strlen($type)+1) != $type.'/')
669
+				if ($subtype || substr($stat['mime'], 0, strlen($type) + 1) != $type.'/')
670 670
 				{
671
-					return;	// wrong mime-type
671
+					return; // wrong mime-type
672 672
 				}
673 673
 			}
674 674
 		}
675
-		if (isset($options['size']) && !self::_check_num($stat['size'],$options['size']) ||
675
+		if (isset($options['size']) && !self::_check_num($stat['size'], $options['size']) ||
676 676
 			(isset($options['empty']) && !!$options['empty'] !== !$stat['size']))
677 677
 		{
678
-			return;	// wrong size
678
+			return; // wrong size
679 679
 		}
680
-		if (isset($options['cmin']) && !self::_check_num(round((time()-$stat['ctime'])/60),$options['cmin']) ||
681
-			isset($options['mmin']) && !self::_check_num(round((time()-$stat['mtime'])/60),$options['mmin']) ||
682
-			isset($options['ctime']) && !self::_check_num(round((time()-$stat['ctime'])/86400),$options['ctime']) ||
683
-			isset($options['mtime']) && !self::_check_num(round((time()-$stat['mtime'])/86400),$options['mtime']))
680
+		if (isset($options['cmin']) && !self::_check_num(round((time() - $stat['ctime']) / 60), $options['cmin']) ||
681
+			isset($options['mmin']) && !self::_check_num(round((time() - $stat['mtime']) / 60), $options['mmin']) ||
682
+			isset($options['ctime']) && !self::_check_num(round((time() - $stat['ctime']) / 86400), $options['ctime']) ||
683
+			isset($options['mtime']) && !self::_check_num(round((time() - $stat['mtime']) / 86400), $options['mtime']))
684 684
 		{
685
-			return;	// not create/modified in the spezified time
685
+			return; // not create/modified in the spezified time
686 686
 		}
687 687
 		// do we return url or just vfs pathes
688 688
 		if (!$options['url'])
689 689
 		{
690
-			$path = self::parse_url($path,PHP_URL_PATH);
690
+			$path = self::parse_url($path, PHP_URL_PATH);
691 691
 		}
692 692
 		$result[$path] = $stat;
693 693
 	}
694 694
 
695
-	private static function _check_num($value,$argument)
695
+	private static function _check_num($value, $argument)
696 696
 	{
697 697
 		if (is_int($argument) && $argument >= 0 || $argument[0] != '-' && $argument[0] != '+')
698 698
 		{
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 			return $value < abs($argument);
706 706
 		}
707 707
 		//echo "_check_num($value,$argument) check > == ".(int)($value > (int)substr($argument,1))."\n";
708
-		return $value > (int) substr($argument,1);
708
+		return $value > (int)substr($argument, 1);
709 709
 	}
710 710
 
711 711
 	/**
@@ -735,10 +735,10 @@  discard block
 block discarded – undo
735 735
 	 * @throws Vfs\Exception\ProtectedDirectory if trying to delete a protected directory, see Vfs::isProtected()
736 736
 	 * @return array
737 737
 	 */
738
-	static function remove($urls,$allow_urls=false)
738
+	static function remove($urls, $allow_urls = false)
739 739
 	{
740 740
 		//error_log(__METHOD__.'('.array2string($urls).')');
741
-		foreach((array)$urls as $url)
741
+		foreach ((array)$urls as $url)
742 742
 		{
743 743
 			// some precaution to never allow to (recursivly) remove /, /apps or /home, see Vfs::isProtected()
744 744
 			if (self::isProtectedDir($url))
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 				throw new Vfs\Exception\ProtectedDirectory("Deleting protected directory '$url' rejected!");
747 747
 			}
748 748
 		}
749
-		return self::find($urls, array('depth'=>true,'url'=>$allow_urls,'hidden'=>true), __CLASS__.'::_rm_rmdir');
749
+		return self::find($urls, array('depth'=>true, 'url'=>$allow_urls, 'hidden'=>true), __CLASS__.'::_rm_rmdir');
750 750
 	}
751 751
 
752 752
 	/**
@@ -759,12 +759,12 @@  discard block
 block discarded – undo
759 759
 	{
760 760
 		if ($url[0] == '/')
761 761
 		{
762
-			$url = self::PREFIX . $url;
762
+			$url = self::PREFIX.$url;
763 763
 		}
764 764
 		$vfs = new Vfs\StreamWrapper();
765 765
 		if (is_dir($url) && !is_link($url))
766 766
 		{
767
-			return $vfs->rmdir($url,0);
767
+			return $vfs->rmdir($url, 0);
768 768
 		}
769 769
 		return $vfs->unlink($url);
770 770
 	}
@@ -778,9 +778,9 @@  discard block
 block discarded – undo
778 778
 	 * 	2 = self::WRITABLE, 1 = self::EXECUTABLE
779 779
 	 * @return boolean
780 780
 	 */
781
-	static function is_readable($path,$check = self::READABLE)
781
+	static function is_readable($path, $check = self::READABLE)
782 782
 	{
783
-		return self::check_access($path,$check);
783
+		return self::check_access($path, $check);
784 784
 	}
785 785
 
786 786
 	/**
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 	 * @param int $user =null user used for check, if not current user (self::$user)
795 795
 	 * @return boolean
796 796
 	 */
797
-	static function check_access($path, $check, $stat=null, $user=null)
797
+	static function check_access($path, $check, $stat = null, $user = null)
798 798
 	{
799 799
 		static $vfs = null;
800 800
 
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 				if (!isset($vfs)) $vfs = new Vfs\StreamWrapper();
813 813
 				$path_user_stat[$path][$user] = $vfs->url_stat($path, 0);
814 814
 
815
-				self::clearstatcache($path);	// we need to clear the stat-cache after the call too, as the next call might be the regular user again!
815
+				self::clearstatcache($path); // we need to clear the stat-cache after the call too, as the next call might be the regular user again!
816 816
 			}
817 817
 			if (($stat = $path_user_stat[$path][$user]))
818 818
 			{
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 			}
829 829
 			else
830 830
 			{
831
-				$ret = false;	// no access, if we can not stat the file
831
+				$ret = false; // no access, if we can not stat the file
832 832
 			}
833 833
 			self::$user = $backup_user;
834 834
 
@@ -853,20 +853,20 @@  discard block
 block discarded – undo
853 853
 		if (is_null($stat))
854 854
 		{
855 855
 			if (!isset($vfs)) $vfs = new Vfs\StreamWrapper();
856
-			$stat = $vfs->url_stat($path,0);
856
+			$stat = $vfs->url_stat($path, 0);
857 857
 		}
858 858
 		//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check)");
859 859
 
860 860
 		if (!$stat)
861 861
 		{
862 862
 			//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check) no stat array!");
863
-			return false;	// file not found
863
+			return false; // file not found
864 864
 		}
865 865
 		// check if we use an EGroupwre stream wrapper, or a stock php one
866 866
 		// if it's not an EGroupware one, we can NOT use uid, gid and mode!
867
-		if (($scheme = self::parse_url($stat['url'],PHP_URL_SCHEME)) && !(class_exists(self::scheme2class($scheme))))
867
+		if (($scheme = self::parse_url($stat['url'], PHP_URL_SCHEME)) && !(class_exists(self::scheme2class($scheme))))
868 868
 		{
869
-			switch($check)
869
+			switch ($check)
870 870
 			{
871 871
 				case self::READABLE:
872 872
 					return is_readable($stat['url']);
@@ -877,19 +877,19 @@  discard block
 block discarded – undo
877 877
 			}
878 878
 		}
879 879
 		// check if other rights grant access
880
-		if (($stat['mode'] & $check) == $check)
880
+		if (($stat['mode']&$check) == $check)
881 881
 		{
882 882
 			//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check) access via other rights!");
883 883
 			return true;
884 884
 		}
885 885
 		// check if there's owner access and we are the owner
886
-		if (($stat['mode'] & ($check << 6)) == ($check << 6) && $stat['uid'] && $stat['uid'] == self::$user)
886
+		if (($stat['mode']&($check << 6)) == ($check << 6) && $stat['uid'] && $stat['uid'] == self::$user)
887 887
 		{
888 888
 			//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check) access via owner rights!");
889 889
 			return true;
890 890
 		}
891 891
 		// check if there's a group access and we have the right membership
892
-		if (($stat['mode'] & ($check << 3)) == ($check << 3) && $stat['gid'])
892
+		if (($stat['mode']&($check << 3)) == ($check << 3) && $stat['gid'])
893 893
 		{
894 894
 			if (($memberships = $GLOBALS['egw']->accounts->memberships(self::$user, true)) && in_array(-abs($stat['gid']), $memberships))
895 895
 			{
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 			}
899 899
 		}
900 900
 		// check backend for extended acls (only if path given)
901
-		$ret = $path && self::_call_on_backend('check_extended_acl',array(isset($stat['url'])?$stat['url']:$path,$check),true);	// true = fail silent if backend does not support
901
+		$ret = $path && self::_call_on_backend('check_extended_acl', array(isset($stat['url']) ? $stat['url'] : $path, $check), true); // true = fail silent if backend does not support
902 902
 
903 903
 		//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check) ".($ret ? 'backend extended acl granted access.' : 'no access!!!'));
904 904
 		return $ret;
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
 	 */
914 914
 	static function is_writable($path)
915 915
 	{
916
-		return self::is_readable($path,self::WRITABLE);
916
+		return self::is_readable($path, self::WRITABLE);
917 917
 	}
918 918
 
919 919
 	/**
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 	 */
926 926
 	static function is_executable($path)
927 927
 	{
928
-		return self::is_readable($path,self::EXECUTABLE);
928
+		return self::is_readable($path, self::EXECUTABLE);
929 929
 	}
930 930
 
931 931
 	/**
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 	 */
937 937
 	static function deny_script($path)
938 938
 	{
939
-		return self::_call_on_backend('deny_script',array($path),true);
939
+		return self::_call_on_backend('deny_script', array($path), true);
940 940
 	}
941 941
 
942 942
 	/**
@@ -955,11 +955,11 @@  discard block
 block discarded – undo
955 955
 	 * @param boolean $session_only =false true: set eacl only for this session, does NO further checks currently!
956 956
 	 * @return boolean true if acl is set/deleted, false on error
957 957
 	 */
958
-	static function eacl($url,$rights=null,$owner=null,$session_only=false)
958
+	static function eacl($url, $rights = null, $owner = null, $session_only = false)
959 959
 	{
960 960
 		if ($session_only)
961 961
 		{
962
-			$session_eacls =& Cache::getSession(__CLASS__, self::SESSION_EACL);
962
+			$session_eacls = & Cache::getSession(__CLASS__, self::SESSION_EACL);
963 963
 			$session_eacls[] = array(
964 964
 				'path'   => $url[0] == '/' ? $url : self::parse_url($url, PHP_URL_PATH),
965 965
 				'owner'  => $owner ? $owner : self::$user,
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
 			);
968 968
 			return true;
969 969
 		}
970
-		return self::_call_on_backend('eacl',array($url,$rights,$owner));
970
+		return self::_call_on_backend('eacl', array($url, $rights, $owner));
971 971
 	}
972 972
 
973 973
 	/**
@@ -980,9 +980,9 @@  discard block
 block discarded – undo
980 980
 	 */
981 981
 	static function get_eacl($path)
982 982
 	{
983
-		$eacls = self::_call_on_backend('get_eacl',array($path),true);	// true = fail silent (no PHP Warning)
983
+		$eacls = self::_call_on_backend('get_eacl', array($path), true); // true = fail silent (no PHP Warning)
984 984
 
985
-		$session_eacls =& Cache::getSession(__CLASS__, self::SESSION_EACL);
985
+		$session_eacls = & Cache::getSession(__CLASS__, self::SESSION_EACL);
986 986
 		if ($session_eacls)
987 987
 		{
988 988
 			// eacl is recursive, therefore we have to match all parent-dirs too
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 			{
992 992
 				$paths[] = $path = self::dirname($path);
993 993
 			}
994
-			foreach((array)$session_eacls as $eacl)
994
+			foreach ((array)$session_eacls as $eacl)
995 995
 			{
996 996
 				if (in_array($eacl['path'], $paths))
997 997
 				{
@@ -1014,9 +1014,9 @@  discard block
 block discarded – undo
1014 1014
 	 * @param array $props array of array with values for keys 'name', 'ns', 'val' (null to delete the prop)
1015 1015
 	 * @return boolean true if props are updated, false otherwise (eg. ressource not found)
1016 1016
 	 */
1017
-	static function proppatch($path,array $props)
1017
+	static function proppatch($path, array $props)
1018 1018
 	{
1019
-		return self::_call_on_backend('proppatch',array($path,$props));
1019
+		return self::_call_on_backend('proppatch', array($path, $props));
1020 1020
 	}
1021 1021
 
1022 1022
 	/**
@@ -1033,9 +1033,9 @@  discard block
 block discarded – undo
1033 1033
 	 * @return array|boolean array with props (values for keys 'name', 'ns', 'val'), or path => array of props for is_array($path)
1034 1034
 	 * 	false if $path does not exist
1035 1035
 	 */
1036
-	static function propfind($path,$ns=self::DEFAULT_PROP_NAMESPACE)
1036
+	static function propfind($path, $ns = self::DEFAULT_PROP_NAMESPACE)
1037 1037
 	{
1038
-		return self::_call_on_backend('propfind',array($path,$ns),true);	// true = fail silent (no PHP Warning)
1038
+		return self::_call_on_backend('propfind', array($path, $ns), true); // true = fail silent (no PHP Warning)
1039 1039
 	}
1040 1040
 
1041 1041
 	/**
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 	 * @param int $mode =0 current mode of the file, necessary for +/- operation
1054 1054
 	 * @return int
1055 1055
 	 */
1056
-	static function mode2int($set,$mode=0)
1056
+	static function mode2int($set, $mode = 0)
1057 1057
 	{
1058 1058
 		if (is_int($set))		// already an integer
1059 1059
 		{
@@ -1062,23 +1062,23 @@  discard block
 block discarded – undo
1062 1062
 		if (is_numeric($set))	// octal string
1063 1063
 		{
1064 1064
 			//error_log(__METHOD__."($set,$mode) returning ".(int)base_convert($set,8,10));
1065
-			return (int)base_convert($set,8,10);	// convert octal to decimal
1065
+			return (int)base_convert($set, 8, 10); // convert octal to decimal
1066 1066
 		}
1067
-		foreach(explode(',',$set) as $s)
1067
+		foreach (explode(',', $set) as $s)
1068 1068
 		{
1069 1069
 			$matches = null;
1070
-			if (!preg_match($use='/^([ugoa]*)([+=-]+)([rwx]+)$/',$s,$matches))
1070
+			if (!preg_match($use = '/^([ugoa]*)([+=-]+)([rwx]+)$/', $s, $matches))
1071 1071
 			{
1072
-				$use = str_replace(array('/','^','$','(',')'),'',$use);
1072
+				$use = str_replace(array('/', '^', '$', '(', ')'), '', $use);
1073 1073
 				throw new Exception\WrongUserinput("$s is not an allowed mode, use $use !");
1074 1074
 			}
1075
-			$base = (strpos($matches[3],'r') !== false ? self::READABLE : 0) |
1076
-				(strpos($matches[3],'w') !== false ? self::WRITABLE : 0) |
1077
-				(strpos($matches[3],'x') !== false ? self::EXECUTABLE : 0);
1075
+			$base = (strpos($matches[3], 'r') !== false ? self::READABLE : 0)|
1076
+				(strpos($matches[3], 'w') !== false ? self::WRITABLE : 0)|
1077
+				(strpos($matches[3], 'x') !== false ? self::EXECUTABLE : 0);
1078 1078
 
1079
-			for($n = $m = 0; $n < strlen($matches[1]); $n++)
1079
+			for ($n = $m = 0; $n < strlen($matches[1]); $n++)
1080 1080
 			{
1081
-				switch($matches[1][$n])
1081
+				switch ($matches[1][$n])
1082 1082
 				{
1083 1083
 					case 'o':
1084 1084
 						$m |= $base;
@@ -1091,10 +1091,10 @@  discard block
 block discarded – undo
1091 1091
 						break;
1092 1092
 					default:
1093 1093
 					case 'a':
1094
-						$m = $base | ($base << 3) | ($base << 6);
1094
+						$m = $base|($base << 3)|($base << 6);
1095 1095
 				}
1096 1096
 			}
1097
-			switch($matches[2])
1097
+			switch ($matches[2])
1098 1098
 			{
1099 1099
 				case '+':
1100 1100
 					$mode |= $m;
@@ -1116,33 +1116,33 @@  discard block
 block discarded – undo
1116 1116
 	 * @param int $mode
1117 1117
 	 * @return string
1118 1118
 	 */
1119
-	static function int2mode( $mode )
1119
+	static function int2mode($mode)
1120 1120
 	{
1121
-		if(($mode & self::MODE_LINK) == self::MODE_LINK) // Symbolic Link
1121
+		if (($mode&self::MODE_LINK) == self::MODE_LINK) // Symbolic Link
1122 1122
 		{
1123 1123
 			$sP = 'l';
1124 1124
 		}
1125
-		elseif(($mode & 0xC000) == 0xC000) // Socket
1125
+		elseif (($mode&0xC000) == 0xC000) // Socket
1126 1126
 		{
1127 1127
 			$sP = 's';
1128 1128
 		}
1129
-		elseif($mode & 0x1000)     // FIFO pipe
1129
+		elseif ($mode&0x1000)     // FIFO pipe
1130 1130
 		{
1131 1131
 			$sP = 'p';
1132 1132
 		}
1133
-		elseif($mode & 0x2000) // Character special
1133
+		elseif ($mode&0x2000) // Character special
1134 1134
 		{
1135 1135
 			$sP = 'c';
1136 1136
 		}
1137
-		elseif($mode & 0x4000) // Directory
1137
+		elseif ($mode&0x4000) // Directory
1138 1138
 		{
1139 1139
 			$sP = 'd';
1140 1140
 		}
1141
-		elseif($mode & 0x6000) // Block special
1141
+		elseif ($mode&0x6000) // Block special
1142 1142
 		{
1143 1143
 			$sP = 'b';
1144 1144
 		}
1145
-		elseif($mode & 0x8000) // Regular
1145
+		elseif ($mode&0x8000) // Regular
1146 1146
 		{
1147 1147
 			$sP = '-';
1148 1148
 		}
@@ -1152,22 +1152,19 @@  discard block
 block discarded – undo
1152 1152
 		}
1153 1153
 
1154 1154
 		// owner
1155
-		$sP .= (($mode & 0x0100) ? 'r' : '-') .
1156
-		(($mode & 0x0080) ? 'w' : '-') .
1157
-		(($mode & 0x0040) ? (($mode & 0x0800) ? 's' : 'x' ) :
1158
-		(($mode & 0x0800) ? 'S' : '-'));
1155
+		$sP .= (($mode&0x0100) ? 'r' : '-').
1156
+		(($mode&0x0080) ? 'w' : '-').
1157
+		(($mode&0x0040) ? (($mode&0x0800) ? 's' : 'x') : (($mode&0x0800) ? 'S' : '-'));
1159 1158
 
1160 1159
 		// group
1161
-		$sP .= (($mode & 0x0020) ? 'r' : '-') .
1162
-		(($mode & 0x0010) ? 'w' : '-') .
1163
-		(($mode & 0x0008) ? (($mode & 0x0400) ? 's' : 'x' ) :
1164
-		(($mode & 0x0400) ? 'S' : '-'));
1160
+		$sP .= (($mode&0x0020) ? 'r' : '-').
1161
+		(($mode&0x0010) ? 'w' : '-').
1162
+		(($mode&0x0008) ? (($mode&0x0400) ? 's' : 'x') : (($mode&0x0400) ? 'S' : '-'));
1165 1163
 
1166 1164
 		// world
1167
-		$sP .= (($mode & 0x0004) ? 'r' : '-') .
1168
-		(($mode & 0x0002) ? 'w' : '-') .
1169
-		(($mode & 0x0001) ? (($mode & 0x0200) ? 't' : 'x' ) :
1170
-		(($mode & 0x0200) ? 'T' : '-'));
1165
+		$sP .= (($mode&0x0004) ? 'r' : '-').
1166
+		(($mode&0x0002) ? 'w' : '-').
1167
+		(($mode&0x0001) ? (($mode&0x0200) ? 't' : 'x') : (($mode&0x0200) ? 'T' : '-'));
1171 1168
 
1172 1169
 		return $sP;
1173 1170
 	}
@@ -1180,26 +1177,26 @@  discard block
 block discarded – undo
1180 1177
 	 * @param int $size =128
1181 1178
 	 * @return string
1182 1179
 	 */
1183
-	static function mime_icon($mime_type, $et_image=true, $size=128)
1180
+	static function mime_icon($mime_type, $et_image = true, $size = 128)
1184 1181
 	{
1185 1182
 		if ($mime_type == self::DIR_MIME_TYPE)
1186 1183
 		{
1187 1184
 			$mime_type = 'Directory';
1188 1185
 		}
1189
-		if(!$mime_type)
1186
+		if (!$mime_type)
1190 1187
 		{
1191 1188
 			$mime_type = 'unknown';
1192 1189
 		}
1193
-		$mime_full = strtolower(str_replace	('/','_',$mime_type));
1194
-		list($mime_part) = explode('_',$mime_full);
1190
+		$mime_full = strtolower(str_replace('/', '_', $mime_type));
1191
+		list($mime_part) = explode('_', $mime_full);
1195 1192
 
1196
-		if (!($img=Image::find('etemplate',$icon='mime'.$size.'_'.$mime_full)) &&
1193
+		if (!($img = Image::find('etemplate', $icon = 'mime'.$size.'_'.$mime_full)) &&
1197 1194
 			// check mime-alias-map before falling back to more generic icons
1198 1195
 			!(isset(MimeMagic::$mime_alias_map[$mime_type]) &&
1199
-				($img=Image::find('etemplate',$icon='mime'.$size.'_'.str_replace('/','_',MimeMagic::$mime_alias_map[$mime_full])))) &&
1200
-			!($img=Image::find('etemplate',$icon='mime'.$size.'_'.$mime_part)))
1196
+				($img = Image::find('etemplate', $icon = 'mime'.$size.'_'.str_replace('/', '_', MimeMagic::$mime_alias_map[$mime_full])))) &&
1197
+			!($img = Image::find('etemplate', $icon = 'mime'.$size.'_'.$mime_part)))
1201 1198
 		{
1202
-			$img = Image::find('etemplate',$icon='mime'.$size.'_unknown');
1199
+			$img = Image::find('etemplate', $icon = 'mime'.$size.'_unknown');
1203 1200
 		}
1204 1201
 		return $et_image ? 'etemplate/'.$icon : $img;
1205 1202
 	}
@@ -1213,9 +1210,9 @@  discard block
 block discarded – undo
1213 1210
 	static function hsize($size)
1214 1211
 	{
1215 1212
 		if ($size < 1024) return $size;
1216
-		if ($size < 1024*1024) return sprintf('%3.1lfk',(float)$size/1024);
1217
-		if ($size < 1024*1024*1024) return sprintf('%3.1lfM',(float)$size/(1024*1024));
1218
-		return sprintf('%3.1lfG',(float)$size/(1024*1024*1024));
1213
+		if ($size < 1024 * 1024) return sprintf('%3.1lfk', (float)$size / 1024);
1214
+		if ($size < 1024 * 1024 * 1024) return sprintf('%3.1lfM', (float)$size / (1024 * 1024));
1215
+		return sprintf('%3.1lfG', (float)$size / (1024 * 1024 * 1024));
1219 1216
 	}
1220 1217
 
1221 1218
 	/**
@@ -1225,7 +1222,7 @@  discard block
 block discarded – undo
1225 1222
 	 */
1226 1223
 	static function int_size($_val)
1227 1224
 	{
1228
-		if(empty($_val))return 0;
1225
+		if (empty($_val))return 0;
1229 1226
 
1230 1227
 		$val = trim($_val);
1231 1228
 
@@ -1233,12 +1230,12 @@  discard block
 block discarded – undo
1233 1230
 		preg_match('#([0-9]+)[\s]*([a-z]+)#i', $val, $matches);
1234 1231
 
1235 1232
 		$last = '';
1236
-		if(isset($matches[2])){
1233
+		if (isset($matches[2])) {
1237 1234
 			$last = $matches[2];
1238 1235
 		}
1239 1236
 
1240
-		if(isset($matches[1])){
1241
-			$val = (int) $matches[1];
1237
+		if (isset($matches[1])) {
1238
+			$val = (int)$matches[1];
1242 1239
 		}
1243 1240
 
1244 1241
 		switch (strtolower($last))
@@ -1254,7 +1251,7 @@  discard block
 block discarded – undo
1254 1251
 			$val *= 1024;
1255 1252
 		}
1256 1253
 
1257
-		return (int) $val;
1254
+		return (int)$val;
1258 1255
 	}
1259 1256
 
1260 1257
 	/**
@@ -1265,8 +1262,8 @@  discard block
 block discarded – undo
1265 1262
 	 */
1266 1263
 	static function basename($_path)
1267 1264
 	{
1268
-		list($path) = explode('?',$_path);	// remove query
1269
-		$parts = explode('/',$path);
1265
+		list($path) = explode('?', $_path); // remove query
1266
+		$parts = explode('/', $path);
1270 1267
 
1271 1268
 		return array_pop($parts);
1272 1269
 	}
@@ -1280,7 +1277,7 @@  discard block
 block discarded – undo
1280 1277
 	 * @param int $component =-1 PHP_URL_* constants
1281 1278
 	 * @return array|string|boolean on success array or string, if $component given, or false on failure
1282 1279
 	 */
1283
-	static function parse_url($url, $component=-1)
1280
+	static function parse_url($url, $component = -1)
1284 1281
 	{
1285 1282
 		static $component2str = array(
1286 1283
 			PHP_URL_SCHEME => 'scheme',
@@ -1292,9 +1289,9 @@  discard block
 block discarded – undo
1292 1289
 			PHP_URL_QUERY => 'query',
1293 1290
 			PHP_URL_FRAGMENT => 'fragment',
1294 1291
 		);
1295
-		static $cache = array();	// some caching
1292
+		static $cache = array(); // some caching
1296 1293
 
1297
-		$result =& $cache[$url];
1294
+		$result = & $cache[$url];
1298 1295
 
1299 1296
 		if (!isset($result))
1300 1297
 		{
@@ -1334,22 +1331,22 @@  discard block
 block discarded – undo
1334 1331
 	 */
1335 1332
 	static function dirname($_url)
1336 1333
 	{
1337
-		list($url,$query) = explode('?',$_url,2);	// strip the query first, as it can contain slashes
1334
+		list($url, $query) = explode('?', $_url, 2); // strip the query first, as it can contain slashes
1338 1335
 
1339
-		if ($url == '/' || $url[0] != '/' && self::parse_url($url,PHP_URL_PATH) == '/')
1336
+		if ($url == '/' || $url[0] != '/' && self::parse_url($url, PHP_URL_PATH) == '/')
1340 1337
 		{
1341 1338
 			//error_log(__METHOD__."($url) returning FALSE: already in root!");
1342 1339
 			return false;
1343 1340
 		}
1344
-		$parts = explode('/',$url);
1345
-		if (substr($url,-1) == '/') array_pop($parts);
1341
+		$parts = explode('/', $url);
1342
+		if (substr($url, -1) == '/') array_pop($parts);
1346 1343
 		array_pop($parts);
1347 1344
 		if ($url[0] != '/' && count($parts) == 3 || count($parts) == 1 && $parts[0] === '')
1348 1345
 		{
1349
-			array_push($parts,'');	// scheme://host is wrong (no path), has to be scheme://host/
1346
+			array_push($parts, ''); // scheme://host is wrong (no path), has to be scheme://host/
1350 1347
 		}
1351 1348
 		//error_log(__METHOD__."($url)=".implode('/',$parts).($query ? '?'.$query : ''));
1352
-		return implode('/',$parts).($query ? '?'.$query : '');
1349
+		return implode('/', $parts).($query ? '?'.$query : '');
1353 1350
 	}
1354 1351
 
1355 1352
 	/**
@@ -1361,18 +1358,18 @@  discard block
 block discarded – undo
1361 1358
 	 * @param array $stat =null stat for path, default queried by this function
1362 1359
 	 * @return boolean
1363 1360
 	 */
1364
-	static function has_owner_rights($path,array $stat=null)
1361
+	static function has_owner_rights($path, array $stat = null)
1365 1362
 	{
1366 1363
 		if (!$stat)
1367 1364
 		{
1368 1365
 			$vfs = new Vfs\StreamWrapper();
1369
-			$stat = $vfs->url_stat($path,0);
1366
+			$stat = $vfs->url_stat($path, 0);
1370 1367
 		}
1371
-		return $stat['uid'] == self::$user &&	// (current) user is the owner
1368
+		return $stat['uid'] == self::$user && // (current) user is the owner
1372 1369
 				// in sharing current user != self::$user and should NOT have owner rights
1373 1370
 				$GLOBALS['egw_info']['user']['account_id'] == self::$user ||
1374
-			self::$is_root ||					// class runs with root rights
1375
-			!$stat['uid'] && $stat['gid'] && self::$is_admin;	// group directory and user is an eGW admin
1371
+			self::$is_root || // class runs with root rights
1372
+			!$stat['uid'] && $stat['gid'] && self::$is_admin; // group directory and user is an eGW admin
1376 1373
 	}
1377 1374
 
1378 1375
 	/**
@@ -1384,22 +1381,22 @@  discard block
 block discarded – undo
1384 1381
 	 * @param string $relative relative path to add to $url
1385 1382
 	 * @return string
1386 1383
 	 */
1387
-	static function concat($_url,$relative)
1384
+	static function concat($_url, $relative)
1388 1385
 	{
1389
-		list($url,$query) = explode('?',$_url,2);
1390
-		if (substr($url,-1) == '/') $url = substr($url,0,-1);
1386
+		list($url, $query) = explode('?', $_url, 2);
1387
+		if (substr($url, -1) == '/') $url = substr($url, 0, -1);
1391 1388
 		$ret = ($relative === '' || $relative[0] == '/' ? $url.$relative : $url.'/'.$relative);
1392 1389
 
1393 1390
 		// now normalize the path (remove "/something/..")
1394
-		while (strpos($ret,'/../') !== false)
1391
+		while (strpos($ret, '/../') !== false)
1395 1392
 		{
1396
-			list($a_str,$b_str) = explode('/../',$ret,2);
1397
-			$a = explode('/',$a_str);
1393
+			list($a_str, $b_str) = explode('/../', $ret, 2);
1394
+			$a = explode('/', $a_str);
1398 1395
 			array_pop($a);
1399
-			$b = explode('/',$b_str);
1400
-			$ret = implode('/',array_merge($a,$b));
1396
+			$b = explode('/', $b_str);
1397
+			$ret = implode('/', array_merge($a, $b));
1401 1398
 		}
1402
-		return $ret.($query ? (strpos($url,'?')===false ? '?' : '&').$query : '');
1399
+		return $ret.($query ? (strpos($url, '?') === false ? '?' : '&').$query : '');
1403 1400
 	}
1404 1401
 
1405 1402
 	/**
@@ -1410,11 +1407,11 @@  discard block
 block discarded – undo
1410 1407
 	 */
1411 1408
 	static function build_url(array $url_parts)
1412 1409
 	{
1413
-		$url = (!isset($url_parts['scheme'])?'':$url_parts['scheme'].'://'.
1414
-			(!isset($url_parts['user'])?'':$url_parts['user'].(!isset($url_parts['pass'])?'':':'.$url_parts['pass']).'@').
1410
+		$url = (!isset($url_parts['scheme']) ? '' : $url_parts['scheme'].'://'.
1411
+			(!isset($url_parts['user']) ? '' : $url_parts['user'].(!isset($url_parts['pass']) ? '' : ':'.$url_parts['pass']).'@').
1415 1412
 			$url_parts['host']).$url_parts['path'].
1416
-			(!isset($url_parts['query'])?'':'?'.$url_parts['query']).
1417
-			(!isset($url_parts['fragment'])?'':'?'.$url_parts['fragment']);
1413
+			(!isset($url_parts['query']) ? '' : '?'.$url_parts['query']).
1414
+			(!isset($url_parts['fragment']) ? '' : '?'.$url_parts['fragment']);
1418 1415
 		//error_log(__METHOD__.'('.array2string($url_parts).") = '".$url."'");
1419 1416
 		return $url;
1420 1417
 	}
@@ -1432,19 +1429,19 @@  discard block
 block discarded – undo
1432 1429
 	 * @todo get $force_download working through webdav
1433 1430
 	 * @return string
1434 1431
 	 */
1435
-	static function download_url($path,$force_download=false)
1432
+	static function download_url($path, $force_download = false)
1436 1433
 	{
1437
-		if (($url = self::_call_on_backend('download_url',array($path,$force_download),true)))
1434
+		if (($url = self::_call_on_backend('download_url', array($path, $force_download), true)))
1438 1435
 		{
1439 1436
 			return $url;
1440 1437
 		}
1441 1438
 		if ($path[0] != '/')
1442 1439
 		{
1443
-			$path = self::parse_url($path,PHP_URL_PATH);
1440
+			$path = self::parse_url($path, PHP_URL_PATH);
1444 1441
 		}
1445 1442
 		// we do NOT need to encode % itself, as our path are already url encoded, with the exception of ' ' and '+'
1446 1443
 		// we urlencode double quotes '"', as that fixes many problems in html markup
1447
-		return '/webdav.php'.strtr($path,array('+' => '%2B',' ' => '%20','"' => '%22')).($force_download ? '?download' : '');
1444
+		return '/webdav.php'.strtr($path, array('+' => '%2B', ' ' => '%20', '"' => '%22')).($force_download ? '?download' : '');
1448 1445
 	}
1449 1446
 
1450 1447
 	/**
@@ -1472,12 +1469,12 @@  discard block
 block discarded – undo
1472 1469
 		// eg: User selected /home/nathan/picture.jpg, /home/Pictures/logo.jpg
1473 1470
 		// We want /home
1474 1471
 		$dirs = array();
1475
-		foreach($_files as $file)
1472
+		foreach ($_files as $file)
1476 1473
 		{
1477 1474
 			$dirs[] = self::dirname($file);
1478 1475
 		}
1479 1476
 		$paths = array_unique($dirs);
1480
-		if(count($paths) > 0)
1477
+		if (count($paths) > 0)
1481 1478
 		{
1482 1479
 			// Shortest to longest
1483 1480
 			usort($paths, function($a, $b) {
@@ -1485,13 +1482,13 @@  discard block
 block discarded – undo
1485 1482
 			});
1486 1483
 
1487 1484
 			// Start with shortest, pop off sub-directories that don't match
1488
-			$parts = explode('/',$paths[0]);
1489
-			foreach($paths as $path)
1485
+			$parts = explode('/', $paths[0]);
1486
+			foreach ($paths as $path)
1490 1487
 			{
1491
-				$dirs = explode('/',$path);
1492
-				foreach($dirs as $dir_index => $dir)
1488
+				$dirs = explode('/', $path);
1489
+				foreach ($dirs as $dir_index => $dir)
1493 1490
 				{
1494
-					if($parts[$dir_index] && $parts[$dir_index] != $dir)
1491
+					if ($parts[$dir_index] && $parts[$dir_index] != $dir)
1495 1492
 					{
1496 1493
 						unset($parts[$dir_index]);
1497 1494
 					}
@@ -1510,24 +1507,23 @@  discard block
 block discarded – undo
1510 1507
 			// Linux
1511 1508
 			'/',
1512 1509
 			// Windows
1513
-			'\\','?','%','*',':','|',/*'.',*/ '"','<','>'
1510
+			'\\', '?', '%', '*', ':', '|', /*'.',*/ '"', '<', '>'
1514 1511
 		);
1515 1512
 
1516 1513
 		// A nice name for the user,
1517
-		$filename = $GLOBALS['egw_info']['server']['site_title'] . '_' .
1518
-			str_replace($replace,'_',(
1514
+		$filename = $GLOBALS['egw_info']['server']['site_title'].'_'.
1515
+			str_replace($replace, '_', (
1519 1516
 			$name ? $name : (
1520 1517
 			count($_files) == 1 ?
1521 1518
 			// Just one file (hopefully a directory?) selected
1522
-			self::basename($_files[0]) :
1523
-			// Use the lowest common directory (eg: Infolog, Open, nathan)
1519
+			self::basename($_files[0]) : // Use the lowest common directory (eg: Infolog, Open, nathan)
1524 1520
 			self::basename($base_dir))
1525
-		)) . '.zip';
1521
+		)).'.zip';
1526 1522
 
1527 1523
 		// Make sure basename is a dir
1528
-		if(substr($base_dir, -1) != '/')
1524
+		if (substr($base_dir, -1) != '/')
1529 1525
 		{
1530
-			$base_dir .='/';
1526
+			$base_dir .= '/';
1531 1527
 		}
1532 1528
 
1533 1529
 		// Go into directories, find them all
@@ -1538,37 +1534,37 @@  discard block
 block discarded – undo
1538 1534
 		$tempfiles = array();
1539 1535
 
1540 1536
 		// Give 1 second per file, but try to allow more time for big files when amount of files is low
1541
-		set_time_limit((count($files)<=9?10:count($files)));
1537
+		set_time_limit((count($files) <= 9 ? 10 : count($files)));
1542 1538
 
1543 1539
 		// Add files to archive
1544
-		foreach($files as &$addfile)
1540
+		foreach ($files as &$addfile)
1545 1541
 		{
1546 1542
 			// Use relative paths inside zip
1547 1543
 			$relative = substr($addfile, strlen($base_dir));
1548 1544
 
1549 1545
 			// Use safe names - replace unsafe chars, convert to ASCII (ZIP spec says CP437, but we'll try)
1550
-			$path = explode('/',$relative);
1551
-			$_name = Translation::convert(Translation::to_ascii(implode('/', str_replace($replace,'_',$path))),false,'ASCII');
1546
+			$path = explode('/', $relative);
1547
+			$_name = Translation::convert(Translation::to_ascii(implode('/', str_replace($replace, '_', $path))), false, 'ASCII');
1552 1548
 
1553 1549
 			// Don't go infinite with app entries
1554
-			if(self::is_link($addfile))
1550
+			if (self::is_link($addfile))
1555 1551
 			{
1556
-				if(in_array($addfile, $links)) continue;
1552
+				if (in_array($addfile, $links)) continue;
1557 1553
 				$links[] = $addfile;
1558 1554
 			}
1559 1555
 			// Add directory - if empty, client app might not show it though
1560
-			if(self::is_dir($addfile))
1556
+			if (self::is_dir($addfile))
1561 1557
 			{
1562 1558
 				// Zip directories
1563 1559
 				$zip->addEmptyDir($addfile);
1564 1560
 			}
1565
-			else if(self::is_readable($addfile))
1561
+			else if (self::is_readable($addfile))
1566 1562
 			{
1567 1563
 				// Copy to temp file, as ZipArchive fails to read VFS
1568 1564
 				$temp = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'zip_');
1569
-				$from = self::fopen($addfile,'r');
1570
-		 		$to = fopen($temp,'w');
1571
-				if(!stream_copy_to_stream($from,$to) || !$zip->addFile($temp, $_name))
1565
+				$from = self::fopen($addfile, 'r');
1566
+		 		$to = fopen($temp, 'w');
1567
+				if (!stream_copy_to_stream($from, $to) || !$zip->addFile($temp, $_name))
1572 1568
 				{
1573 1569
 					unlink($temp);
1574 1570
 					trigger_error("Could not add $addfile to ZIP file", E_USER_ERROR);
@@ -1579,10 +1575,10 @@  discard block
 block discarded – undo
1579 1575
 
1580 1576
 				// Add comment in
1581 1577
 				$props = self::propfind($addfile);
1582
-				if($props)
1578
+				if ($props)
1583 1579
 				{
1584
-					$comment = self::find_prop($props,'comment');
1585
-					if($comment)
1580
+					$comment = self::find_prop($props, 'comment');
1581
+					if ($comment)
1586 1582
 					{
1587 1583
 						$zip->setCommentName($_name, $comment);
1588 1584
 					}
@@ -1592,34 +1588,34 @@  discard block
 block discarded – undo
1592 1588
 		}
1593 1589
 
1594 1590
 		// Set a comment to help tell them apart
1595
-		$zip->setArchiveComment(lang('Created by %1', $GLOBALS['egw_info']['user']['account_lid']) . ' ' .DateTime::to());
1591
+		$zip->setArchiveComment(lang('Created by %1', $GLOBALS['egw_info']['user']['account_lid']).' '.DateTime::to());
1596 1592
 
1597 1593
 		// Record total for debug, not available after close()
1598 1594
 		$total_files = $zip->numFiles;
1599 1595
 
1600 1596
 		$result = $zip->close();
1601
-		if(!$result || !filesize($zip_file))
1597
+		if (!$result || !filesize($zip_file))
1602 1598
 		{
1603 1599
 			error_log('close() result: '.array2string($result));
1604 1600
 			return 'Error creating zip file';
1605 1601
 		}
1606 1602
 
1607
-		error_log("Total files: " . $total_files . " Peak memory to zip: " . self::hsize(memory_get_peak_usage(true)));
1603
+		error_log("Total files: ".$total_files." Peak memory to zip: ".self::hsize(memory_get_peak_usage(true)));
1608 1604
 
1609 1605
 		// Stop any buffering
1610
-		while(ob_get_level() > 0)
1606
+		while (ob_get_level() > 0)
1611 1607
 		{
1612 1608
 			ob_end_clean();
1613 1609
 		}
1614 1610
 
1615 1611
 		// Stream the file to the client
1616 1612
 		header("Content-Type: application/zip");
1617
-		header("Content-Length: " . filesize($zip_file));
1613
+		header("Content-Length: ".filesize($zip_file));
1618 1614
 		header("Content-Disposition: attachment; filename=\"$filename\"");
1619 1615
 		readfile($zip_file);
1620 1616
 
1621 1617
 		unlink($zip_file);
1622
-		foreach($tempfiles as $temp_file)
1618
+		foreach ($tempfiles as $temp_file)
1623 1619
 		{
1624 1620
 			unlink($temp_file);
1625 1621
 		}
@@ -1653,11 +1649,11 @@  discard block
 block discarded – undo
1653 1649
 	 * @param boolean $check_writable =true should we check if the ressource is writable, before granting locks, default yes
1654 1650
 	 * @return boolean true on success
1655 1651
 	 */
1656
-	static function lock($path,&$token,&$timeout,&$owner,&$scope,&$type,$update=false,$check_writable=true)
1652
+	static function lock($path, &$token, &$timeout, &$owner, &$scope, &$type, $update = false, $check_writable = true)
1657 1653
 	{
1658 1654
 		// we require write rights to lock/unlock a resource
1659 1655
 		if (!$path || $update && !$token || $check_writable &&
1660
-			!(self::is_writable($path) || !self::file_exists($path) && ($dir=self::dirname($path)) && self::is_writable($dir)))
1656
+			!(self::is_writable($path) || !self::file_exists($path) && ($dir = self::dirname($path)) && self::is_writable($dir)))
1661 1657
 		{
1662 1658
 			return false;
1663 1659
 		}
@@ -1671,28 +1667,28 @@  discard block
 block discarded – undo
1671 1667
 
1672 1668
 		if ($update)	// Lock Update
1673 1669
 		{
1674
-			if (($ret = (boolean)($row = self::$db->select(self::LOCK_TABLE,array('lock_owner','lock_exclusive','lock_write'),array(
1670
+			if (($ret = (boolean)($row = self::$db->select(self::LOCK_TABLE, array('lock_owner', 'lock_exclusive', 'lock_write'), array(
1675 1671
 				'lock_path' => $path,
1676 1672
 				'lock_token' => $token,
1677
-			),__LINE__,__FILE__)->fetch())))
1673
+			), __LINE__, __FILE__)->fetch())))
1678 1674
 			{
1679 1675
 				$owner = $row['lock_owner'];
1680 1676
 				$scope = Db::from_bool($row['lock_exclusive']) ? 'exclusive' : 'shared';
1681 1677
 				$type  = Db::from_bool($row['lock_write']) ? 'write' : 'read';
1682 1678
 
1683
-				self::$db->update(self::LOCK_TABLE,array(
1679
+				self::$db->update(self::LOCK_TABLE, array(
1684 1680
 					'lock_expires' => $timeout,
1685 1681
 					'lock_modified' => time(),
1686
-				),array(
1682
+				), array(
1687 1683
 					'lock_path' => $path,
1688 1684
 					'lock_token' => $token,
1689
-				),__LINE__,__FILE__);
1685
+				), __LINE__, __FILE__);
1690 1686
 			}
1691 1687
 		}
1692 1688
 		// HTTP_WebDAV_Server does this check before calling LOCK, but we want to be complete and usable outside WebDAV
1693
-		elseif(($lock = self::checkLock($path)) && ($lock['scope'] == 'exclusive' || $scope == 'exclusive'))
1689
+		elseif (($lock = self::checkLock($path)) && ($lock['scope'] == 'exclusive' || $scope == 'exclusive'))
1694 1690
 		{
1695
-			$ret = false;	// there's alread a lock
1691
+			$ret = false; // there's alread a lock
1696 1692
 		}
1697 1693
 		else
1698 1694
 		{
@@ -1707,7 +1703,7 @@  discard block
 block discarded – undo
1707 1703
 				$token = HTTP_WebDAV_Server::_new_locktoken();
1708 1704
 			}
1709 1705
 			try {
1710
-				self::$db->insert(self::LOCK_TABLE,array(
1706
+				self::$db->insert(self::LOCK_TABLE, array(
1711 1707
 					'lock_token' => $token,
1712 1708
 					'lock_path'  => $path,
1713 1709
 					'lock_created' => time(),
@@ -1716,12 +1712,12 @@  discard block
 block discarded – undo
1716 1712
 					'lock_expires' => $timeout,
1717 1713
 					'lock_exclusive' => $scope == 'exclusive',
1718 1714
 					'lock_write' => $type == 'write',
1719
-				),false,__LINE__,__FILE__);
1715
+				), false, __LINE__, __FILE__);
1720 1716
 				$ret = true;
1721 1717
 			}
1722
-			catch(Db\Exception $e) {
1718
+			catch (Db\Exception $e) {
1723 1719
 				unset($e);
1724
-				$ret = false;	// there's already a lock
1720
+				$ret = false; // there's already a lock
1725 1721
 			}
1726 1722
 		}
1727 1723
 		if (self::LOCK_DEBUG) error_log(__METHOD__."($path,$token,$timeout,$owner,$scope,$type,update=$update,check_writable=$check_writable) returns ".($ret ? 'true' : 'false'));
@@ -1736,17 +1732,17 @@  discard block
 block discarded – undo
1736 1732
 	 * @param boolean $check_writable =true should we check if the ressource is writable, before granting locks, default yes
1737 1733
      * @return boolean true on success
1738 1734
      */
1739
-    static function unlock($path,$token,$check_writable=true)
1735
+    static function unlock($path, $token, $check_writable = true)
1740 1736
     {
1741 1737
 		// we require write rights to lock/unlock a resource
1742 1738
 		if ($check_writable && !self::is_writable($path))
1743 1739
 		{
1744 1740
 			return false;
1745 1741
 		}
1746
-        if (($ret = self::$db->delete(self::LOCK_TABLE,array(
1742
+        if (($ret = self::$db->delete(self::LOCK_TABLE, array(
1747 1743
         	'lock_path' => $path,
1748 1744
         	'lock_token' => $token,
1749
-        ),__LINE__,__FILE__) && self::$db->affected_rows()))
1745
+        ), __LINE__, __FILE__) && self::$db->affected_rows()))
1750 1746
         {
1751 1747
         	// remove the lock from the cache too
1752 1748
         	unset(self::$lock_cache[$path]);
@@ -1765,31 +1761,31 @@  discard block
 block discarded – undo
1765 1761
 	{
1766 1762
 		if (isset(self::$lock_cache[$path]))
1767 1763
 		{
1768
-			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns from CACHE ".str_replace(array("\n",'    '),'',print_r(self::$lock_cache[$path],true)));
1764
+			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns from CACHE ".str_replace(array("\n", '    '), '', print_r(self::$lock_cache[$path], true)));
1769 1765
 			return self::$lock_cache[$path];
1770 1766
 		}
1771 1767
 		$where = 'lock_path='.self::$db->quote($path);
1772 1768
 		// ToDo: additional check parent dirs for locks and children of the requested directory
1773 1769
 		//$where .= ' OR '.self::$db->quote($path).' LIKE '.self::$db->concat('lock_path',"'%'").' OR lock_path LIKE '.self::$db->quote($path.'%');
1774 1770
 		// ToDo: shared locks can return multiple rows
1775
-		if (($result = self::$db->select(self::LOCK_TABLE,'*',$where,__LINE__,__FILE__)->fetch()))
1771
+		if (($result = self::$db->select(self::LOCK_TABLE, '*', $where, __LINE__, __FILE__)->fetch()))
1776 1772
 		{
1777
-			$result = Db::strip_array_keys($result,'lock_');
1773
+			$result = Db::strip_array_keys($result, 'lock_');
1778 1774
 			$result['type']  = Db::from_bool($result['write']) ? 'write' : 'read';
1779 1775
 			$result['scope'] = Db::from_bool($result['exclusive']) ? 'exclusive' : 'shared';
1780 1776
 			$result['depth'] = Db::from_bool($result['recursive']) ? 'infinite' : 0;
1781 1777
 		}
1782 1778
 		if ($result && $result['expires'] < time())	// lock is expired --> remove it
1783 1779
 		{
1784
-	        self::$db->delete(self::LOCK_TABLE,array(
1780
+	        self::$db->delete(self::LOCK_TABLE, array(
1785 1781
 	        	'lock_path' => $result['path'],
1786 1782
 	        	'lock_token' => $result['token'],
1787
-	        ),__LINE__,__FILE__);
1783
+	        ), __LINE__, __FILE__);
1788 1784
 
1789
-			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) lock is expired at ".date('Y-m-d H:i:s',$result['expires'])." --> removed");
1785
+			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) lock is expired at ".date('Y-m-d H:i:s', $result['expires'])." --> removed");
1790 1786
 	        $result = false;
1791 1787
 		}
1792
-		if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns ".($result?array2string($result):'false'));
1788
+		if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns ".($result ?array2string($result) : 'false'));
1793 1789
 		return self::$lock_cache[$path] = $result;
1794 1790
 	}
1795 1791
 
@@ -1800,10 +1796,10 @@  discard block
 block discarded – undo
1800 1796
 	 * @param array $content =null
1801 1797
 	 * @return array|boolean array with values for keys 'data','etemplate','name','label','help' or false if not supported by backend
1802 1798
 	 */
1803
-	static function getExtraInfo($path,array $content=null)
1799
+	static function getExtraInfo($path, array $content = null)
1804 1800
 	{
1805 1801
 		$extra = array();
1806
-		if (($extra_info = self::_call_on_backend('extra_info',array($path,$content),true)))	// true = fail silent if backend does NOT support it
1802
+		if (($extra_info = self::_call_on_backend('extra_info', array($path, $content), true)))	// true = fail silent if backend does NOT support it
1807 1803
 		{
1808 1804
 			$extra[] = $extra_info;
1809 1805
 		}
@@ -1814,7 +1810,7 @@  discard block
 block discarded – undo
1814 1810
 			'content' => $content,
1815 1811
 		))))
1816 1812
 		{
1817
-			foreach($vfs_extra as $data)
1813
+			foreach ($vfs_extra as $data)
1818 1814
 			{
1819 1815
 				$extra = $extra ? array_merge($extra, $data) : $data;
1820 1816
 			}
@@ -1829,7 +1825,7 @@  discard block
 block discarded – undo
1829 1825
 	 * @param int|string $id
1830 1826
 	 * @return string
1831 1827
 	 */
1832
-	static function app_entry_lock_path($app,$id)
1828
+	static function app_entry_lock_path($app, $id)
1833 1829
 	{
1834 1830
 		return "/apps/$app/entry/$id";
1835 1831
 	}
@@ -1843,7 +1839,7 @@  discard block
 block discarded – undo
1843 1839
 		//'%' => '%25',	// % should be encoded, but easily leads to double encoding, therefore better NOT encodig it
1844 1840
 		'#' => '%23',
1845 1841
 		'?' => '%3F',
1846
-		'/' => '',	// better remove it completly
1842
+		'/' => '', // better remove it completly
1847 1843
 	);
1848 1844
 
1849 1845
 	/**
@@ -1858,7 +1854,7 @@  discard block
 block discarded – undo
1858 1854
 	 */
1859 1855
 	static public function encodePathComponent($component)
1860 1856
 	{
1861
-		return str_replace(array_keys(self::$encode),array_values(self::$encode),$component);
1857
+		return str_replace(array_keys(self::$encode), array_values(self::$encode), $component);
1862 1858
 	}
1863 1859
 
1864 1860
 	/**
@@ -1871,7 +1867,7 @@  discard block
 block discarded – undo
1871 1867
 	 */
1872 1868
 	static public function encodePath($path)
1873 1869
 	{
1874
-		return implode('/',self::encodePathComponent(explode('/',$path)));
1870
+		return implode('/', self::encodePathComponent(explode('/', $path)));
1875 1871
 	}
1876 1872
 
1877 1873
 	/**
@@ -1926,7 +1922,7 @@  discard block
 block discarded – undo
1926 1922
 		{
1927 1923
 			$image = Image::find($mime_sub, 'navbar');
1928 1924
 		}
1929
-		else if ($file && $mime_main == 'image' && in_array($mime_sub, array('png','jpeg','jpg','gif','bmp')) &&
1925
+		else if ($file && $mime_main == 'image' && in_array($mime_sub, array('png', 'jpeg', 'jpg', 'gif', 'bmp')) &&
1930 1926
 		         (string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] != '0' &&
1931 1927
 		         (string)$GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] != '0' &&
1932 1928
 		         ($stat = self::stat($file)) && $stat['size'] < 1500000)
@@ -1981,7 +1977,7 @@  discard block
 block discarded – undo
1981 1977
 	 * @param array& $copied =null on return files copied
1982 1978
 	 * @return boolean true for no errors, false otherwise
1983 1979
 	 */
1984
-	static public function copy_files(array $src, $dst, &$errs=null, array &$copied=null)
1980
+	static public function copy_files(array $src, $dst, &$errs = null, array &$copied = null)
1985 1981
 	{
1986 1982
 		if (self::is_dir($dst))
1987 1983
 		{
@@ -1999,7 +1995,7 @@  discard block
 block discarded – undo
1999 1995
 						if ($file !== $target)
2000 1996
 						{
2001 1997
 							// Create the target directory
2002
-							self::mkdir($target,null,STREAM_MKDIR_RECURSIVE);
1998
+							self::mkdir($target, null, STREAM_MKDIR_RECURSIVE);
2003 1999
 
2004 2000
 							$copied[] = $file;
2005 2001
 							$copied[] = $target; // < newly created folder must not be copied again!
@@ -2043,7 +2039,7 @@  discard block
 block discarded – undo
2043 2039
 		if (self::is_dir($dst))
2044 2040
 		{
2045 2041
 			$vfs = new Vfs\StreamWrapper();
2046
-			foreach($src as $file)
2042
+			foreach ($src as $file)
2047 2043
 			{
2048 2044
 				$target = self::concat($dst, self::basename($file));
2049 2045
 
@@ -2075,7 +2071,7 @@  discard block
 block discarded – undo
2075 2071
 	 * @param boolean $check_is_uploaded_file =true should method perform an is_uploaded_file check, default yes
2076 2072
 	 * @return boolean|array stat array on success, false on error
2077 2073
 	 */
2078
-	static public function copy_uploaded($src,$target,$props=null,$check_is_uploaded_file=true)
2074
+	static public function copy_uploaded($src, $target, $props = null, $check_is_uploaded_file = true)
2079 2075
 	{
2080 2076
 		$tmp_name = is_array($src) ? $src['tmp_name'] : $src;
2081 2077
 
@@ -2095,12 +2091,12 @@  discard block
 block discarded – undo
2095 2091
 		}
2096 2092
 		if ($props)
2097 2093
 		{
2098
-			if (!is_array($props)) $props = array(array('name' => 'comment','val' => $props));
2094
+			if (!is_array($props)) $props = array(array('name' => 'comment', 'val' => $props));
2099 2095
 
2100 2096
 			// if $props is name => value pairs, convert it to internal array or array with values for keys 'name', 'val' and optional 'ns'
2101 2097
 			if (!isset($props[0]))
2102 2098
 			{
2103
-				foreach($props as $name => $val)
2099
+				foreach ($props as $name => $val)
2104 2100
 				{
2105 2101
 					if (($name == 'comment' || $name[0] == '#') && $val)	// only copy 'comment' and cfs
2106 2102
 					{
@@ -2118,7 +2114,7 @@  discard block
 block discarded – undo
2118 2114
 			// set props before copying the file, so notifications already contain them
2119 2115
 			if (!self::stat($target))
2120 2116
 			{
2121
-				self::touch($target);	// create empty file, to be able to attach properties
2117
+				self::touch($target); // create empty file, to be able to attach properties
2122 2118
 				// tell vfs stream-wrapper to treat file in following copy as a new file notification-wises
2123 2119
 				$context = stream_context_create(array(
2124 2120
 					self::SCHEME => array('treat_as_new' => true)
@@ -2136,8 +2132,7 @@  discard block
 block discarded – undo
2136 2132
 		}
2137 2133
 		else
2138 2134
 		{
2139
-			$ret = ($context ? copy($tmp_name, self::PREFIX.$target, $context) :
2140
-				copy($tmp_name, self::PREFIX.$target)) ?
2135
+			$ret = ($context ? copy($tmp_name, self::PREFIX.$target, $context) : copy($tmp_name, self::PREFIX.$target)) ?
2141 2136
 				self::stat($target) : false;
2142 2137
 		}
2143 2138
 		if (self::LOG_LEVEL > 1 || !$ret && self::LOG_LEVEL) error_log(__METHOD__."($tmp_name, $target, ".array2string($props).") returning ".array2string($ret));
@@ -2183,7 +2178,7 @@  discard block
 block discarded – undo
2183 2178
 	 * @param array|boolean &$stat=null on return: stat of existing file or false for non-existing files
2184 2179
 	 * @return string|boolean false if the url cant be resolved, should not happen if fstab has a root entry
2185 2180
 	 */
2186
-	static function resolve_url_symlinks($_path,$file_exists=true,$resolve_last_symlink=true,&$stat=null)
2181
+	static function resolve_url_symlinks($_path, $file_exists = true, $resolve_last_symlink = true, &$stat = null)
2187 2182
 	{
2188 2183
 		$vfs = new Vfs\StreamWrapper();
2189 2184
 		return $vfs->resolve_url_symlinks($_path, $file_exists, $resolve_last_symlink, $stat);
@@ -2199,7 +2194,7 @@  discard block
 block discarded – undo
2199 2194
 	 * @param boolean $fix_url_query =false true append relativ path to url query parameter, default not
2200 2195
 	 * @return string|boolean false if the url cant be resolved, should not happen if fstab has a root entry
2201 2196
 	 */
2202
-	static function resolve_url($_path,$do_symlink=true,$use_symlinkcache=true,$replace_user_pass_host=true,$fix_url_query=false)
2197
+	static function resolve_url($_path, $do_symlink = true, $use_symlinkcache = true, $replace_user_pass_host = true, $fix_url_query = false)
2203 2198
 	{
2204 2199
 		return Vfs\StreamWrapper::resolve_url($_path, $do_symlink, $use_symlinkcache, $replace_user_pass_host, $fix_url_query);
2205 2200
 	}
@@ -2215,7 +2210,7 @@  discard block
 block discarded – undo
2215 2210
 	 * @param boolean $recursive =false true: create missing parents too
2216 2211
 	 * @return boolean TRUE on success or FALSE on failure
2217 2212
 	 */
2218
-	static function mkdir ($path, $mode=0750, $recursive=false)
2213
+	static function mkdir($path, $mode = 0750, $recursive = false)
2219 2214
 	{
2220 2215
 		return $path[0] == '/' && mkdir(self::PREFIX.$path, $mode, $recursive);
2221 2216
 	}
@@ -2244,7 +2239,7 @@  discard block
 block discarded – undo
2244 2239
 	 * @param string $path
2245 2240
 	 * @return boolean TRUE on success or FALSE on failure
2246 2241
 	 */
2247
-	static function unlink ( $path )
2242
+	static function unlink($path)
2248 2243
 	{
2249 2244
 		return $path[0] == '/' && unlink(self::PREFIX.$path);
2250 2245
 	}
@@ -2261,60 +2256,60 @@  discard block
 block discarded – undo
2261 2256
 	 * @param int $path_param_key =0 key in params containing the path, default 0
2262 2257
 	 * @return mixed return value of backend or false if function does not exist on backend
2263 2258
 	 */
2264
-	static protected function _call_on_backend($name,$params,$fail_silent=false,$path_param_key=0)
2259
+	static protected function _call_on_backend($name, $params, $fail_silent = false, $path_param_key = 0)
2265 2260
 	{
2266 2261
 		$pathes = $params[$path_param_key];
2267 2262
 
2268 2263
 		$scheme2urls = array();
2269
-		foreach(is_array($pathes) ? $pathes : array($pathes) as $path)
2264
+		foreach (is_array($pathes) ? $pathes : array($pathes) as $path)
2270 2265
 		{
2271
-			if (!($url = self::resolve_url_symlinks($path,false,false)))
2266
+			if (!($url = self::resolve_url_symlinks($path, false, false)))
2272 2267
 			{
2273 2268
 				return false;
2274 2269
 			}
2275
-			$k=(string)self::parse_url($url,PHP_URL_SCHEME);
2270
+			$k = (string)self::parse_url($url, PHP_URL_SCHEME);
2276 2271
 			if (!(is_array($scheme2urls[$k]))) $scheme2urls[$k] = array();
2277 2272
 			$scheme2urls[$k][$path] = $url;
2278 2273
 		}
2279 2274
 		$ret = array();
2280
-		foreach($scheme2urls as $scheme => $urls)
2275
+		foreach ($scheme2urls as $scheme => $urls)
2281 2276
 		{
2282 2277
 			if ($scheme)
2283 2278
 			{
2284
-				if (!class_exists($class = self::scheme2class($scheme)) || !method_exists($class,$name))
2279
+				if (!class_exists($class = self::scheme2class($scheme)) || !method_exists($class, $name))
2285 2280
 				{
2286
-					if (!$fail_silent) trigger_error("Can't $name for scheme $scheme!\n",E_USER_WARNING);
2281
+					if (!$fail_silent) trigger_error("Can't $name for scheme $scheme!\n", E_USER_WARNING);
2287 2282
 					return false;
2288 2283
 				}
2289 2284
 				if (!is_array($pathes))
2290 2285
 				{
2291 2286
 					$params[$path_param_key] = $url;
2292 2287
 
2293
-					return call_user_func_array(array($class,$name),$params);
2288
+					return call_user_func_array(array($class, $name), $params);
2294 2289
 				}
2295 2290
 				$params[$path_param_key] = $urls;
2296
-				if (!is_array($r = call_user_func_array(array($class,$name),$params)))
2291
+				if (!is_array($r = call_user_func_array(array($class, $name), $params)))
2297 2292
 				{
2298 2293
 					return $r;
2299 2294
 				}
2300 2295
 				// we need to re-translate the urls to pathes, as they can eg. contain symlinks
2301
-				foreach($urls as $path => $url)
2296
+				foreach ($urls as $path => $url)
2302 2297
 				{
2303
-					if (isset($r[$url]) || isset($r[$url=self::parse_url($url,PHP_URL_PATH)]))
2298
+					if (isset($r[$url]) || isset($r[$url = self::parse_url($url, PHP_URL_PATH)]))
2304 2299
 					{
2305 2300
 						$ret[$path] = $r[$url];
2306 2301
 					}
2307 2302
 				}
2308 2303
 			}
2309 2304
 			// call the filesystem specific function (dont allow to use arrays!)
2310
-			elseif(!function_exists($name) || is_array($pathes))
2305
+			elseif (!function_exists($name) || is_array($pathes))
2311 2306
 			{
2312 2307
 				return false;
2313 2308
 			}
2314 2309
 			else
2315 2310
 			{
2316 2311
 				$time = null;
2317
-				return $name($url,$time);
2312
+				return $name($url, $time);
2318 2313
 			}
2319 2314
 		}
2320 2315
 		return $ret;
@@ -2328,7 +2323,7 @@  discard block
 block discarded – undo
2328 2323
 	 * @param int $atime =null access time (unix timestamp), default null = current time, not implemented in the vfs!
2329 2324
 	 * @return boolean true on success, false otherwise
2330 2325
 	 */
2331
-	static function touch($path,$time=null,$atime=null)
2326
+	static function touch($path, $time = null, $atime = null)
2332 2327
 	{
2333 2328
 		return $path[0] == '/' && touch(self::PREFIX.$path, $time, $atime);
2334 2329
 	}
@@ -2342,7 +2337,7 @@  discard block
 block discarded – undo
2342 2337
 	 * @param string $mode mode string see Vfs::mode2int
2343 2338
 	 * @return boolean true on success, false otherwise
2344 2339
 	 */
2345
-	static function chmod($path,$mode)
2340
+	static function chmod($path, $mode)
2346 2341
 	{
2347 2342
 		return $path[0] == '/' && chmod(self::PREFIX.$path, $mode);
2348 2343
 	}
@@ -2356,7 +2351,7 @@  discard block
 block discarded – undo
2356 2351
 	 * @param int|string $owner numeric user id or account-name
2357 2352
 	 * @return boolean true on success, false otherwise
2358 2353
 	 */
2359
-	static function chown($path,$owner)
2354
+	static function chown($path, $owner)
2360 2355
 	{
2361 2356
 		return $path[0] == '/' && chown(self::PREFIX.$path, is_numeric($owner) ? abs($owner) : $owner);
2362 2357
 	}
@@ -2370,7 +2365,7 @@  discard block
 block discarded – undo
2370 2365
 	 * @param int|string $group numeric group id or group-name
2371 2366
 	 * @return boolean true on success, false otherwise
2372 2367
 	 */
2373
-	static function chgrp($path,$group)
2368
+	static function chgrp($path, $group)
2374 2369
 	{
2375 2370
 		return $path[0] == '/' && chgrp(self::PREFIX.$path, is_numeric($group) ? abs($group) : $group);
2376 2371
 	}
@@ -2385,7 +2380,7 @@  discard block
 block discarded – undo
2385 2380
 	 */
2386 2381
 	static function readlink($path)
2387 2382
 	{
2388
-		$ret = self::_call_on_backend('readlink',array($path),true);	// true = fail silent, if backend does not support readlink
2383
+		$ret = self::_call_on_backend('readlink', array($path), true); // true = fail silent, if backend does not support readlink
2389 2384
 		//error_log(__METHOD__."('$path') returning ".array2string($ret).' '.function_backtrace());
2390 2385
 		return $ret;
2391 2386
 	}
@@ -2399,9 +2394,9 @@  discard block
 block discarded – undo
2399 2394
 	 * @param string $link path of the link to create
2400 2395
 	 * @return boolean true on success, false on error
2401 2396
 	 */
2402
-	static function symlink($target,$link)
2397
+	static function symlink($target, $link)
2403 2398
 	{
2404
-		if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1)))	// 1=path is in $link!
2399
+		if (($ret = self::_call_on_backend('symlink', array($target, $link), false, 1)))	// 1=path is in $link!
2405 2400
 		{
2406 2401
 			Vfs\StreamWrapper::symlinkCache_remove($link);
2407 2402
 		}
@@ -2421,13 +2416,13 @@  discard block
 block discarded – undo
2421 2416
 	 * @param boolean $recheck =false true = do a new check, false = rely on stored mime type (if existing)
2422 2417
 	 * @return string mime-type (self::DIR_MIME_TYPE for directories)
2423 2418
 	 */
2424
-	static function mime_content_type($path,$recheck=false)
2419
+	static function mime_content_type($path, $recheck = false)
2425 2420
 	{
2426 2421
 		if (!($url = self::resolve_url_symlinks($path)))
2427 2422
 		{
2428 2423
 			return false;
2429 2424
 		}
2430
-		if (($scheme = self::parse_url($url,PHP_URL_SCHEME)) && !$recheck)
2425
+		if (($scheme = self::parse_url($url, PHP_URL_SCHEME)) && !$recheck)
2431 2426
 		{
2432 2427
 			// check it it's an eGW stream wrapper returning mime-type via url_stat
2433 2428
 			// we need to first check if the constant is defined, as we get a fatal error in php5.3 otherwise
@@ -2436,7 +2431,7 @@  discard block
 block discarded – undo
2436 2431
 				($mime_attr = constant($class.'::STAT_RETURN_MIME_TYPE')))
2437 2432
 			{
2438 2433
 				$inst = new $class;
2439
-				$stat = $inst->url_stat(self::parse_url($url,PHP_URL_PATH),0);
2434
+				$stat = $inst->url_stat(self::parse_url($url, PHP_URL_PATH), 0);
2440 2435
 				if ($stat && $stat[$mime_attr])
2441 2436
 				{
2442 2437
 					$mime = $stat[$mime_attr];
@@ -2455,7 +2450,7 @@  discard block
 block discarded – undo
2455 2450
 		// using EGw's own mime magic (currently only checking the extension!)
2456 2451
 		if (!$mime)
2457 2452
 		{
2458
-			$mime = MimeMagic::filename2mime(self::parse_url($url,PHP_URL_PATH));
2453
+			$mime = MimeMagic::filename2mime(self::parse_url($url, PHP_URL_PATH));
2459 2454
 		}
2460 2455
 		//error_log(__METHOD__."($path,$recheck) mime=$mime");
2461 2456
 		return $mime;
@@ -2485,7 +2480,7 @@  discard block
 block discarded – undo
2485 2480
 	 *
2486 2481
 	 * @param string $path ='/' path of backend, whos cache to clear
2487 2482
 	 */
2488
-	static function clearstatcache($path='/')
2483
+	static function clearstatcache($path = '/')
2489 2484
 	{
2490 2485
 		//error_log(__METHOD__."('$path')");
2491 2486
 		Vfs\StreamWrapper::clearstatcache($path);
@@ -2505,7 +2500,7 @@  discard block
 block discarded – undo
2505 2500
 	 * @param string $path_to
2506 2501
 	 * @return boolean TRUE on success or FALSE on failure
2507 2502
 	 */
2508
-	static function rename ( $path_from, $path_to )
2503
+	static function rename($path_from, $path_to)
2509 2504
 	{
2510 2505
 		$vfs = new Vfs\StreamWrapper();
2511 2506
 		return $vfs->rename($path_from, $path_to);
Please login to merge, or discard this patch.