mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-26 01:43:47 +01:00
single backend methods to copy, move or symlink files
This commit is contained in:
parent
f7214ecd4f
commit
e4d7e59a0a
@ -614,20 +614,8 @@ class filemanager_ui
|
|||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
return self::do_delete($selected,$errs,$files,$dirs);
|
return self::do_delete($selected,$errs,$files,$dirs);
|
||||||
/* done on clientside now
|
|
||||||
case 'add':
|
|
||||||
$files = egw_session::appsession('clipboard_files','filemanager');
|
|
||||||
egw_session::appsession('clipboard_files','filemanager',$files ? array_unique(array_merge($files,$selected)) : $selected);
|
|
||||||
egw_session::appsession('clipboard_type','filemanager','copy'); // always switch to copy, to be on the save side
|
|
||||||
return lang('%1 URLs %2 to clipboard.',count($selected),lang('copied'));
|
|
||||||
|
|
||||||
case 'copy':
|
case 'copy':
|
||||||
case 'cut':
|
|
||||||
egw_session::appsession('clipboard_files','filemanager',$selected);
|
|
||||||
egw_session::appsession('clipboard_type','filemanager',$action);
|
|
||||||
return lang('%1 URLs %2 to clipboard.',count($selected),$action=='copy'?lang('copied'):lang('cut'));
|
|
||||||
*/
|
|
||||||
case 'copy_paste':
|
|
||||||
foreach($selected as $path)
|
foreach($selected as $path)
|
||||||
{
|
{
|
||||||
if (!egw_vfs::is_dir($path))
|
if (!egw_vfs::is_dir($path))
|
||||||
@ -675,9 +663,6 @@ class filemanager_ui
|
|||||||
return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files);
|
return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files);
|
||||||
|
|
||||||
case 'move':
|
case 'move':
|
||||||
if (!isset($dir)) $dir = array_pop($selected);
|
|
||||||
// fall throught
|
|
||||||
case 'cut_paste':
|
|
||||||
foreach($selected as $path)
|
foreach($selected as $path)
|
||||||
{
|
{
|
||||||
$to = egw_vfs::is_dir($dir) || count($selected) > 1 ? egw_vfs::concat($dir,egw_vfs::basename($path)) : $dir;
|
$to = egw_vfs::is_dir($dir) || count($selected) > 1 ? egw_vfs::concat($dir,egw_vfs::basename($path)) : $dir;
|
||||||
@ -690,18 +675,22 @@ class filemanager_ui
|
|||||||
++$errs;
|
++$errs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($action == 'cut_paste') egw_session::appsession('clipboard_files','filemanager',false); // cant move again
|
|
||||||
if ($errs)
|
if ($errs)
|
||||||
{
|
{
|
||||||
return lang('%1 errors moving (%2 files moved)!',$errs,$files);
|
return lang('%1 errors moving (%2 files moved)!',$errs,$files);
|
||||||
}
|
}
|
||||||
return lang('%1 files moved.',$files);
|
return lang('%1 files moved.',$files);
|
||||||
|
|
||||||
case 'link_paste':
|
case 'symlink': // symlink given files to $dir
|
||||||
foreach($selected as $path)
|
foreach((array)$selected as $target)
|
||||||
{
|
{
|
||||||
$to = egw_vfs::concat($dir,egw_vfs::basename($path));
|
$link = egw_vfs::concat($dir, egw_vfs::basename($target));
|
||||||
if ($path != $to && egw_vfs::symlink($path,$to))
|
if ($target[0] != '/') $target = egw_vfs::concat($dir, $target);
|
||||||
|
if (!egw_vfs::stat($target))
|
||||||
|
{
|
||||||
|
return lang('Link target %1 not found!', egw_vfs::decodePath($target));
|
||||||
|
}
|
||||||
|
if ($target != $link && egw_vfs::symlink($target, $link))
|
||||||
{
|
{
|
||||||
++$files;
|
++$files;
|
||||||
}
|
}
|
||||||
@ -710,12 +699,17 @@ class filemanager_ui
|
|||||||
++$errs;
|
++$errs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ret = lang('%1 elements linked.',$files);
|
if (count((array)$selected) == 1)
|
||||||
|
{
|
||||||
|
return $files ? lang('Symlink to %1 created.', egw_vfs::decodePath($target)) :
|
||||||
|
lang('Error creating symlink to target %1!', egw_vfs::decodePath($target));
|
||||||
|
}
|
||||||
|
$ret = lang('%1 elements linked.', $files);
|
||||||
if ($errs)
|
if ($errs)
|
||||||
{
|
{
|
||||||
$ret = lang('%1 errors linking (%2)!',$errs,$ret);
|
$ret = lang('%1 errors linking (%2)!',$errs, $ret);
|
||||||
}
|
}
|
||||||
return $ret." egw_vfs::symlink('$to','$path')";
|
return $ret;//." egw_vfs::symlink('$target', '$link')";
|
||||||
|
|
||||||
case 'createdir':
|
case 'createdir':
|
||||||
$dst = egw_vfs::concat($dir, is_array($selected) ? $selected[0] : $selected);
|
$dst = egw_vfs::concat($dir, is_array($selected) ? $selected[0] : $selected);
|
||||||
@ -725,18 +719,6 @@ class filemanager_ui
|
|||||||
}
|
}
|
||||||
return lang("Error while creating directory.");
|
return lang("Error while creating directory.");
|
||||||
|
|
||||||
case 'symlink': // symlink given file into current dir
|
|
||||||
$target = is_array($selected) ? $selected[0] : $selected;
|
|
||||||
$link = egw_vfs::concat($dir, egw_vfs::basename($target));
|
|
||||||
$abs_target = $target[0] == '/' ? $target : egw_vfs::concat($dir, $target);
|
|
||||||
if (!egw_vfs::stat($abs_target))
|
|
||||||
{
|
|
||||||
return lang('Link target %1 not found!', egw_vfs::decodePath($abs_target));
|
|
||||||
}
|
|
||||||
return egw_vfs::symlink($target,$link) ?
|
|
||||||
lang('Symlink to %1 created.',$target) :
|
|
||||||
lang('Error creating symlink to target %1!',egw_vfs::decodePath($target));
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
list($action, $settings) = explode('_', $action, 2);
|
list($action, $settings) = explode('_', $action, 2);
|
||||||
switch($action)
|
switch($action)
|
||||||
|
@ -228,7 +228,7 @@ app.filemanager = AppJS.extend(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'paste':
|
case 'paste':
|
||||||
this._do_action(this.clipboard_is_cut ? 'cut_paste' : 'copy_paste', this.clipboard_files);
|
this._do_action(this.clipboard_is_cut ? 'move' : 'copy', this.clipboard_files);
|
||||||
|
|
||||||
if (this.clipboard_is_cut)
|
if (this.clipboard_is_cut)
|
||||||
{
|
{
|
||||||
@ -239,7 +239,7 @@ app.filemanager = AppJS.extend(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'linkpaste':
|
case 'linkpaste':
|
||||||
this._do_action('link_paste', this.clipboard_files);
|
this._do_action('symlink', this.clipboard_files);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -292,11 +292,12 @@ app.filemanager = AppJS.extend(
|
|||||||
* @param _type 'move_file', 'copy_file', ...
|
* @param _type 'move_file', 'copy_file', ...
|
||||||
* @param _selected selected paths
|
* @param _selected selected paths
|
||||||
* @param _sync send a synchronous ajax request
|
* @param _sync send a synchronous ajax request
|
||||||
|
* @param _path defaults to current path
|
||||||
*/
|
*/
|
||||||
_do_action: function(_type, _selected, _sync)
|
_do_action: function(_type, _selected, _sync, _path)
|
||||||
{
|
{
|
||||||
var path = this.path_widget.get_value();
|
if (typeof _path == 'undefined') _path = this.path_widget.get_value();
|
||||||
var request = new egw_json_request('filemanager_ui::ajax_action', [_type, _selected, path], this);
|
var request = new egw_json_request('filemanager_ui::ajax_action', [_type, _selected, _path], this);
|
||||||
request.sendRequest(!_sync, this._do_action_callback, this);
|
request.sendRequest(!_sync, this._do_action_callback, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -386,14 +387,7 @@ app.filemanager = AppJS.extend(
|
|||||||
|
|
||||||
alert(_action.id+': '+src.join(', ')+' --> '+dst);
|
alert(_action.id+': '+src.join(', ')+' --> '+dst);
|
||||||
|
|
||||||
if (_action.id == "file_drop_move")
|
this._do_action(_action.id == "file_drop_move" ? 'move' : 'copy', src, false, dst);
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -460,5 +454,5 @@ app.filemanager = AppJS.extend(
|
|||||||
div.append(text);
|
div.append(text);
|
||||||
|
|
||||||
return div;
|
return div;
|
||||||
},
|
}
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user