@@ -22,11 +22,11 @@ discard block |
||
| 22 | 22 | "<a href=\"$webserverURL/redirect.php?go=".htmlentities(urlencode('http://www.egroupware.org')).'">' |
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | - if(!function_exists('html_entity_decode')) |
|
| 25 | + if (!function_exists('html_entity_decode')) |
|
| 26 | 26 | { |
| 27 | 27 | function html_entity_decode($given_html, $quote_style = ENT_QUOTES) |
| 28 | 28 | { |
| 29 | - $trans_table = array_flip(get_html_translation_table( HTML_SPECIALCHARS, $quote_style)); |
|
| 29 | + $trans_table = array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)); |
|
| 30 | 30 | $trans_table['''] = "'"; |
| 31 | 31 | return(strtr($given_html, $trans_table)); |
| 32 | 32 | } |
@@ -45,17 +45,17 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | /* Only allow redirects from inside this eGroupware installation. */ |
| 47 | 47 | $valid_referer = array(); |
| 48 | - $path = preg_replace('/\/[^\/]*$/','',$_SERVER['PHP_SELF']) . '/'; |
|
| 48 | + $path = preg_replace('/\/[^\/]*$/', '', $_SERVER['PHP_SELF']).'/'; |
|
| 49 | 49 | array_push($valid_referer, $path); |
| 50 | - array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_ADDR'] . $path); |
|
| 51 | - array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . $path); |
|
| 50 | + array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['SERVER_ADDR'].$path); |
|
| 51 | + array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].$path); |
|
| 52 | 52 | |
| 53 | 53 | $referrer = trim($_SERVER['HTTP_REFERER']); |
| 54 | 54 | if ((!isset($_SERVER['HTTP_REFERER'])) || (empty($referrer))) |
| 55 | 55 | { |
| 56 | 56 | echo "Only usable from within eGroupware.\n"; |
| 57 | 57 | } |
| 58 | - else if($_GET['go']) |
|
| 58 | + else if ($_GET['go']) |
|
| 59 | 59 | { |
| 60 | 60 | $allow = false; |
| 61 | 61 | foreach ($valid_referer as $urlRoot) |
@@ -69,15 +69,15 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | if ($allow) |
| 71 | 71 | { |
| 72 | - $url= html_entity_decode(urldecode($_GET['go'])); |
|
| 72 | + $url = html_entity_decode(urldecode($_GET['go'])); |
|
| 73 | 73 | unset($_GET['go']); |
| 74 | 74 | /* Only add "&" if there is something to append. */ |
| 75 | 75 | if (!empty($_GET)) |
| 76 | 76 | { |
| 77 | - $url=$url."&".http_build_query($_GET); |
|
| 77 | + $url = $url."&".http_build_query($_GET); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - Header('Location: ' . html_entity_decode(urldecode($url))); |
|
| 80 | + Header('Location: '.html_entity_decode(urldecode($url))); |
|
| 81 | 81 | exit; |
| 82 | 82 | } |
| 83 | 83 | else |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | 'name' => 'Ralf Becker', |
| 21 | 21 | 'email' => '[email protected]' |
| 22 | 22 | ); |
| 23 | -$setup_info['filemanager']['license'] = 'GPL'; |
|
| 23 | +$setup_info['filemanager']['license'] = 'GPL'; |
|
| 24 | 24 | |
| 25 | 25 | /* The hooks this app includes, needed for hooks registration */ |
| 26 | 26 | $setup_info['filemanager']['hooks']['settings'] = 'filemanager_hooks::settings'; |
@@ -80,12 +80,12 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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( |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | ), |
| 180 | 180 | // DRAG and DROP events |
| 181 | 181 | 'file_drag' => array( |
| 182 | - 'dragType' => array('file','link'), |
|
| 182 | + 'dragType' => array('file', 'link'), |
|
| 183 | 183 | 'type' => 'drag', |
| 184 | 184 | 'onExecute' => 'javaScript:app.filemanager.drag' |
| 185 | 185 | ), |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | else |
| 220 | 220 | { |
| 221 | - foreach(Vfs\Sharing::$modes as $mode => $data) |
|
| 221 | + foreach (Vfs\Sharing::$modes as $mode => $data) |
|
| 222 | 222 | { |
| 223 | 223 | $actions['mail']['children']['mail_'.$mode] = array( |
| 224 | 224 | 'caption' => $data['label'], |
@@ -240,10 +240,10 @@ discard block |
||
| 240 | 240 | * |
| 241 | 241 | * @return string merge application or NULL if no property found |
| 242 | 242 | */ |
| 243 | - private static function get_mergeapp($path, $scope='self') |
|
| 243 | + private static function get_mergeapp($path, $scope = 'self') |
|
| 244 | 244 | { |
| 245 | 245 | $app = null; |
| 246 | - switch($scope) |
|
| 246 | + switch ($scope) |
|
| 247 | 247 | { |
| 248 | 248 | case 'self': |
| 249 | 249 | $props = Vfs::propfind($path, static::$merge_prop_namespace); |
@@ -252,10 +252,10 @@ discard block |
||
| 252 | 252 | case 'parents': |
| 253 | 253 | // search for props in parent directories |
| 254 | 254 | $currentpath = $path; |
| 255 | - while($dir = Vfs::dirname($currentpath)) |
|
| 255 | + while ($dir = Vfs::dirname($currentpath)) |
|
| 256 | 256 | { |
| 257 | 257 | $props = Vfs::propfind($dir, static::$merge_prop_namespace); |
| 258 | - if(!empty($props)) |
|
| 258 | + if (!empty($props)) |
|
| 259 | 259 | { |
| 260 | 260 | // found prop in parent directory |
| 261 | 261 | return $app = $props[0]['val']; |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | * @param array $content |
| 275 | 275 | * @param string $msg |
| 276 | 276 | */ |
| 277 | - function index(array $content=null,$msg=null) |
|
| 277 | + function index(array $content = null, $msg = null) |
|
| 278 | 278 | { |
| 279 | 279 | if (!is_array($content)) |
| 280 | 280 | { |
@@ -284,16 +284,16 @@ discard block |
||
| 284 | 284 | if (!is_array($content['nm'])) |
| 285 | 285 | { |
| 286 | 286 | $content['nm'] = array( |
| 287 | - 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 288 | - 'filter' => '', // current dir only |
|
| 289 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 290 | - 'no_cat' => True, // I disable the cat-selectbox |
|
| 291 | - 'lettersearch' => True, // I show a lettersearch |
|
| 292 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 293 | - 'start' => 0, // IO position in list |
|
| 294 | - 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
| 295 | - 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 296 | - '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 |
|
| 287 | + 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 288 | + 'filter' => '', // current dir only |
|
| 289 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 290 | + 'no_cat' => True, // I disable the cat-selectbox |
|
| 291 | + 'lettersearch' => True, // I show a lettersearch |
|
| 292 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 293 | + 'start' => 0, // IO position in list |
|
| 294 | + 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
| 295 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 296 | + '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 |
|
| 297 | 297 | 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
| 298 | 298 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
| 299 | 299 | 'actions' => static::get_actions(), |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | 'is_parent' => 'mime', |
| 304 | 304 | 'is_parent_value'=> Vfs::DIR_MIME_TYPE, |
| 305 | 305 | 'favorites' => true, |
| 306 | - 'placeholder_actions' => array('mkdir','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink') |
|
| 306 | + 'placeholder_actions' => array('mkdir', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink') |
|
| 307 | 307 | ); |
| 308 | 308 | $content['nm']['path'] = static::get_home_dir(); |
| 309 | 309 | } |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | if (isset($_GET['path']) && ($path = $_GET['path'])) |
| 326 | 326 | { |
| 327 | - switch($path) |
|
| 327 | + switch ($path) |
|
| 328 | 328 | { |
| 329 | 329 | case '..': |
| 330 | 330 | $path = Vfs::dirname($content['nm']['path']); |
@@ -333,13 +333,13 @@ discard block |
||
| 333 | 333 | $path = static::get_home_dir(); |
| 334 | 334 | break; |
| 335 | 335 | } |
| 336 | - if ($path[0] == '/' && Vfs::stat($path,true) && Vfs::is_dir($path) && Vfs::check_access($path,Vfs::READABLE)) |
|
| 336 | + if ($path[0] == '/' && Vfs::stat($path, true) && Vfs::is_dir($path) && Vfs::check_access($path, Vfs::READABLE)) |
|
| 337 | 337 | { |
| 338 | 338 | $content['nm']['path'] = $path; |
| 339 | 339 | } |
| 340 | 340 | else |
| 341 | 341 | { |
| 342 | - $msg .= lang('The requested path %1 is not available.',Vfs::decodePath($path)); |
|
| 342 | + $msg .= lang('The requested path %1 is not available.', Vfs::decodePath($path)); |
|
| 343 | 343 | } |
| 344 | 344 | // reset lettersearch as it confuses users (they think the dir is empty) |
| 345 | 345 | $content['nm']['searchletter'] = false; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | } |
| 350 | 350 | $view = static::get_view(); |
| 351 | 351 | |
| 352 | - call_user_func($view,$content,$msg); |
|
| 352 | + call_user_func($view, $content, $msg); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | /** |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | * @param boolean &$is_setup=null on return true if authenticated user is setup config user, false otherwise |
| 363 | 363 | * @return boolean true is root user given, false otherwise (including logout / empty $user) |
| 364 | 364 | */ |
| 365 | - protected function sudo($user='',$password=null,&$is_setup=null) |
|
| 365 | + protected function sudo($user = '', $password = null, &$is_setup = null) |
|
| 366 | 366 | { |
| 367 | 367 | if (!$user) |
| 368 | 368 | { |
@@ -371,15 +371,15 @@ discard block |
||
| 371 | 371 | else |
| 372 | 372 | { |
| 373 | 373 | // config user & password |
| 374 | - $is_setup = Api\Session::user_pw_hash($user,$password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
| 374 | + $is_setup = Api\Session::user_pw_hash($user, $password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
| 375 | 375 | // or vfs root user from setup >> configuration |
| 376 | - $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
| 377 | - in_array($user,preg_split('/, */',$GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
| 376 | + $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
| 377 | + in_array($user, preg_split('/, */', $GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
| 378 | 378 | $GLOBALS['egw']->auth->authenticate($user, $password, 'text'); |
| 379 | 379 | } |
| 380 | 380 | //echo "<p>".__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)."</p>\n"; |
| 381 | - Api\Cache::setSession('filemanager', 'is_setup',$is_setup); |
|
| 382 | - return Api\Cache::setSession('filemanager', 'is_root',Vfs::$is_root = $is_root); |
|
| 381 | + Api\Cache::setSession('filemanager', 'is_setup', $is_setup); |
|
| 382 | + return Api\Cache::setSession('filemanager', 'is_root', Vfs::$is_root = $is_root); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | /** |
@@ -388,18 +388,18 @@ discard block |
||
| 388 | 388 | * @param array $content |
| 389 | 389 | * @param string $msg |
| 390 | 390 | */ |
| 391 | - function listview(array $content=null,$msg=null) |
|
| 391 | + function listview(array $content = null, $msg = null) |
|
| 392 | 392 | { |
| 393 | 393 | $tpl = new Etemplate('filemanager.index'); |
| 394 | 394 | |
| 395 | - if($msg) Framework::message($msg); |
|
| 395 | + if ($msg) Framework::message($msg); |
|
| 396 | 396 | |
| 397 | 397 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
| 398 | 398 | { |
| 399 | 399 | if ($content['nm']['action']) |
| 400 | 400 | { |
| 401 | - $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
|
| 402 | - if($msg) Framework::message($msg); |
|
| 401 | + $msg = static::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']); |
|
| 402 | + if ($msg) Framework::message($msg); |
|
| 403 | 403 | |
| 404 | 404 | // clean up after action |
| 405 | 405 | unset($content['nm']['selected']); |
@@ -410,10 +410,10 @@ discard block |
||
| 410 | 410 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
| 411 | 411 | if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
| 412 | 412 | } |
| 413 | - elseif($content['nm']['rows']['delete']) |
|
| 413 | + elseif ($content['nm']['rows']['delete']) |
|
| 414 | 414 | { |
| 415 | - $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
|
| 416 | - if($msg) Framework::message($msg); |
|
| 415 | + $msg = static::action('delete', array_keys($content['nm']['rows']['delete']), $content['nm']['path']); |
|
| 416 | + if ($msg) Framework::message($msg); |
|
| 417 | 417 | |
| 418 | 418 | // clean up after action |
| 419 | 419 | unset($content['nm']['rows']['delete']); |
@@ -425,11 +425,11 @@ discard block |
||
| 425 | 425 | if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
| 426 | 426 | } |
| 427 | 427 | unset($content['nm']['rows']); |
| 428 | - Api\Cache::setSession('filemanager', 'index',$content['nm']); |
|
| 428 | + Api\Cache::setSession('filemanager', 'index', $content['nm']); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | // be tolerant with (in previous versions) not correct urlencoded pathes |
| 432 | - if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'],true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
| 432 | + if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'], true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
| 433 | 433 | { |
| 434 | 434 | $content['nm']['path'] = urldecode($content['nm']['path']); |
| 435 | 435 | } |
@@ -440,22 +440,22 @@ discard block |
||
| 440 | 440 | list($button) = each($content['button']); |
| 441 | 441 | unset($content['button']); |
| 442 | 442 | } |
| 443 | - switch($button) |
|
| 443 | + switch ($button) |
|
| 444 | 444 | { |
| 445 | 445 | case 'upload': |
| 446 | 446 | if (!$content['upload']) |
| 447 | 447 | { |
| 448 | - Framework::message(lang('You need to select some files first!'),'error'); |
|
| 448 | + Framework::message(lang('You need to select some files first!'), 'error'); |
|
| 449 | 449 | break; |
| 450 | 450 | } |
| 451 | 451 | $upload_success = $upload_failure = array(); |
| 452 | - foreach(isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
| 452 | + foreach (isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
| 453 | 453 | { |
| 454 | 454 | // encode chars which special meaning in url/vfs (some like / get removed!) |
| 455 | - $to = Vfs::concat($content['nm']['path'],Vfs::encodePathComponent($upload['name'])); |
|
| 455 | + $to = Vfs::concat($content['nm']['path'], Vfs::encodePathComponent($upload['name'])); |
|
| 456 | 456 | if ($upload && |
| 457 | 457 | (Vfs::is_writable($content['nm']['path']) || Vfs::is_writable($to)) && |
| 458 | - copy($upload['tmp_name'],Vfs::PREFIX.$to)) |
|
| 458 | + copy($upload['tmp_name'], Vfs::PREFIX.$to)) |
|
| 459 | 459 | { |
| 460 | 460 | $upload_success[] = $upload['name']; |
| 461 | 461 | } |
@@ -467,12 +467,11 @@ discard block |
||
| 467 | 467 | $content['nm']['msg'] = ''; |
| 468 | 468 | if ($upload_success) |
| 469 | 469 | { |
| 470 | - Framework::message( count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : |
|
| 471 | - lang('%1 successful uploaded.',implode(', ',$upload_success))); |
|
| 470 | + Framework::message(count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : lang('%1 successful uploaded.', implode(', ', $upload_success))); |
|
| 472 | 471 | } |
| 473 | 472 | if ($upload_failure) |
| 474 | 473 | { |
| 475 | - Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(),'error'); |
|
| 474 | + Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(), 'error'); |
|
| 476 | 475 | } |
| 477 | 476 | break; |
| 478 | 477 | } |
@@ -493,16 +492,16 @@ discard block |
||
| 493 | 492 | $tpl->setElementAttribute('nm[buttons][upload]', 'drop_target', 'popupMainDiv'); |
| 494 | 493 | } |
| 495 | 494 | // Set view button to match current settings |
| 496 | - if($content['nm']['view'] == 'tile') |
|
| 495 | + if ($content['nm']['view'] == 'tile') |
|
| 497 | 496 | { |
| 498 | - $tpl->setElementAttribute('nm[button][change_view]','statustext',lang('List view')); |
|
| 499 | - $tpl->setElementAttribute('nm[button][change_view]','image','list_row'); |
|
| 497 | + $tpl->setElementAttribute('nm[button][change_view]', 'statustext', lang('List view')); |
|
| 498 | + $tpl->setElementAttribute('nm[button][change_view]', 'image', 'list_row'); |
|
| 500 | 499 | } |
| 501 | 500 | // if initial load is done via GET request (idots template or share.php) |
| 502 | 501 | // get_rows cant call app.filemanager.set_readonly, so we need to do that here |
| 503 | 502 | $content['initial_path_readonly'] = !Vfs::is_writable($content['nm']['path']); |
| 504 | 503 | |
| 505 | - $tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm'])); |
|
| 504 | + $tpl->exec('filemanager.filemanager_ui.index', $content, $sel_options, $readonlys, array('nm' => $content['nm'])); |
|
| 506 | 505 | } |
| 507 | 506 | |
| 508 | 507 | /** |
@@ -538,7 +537,7 @@ discard block |
||
| 538 | 537 | * @param int &$files=null on return number of files deleted |
| 539 | 538 | * @return string success or failure message displayed to the user |
| 540 | 539 | */ |
| 541 | - static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null) |
|
| 540 | + static public function action($action, $selected, $dir = null, &$errs = null, &$files = null, &$dirs = null) |
|
| 542 | 541 | { |
| 543 | 542 | if (!count($selected)) |
| 544 | 543 | { |
@@ -546,20 +545,20 @@ discard block |
||
| 546 | 545 | } |
| 547 | 546 | $errs = $dirs = $files = 0; |
| 548 | 547 | |
| 549 | - switch($action) |
|
| 548 | + switch ($action) |
|
| 550 | 549 | { |
| 551 | 550 | |
| 552 | 551 | case 'delete': |
| 553 | - return static::do_delete($selected,$errs,$files,$dirs); |
|
| 552 | + return static::do_delete($selected, $errs, $files, $dirs); |
|
| 554 | 553 | |
| 555 | 554 | case 'mail': |
| 556 | 555 | case 'copy': |
| 557 | - foreach($selected as $path) |
|
| 556 | + foreach ($selected as $path) |
|
| 558 | 557 | { |
| 559 | 558 | if (strpos($path, 'mail::') === 0 && $path = substr($path, 6)) |
| 560 | 559 | { |
| 561 | 560 | // Support for dropping mail in filemanager - Pass mail back to mail app |
| 562 | - if(ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) |
|
| 561 | + if (ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) |
|
| 563 | 562 | { |
| 564 | 563 | ++$files; |
| 565 | 564 | } |
@@ -570,8 +569,8 @@ discard block |
||
| 570 | 569 | } |
| 571 | 570 | elseif (!Vfs::is_dir($path)) |
| 572 | 571 | { |
| 573 | - $to = Vfs::concat($dir,Vfs::basename($path)); |
|
| 574 | - if ($path != $to && Vfs::copy($path,$to)) |
|
| 572 | + $to = Vfs::concat($dir, Vfs::basename($path)); |
|
| 573 | + if ($path != $to && Vfs::copy($path, $to)) |
|
| 575 | 574 | { |
| 576 | 575 | ++$files; |
| 577 | 576 | } |
@@ -583,19 +582,19 @@ discard block |
||
| 583 | 582 | else |
| 584 | 583 | { |
| 585 | 584 | $len = strlen(dirname($path)); |
| 586 | - foreach(Vfs::find($path) as $p) |
|
| 585 | + foreach (Vfs::find($path) as $p) |
|
| 587 | 586 | { |
| 588 | - $to = $dir.substr($p,$len); |
|
| 587 | + $to = $dir.substr($p, $len); |
|
| 589 | 588 | if ($to == $p) // cant copy into itself! |
| 590 | 589 | { |
| 591 | 590 | ++$errs; |
| 592 | 591 | continue; |
| 593 | 592 | } |
| 594 | - if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
|
| 593 | + if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to, null, STREAM_MKDIR_RECURSIVE)) |
|
| 595 | 594 | { |
| 596 | 595 | ++$dirs; |
| 597 | 596 | } |
| 598 | - elseif(!$is_dir && Vfs::copy($p,$to)) |
|
| 597 | + elseif (!$is_dir && Vfs::copy($p, $to)) |
|
| 599 | 598 | { |
| 600 | 599 | ++$files; |
| 601 | 600 | } |
@@ -608,15 +607,15 @@ discard block |
||
| 608 | 607 | } |
| 609 | 608 | if ($errs) |
| 610 | 609 | { |
| 611 | - return lang('%1 errors copying (%2 diretories and %3 files copied)!',$errs,$dirs,$files); |
|
| 610 | + return lang('%1 errors copying (%2 diretories and %3 files copied)!', $errs, $dirs, $files); |
|
| 612 | 611 | } |
| 613 | - return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files); |
|
| 612 | + return $dirs ? lang('%1 directories and %2 files copied.', $dirs, $files) : lang('%1 files copied.', $files); |
|
| 614 | 613 | |
| 615 | 614 | case 'move': |
| 616 | - foreach($selected as $path) |
|
| 615 | + foreach ($selected as $path) |
|
| 617 | 616 | { |
| 618 | - $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir,Vfs::basename($path)) : $dir; |
|
| 619 | - if ($path != $to && Vfs::rename($path,$to)) |
|
| 617 | + $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir, Vfs::basename($path)) : $dir; |
|
| 618 | + if ($path != $to && Vfs::rename($path, $to)) |
|
| 620 | 619 | { |
| 621 | 620 | ++$files; |
| 622 | 621 | } |
@@ -627,17 +626,17 @@ discard block |
||
| 627 | 626 | } |
| 628 | 627 | if ($errs) |
| 629 | 628 | { |
| 630 | - return lang('%1 errors moving (%2 files moved)!',$errs,$files); |
|
| 629 | + return lang('%1 errors moving (%2 files moved)!', $errs, $files); |
|
| 631 | 630 | } |
| 632 | - return lang('%1 files moved.',$files); |
|
| 631 | + return lang('%1 files moved.', $files); |
|
| 633 | 632 | |
| 634 | 633 | case 'symlink': // symlink given files to $dir |
| 635 | - foreach((array)$selected as $target) |
|
| 634 | + foreach ((array)$selected as $target) |
|
| 636 | 635 | { |
| 637 | 636 | $link = Vfs::concat($dir, Vfs::basename($target)); |
| 638 | - if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir,0,true))) |
|
| 637 | + if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir, 0, true))) |
|
| 639 | 638 | { |
| 640 | - if(!$ok) |
|
| 639 | + if (!$ok) |
|
| 641 | 640 | { |
| 642 | 641 | $errs++; |
| 643 | 642 | continue; |
@@ -659,15 +658,14 @@ discard block |
||
| 659 | 658 | } |
| 660 | 659 | if (count((array)$selected) == 1) |
| 661 | 660 | { |
| 662 | - return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : |
|
| 663 | - lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
| 661 | + return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
| 664 | 662 | } |
| 665 | 663 | $ret = lang('%1 elements linked.', $files); |
| 666 | 664 | if ($errs) |
| 667 | 665 | { |
| 668 | - $ret = lang('%1 errors linking (%2)!',$errs, $ret); |
|
| 666 | + $ret = lang('%1 errors linking (%2)!', $errs, $ret); |
|
| 669 | 667 | } |
| 670 | - return $ret;//." Vfs::symlink('$target', '$link')"; |
|
| 668 | + return $ret; //." Vfs::symlink('$target', '$link')"; |
|
| 671 | 669 | |
| 672 | 670 | case 'createdir': |
| 673 | 671 | $dst = Vfs::concat($dir, is_array($selected) ? $selected[0] : $selected); |
@@ -683,13 +681,13 @@ discard block |
||
| 683 | 681 | |
| 684 | 682 | default: |
| 685 | 683 | list($action, $settings) = explode('_', $action, 2); |
| 686 | - switch($action) |
|
| 684 | + switch ($action) |
|
| 687 | 685 | { |
| 688 | 686 | case 'document': |
| 689 | 687 | if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
| 690 | 688 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
| 691 | 689 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
| 692 | - if($msg) return $msg; |
|
| 690 | + if ($msg) return $msg; |
|
| 693 | 691 | $errs = count($selected); |
| 694 | 692 | return false; |
| 695 | 693 | } |
@@ -706,12 +704,12 @@ discard block |
||
| 706 | 704 | * @param int &$files=null on return number of files deleted |
| 707 | 705 | * @return string |
| 708 | 706 | */ |
| 709 | - public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null) |
|
| 707 | + public static function do_delete(array $selected, &$errs = null, &$dirs = null, &$files = null) |
|
| 710 | 708 | { |
| 711 | 709 | $dirs = $files = $errs = 0; |
| 712 | 710 | // we first delete all selected links (and files) |
| 713 | 711 | // feeding the links to dirs to Vfs::find() deletes the content of the dirs, not just the link! |
| 714 | - foreach($selected as $key => $path) |
|
| 712 | + foreach ($selected as $key => $path) |
|
| 715 | 713 | { |
| 716 | 714 | if (!Vfs::is_dir($path) || Vfs::is_link($path)) |
| 717 | 715 | { |
@@ -729,21 +727,21 @@ discard block |
||
| 729 | 727 | if ($selected) // somethings left to delete |
| 730 | 728 | { |
| 731 | 729 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
| 732 | - foreach((array)$selected as $path) |
|
| 730 | + foreach ((array)$selected as $path) |
|
| 733 | 731 | { |
| 734 | - if (preg_match('/^\/?(home|apps|)\/*$/',$path)) |
|
| 732 | + if (preg_match('/^\/?(home|apps|)\/*$/', $path)) |
|
| 735 | 733 | { |
| 736 | 734 | $errs++; |
| 737 | - return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
|
| 735 | + return lang("Cautiously rejecting to remove folder '%1'!", Vfs::decodePath($path)); |
|
| 738 | 736 | } |
| 739 | 737 | } |
| 740 | 738 | // now we use find to loop through all files and dirs: (selected only contains dirs now) |
| 741 | 739 | // - depth=true to get first the files and then the dir containing it |
| 742 | 740 | // - hidden=true to also return hidden files (eg. Thumbs.db), as we cant delete non-empty dirs |
| 743 | 741 | // - show-deleted=false to not (finally) deleted versioned files |
| 744 | - foreach(Vfs::find($selected,array('depth'=>true,'hidden'=>true,'show-deleted'=>false)) as $path) |
|
| 742 | + foreach (Vfs::find($selected, array('depth'=>true, 'hidden'=>true, 'show-deleted'=>false)) as $path) |
|
| 745 | 743 | { |
| 746 | - if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path,0)) |
|
| 744 | + if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path, 0)) |
|
| 747 | 745 | { |
| 748 | 746 | ++$dirs; |
| 749 | 747 | } |
@@ -759,13 +757,13 @@ discard block |
||
| 759 | 757 | } |
| 760 | 758 | if ($errs) |
| 761 | 759 | { |
| 762 | - return lang('%1 errors deleteting (%2 directories and %3 files deleted)!',$errs,$dirs,$files); |
|
| 760 | + return lang('%1 errors deleteting (%2 directories and %3 files deleted)!', $errs, $dirs, $files); |
|
| 763 | 761 | } |
| 764 | 762 | if ($dirs) |
| 765 | 763 | { |
| 766 | - return lang('%1 directories and %2 files deleted.',$dirs,$files); |
|
| 764 | + return lang('%1 directories and %2 files deleted.', $dirs, $files); |
|
| 767 | 765 | } |
| 768 | - return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.',$files); |
|
| 766 | + return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.', $files); |
|
| 769 | 767 | } |
| 770 | 768 | |
| 771 | 769 | /** |
@@ -777,44 +775,44 @@ discard block |
||
| 777 | 775 | function get_rows(&$query, &$rows) |
| 778 | 776 | { |
| 779 | 777 | // show projectmanager sidebox for projectmanager path |
| 780 | - if (substr($query['path'],0,20) == '/apps/projectmanager' && isset($GLOBALS['egw_info']['user']['apps']['projectmanager'])) |
|
| 778 | + if (substr($query['path'], 0, 20) == '/apps/projectmanager' && isset($GLOBALS['egw_info']['user']['apps']['projectmanager'])) |
|
| 781 | 779 | { |
| 782 | 780 | $GLOBALS['egw_info']['flags']['currentapp'] = 'projectmanager'; |
| 783 | 781 | } |
| 784 | 782 | // do NOT store query, if hierarchical data / children are requested |
| 785 | 783 | if (!$query['csv_export']) |
| 786 | 784 | { |
| 787 | - Api\Cache::setSession('filemanager', 'index',$query); |
|
| 785 | + Api\Cache::setSession('filemanager', 'index', $query); |
|
| 788 | 786 | } |
| 789 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
| 787 | + if (!$query['path']) $query['path'] = static::get_home_dir(); |
|
| 790 | 788 | |
| 791 | 789 | // Change template to match selected view |
| 792 | - if($query['view']) |
|
| 790 | + if ($query['view']) |
|
| 793 | 791 | { |
| 794 | 792 | $query['template'] = ($query['view'] == 'row' ? 'filemanager.index.rows' : 'filemanager.tile'); |
| 795 | 793 | |
| 796 | 794 | // Store as preference but only for index, not home |
| 797 | - if($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
| 795 | + if ($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
| 798 | 796 | { |
| 799 | - $GLOBALS['egw']->preferences->add('filemanager','nm_view',$query['view']); |
|
| 797 | + $GLOBALS['egw']->preferences->add('filemanager', 'nm_view', $query['view']); |
|
| 800 | 798 | $GLOBALS['egw']->preferences->save_repository(); |
| 801 | 799 | } |
| 802 | 800 | } |
| 803 | 801 | // be tolerant with (in previous versions) not correct urlencoded pathes |
| 804 | - if (!Vfs::stat($query['path'],true) && Vfs::stat(urldecode($query['path']))) |
|
| 802 | + if (!Vfs::stat($query['path'], true) && Vfs::stat(urldecode($query['path']))) |
|
| 805 | 803 | { |
| 806 | 804 | $query['path'] = urldecode($query['path']); |
| 807 | 805 | } |
| 808 | - if (!Vfs::stat($query['path'],true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'],Vfs::READABLE)) |
|
| 806 | + if (!Vfs::stat($query['path'], true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'], Vfs::READABLE)) |
|
| 809 | 807 | { |
| 810 | 808 | // only redirect, if it would be to some other location, gives redirect-loop otherwise |
| 811 | 809 | if ($query['path'] != ($path = static::get_home_dir())) |
| 812 | 810 | { |
| 813 | 811 | // we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give |
| 814 | 812 | // an appropriate message |
| 815 | - Egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index', |
|
| 813 | + Egw::redirect_link('/index.php', array('menuaction'=>'filemanager.filemanager_ui.index', |
|
| 816 | 814 | 'path' => $path, |
| 817 | - 'msg' => lang('The requested path %1 is not available.',Vfs::decodePath($query['path'])), |
|
| 815 | + 'msg' => lang('The requested path %1 is not available.', Vfs::decodePath($query['path'])), |
|
| 818 | 816 | 'ajax' => 'true' |
| 819 | 817 | )); |
| 820 | 818 | } |
@@ -822,35 +820,35 @@ discard block |
||
| 822 | 820 | return 0; |
| 823 | 821 | } |
| 824 | 822 | $rows = $dir_is_writable = array(); |
| 825 | - if($query['searchletter'] && !empty($query['search'])) |
|
| 823 | + if ($query['searchletter'] && !empty($query['search'])) |
|
| 826 | 824 | { |
| 827 | - $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
| 825 | + $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
| 828 | 826 | if ($query['searchletter'] == strtolower($query['search'][0])) |
| 829 | 827 | { |
| 830 | - $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'|'. |
|
| 831 | - str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).')/i'; |
|
| 828 | + $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'|'. |
|
| 829 | + str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).')/i'; |
|
| 832 | 830 | } |
| 833 | 831 | } |
| 834 | 832 | elseif ($query['searchletter']) |
| 835 | 833 | { |
| 836 | 834 | $namefilter = '/^'.$query['searchletter'].'/i'; |
| 837 | 835 | } |
| 838 | - elseif(!empty($query['search'])) |
|
| 836 | + elseif (!empty($query['search'])) |
|
| 839 | 837 | { |
| 840 | - $namefilter = '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
| 838 | + $namefilter = '/'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
| 841 | 839 | } |
| 842 | 840 | |
| 843 | 841 | // Re-map so 'No filters' favorite ('') is depth 1 |
| 844 | 842 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
| 845 | 843 | |
| 846 | 844 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
| 847 | - if($filter == 5) $maxdepth = 2; |
|
| 845 | + if ($filter == 5) $maxdepth = 2; |
|
| 848 | 846 | $n = 0; |
| 849 | 847 | $vfs_options = array( |
| 850 | 848 | 'mindepth' => 1, |
| 851 | 849 | 'maxdepth' => $maxdepth, |
| 852 | 850 | 'dirsontop' => $filter <= 1, |
| 853 | - 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F':'f'), |
|
| 851 | + 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F' : 'f'), |
|
| 854 | 852 | 'order' => $query['order'], 'sort' => $query['sort'], |
| 855 | 853 | 'limit' => (int)$query['num_rows'].','.(int)$query['start'], |
| 856 | 854 | 'need_mime' => true, |
@@ -858,11 +856,11 @@ discard block |
||
| 858 | 856 | 'hidden' => $filter == 3, |
| 859 | 857 | 'follow' => $filter == 5, |
| 860 | 858 | ); |
| 861 | - if($query['col_filter']['mime']) |
|
| 859 | + if ($query['col_filter']['mime']) |
|
| 862 | 860 | { |
| 863 | 861 | $vfs_options['mime'] = $query['col_filter']['mime']; |
| 864 | 862 | } |
| 865 | - foreach(Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],$vfs_options,true) as $path => $row) |
|
| 863 | + foreach (Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'], $vfs_options, true) as $path => $row) |
|
| 866 | 864 | { |
| 867 | 865 | //echo $path; _debug_array($row); |
| 868 | 866 | |
@@ -876,32 +874,32 @@ discard block |
||
| 876 | 874 | $row['class'] = 'isDir'; |
| 877 | 875 | } |
| 878 | 876 | $row['download_url'] = Vfs::download_url($path); |
| 879 | - $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
| 877 | + $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
| 880 | 878 | |
| 881 | 879 | $rows[++$n] = $row; |
| 882 | 880 | $path2n[$path] = $n; |
| 883 | 881 | } |
| 884 | 882 | // query comments and cf's for the displayed rows |
| 885 | - $cols_to_show = explode(',',$GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
| 883 | + $cols_to_show = explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
| 886 | 884 | |
| 887 | 885 | // Always include comment in tiles |
| 888 | - if($query['view'] == 'tile') |
|
| 886 | + if ($query['view'] == 'tile') |
|
| 889 | 887 | { |
| 890 | 888 | $cols_to_show[] = 'comment'; |
| 891 | 889 | } |
| 892 | - $all_cfs = in_array('customfields',$cols_to_show) && $cols_to_show[count($cols_to_show)-1][0] != '#'; |
|
| 893 | - if ($path2n && (in_array('comment',$cols_to_show) || in_array('customfields',$cols_to_show)) && |
|
| 890 | + $all_cfs = in_array('customfields', $cols_to_show) && $cols_to_show[count($cols_to_show) - 1][0] != '#'; |
|
| 891 | + if ($path2n && (in_array('comment', $cols_to_show) || in_array('customfields', $cols_to_show)) && |
|
| 894 | 892 | ($path2props = Vfs::propfind(array_keys($path2n)))) |
| 895 | 893 | { |
| 896 | - foreach($path2props as $path => $props) |
|
| 894 | + foreach ($path2props as $path => $props) |
|
| 897 | 895 | { |
| 898 | - unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
| 899 | - $row =& $rows[$path2n[$path]]; |
|
| 900 | - if ( !is_array($props) ) continue; |
|
| 901 | - foreach($props as $prop) |
|
| 896 | + unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
| 897 | + $row = & $rows[$path2n[$path]]; |
|
| 898 | + if (!is_array($props)) continue; |
|
| 899 | + foreach ($props as $prop) |
|
| 902 | 900 | { |
| 903 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
| 904 | - $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
|
| 901 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'], $cols_to_show)) continue; |
|
| 902 | + $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'], 0, 64).' ...'; |
|
| 905 | 903 | } |
| 906 | 904 | } |
| 907 | 905 | } |
@@ -913,7 +911,7 @@ discard block |
||
| 913 | 911 | if ($GLOBALS['egw_info']['flags']['currentapp'] == 'projectmanager') |
| 914 | 912 | { |
| 915 | 913 | // we need our app.css file |
| 916 | - if (!file_exists(EGW_SERVER_ROOT.($css_file='/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
| 914 | + if (!file_exists(EGW_SERVER_ROOT.($css_file = '/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
| 917 | 915 | { |
| 918 | 916 | $css_file = '/filemanager/templates/default/app.css'; |
| 919 | 917 | } |
@@ -929,7 +927,7 @@ discard block |
||
| 929 | 927 | * @param array $content |
| 930 | 928 | * @param string $msg |
| 931 | 929 | */ |
| 932 | - function file(array $content=null,$msg='') |
|
| 930 | + function file(array $content = null, $msg = '') |
|
| 933 | 931 | { |
| 934 | 932 | $tpl = new Etemplate('filemanager.file'); |
| 935 | 933 | |
@@ -939,9 +937,9 @@ discard block |
||
| 939 | 937 | { |
| 940 | 938 | $msg .= $_GET['msg']; |
| 941 | 939 | } |
| 942 | - if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) || // ?, # need to stay encoded! |
|
| 940 | + if (!($path = str_replace(array('#', '?'), array('%23', '%3F'), $_GET['path'])) || // ?, # need to stay encoded! |
|
| 943 | 941 | // actions enclose pathes containing comma with " |
| 944 | - ($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) || |
|
| 942 | + ($path[0] == '"' && substr($path, -1) == '"' && !($path = substr(str_replace('""', '"', $path), 1, -1))) || |
|
| 945 | 943 | !($stat = Vfs::lstat($path))) |
| 946 | 944 | { |
| 947 | 945 | $msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat); |
@@ -954,10 +952,10 @@ discard block |
||
| 954 | 952 | $content['path'] = $path; |
| 955 | 953 | $content['hsize'] = Vfs::hsize($stat['size']); |
| 956 | 954 | $content['mime'] = Vfs::mime_content_type($path); |
| 957 | - $content['gid'] *= -1; // our widgets use negative gid's |
|
| 955 | + $content['gid'] *= -1; // our widgets use negative gid's |
|
| 958 | 956 | if (($props = Vfs::propfind($path))) |
| 959 | 957 | { |
| 960 | - foreach($props as $prop) |
|
| 958 | + foreach ($props as $prop) |
|
| 961 | 959 | { |
| 962 | 960 | $content[$prop['name']] = $prop['val']; |
| 963 | 961 | } |
@@ -970,9 +968,9 @@ discard block |
||
| 970 | 968 | $content['tabs'] = $_GET['tabs']; |
| 971 | 969 | if (!($content['is_dir'] = Vfs::is_dir($path) && !Vfs::is_link($path))) |
| 972 | 970 | { |
| 973 | - $content['perms']['executable'] = (int)!!($content['mode'] & 0111); |
|
| 971 | + $content['perms']['executable'] = (int)!!($content['mode']&0111); |
|
| 974 | 972 | $mask = 6; |
| 975 | - if (preg_match('/^text/',$content['mime']) && $content['size'] < 100000) |
|
| 973 | + if (preg_match('/^text/', $content['mime']) && $content['size'] < 100000) |
|
| 976 | 974 | { |
| 977 | 975 | $content['text_content'] = file_get_contents(Vfs::PREFIX.$path); |
| 978 | 976 | } |
@@ -982,19 +980,19 @@ discard block |
||
| 982 | 980 | //currently not implemented in backend $content['perms']['sticky'] = (int)!!($content['mode'] & 0x201); |
| 983 | 981 | $mask = 7; |
| 984 | 982 | } |
| 985 | - foreach(array('owner' => 6,'group' => 3,'other' => 0) as $name => $shift) |
|
| 983 | + foreach (array('owner' => 6, 'group' => 3, 'other' => 0) as $name => $shift) |
|
| 986 | 984 | { |
| 987 | - $content['perms'][$name] = ($content['mode'] >> $shift) & $mask; |
|
| 985 | + $content['perms'][$name] = ($content['mode'] >> $shift)&$mask; |
|
| 988 | 986 | } |
| 989 | - $content['is_owner'] = Vfs::has_owner_rights($path,$content); |
|
| 987 | + $content['is_owner'] = Vfs::has_owner_rights($path, $content); |
|
| 990 | 988 | } |
| 991 | 989 | else |
| 992 | 990 | { |
| 993 | 991 | //_debug_array($content); |
| 994 | - $path =& $content['path']; |
|
| 992 | + $path = & $content['path']; |
|
| 995 | 993 | |
| 996 | 994 | list($button) = @each($content['button']); unset($content['button']); |
| 997 | - if(!$button && $content['sudo']) |
|
| 995 | + if (!$button && $content['sudo']) |
|
| 998 | 996 | { |
| 999 | 997 | // Button to stop sudo is not in button namespace |
| 1000 | 998 | $button = 'sudo'; |
@@ -1003,45 +1001,45 @@ discard block |
||
| 1003 | 1001 | // need to check 'setup' button (submit button in sudo popup), as some browsers (eg. chrome) also fill the hidden field |
| 1004 | 1002 | if ($button == 'sudo' && Vfs::$is_root || $button == 'setup' && $content['sudo']['user']) |
| 1005 | 1003 | { |
| 1006 | - $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '',$content['sudo']['passwd']) ? |
|
| 1004 | + $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '', $content['sudo']['passwd']) ? |
|
| 1007 | 1005 | lang('Root access granted.') : ($button == 'setup' && $content['sudo']['user'] ? |
| 1008 | 1006 | lang('Wrong username or password!') : lang('Root access stopped.')); |
| 1009 | 1007 | unset($content['sudo']); |
| 1010 | 1008 | $content['is_owner'] = Vfs::has_owner_rights($path); |
| 1011 | 1009 | } |
| 1012 | - if (in_array($button,array('save','apply'))) |
|
| 1010 | + if (in_array($button, array('save', 'apply'))) |
|
| 1013 | 1011 | { |
| 1014 | 1012 | $props = array(); |
| 1015 | 1013 | $perm_changed = $perm_failed = 0; |
| 1016 | - foreach($content['old'] as $name => $old_value) |
|
| 1014 | + foreach ($content['old'] as $name => $old_value) |
|
| 1017 | 1015 | { |
| 1018 | 1016 | if (isset($content[$name]) && ($old_value != $content[$name] || |
| 1019 | 1017 | // do not check for modification, if modify_subs is checked! |
| 1020 | - $content['modify_subs'] && in_array($name,array('uid','gid','perms'))) && |
|
| 1018 | + $content['modify_subs'] && in_array($name, array('uid', 'gid', 'perms'))) && |
|
| 1021 | 1019 | ($name != 'uid' || Vfs::$is_root)) |
| 1022 | 1020 | { |
| 1023 | 1021 | if ($name == 'name') |
| 1024 | 1022 | { |
| 1025 | - $to = Vfs::concat(Vfs::dirname($path),$content['name']); |
|
| 1023 | + $to = Vfs::concat(Vfs::dirname($path), $content['name']); |
|
| 1026 | 1024 | if (file_exists(Vfs::PREFIX.$to) && $content['confirm_overwrite'] !== $to) |
| 1027 | 1025 | { |
| 1028 | - $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
|
| 1029 | - lang('To overwrite the existing file store again.',lang($button))); |
|
| 1026 | + $tpl->set_validation_error('name', lang("There's already a file with that name!").'<br />'. |
|
| 1027 | + lang('To overwrite the existing file store again.', lang($button))); |
|
| 1030 | 1028 | $content['confirm_overwrite'] = $to; |
| 1031 | 1029 | if ($button == 'save') $button = 'apply'; |
| 1032 | 1030 | continue; |
| 1033 | 1031 | } |
| 1034 | - if (Vfs::rename($path,$to)) |
|
| 1032 | + if (Vfs::rename($path, $to)) |
|
| 1035 | 1033 | { |
| 1036 | - $msg .= lang('Renamed %1 to %2.',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
| 1034 | + $msg .= lang('Renamed %1 to %2.', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
| 1037 | 1035 | $content['old']['name'] = $content[$name]; |
| 1038 | 1036 | $path = $to; |
| 1039 | - $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
| 1040 | - $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
| 1037 | + $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
| 1038 | + $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
| 1041 | 1039 | } |
| 1042 | 1040 | else |
| 1043 | 1041 | { |
| 1044 | - $msg .= lang('Rename of %1 to %2 failed!',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
| 1042 | + $msg .= lang('Rename of %1 to %2 failed!', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
| 1045 | 1043 | if (Vfs::deny_script($to)) |
| 1046 | 1044 | { |
| 1047 | 1045 | $msg .= lang('You are NOT allowed to upload a script!').' '; |
@@ -1061,7 +1059,7 @@ discard block |
||
| 1061 | 1059 | 'val' => (!empty($content[$name]) ? $content[$name] : null), |
| 1062 | 1060 | ), |
| 1063 | 1061 | ); |
| 1064 | - if (Vfs::proppatch($path,$mergeprop)) |
|
| 1062 | + if (Vfs::proppatch($path, $mergeprop)) |
|
| 1065 | 1063 | { |
| 1066 | 1064 | $content['old'][$name] = $content[$name]; |
| 1067 | 1065 | $msg .= lang('Setting for document merge saved.'); |
@@ -1073,22 +1071,22 @@ discard block |
||
| 1073 | 1071 | } |
| 1074 | 1072 | else |
| 1075 | 1073 | { |
| 1076 | - static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod'); |
|
| 1077 | - $cmd = array('egw_vfs',$name2cmd[$name]); |
|
| 1074 | + static $name2cmd = array('uid' => 'chown', 'gid' => 'chgrp', 'perms' => 'chmod'); |
|
| 1075 | + $cmd = array('egw_vfs', $name2cmd[$name]); |
|
| 1078 | 1076 | $value = $name == 'perms' ? static::perms2mode($content['perms']) : $content[$name]; |
| 1079 | 1077 | if ($content['modify_subs']) |
| 1080 | 1078 | { |
| 1081 | 1079 | if ($name == 'perms') |
| 1082 | 1080 | { |
| 1083 | - $changed = Vfs::find($path,array('type'=>'d'),$cmd,array($value)); |
|
| 1084 | - $changed += Vfs::find($path,array('type'=>'f'),$cmd,array($value & 0666)); // no execute for files |
|
| 1081 | + $changed = Vfs::find($path, array('type'=>'d'), $cmd, array($value)); |
|
| 1082 | + $changed += Vfs::find($path, array('type'=>'f'), $cmd, array($value&0666)); // no execute for files |
|
| 1085 | 1083 | } |
| 1086 | 1084 | else |
| 1087 | 1085 | { |
| 1088 | - $changed = Vfs::find($path,null,$cmd,array($value)); |
|
| 1086 | + $changed = Vfs::find($path, null, $cmd, array($value)); |
|
| 1089 | 1087 | } |
| 1090 | 1088 | $ok = $failed = 0; |
| 1091 | - foreach($changed as &$r) |
|
| 1089 | + foreach ($changed as &$r) |
|
| 1092 | 1090 | { |
| 1093 | 1091 | if ($r) |
| 1094 | 1092 | { |
@@ -1101,32 +1099,32 @@ discard block |
||
| 1101 | 1099 | } |
| 1102 | 1100 | if ($ok && !$failed) |
| 1103 | 1101 | { |
| 1104 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
| 1102 | + if (!$perm_changed++) $msg .= lang('Permissions of %1 changed.', $path.' '.lang('and all it\'s childeren')); |
|
| 1105 | 1103 | $content['old'][$name] = $content[$name]; |
| 1106 | 1104 | } |
| 1107 | - elseif($failed) |
|
| 1105 | + elseif ($failed) |
|
| 1108 | 1106 | { |
| 1109 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
| 1110 | - ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
|
| 1107 | + if (!$perm_failed++) $msg .= lang('Failed to change permissions of %1!', $path.lang('and all it\'s childeren'). |
|
| 1108 | + ($ok ? ' ('.lang('%1 failed, %2 succeded', $failed, $ok).')' : '')); |
|
| 1111 | 1109 | } |
| 1112 | 1110 | } |
| 1113 | - elseif (call_user_func_array($cmd,array($path,$value))) |
|
| 1111 | + elseif (call_user_func_array($cmd, array($path, $value))) |
|
| 1114 | 1112 | { |
| 1115 | - $msg .= lang('Permissions of %1 changed.',$path); |
|
| 1113 | + $msg .= lang('Permissions of %1 changed.', $path); |
|
| 1116 | 1114 | $content['old'][$name] = $content[$name]; |
| 1117 | 1115 | } |
| 1118 | 1116 | else |
| 1119 | 1117 | { |
| 1120 | - $msg .= lang('Failed to change permissions of %1!',$path); |
|
| 1118 | + $msg .= lang('Failed to change permissions of %1!', $path); |
|
| 1121 | 1119 | } |
| 1122 | 1120 | } |
| 1123 | 1121 | } |
| 1124 | 1122 | } |
| 1125 | 1123 | if ($props) |
| 1126 | 1124 | { |
| 1127 | - if (Vfs::proppatch($path,$props)) |
|
| 1125 | + if (Vfs::proppatch($path, $props)) |
|
| 1128 | 1126 | { |
| 1129 | - foreach($props as $prop) |
|
| 1127 | + foreach ($props as $prop) |
|
| 1130 | 1128 | { |
| 1131 | 1129 | $content['old'][$prop['name']] = $prop['val']; |
| 1132 | 1130 | } |
@@ -1143,8 +1141,8 @@ discard block |
||
| 1143 | 1141 | if ($content['eacl']['delete']) |
| 1144 | 1142 | { |
| 1145 | 1143 | list($ino_owner) = each($content['eacl']['delete']); |
| 1146 | - list(, $owner) = explode('-',$ino_owner,2); // $owner is a group and starts with a minus! |
|
| 1147 | - $msg .= Vfs::eacl($path,null,$owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
| 1144 | + list(, $owner) = explode('-', $ino_owner, 2); // $owner is a group and starts with a minus! |
|
| 1145 | + $msg .= Vfs::eacl($path, null, $owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
| 1148 | 1146 | } |
| 1149 | 1147 | elseif ($button == 'eacl') |
| 1150 | 1148 | { |
@@ -1154,7 +1152,7 @@ discard block |
||
| 1154 | 1152 | } |
| 1155 | 1153 | else |
| 1156 | 1154 | { |
| 1157 | - $msg .= Vfs::eacl($path,$content['eacl']['rights'],$content['eacl_owner']) ? |
|
| 1155 | + $msg .= Vfs::eacl($path, $content['eacl']['rights'], $content['eacl_owner']) ? |
|
| 1158 | 1156 | lang('ACL added.') : lang('Error adding the ACL!'); |
| 1159 | 1157 | } |
| 1160 | 1158 | } |
@@ -1164,7 +1162,7 @@ discard block |
||
| 1164 | 1162 | } |
| 1165 | 1163 | if ($content['is_link'] && !Vfs::stat($path)) |
| 1166 | 1164 | { |
| 1167 | - $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!',$content['symlink']); |
|
| 1165 | + $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!', $content['symlink']); |
|
| 1168 | 1166 | } |
| 1169 | 1167 | $content['link'] = Egw::link(Vfs::download_url($path)); |
| 1170 | 1168 | $content['icon'] = Vfs::mime_icon($content['mime']); |
@@ -1173,10 +1171,10 @@ discard block |
||
| 1173 | 1171 | if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
| 1174 | 1172 | // only owner can change group & perms |
| 1175 | 1173 | if (($readonlys['gid'] = !$content['is_owner'] || |
| 1176 | - Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs')) // no uid, gid or perms in oldvfs |
|
| 1174 | + Vfs::parse_url(Vfs::resolve_url($content['path']), PHP_URL_SCHEME) == 'oldvfs')) // no uid, gid or perms in oldvfs |
|
| 1177 | 1175 | { |
| 1178 | 1176 | if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
| 1179 | - foreach($content['perms'] as $name => $value) |
|
| 1177 | + foreach ($content['perms'] as $name => $value) |
|
| 1180 | 1178 | { |
| 1181 | 1179 | $readonlys['perms['.$name.']'] = true; |
| 1182 | 1180 | } |
@@ -1194,37 +1192,37 @@ discard block |
||
| 1194 | 1192 | } |
| 1195 | 1193 | elseif (!Vfs::is_writable($path)) |
| 1196 | 1194 | { |
| 1197 | - foreach($cfs as $name => $data) |
|
| 1195 | + foreach ($cfs as $name => $data) |
|
| 1198 | 1196 | { |
| 1199 | 1197 | $readonlys['#'.$name] = true; |
| 1200 | 1198 | } |
| 1201 | 1199 | } |
| 1202 | - $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
| 1200 | + $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
| 1203 | 1201 | if ($content['is_dir']) |
| 1204 | 1202 | { |
| 1205 | - $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
| 1206 | - $sel_options['rights']=$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
| 1203 | + $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
| 1204 | + $sel_options['rights'] = $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
| 1207 | 1205 | 7 => lang('Display and modification of content'), |
| 1208 | 1206 | 5 => lang('Display of content'), |
| 1209 | 1207 | 0 => lang('No access'), |
| 1210 | 1208 | ); |
| 1211 | - if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
| 1209 | + if (($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
| 1212 | 1210 | { |
| 1213 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
| 1214 | - foreach($content['eacl'] as &$eacl) |
|
| 1211 | + unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
| 1212 | + foreach ($content['eacl'] as &$eacl) |
|
| 1215 | 1213 | { |
| 1216 | - $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
|
| 1214 | + $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'], PHP_URL_PATH), '/'); |
|
| 1217 | 1215 | $readonlys['delete['.$eacl['ino'].'-'.$eacl['owner'].']'] = $eacl['ino'] != $content['ino'] || |
| 1218 | 1216 | $eacl['path'] != $content['path'] || !$content['is_owner']; |
| 1219 | 1217 | } |
| 1220 | - array_unshift($content['eacl'],false); // make the keys start with 1, not 0 |
|
| 1218 | + array_unshift($content['eacl'], false); // make the keys start with 1, not 0 |
|
| 1221 | 1219 | $content['eacl']['owner'] = 0; |
| 1222 | 1220 | $content['eacl']['rights'] = 5; |
| 1223 | 1221 | } |
| 1224 | 1222 | } |
| 1225 | 1223 | else |
| 1226 | 1224 | { |
| 1227 | - $sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
| 1225 | + $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
| 1228 | 1226 | 6 => lang('Read & write access'), |
| 1229 | 1227 | 4 => lang('Read access only'), |
| 1230 | 1228 | 0 => lang('No access'), |
@@ -1234,11 +1232,11 @@ discard block |
||
| 1234 | 1232 | // mergeapp |
| 1235 | 1233 | $content['mergeapp'] = static::get_mergeapp($path, 'self'); |
| 1236 | 1234 | $content['mergeapp_parent'] = static::get_mergeapp($path, 'parents'); |
| 1237 | - if(!empty($content['mergeapp'])) |
|
| 1235 | + if (!empty($content['mergeapp'])) |
|
| 1238 | 1236 | { |
| 1239 | 1237 | $content['mergeapp_effective'] = $content['mergeapp']; |
| 1240 | 1238 | } |
| 1241 | - elseif(!empty($content['mergeapp_parent'])) |
|
| 1239 | + elseif (!empty($content['mergeapp_parent'])) |
|
| 1242 | 1240 | { |
| 1243 | 1241 | $content['mergeapp_effective'] = $content['mergeapp_parent']; |
| 1244 | 1242 | } |
@@ -1250,7 +1248,7 @@ discard block |
||
| 1250 | 1248 | $mergeapp_list = Link::app_list('merge'); |
| 1251 | 1249 | unset($mergeapp_list[$GLOBALS['egw_info']['flags']['currentapp']]); // exclude filemanager from list |
| 1252 | 1250 | $mergeapp_empty = !empty($content['mergeapp_parent']) |
| 1253 | - ? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : ''; |
|
| 1251 | + ? $mergeapp_list[$content['mergeapp_parent']].' (parent setting)' : ''; |
|
| 1254 | 1252 | $sel_options['mergeapp'] = array('' => $mergeapp_empty); |
| 1255 | 1253 | $sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list; |
| 1256 | 1254 | // mergeapp other gui options |
@@ -1267,7 +1265,7 @@ discard block |
||
| 1267 | 1265 | 'comment' => (string)$content['comment'], |
| 1268 | 1266 | 'mergeapp' => $content['mergeapp'] |
| 1269 | 1267 | ); |
| 1270 | - if ($cfs) foreach($cfs as $name => $data) |
|
| 1268 | + if ($cfs) foreach ($cfs as $name => $data) |
|
| 1271 | 1269 | { |
| 1272 | 1270 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
| 1273 | 1271 | } |
@@ -1275,26 +1273,26 @@ discard block |
||
| 1275 | 1273 | if (Vfs::$is_root) |
| 1276 | 1274 | { |
| 1277 | 1275 | $tpl->setElementAttribute('sudouser', 'label', 'Logout'); |
| 1278 | - $tpl->setElementAttribute('sudouser', 'help','Log out as superuser'); |
|
| 1276 | + $tpl->setElementAttribute('sudouser', 'help', 'Log out as superuser'); |
|
| 1279 | 1277 | // Need a more complex submit because button type is buttononly, which doesn't submit |
| 1280 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")'); |
|
| 1278 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"login")'); |
|
| 1281 | 1279 | |
| 1282 | 1280 | } |
| 1283 | 1281 | elseif ($button == 'sudo') |
| 1284 | 1282 | { |
| 1285 | 1283 | $tpl->setElementAttribute('sudouser', 'label', 'Superuser'); |
| 1286 | - $tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights'); |
|
| 1287 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")'); |
|
| 1284 | + $tpl->setElementAttribute('sudouser', 'help', 'Enter setup user and password to get root rights'); |
|
| 1285 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"logout")'); |
|
| 1288 | 1286 | } |
| 1289 | - if (($extra_tabs = Vfs::getExtraInfo($path,$content))) |
|
| 1287 | + if (($extra_tabs = Vfs::getExtraInfo($path, $content))) |
|
| 1290 | 1288 | { |
| 1291 | 1289 | // add to existing tabs in template |
| 1292 | 1290 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
| 1293 | 1291 | |
| 1294 | - $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
|
| 1292 | + $tabs = & $tpl->getElementAttribute('tabs', 'tabs'); |
|
| 1295 | 1293 | if (true) $tabs = array(); |
| 1296 | 1294 | |
| 1297 | - foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
| 1295 | + foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
| 1298 | 1296 | { |
| 1299 | 1297 | $tabs[] = array( |
| 1300 | 1298 | 'label' => $extra_tab['label'], |
@@ -1317,7 +1315,7 @@ discard block |
||
| 1317 | 1315 | Framework::window_focus(); |
| 1318 | 1316 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.Vfs::decodePath($path); |
| 1319 | 1317 | |
| 1320 | - $tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2); |
|
| 1318 | + $tpl->exec('filemanager.filemanager_ui.file', $content, $sel_options, $readonlys, $preserve, 2); |
|
| 1321 | 1319 | } |
| 1322 | 1320 | |
| 1323 | 1321 | /** |
@@ -1328,7 +1326,7 @@ discard block |
||
| 1328 | 1326 | * @param string $dir=null current directory |
| 1329 | 1327 | * @see static::action() |
| 1330 | 1328 | */ |
| 1331 | - public static function ajax_action($action, $selected, $dir=null, $props=null) |
|
| 1329 | + public static function ajax_action($action, $selected, $dir = null, $props = null) |
|
| 1332 | 1330 | { |
| 1333 | 1331 | // do we have root rights, need to run here too, as method is static and therefore does NOT run __construct |
| 1334 | 1332 | if (Api\Cache::getSession('filemanager', 'is_root')) |
@@ -1347,15 +1345,15 @@ discard block |
||
| 1347 | 1345 | |
| 1348 | 1346 | if (!isset($dir)) $dir = array_pop($selected); |
| 1349 | 1347 | |
| 1350 | - switch($action) |
|
| 1348 | + switch ($action) |
|
| 1351 | 1349 | { |
| 1352 | 1350 | case 'upload': |
| 1353 | 1351 | $script_error = 0; |
| 1354 | - foreach($selected as $tmp_name => &$data) |
|
| 1352 | + foreach ($selected as $tmp_name => &$data) |
|
| 1355 | 1353 | { |
| 1356 | 1354 | $path = Vfs::concat($dir, Vfs::encodePathComponent($data['name'])); |
| 1357 | 1355 | |
| 1358 | - if(Vfs::deny_script($path)) |
|
| 1356 | + if (Vfs::deny_script($path)) |
|
| 1359 | 1357 | { |
| 1360 | 1358 | if (!isset($script_error)) |
| 1361 | 1359 | { |
@@ -1377,7 +1375,7 @@ discard block |
||
| 1377 | 1375 | { |
| 1378 | 1376 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
| 1379 | 1377 | { |
| 1380 | - $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name); |
|
| 1378 | + $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmp_name); |
|
| 1381 | 1379 | } |
| 1382 | 1380 | else |
| 1383 | 1381 | { |
@@ -1412,16 +1410,16 @@ discard block |
||
| 1412 | 1410 | case 'link': |
| 1413 | 1411 | // First upload |
| 1414 | 1412 | $arr = static::ajax_action('upload', $selected, $dir, $props); |
| 1415 | - $app_dir = Link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true); |
|
| 1413 | + $app_dir = Link::vfs_path($props['entry']['app'], $props['entry']['id'], '', true); |
|
| 1416 | 1414 | |
| 1417 | - foreach($arr['uploaded'] as $file) |
|
| 1415 | + foreach ($arr['uploaded'] as $file) |
|
| 1418 | 1416 | { |
| 1419 | - $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
|
| 1417 | + $target = Vfs::concat($dir, Vfs::encodePathComponent($file['name'])); |
|
| 1420 | 1418 | if (Vfs::file_exists($target) && $app_dir) |
| 1421 | 1419 | { |
| 1422 | 1420 | if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
| 1423 | 1421 | error_log("Symlinking $target to $app_dir"); |
| 1424 | - Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
|
| 1422 | + Vfs::symlink($target, Vfs::concat($app_dir, Vfs::encodePathComponent($file['name']))); |
|
| 1425 | 1423 | } |
| 1426 | 1424 | } |
| 1427 | 1425 | // Must return to avoid adding to $response again |
@@ -1443,7 +1441,7 @@ discard block |
||
| 1443 | 1441 | */ |
| 1444 | 1442 | private function perms2mode(array $perms) |
| 1445 | 1443 | { |
| 1446 | - $mode = $perms['owner'] << 6 | $perms['group'] << 3 | $perms['other']; |
|
| 1444 | + $mode = $perms['owner'] << 6|$perms['group'] << 3|$perms['other']; |
|
| 1447 | 1445 | if ($mode['executable']) |
| 1448 | 1446 | { |
| 1449 | 1447 | $mode |= 0111; |
@@ -36,19 +36,19 @@ discard block |
||
| 36 | 36 | $basepath = '/home'; |
| 37 | 37 | $homepath = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
| 38 | 38 | //echo "<p>admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n"; |
| 39 | - $file_prefs = &$GLOBALS['egw_info']['user']['preferences'][self::$appname]; |
|
| 39 | + $file_prefs = &$GLOBALS['egw_info']['user']['preferences'][self::$appname]; |
|
| 40 | 40 | if ($location == 'sidebox_menu') |
| 41 | 41 | { |
| 42 | - $title = $GLOBALS['egw_info']['apps'][self::$appname]['title'] . ' '. lang('Menu'); |
|
| 42 | + $title = $GLOBALS['egw_info']['apps'][self::$appname]['title'].' '.lang('Menu'); |
|
| 43 | 43 | $file = array(); |
| 44 | - if($GLOBALS['egw_info']['apps']['stylite']) |
|
| 44 | + if ($GLOBALS['egw_info']['apps']['stylite']) |
|
| 45 | 45 | { |
| 46 | 46 | // add "file a file" (upload) dialog |
| 47 | 47 | $file[] = array( |
| 48 | 48 | 'text' => 'File a file', |
| 49 | - 'link' => "javascript:egw_openWindowCentered2('".Egw::link('/index.php',array( |
|
| 49 | + 'link' => "javascript:egw_openWindowCentered2('".Egw::link('/index.php', array( |
|
| 50 | 50 | 'menuaction'=>'stylite.stylite_filemanager.upload', |
| 51 | - ),false)."','_blank',550,350)", |
|
| 51 | + ), false)."','_blank',550,350)", |
|
| 52 | 52 | 'app' => 'phpgwapi', |
| 53 | 53 | 'icon' => 'upload', |
| 54 | 54 | ); |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | // add selection for available views, if we have more then one |
| 57 | 57 | if (count(filemanager_ui::init_views()) > 1) |
| 58 | 58 | { |
| 59 | - $index_url = Egw::link('/index.php',array('menuaction' => 'filemanager.filemanager_ui.index'),false); |
|
| 59 | + $index_url = Egw::link('/index.php', array('menuaction' => 'filemanager.filemanager_ui.index'), false); |
|
| 60 | 60 | $file[] = array( |
| 61 | - 'text' => Api\Html::select('filemanager_view',filemanager_ui::get_view(),filemanager_ui::$views,false, |
|
| 61 | + 'text' => Api\Html::select('filemanager_view', filemanager_ui::get_view(), filemanager_ui::$views, false, |
|
| 62 | 62 | ' onchange="'."egw_appWindow('filemanager').location='$index_url&view='+this.value;". |
| 63 | 63 | '" style="width: 100%;"'), |
| 64 | 64 | 'no_lang' => True, |
@@ -67,23 +67,23 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | if ($file_prefs['showhome'] != 'no') |
| 69 | 69 | { |
| 70 | - $file['Your home directory'] = Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$homepath,'ajax'=>'true')); |
|
| 70 | + $file['Your home directory'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$homepath, 'ajax'=>'true')); |
|
| 71 | 71 | } |
| 72 | 72 | if ($file_prefs['showusers'] != 'no') |
| 73 | 73 | { |
| 74 | - $file['Users and groups'] = Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$basepath,'ajax'=>'true')); |
|
| 74 | + $file['Users and groups'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$basepath, 'ajax'=>'true')); |
|
| 75 | 75 | } |
| 76 | - if (!empty($file_prefs['showbase']) && $file_prefs['showbase']=='yes') |
|
| 76 | + if (!empty($file_prefs['showbase']) && $file_prefs['showbase'] == 'yes') |
|
| 77 | 77 | { |
| 78 | - $file['Basedirectory'] = Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$rootpath,'ajax'=>'true')); |
|
| 78 | + $file['Basedirectory'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$rootpath, 'ajax'=>'true')); |
|
| 79 | 79 | } |
| 80 | 80 | if (!empty($file_prefs['startfolder'])) |
| 81 | 81 | { |
| 82 | - $file['Startfolder']= Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$file_prefs['startfolder'],'ajax'=>'true')); |
|
| 82 | + $file['Startfolder'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$file_prefs['startfolder'], 'ajax'=>'true')); |
|
| 83 | 83 | } |
| 84 | - $file['Placeholders'] = Egw::link('/index.php','menuaction=filemanager.filemanager_merge.show_replacements'); |
|
| 85 | - $file['Shared files'] = Egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true'); |
|
| 86 | - display_sidebox(self::$appname,$title,$file); |
|
| 84 | + $file['Placeholders'] = Egw::link('/index.php', 'menuaction=filemanager.filemanager_merge.show_replacements'); |
|
| 85 | + $file['Shared files'] = Egw::link('/index.php', 'menuaction=filemanager.filemanager_shares.index&ajax=true'); |
|
| 86 | + display_sidebox(self::$appname, $title, $file); |
|
| 87 | 87 | } |
| 88 | 88 | if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname); |
| 89 | 89 | } |
@@ -99,17 +99,17 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | $file = Array( |
| 101 | 101 | //'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname='.self::$appname.'&ajax=true'), |
| 102 | - 'Custom fields' => Egw::link('/index.php','menuaction=admin.customfields.index&appname='.self::$appname.'&ajax=true'), |
|
| 103 | - 'Check virtual filesystem' => Egw::link('/index.php','menuaction=filemanager.filemanager_admin.fsck'), |
|
| 102 | + 'Custom fields' => Egw::link('/index.php', 'menuaction=admin.customfields.index&appname='.self::$appname.'&ajax=true'), |
|
| 103 | + 'Check virtual filesystem' => Egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.fsck'), |
|
| 104 | 104 | 'VFS mounts and versioning' => Egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.index'), |
| 105 | 105 | ); |
| 106 | 106 | if ($location == 'admin') |
| 107 | 107 | { |
| 108 | - display_section(self::$appname,$file); |
|
| 108 | + display_section(self::$appname, $file); |
|
| 109 | 109 | } |
| 110 | 110 | else |
| 111 | 111 | { |
| 112 | - display_sidebox(self::$appname,lang('Admin'),$file); |
|
| 112 | + display_sidebox(self::$appname, lang('Admin'), $file); |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | 'type' => 'select', |
| 156 | 156 | 'name' => 'showhome', |
| 157 | 157 | 'values' => $yes_no, |
| 158 | - 'label' => lang('Show link "%1" in side box menu?',lang('Your home directory')), |
|
| 158 | + 'label' => lang('Show link "%1" in side box menu?', lang('Your home directory')), |
|
| 159 | 159 | 'xmlrpc' => True, |
| 160 | 160 | 'admin' => False, |
| 161 | 161 | 'forced' => 'yes', |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | 'type' => 'select', |
| 165 | 165 | 'name' => 'showusers', |
| 166 | 166 | 'values' => $yes_no, |
| 167 | - 'label' => lang('Show link "%1" in side box menu?',lang('Users and groups')), |
|
| 167 | + 'label' => lang('Show link "%1" in side box menu?', lang('Users and groups')), |
|
| 168 | 168 | 'xmlrpc' => True, |
| 169 | 169 | 'admin' => False, |
| 170 | 170 | 'forced' => 'yes', |
@@ -176,9 +176,9 @@ discard block |
||
| 176 | 176 | 'size' => 60, |
| 177 | 177 | 'label' => 'Default document to insert entries', |
| 178 | 178 | 'name' => 'default_document', |
| 179 | - 'help' => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.',lang('filemanager')).' '. |
|
| 179 | + 'help' => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.', lang('filemanager')).' '. |
|
| 180 | 180 | lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '. |
| 181 | - lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()), |
|
| 181 | + lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()), |
|
| 182 | 182 | 'run_lang' => false, |
| 183 | 183 | 'xmlrpc' => True, |
| 184 | 184 | 'admin' => False, |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | 'label' => 'Directory with documents to insert entries', |
| 190 | 190 | 'name' => 'document_dir', |
| 191 | 191 | 'help' => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the %1 data inserted.', lang('filemanager')).' '. |
| 192 | - lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','name').' '. |
|
| 193 | - lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()), |
|
| 192 | + lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '. |
|
| 193 | + lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()), |
|
| 194 | 194 | 'run_lang' => false, |
| 195 | 195 | 'xmlrpc' => True, |
| 196 | 196 | 'admin' => False, |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | * @param array $content=null |
| 79 | 79 | * @param string $msg='' |
| 80 | 80 | */ |
| 81 | - public function index(array $content=null, $msg='', $msg_type=null) |
|
| 81 | + public function index(array $content = null, $msg = '', $msg_type = null) |
|
| 82 | 82 | { |
| 83 | 83 | if (is_array($content)) |
| 84 | 84 | { |
| 85 | 85 | //_debug_array($content); |
| 86 | 86 | if ($content['sudo']) |
| 87 | 87 | { |
| 88 | - $msg = $this->sudo($content['user'],$content['password'],self::$is_setup) ? |
|
| 88 | + $msg = $this->sudo($content['user'], $content['password'], self::$is_setup) ? |
|
| 89 | 89 | lang('Root access granted.') : lang('Wrong username or password!'); |
| 90 | 90 | $msg_type = Vfs::$is_root ? 'success' : 'error'; |
| 91 | 91 | } |
@@ -96,14 +96,14 @@ discard block |
||
| 96 | 96 | $backup = Vfs::$is_root; |
| 97 | 97 | Vfs::$is_root = true; |
| 98 | 98 | $msg = Vfs::mount($url, $path) ? |
| 99 | - lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path); |
|
| 99 | + lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path); |
|
| 100 | 100 | Vfs::$is_root = $backup; |
| 101 | 101 | } |
| 102 | 102 | elseif (Vfs::$is_root) |
| 103 | 103 | { |
| 104 | 104 | if ($content['logout']) |
| 105 | 105 | { |
| 106 | - $msg = $this->sudo('','',self::$is_setup) ? 'Logout failed!' : lang('Root access stopped.'); |
|
| 106 | + $msg = $this->sudo('', '', self::$is_setup) ? 'Logout failed!' : lang('Root access stopped.'); |
|
| 107 | 107 | $msg_type = !Vfs::$is_root ? 'success' : 'error'; |
| 108 | 108 | } |
| 109 | 109 | if ($content['mounts']['disable'] || self::$is_setup && $content['mounts']['umount']) |
@@ -119,18 +119,18 @@ discard block |
||
| 119 | 119 | if (!in_array($path, self::$protected_path) && $path != '/') |
| 120 | 120 | { |
| 121 | 121 | $msg = Vfs::umount($path) ? |
| 122 | - lang('%1 successful unmounted.',$path) : lang('Error unmounting %1!',$path); |
|
| 122 | + lang('%1 successful unmounted.', $path) : lang('Error unmounting %1!', $path); |
|
| 123 | 123 | } |
| 124 | 124 | else // re-mount / with sqlFS, to disable versioning |
| 125 | 125 | { |
| 126 | - $msg = Vfs::mount($url=Vfs\Sqlfs\StreamWrapper::SCHEME.'://default'.$path,$path) ? |
|
| 127 | - lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path); |
|
| 126 | + $msg = Vfs::mount($url = Vfs\Sqlfs\StreamWrapper::SCHEME.'://default'.$path, $path) ? |
|
| 127 | + lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | if (($path = $content['mounts']['path']) && |
| 131 | 131 | ($content['mounts']['enable'] || self::$is_setup && $content['mounts']['mount'])) |
| 132 | 132 | { |
| 133 | - $url = str_replace('$path',$path,$content['mounts']['url']); |
|
| 133 | + $url = str_replace('$path', $path, $content['mounts']['url']); |
|
| 134 | 134 | if (empty($url) && $this->versioning) $url = Versioning\StreamWrapper::PREFIX.$path; |
| 135 | 135 | |
| 136 | 136 | if ($content['mounts']['enable'] && !$this->versioning) |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | elseif (!Vfs::file_exists($path) || !Vfs::is_dir($path)) |
| 142 | 142 | { |
| 143 | - $msg = lang('Path %1 not found or not a directory!',$path); |
|
| 143 | + $msg = lang('Path %1 not found or not a directory!', $path); |
|
| 144 | 144 | $msg_type = 'error'; |
| 145 | 145 | } |
| 146 | 146 | // dont allow to change mount of /apps or /templates (eg. switching on versioning) |
@@ -151,8 +151,8 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | else |
| 153 | 153 | { |
| 154 | - $msg = Vfs::mount($url,$path) ? |
|
| 155 | - lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path); |
|
| 154 | + $msg = Vfs::mount($url, $path) ? |
|
| 155 | + lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path); |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | if ($content['allow_delete_versions'] != $GLOBALS['egw_info']['server']['allow_delete_versions']) |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | 'hidden' => true, |
| 198 | 198 | 'depth' => true, |
| 199 | 199 | 'path_preg' => '#/\.(attic|versions)/#', |
| 200 | - )+(!(int)$content['mtime'] ? array() : array( |
|
| 201 | - 'mtime' => ($content['mtime']<0?'-':'+').(int)$content['mtime'], |
|
| 200 | + ) + (!(int)$content['mtime'] ? array() : array( |
|
| 201 | + 'mtime' => ($content['mtime'] < 0 ? '-' : '+').(int)$content['mtime'], |
|
| 202 | 202 | )), function($path) use (&$deleted, &$errors) |
| 203 | 203 | { |
| 204 | 204 | if (($is_dir = Vfs::is_dir($path)) && Vfs::rmdir($path) || |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | }); |
| 214 | 214 | } |
| 215 | - $time = number_format(microtime(true)-$starttime, 1); |
|
| 215 | + $time = number_format(microtime(true) - $starttime, 1); |
|
| 216 | 216 | $msg = ($errors ? lang('%1 errors deleting!', $errors)."\n\n" : ''). |
| 217 | 217 | lang('%1 files or directories deleted in %2 seconds.', $deleted, $time); |
| 218 | 218 | $msg_type = $errors ? 'error' : 'info'; |
@@ -235,10 +235,10 @@ discard block |
||
| 235 | 235 | { |
| 236 | 236 | // statistical information |
| 237 | 237 | $content += Versioning\StreamWrapper::summary(); |
| 238 | - if ($content['total_files']) $content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%'; |
|
| 239 | - if ($content['total_size']) $content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%'; |
|
| 238 | + if ($content['total_files']) $content['percent_files'] = number_format(100.0 * $content['version_files'] / $content['total_files'], 1).'%'; |
|
| 239 | + if ($content['total_size']) $content['percent_size'] = number_format(100.0 * $content['version_size'] / $content['total_size'], 1).'%'; |
|
| 240 | 240 | } |
| 241 | - if (!($content['is_root']=Vfs::$is_root)) |
|
| 241 | + if (!($content['is_root'] = Vfs::$is_root)) |
|
| 242 | 242 | { |
| 243 | 243 | if (empty($msg)) |
| 244 | 244 | { |
@@ -254,16 +254,16 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | $n = 2; |
| 256 | 256 | $content['mounts'] = array(); |
| 257 | - foreach(Vfs::mount() as $path => $url) |
|
| 257 | + foreach (Vfs::mount() as $path => $url) |
|
| 258 | 258 | { |
| 259 | 259 | $content['mounts'][$n++] = array( |
| 260 | 260 | 'path' => $path, |
| 261 | 261 | 'url' => $url, |
| 262 | 262 | ); |
| 263 | 263 | $readonlys["disable[$path]"] = !$this->versioning || !Vfs::$is_root || |
| 264 | - Vfs::parse_url($url,PHP_URL_SCHEME) != $this->versioning; |
|
| 264 | + Vfs::parse_url($url, PHP_URL_SCHEME) != $this->versioning; |
|
| 265 | 265 | } |
| 266 | - $readonlys['umount[/]'] = $readonlys['umount[/apps]'] = true; // do not allow to unmount / or /apps |
|
| 266 | + $readonlys['umount[/]'] = $readonlys['umount[/apps]'] = true; // do not allow to unmount / or /apps |
|
| 267 | 267 | $readonlys['url'] = !self::$is_setup; |
| 268 | 268 | |
| 269 | 269 | $sel_options['allow_delete_versions'] = array( |
@@ -274,13 +274,13 @@ discard block |
||
| 274 | 274 | ); |
| 275 | 275 | // show [Mount /etemplates] button for admin, if not already mounted and available |
| 276 | 276 | $readonlys['etemplates'] = !class_exists('\EGroupware\Stylite\Vfs\Merge\StreamWrapper') || |
| 277 | - ($fs_tab=Vfs::mount($url)) && isset($fs_tab['/etemplates']) || |
|
| 277 | + ($fs_tab = Vfs::mount($url)) && isset($fs_tab['/etemplates']) || |
|
| 278 | 278 | !isset($GLOBALS['egw_info']['user']['apps']['admin']); |
| 279 | 279 | //_debug_array($content); |
| 280 | 280 | |
| 281 | 281 | $tpl = new Etemplate('filemanager.admin'); |
| 282 | 282 | $GLOBALS['egw_info']['flags']['app_header'] = lang('VFS mounts and versioning'); |
| 283 | - $tpl->exec('filemanager.filemanager_admin.index',$content,$sel_options,$readonlys); |
|
| 283 | + $tpl->exec('filemanager.filemanager_admin.index', $content, $sel_options, $readonlys); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -300,10 +300,10 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | $content = '<p>'.implode("</p>\n<p>", (array)$msgs)."</p>\n"; |
| 302 | 302 | |
| 303 | - $content .= Api\Html::form('<p>'.($check_only&&is_array($msgs) ? |
|
| 303 | + $content .= Api\Html::form('<p>'.($check_only && is_array($msgs) ? |
|
| 304 | 304 | Api\Html::submit_button('fix', lang('Fix reported problems')) : ''). |
| 305 | 305 | Api\Html::submit_button('cancel', lang('Cancel')).'</p>', |
| 306 | - '','/index.php',array('menuaction'=>'filemanager.filemanager_admin.fsck')); |
|
| 306 | + '', '/index.php', array('menuaction'=>'filemanager.filemanager_admin.fsck')); |
|
| 307 | 307 | |
| 308 | 308 | $GLOBALS['egw']->framework->render($content, lang('Admin').' - '.lang('Check virtual filesystem'), true); |
| 309 | 309 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @param array $content |
| 67 | 67 | */ |
| 68 | - function select(array $content=null) |
|
| 68 | + function select(array $content = null) |
|
| 69 | 69 | { |
| 70 | 70 | if (!is_array($content)) |
| 71 | 71 | { |
@@ -76,10 +76,10 @@ discard block |
||
| 76 | 76 | $content['msg'] = $_GET['msg']; |
| 77 | 77 | $_GET['mode'] = 'open'; |
| 78 | 78 | $_GET['method'] = 'ckeditor_return'; |
| 79 | - $_GET['CKEditorFuncNum'] = Api\Cache::getSession('filemanager','ckeditorfuncnum'); |
|
| 79 | + $_GET['CKEditorFuncNum'] = Api\Cache::getSession('filemanager', 'ckeditorfuncnum'); |
|
| 80 | 80 | } |
| 81 | 81 | $content['mode'] = $_GET['mode']; |
| 82 | - if (!in_array($content['mode'],array('open','open-multiple','saveas','select-dir'))) |
|
| 82 | + if (!in_array($content['mode'], array('open', 'open-multiple', 'saveas', 'select-dir'))) |
|
| 83 | 83 | { |
| 84 | 84 | throw new Api\Exception\WrongParameter("Wrong or unset required mode parameter!"); |
| 85 | 85 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | if (isset($_GET['CKEditorFuncNum']) && is_numeric($_GET['CKEditorFuncNum'])) |
| 96 | 96 | { |
| 97 | - Api\Cache::setSession('filemanager','ckeditorfuncnum', |
|
| 97 | + Api\Cache::setSession('filemanager', 'ckeditorfuncnum', |
|
| 98 | 98 | $content['ckeditorfuncnum'] = $_GET['CKEditorFuncNum']); |
| 99 | 99 | } |
| 100 | 100 | else |
@@ -102,20 +102,20 @@ discard block |
||
| 102 | 102 | throw new Api\Exception\WrongParameter("chkeditor_return has been specified as a method but some parameters are missing or invalid."); |
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | - $content['id'] = $_GET['id']; |
|
| 105 | + $content['id'] = $_GET['id']; |
|
| 106 | 106 | $content['label'] = isset($_GET['label']) ? $_GET['label'] : lang('Open'); |
| 107 | 107 | if (($content['options-mime'] = isset($_GET['mime']))) |
| 108 | 108 | { |
| 109 | 109 | $sel_options['mime'] = array(); |
| 110 | - foreach((array)$_GET['mime'] as $key => $value) |
|
| 110 | + foreach ((array)$_GET['mime'] as $key => $value) |
|
| 111 | 111 | { |
| 112 | 112 | if (is_numeric($key)) |
| 113 | 113 | { |
| 114 | - $sel_options['mime'][$value] = lang('%1 files',strtoupper(Api\MimeMagic::mime2ext($value))).' ('.$value.')'; |
|
| 114 | + $sel_options['mime'][$value] = lang('%1 files', strtoupper(Api\MimeMagic::mime2ext($value))).' ('.$value.')'; |
|
| 115 | 115 | } |
| 116 | 116 | else |
| 117 | 117 | { |
| 118 | - $sel_options['mime'][$key] = lang('%1 files',strtoupper($value)).' ('.$key.')'; |
|
| 118 | + $sel_options['mime'][$key] = lang('%1 files', strtoupper($value)).' ('.$key.')'; |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | error_log(array2string($content['options-mime'])); |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | - elseif(isset($content['button'])) |
|
| 126 | + elseif (isset($content['button'])) |
|
| 127 | 127 | { |
| 128 | 128 | list($button) = each($content['button']); |
| 129 | 129 | unset($content['button']); |
| 130 | - switch($button) |
|
| 130 | + switch ($button) |
|
| 131 | 131 | { |
| 132 | 132 | case 'home': |
| 133 | 133 | $content['path'] = filemanager_ui::get_home_dir(); |
@@ -139,10 +139,10 @@ discard block |
||
| 139 | 139 | //Set the "content" name filed accordingly to the uploaded file |
| 140 | 140 | // encode chars which special meaning in url/vfs (some like / get removed!) |
| 141 | 141 | $content['name'] = Vfs::encodePathComponent($content['file_upload']['name']); |
| 142 | - $to_path = Vfs::concat($content['path'],$content['name']); |
|
| 142 | + $to_path = Vfs::concat($content['path'], $content['name']); |
|
| 143 | 143 | |
| 144 | 144 | $copy_result = (Vfs::is_writable($content['path']) || Vfs::is_writable($to_path)) && |
| 145 | - copy($content['file_upload']['tmp_name'],Vfs::PREFIX.$to_path); |
|
| 145 | + copy($content['file_upload']['tmp_name'], Vfs::PREFIX.$to_path); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | //Break on an error condition |
@@ -161,12 +161,12 @@ discard block |
||
| 161 | 161 | break; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - switch($content['mode']) |
|
| 164 | + switch ($content['mode']) |
|
| 165 | 165 | { |
| 166 | 166 | case 'open-multiple': |
| 167 | - foreach((array)$content['dir']['selected'] as $name) |
|
| 167 | + foreach ((array)$content['dir']['selected'] as $name) |
|
| 168 | 168 | { |
| 169 | - $files[] = Vfs::concat($content['path'],$name); |
|
| 169 | + $files[] = Vfs::concat($content['path'], $name); |
|
| 170 | 170 | } |
| 171 | 171 | //Add an uploaded file to the files result array2string |
| 172 | 172 | if ($copy_result === true) $files[] = $to_path; |
@@ -182,33 +182,33 @@ discard block |
||
| 182 | 182 | // Fall through |
| 183 | 183 | |
| 184 | 184 | default: |
| 185 | - $files = Vfs::concat($content['path'],$content['name']); |
|
| 185 | + $files = Vfs::concat($content['path'], $content['name']); |
|
| 186 | 186 | break; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | if ($content['method'] && $content['method'] != 'ckeditor_return') |
| 190 | 190 | { |
| 191 | - $js = ExecMethod2($content['method'],$content['id'],$files); |
|
| 191 | + $js = ExecMethod2($content['method'], $content['id'], $files); |
|
| 192 | 192 | } |
| 193 | 193 | else if ($content['method'] == 'ckeditor_return') |
| 194 | 194 | { |
| 195 | - $download_url = Vfs::download_url(Vfs::concat($content['path'],$content['name'])); |
|
| 195 | + $download_url = Vfs::download_url(Vfs::concat($content['path'], $content['name'])); |
|
| 196 | 196 | if ($download_url[0] == '/') $download_url = Egw::link($download_url); |
| 197 | 197 | $js = "window.opener.CKEDITOR.tools.callFunction(". |
| 198 | 198 | $content['ckeditorfuncnum'].",'". |
| 199 | 199 | htmlspecialchars($download_url)."',". |
| 200 | 200 | "'');\negw(window).close();"; |
| 201 | 201 | } |
| 202 | - if(Api\Json\Response::isJSONResponse() && !($content['method'] == 'ckeditor_return')) |
|
| 202 | + if (Api\Json\Response::isJSONResponse() && !($content['method'] == 'ckeditor_return')) |
|
| 203 | 203 | { |
| 204 | 204 | $response = Api\Json\Response::get(); |
| 205 | - if($js) |
|
| 205 | + if ($js) |
|
| 206 | 206 | { |
| 207 | 207 | $response->script($js); |
| 208 | 208 | } |
| 209 | 209 | // Ahh! |
| 210 | 210 | // The vfs-select widget looks for this |
| 211 | - $response->script('this.selected_files = '.json_encode($files) . '; egw(this).close();'); |
|
| 211 | + $response->script('this.selected_files = '.json_encode($files).'; egw(this).close();'); |
|
| 212 | 212 | } |
| 213 | 213 | else |
| 214 | 214 | { |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | $sel_options['mime'] = $content['options-mime']; |
| 222 | 222 | } |
| 223 | - elseif(isset($content['apps'])) |
|
| 223 | + elseif (isset($content['apps'])) |
|
| 224 | 224 | { |
| 225 | 225 | list($app) = each($content['apps']); |
| 226 | 226 | if ($app == 'home') $content['path'] = filemanager_ui::get_home_dir(); |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | //Deactivate the opload field if the current directory is not writeable or |
| 230 | 230 | //we're currently not in the single file open mode. |
| 231 | 231 | $content['no_upload'] = !Vfs::is_writable($content['path']) || |
| 232 | - !in_array($content['mode'],array('open')); |
|
| 232 | + !in_array($content['mode'], array('open')); |
|
| 233 | 233 | |
| 234 | 234 | $content['apps'] = array_keys(self::get_apps()); |
| 235 | 235 | |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | // Set a flag for easy detection as we go |
| 242 | - $favorites_flag = substr($content['path'],0,strlen('/apps/favorites')) == '/apps/favorites'; |
|
| 242 | + $favorites_flag = substr($content['path'], 0, strlen('/apps/favorites')) == '/apps/favorites'; |
|
| 243 | 243 | |
| 244 | 244 | if (!$favorites_flag && (!$content['path'] || !Vfs::is_dir($content['path']))) |
| 245 | 245 | { |
@@ -253,12 +253,12 @@ discard block |
||
| 253 | 253 | $files = array(); |
| 254 | 254 | $favorites = Framework\Favorites::get_favorites('filemanager'); |
| 255 | 255 | $n = 0; |
| 256 | - foreach($favorites as $favorite) |
|
| 256 | + foreach ($favorites as $favorite) |
|
| 257 | 257 | { |
| 258 | 258 | $path = $favorite['state']['path']; |
| 259 | 259 | // Just directories |
| 260 | - if(!$path) continue; |
|
| 261 | - if ($path == $content['path']) continue; // remove directory itself |
|
| 260 | + if (!$path) continue; |
|
| 261 | + if ($path == $content['path']) continue; // remove directory itself |
|
| 262 | 262 | |
| 263 | 263 | $mime = Vfs::mime_content_type($path); |
| 264 | 264 | $content['dir'][$n] = array( |
@@ -274,29 +274,29 @@ discard block |
||
| 274 | 274 | ++$n; |
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | - else if (!($files = Vfs::find($content['path'],array( |
|
| 277 | + else if (!($files = Vfs::find($content['path'], array( |
|
| 278 | 278 | 'dirsontop' => true, |
| 279 | 279 | 'order' => 'name', |
| 280 | 280 | 'sort' => 'ASC', |
| 281 | 281 | 'maxdepth' => 1, |
| 282 | 282 | )))) |
| 283 | 283 | { |
| 284 | - $content['msg'] = lang("Can't open directory %1!",$content['path']); |
|
| 284 | + $content['msg'] = lang("Can't open directory %1!", $content['path']); |
|
| 285 | 285 | } |
| 286 | 286 | else |
| 287 | 287 | { |
| 288 | 288 | $n = 0; |
| 289 | 289 | $content['dir'] = array('mode' => $content['mode']); |
| 290 | - foreach($files as $path) |
|
| 290 | + foreach ($files as $path) |
|
| 291 | 291 | { |
| 292 | - if ($path == $content['path']) continue; // remove directory itself |
|
| 292 | + if ($path == $content['path']) continue; // remove directory itself |
|
| 293 | 293 | |
| 294 | 294 | $name = Vfs::basename($path); |
| 295 | 295 | $is_dir = Vfs::is_dir($path); |
| 296 | 296 | $mime = Vfs::mime_content_type($path); |
| 297 | 297 | if ($content['mime'] && !$is_dir && $mime != $content['mime']) |
| 298 | 298 | { |
| 299 | - continue; // does not match mime-filter --> ignore |
|
| 299 | + continue; // does not match mime-filter --> ignore |
|
| 300 | 300 | } |
| 301 | 301 | $content['dir'][$n] = array( |
| 302 | 302 | 'name' => $name, |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | } |
| 311 | 311 | ++$n; |
| 312 | 312 | } |
| 313 | - if (!$n) $readonlys['selected[]'] = true; // remove checkbox from empty line |
|
| 313 | + if (!$n) $readonlys['selected[]'] = true; // remove checkbox from empty line |
|
| 314 | 314 | } |
| 315 | 315 | $readonlys['button[createdir]'] = !Vfs::is_writable($content['path']); |
| 316 | 316 | |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | { |
| 338 | 338 | Api\Header\ContentSecurityPolicy::add('script-src', 'unsafe-inline'); |
| 339 | 339 | } |
| 340 | - $tpl->exec('filemanager.filemanager_select.select',$content,$sel_options,$readonlys,$preserve,2); |
|
| 340 | + $tpl->exec('filemanager.filemanager_select.select', $content, $sel_options, $readonlys, $preserve, 2); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
@@ -347,11 +347,11 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | static function get_apps() |
| 349 | 349 | { |
| 350 | - $apps = array(false); // index starting from 1 |
|
| 350 | + $apps = array(false); // index starting from 1 |
|
| 351 | 351 | if (isset($GLOBALS['egw_info']['apps']['stylite'])) $apps = array('favorites' => lang('Favorites')); |
| 352 | 352 | $apps += Link::app_list('query'); |
| 353 | 353 | |
| 354 | - unset($apps['mydms']); // they do NOT support adding files to VFS |
|
| 354 | + unset($apps['mydms']); // they do NOT support adding files to VFS |
|
| 355 | 355 | unset($apps['wiki']); |
| 356 | 356 | unset($apps['api-accounts']); |
| 357 | 357 | unset($apps['addressbook-email']); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | parent::__construct(); |
| 62 | 62 | |
| 63 | - if($_dir) |
|
| 63 | + if ($_dir) |
|
| 64 | 64 | { |
| 65 | 65 | $this->dir = $_dir; |
| 66 | 66 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * @param string &$content=null content to create some replacements only if they are use |
| 77 | 77 | * @return array|boolean |
| 78 | 78 | */ |
| 79 | - protected function get_replacements($id,&$content=null) |
|
| 79 | + protected function get_replacements($id, &$content = null) |
|
| 80 | 80 | { |
| 81 | 81 | if (!($replacements = $this->filemanager_replacements($id, '', $content))) |
| 82 | 82 | { |
@@ -92,27 +92,27 @@ discard block |
||
| 92 | 92 | * @param string $prefix='' prefix like eg. 'erole' |
| 93 | 93 | * @return array|boolean |
| 94 | 94 | */ |
| 95 | - public function filemanager_replacements($id,$prefix='', &$content = null) |
|
| 95 | + public function filemanager_replacements($id, $prefix = '', &$content = null) |
|
| 96 | 96 | { |
| 97 | 97 | $info = array(); |
| 98 | - $file = Vfs::lstat($id,true); |
|
| 98 | + $file = Vfs::lstat($id, true); |
|
| 99 | 99 | |
| 100 | 100 | $file['mtime'] = Api\DateTime::to($file['mtime']); |
| 101 | 101 | $file['ctime'] = Api\DateTime::to($file['ctime']); |
| 102 | 102 | |
| 103 | 103 | $file['name'] = Vfs::basename($id); |
| 104 | 104 | $file['dir'] = Vfs::decodePath(Vfs::dirname($id)); |
| 105 | - $dirlist = explode('/',$file['dir']); |
|
| 105 | + $dirlist = explode('/', $file['dir']); |
|
| 106 | 106 | $file['folder'] = array_pop($dirlist); |
| 107 | - $file['folder_file'] = $file['folder'] . '/'.$file['name']; |
|
| 107 | + $file['folder_file'] = $file['folder'].'/'.$file['name']; |
|
| 108 | 108 | $file['path'] = $id; |
| 109 | 109 | $file['rel_path'] = str_replace($this->dir.'/', '', $id); |
| 110 | 110 | $file['hsize'] = Vfs::hsize($file['size']); |
| 111 | 111 | $file['mime'] = Vfs::mime_content_type($id); |
| 112 | - $file['gid'] *= -1; // our widgets use negative gid's |
|
| 112 | + $file['gid'] *= -1; // our widgets use negative gid's |
|
| 113 | 113 | if (($props = Vfs::propfind($id))) |
| 114 | 114 | { |
| 115 | - foreach($props as $prop) |
|
| 115 | + foreach ($props as $prop) |
|
| 116 | 116 | { |
| 117 | 117 | $file[$prop['name']] = $prop['val']; |
| 118 | 118 | } |
@@ -122,22 +122,22 @@ discard block |
||
| 122 | 122 | $file['symlink'] = Vfs::readlink($id); |
| 123 | 123 | } |
| 124 | 124 | // Custom fields |
| 125 | - if($content && strpos($content, '#') !== 0) |
|
| 125 | + if ($content && strpos($content, '#') !== 0) |
|
| 126 | 126 | { |
| 127 | 127 | // Expand link-to custom fields |
| 128 | 128 | $this->cf_link_to_expand($file, $content, $info); |
| 129 | 129 | |
| 130 | - foreach(Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
| 130 | + foreach (Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
| 131 | 131 | { |
| 132 | 132 | // Set any missing custom fields, or the marker will stay |
| 133 | - if(!$file['#'.$name]) |
|
| 133 | + if (!$file['#'.$name]) |
|
| 134 | 134 | { |
| 135 | 135 | $file['#'.$name] = ''; |
| 136 | 136 | continue; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Format date cfs per user Api\Preferences |
| 140 | - if($field['type'] == 'date' || $field['type'] == 'date-time') |
|
| 140 | + if ($field['type'] == 'date' || $field['type'] == 'date-time') |
|
| 141 | 141 | { |
| 142 | 142 | $this->date_fields[] = '#'.$name; |
| 143 | 143 | $file['#'.$name] = Api\DateTime::to($file['#'.$name], $field['type'] == 'date' ? true : ''); |
@@ -146,51 +146,51 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // If in apps folder, try for app-specific placeholders |
| 149 | - if($dirlist[1] == 'apps' && count($dirlist) > 1) |
|
| 149 | + if ($dirlist[1] == 'apps' && count($dirlist) > 1) |
|
| 150 | 150 | { |
| 151 | 151 | // Try this first - a normal path /apps/appname/id/file |
| 152 | - list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/')+5)); |
|
| 152 | + list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/') + 5)); |
|
| 153 | 153 | // Symlink? |
| 154 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
| 154 | + if (!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
| 155 | 155 | // Try resolving just app + ID - /apps/App Name/Record Title/file |
| 156 | - $resolved = Vfs::resolve_url_symlinks(implode('/',array_slice(explode('/',$file['dir']),0,4))); |
|
| 157 | - list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
|
| 156 | + $resolved = Vfs::resolve_url_symlinks(implode('/', array_slice(explode('/', $file['dir']), 0, 4))); |
|
| 157 | + list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/') + 5)); |
|
| 158 | 158 | |
| 159 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
| 159 | + if (!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
| 160 | 160 | // Get rid of any virtual folders (eg: All$) and symlinks |
| 161 | 161 | $resolved = Vfs::resolve_url_symlinks($file['path']); |
| 162 | - list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
|
| 162 | + list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/') + 5)); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | - if($app && $app_id) |
|
| 165 | + if ($app && $app_id) |
|
| 166 | 166 | { |
| 167 | - if($app && $GLOBALS['egw_info']['user']['apps'][$app]) |
|
| 167 | + if ($app && $GLOBALS['egw_info']['user']['apps'][$app]) |
|
| 168 | 168 | { |
| 169 | 169 | $app_merge = null; |
| 170 | 170 | try |
| 171 | 171 | { |
| 172 | - $classname = $app .'_merge'; |
|
| 173 | - if(class_exists($classname)) |
|
| 172 | + $classname = $app.'_merge'; |
|
| 173 | + if (class_exists($classname)) |
|
| 174 | 174 | { |
| 175 | 175 | $app_merge = new $classname(); |
| 176 | - if($app_merge && method_exists($app_merge, 'get_replacements')) |
|
| 176 | + if ($app_merge && method_exists($app_merge, 'get_replacements')) |
|
| 177 | 177 | { |
| 178 | 178 | $app_placeholders = $app_merge->get_replacements($app_id, $content); |
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | // Silently discard & continue |
| 183 | - catch(Exception $e) { |
|
| 184 | - unset($e); // not used |
|
| 183 | + catch (Exception $e) { |
|
| 184 | + unset($e); // not used |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | $link = Link::mime_open($file['url'], $file['mime']); |
| 190 | - if(is_array($link)) |
|
| 190 | + if (is_array($link)) |
|
| 191 | 191 | { |
| 192 | 192 | // Directories have their internal protocol in path here |
| 193 | - if($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path']; |
|
| 193 | + if ($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path']; |
|
| 194 | 194 | $link = Api\Session::link('/index.php', $link); |
| 195 | 195 | } |
| 196 | 196 | else |
@@ -209,12 +209,12 @@ discard block |
||
| 209 | 209 | $file['url'] = $link; |
| 210 | 210 | |
| 211 | 211 | // Add markers |
| 212 | - foreach($file as $key => &$value) |
|
| 212 | + foreach ($file as $key => &$value) |
|
| 213 | 213 | { |
| 214 | - if(!$value) $value = ''; |
|
| 215 | - $info['$$'.($prefix ? $prefix.'/':'').$key.'$$'] = $value; |
|
| 214 | + if (!$value) $value = ''; |
|
| 215 | + $info['$$'.($prefix ? $prefix.'/' : '').$key.'$$'] = $value; |
|
| 216 | 216 | } |
| 217 | - if($app_placeholders) |
|
| 217 | + if ($app_placeholders) |
|
| 218 | 218 | { |
| 219 | 219 | $info = array_merge($app_placeholders, $info); |
| 220 | 220 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | 'hsize' => 'Size', |
| 251 | 251 | 'size' => 'Size (in bytes)', |
| 252 | 252 | ); |
| 253 | - foreach($fields as $name => $label) |
|
| 253 | + foreach ($fields as $name => $label) |
|
| 254 | 254 | { |
| 255 | 255 | if (!($n&1)) echo '<tr>'; |
| 256 | 256 | echo '<td>{{'.$name.'}}</td><td>'.lang($label).'</td>'; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>"; |
| 262 | - foreach(Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
| 262 | + foreach (Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
| 263 | 263 | { |
| 264 | 264 | echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n"; |
| 265 | 265 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | echo '<tr><td colspan="4">'.lang('For files linked to an application entry (inside /apps/appname/id/) the placeholders for that application are also available. See the specific application for a list of available placeholders.').'</td></tr>'; |
| 269 | 269 | |
| 270 | 270 | echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>"; |
| 271 | - foreach(array( |
|
| 271 | + foreach (array( |
|
| 272 | 272 | 'date' => lang('Date'), |
| 273 | 273 | 'user/n_fn' => lang('Name of current user, all other contact fields are valid too'), |
| 274 | 274 | 'user/account_lid' => lang('Username'), |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $readonlys = null; |
| 90 | 90 | $total = Sharing::so()->get_rows($query, $rows, $readonlys); |
| 91 | 91 | |
| 92 | - foreach($rows as &$row) |
|
| 92 | + foreach ($rows as &$row) |
|
| 93 | 93 | { |
| 94 | 94 | if (substr($row['share_path'], 0, strlen(self::$tmp_dir)) === self::$tmp_dir) |
| 95 | 95 | { |
@@ -130,21 +130,21 @@ discard block |
||
| 130 | 130 | * @param array $content=null |
| 131 | 131 | * @param string $msg='' |
| 132 | 132 | */ |
| 133 | - public function index(array $content=null) |
|
| 133 | + public function index(array $content = null) |
|
| 134 | 134 | { |
| 135 | 135 | if (!is_array($content)) |
| 136 | 136 | { |
| 137 | 137 | $content = array( |
| 138 | 138 | 'nm' => array( |
| 139 | - 'get_rows' => 'filemanager.filemanager_shares.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 140 | - 'no_filter' => True, // current dir only |
|
| 141 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 142 | - 'no_cat' => True, // I disable the cat-selectbox |
|
| 143 | - 'lettersearch' => false, // I show a lettersearch |
|
| 144 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 145 | - 'start' => 0, // IO position in list |
|
| 146 | - 'order' => 'share_created', // IO name of the column to sort after (optional for the sortheaders) |
|
| 147 | - 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 139 | + 'get_rows' => 'filemanager.filemanager_shares.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 140 | + 'no_filter' => True, // current dir only |
|
| 141 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 142 | + 'no_cat' => True, // I disable the cat-selectbox |
|
| 143 | + 'lettersearch' => false, // I show a lettersearch |
|
| 144 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 145 | + 'start' => 0, // IO position in list |
|
| 146 | + 'order' => 'share_created', // IO name of the column to sort after (optional for the sortheaders) |
|
| 147 | + 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 148 | 148 | //'default_cols' => '!', // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
| 149 | 149 | 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
| 150 | 150 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | elseif ($content['nm']['action']) |
| 158 | 158 | { |
| 159 | - switch($content['nm']['action']) |
|
| 159 | + switch ($content['nm']['action']) |
|
| 160 | 160 | { |
| 161 | 161 | case 'delete': |
| 162 | 162 | $where = array('share_owner' => $GLOBALS['egw_info']['user']['account_id']); |
@@ -28,13 +28,13 @@ discard block |
||
| 28 | 28 | $context['appname'] = 'filemanager'; |
| 29 | 29 | |
| 30 | 30 | // Let parent handle the basic stuff |
| 31 | - parent::__construct($context,$need_reload); |
|
| 31 | + parent::__construct($context, $need_reload); |
|
| 32 | 32 | |
| 33 | 33 | $this->nm_settings += array( |
| 34 | 34 | 'get_rows' => 'filemanager.filemanager_favorite_portlet.get_rows', |
| 35 | 35 | 'csv_export' => true, |
| 36 | 36 | // Use a different template so it can be accessed from client side |
| 37 | - 'template' => ($this->nm_settings['view'] == 'tile' ? 'filemanager.tile' : 'filemanager.home.rows' ), |
|
| 37 | + 'template' => ($this->nm_settings['view'] == 'tile' ? 'filemanager.tile' : 'filemanager.home.rows'), |
|
| 38 | 38 | // Filemanager needs this header, it's an important component for actions, but we reduce it to the minimum |
| 39 | 39 | 'header_left' => 'filemanager.home.header_left', |
| 40 | 40 | // Use a reduced column set for home, user can change if needed |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | 'parent_id' => 'dir', |
| 47 | 47 | 'is_parent' => 'mime', |
| 48 | 48 | 'is_parent_value'=> Vfs::DIR_MIME_TYPE, |
| 49 | - 'placeholder_actions' => array('mkdir','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink') |
|
| 49 | + 'placeholder_actions' => array('mkdir', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink') |
|
| 50 | 50 | ); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function exec($id = null, Etemplate &$etemplate = null) |
|
| 53 | + public function exec($id = null, Etemplate&$etemplate = null) |
|
| 54 | 54 | { |
| 55 | 55 | |
| 56 | 56 | $this->context['sel_options']['filter'] = array( |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $ui = new filemanager_ui(); |
| 81 | 81 | $total = $ui->get_rows($query, $rows, $readonlys); |
| 82 | 82 | // Change template to match selected view |
| 83 | - if($query['view']) |
|
| 83 | + if ($query['view']) |
|
| 84 | 84 | { |
| 85 | 85 | $query['template'] = ($query['view'] == 'row' ? 'filemanager.home.rows' : 'filemanager.tile'); |
| 86 | 86 | } |
@@ -103,14 +103,14 @@ discard block |
||
| 103 | 103 | // the etemplate exec to fire again. |
| 104 | 104 | if ($content['nm']['action']) |
| 105 | 105 | { |
| 106 | - $msg = filemanager_ui::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
|
| 107 | - if($msg) Api\Json\Response::get()->apply('egw.message',array($msg)); |
|
| 108 | - foreach($content['nm']['selected'] as &$id) |
|
| 106 | + $msg = filemanager_ui::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']); |
|
| 107 | + if ($msg) Api\Json\Response::get()->apply('egw.message', array($msg)); |
|
| 108 | + foreach ($content['nm']['selected'] as &$id) |
|
| 109 | 109 | { |
| 110 | 110 | $id = 'filemanager::'.$id; |
| 111 | 111 | } |
| 112 | 112 | // Directly request an update - this will get filemanager tab too |
| 113 | - Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected'])); |
|
| 113 | + Api\Json\Response::get()->apply('egw.dataRefreshUIDs', array($content['nm']['selected'])); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | \ No newline at end of file |