mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 23:43:17 +01:00
first - not yet fully working - version of upload
This commit is contained in:
parent
3a14e96d1a
commit
588f87eddb
@ -448,6 +448,9 @@ class filemanager_ui
|
||||
'3' => 'Show hidden files',
|
||||
'' => 'Files from subdirectories',
|
||||
);
|
||||
$tpl->setElementAttribute('nm[upload]', 'onFinish', 'app.filemanager.upload');
|
||||
$tpl->setElementAttribute('nm[upload]', 'multiple', true);
|
||||
|
||||
$tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm']));
|
||||
}
|
||||
|
||||
@ -1292,8 +1295,65 @@ class filemanager_ui
|
||||
|
||||
if (!isset($dir)) $dir = array_pop($selected);
|
||||
|
||||
$arr['msg'] = self::action($action, $selected, $dir, $arr['errs'], $arr['dirs'], $arr['files']);
|
||||
switch($action)
|
||||
{
|
||||
case 'upload':
|
||||
$script_error = 0;
|
||||
foreach($selected as $tmp_name => &$data)
|
||||
{
|
||||
$path = egw_vfs::concat($dir, egw_vfs::encodePathComponent($data['name']));
|
||||
|
||||
if(egw_vfs::deny_script($path))
|
||||
{
|
||||
if (!isset($script_error))
|
||||
{
|
||||
$arr['msg'] .= ($arr['msg'] ? "\n" : '').lang('You are NOT allowed to upload a script!');
|
||||
}
|
||||
++$script_error;
|
||||
++$arr['errs'];
|
||||
unset($selected[$tmp_name]);
|
||||
}
|
||||
elseif (!$data['confirmed'] && egw_vfs::stat($path))
|
||||
{
|
||||
$data['confirm'] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
|
||||
{
|
||||
$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmp_path = ini_get('upload_tmp_dir').'/'.basename($tmp_name);
|
||||
}
|
||||
|
||||
if (egw_vfs::copy_uploaded($tmp_path, $path, null, false))
|
||||
{
|
||||
++$arr['files'];
|
||||
$uploaded[] = $data['name'];
|
||||
}
|
||||
else
|
||||
{
|
||||
++$arr['errs'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($arr['errs'] > $script_error)
|
||||
{
|
||||
$arr['msg'] .= ($arr['msg'] ? "\n" : '').lang('Error uploading file!');
|
||||
}
|
||||
if ($arr['files'])
|
||||
{
|
||||
$arr['msg'] .= ($arr['msg'] ? "\n" : '').lang('%1 successful uploaded.', implode(', ', $uploaded));
|
||||
}
|
||||
$arr['uploaded'] = $selected;
|
||||
$arr['path'] = $dir;
|
||||
break;
|
||||
|
||||
default:
|
||||
$arr['msg'] = self::action($action, $selected, $dir, $arr['errs'], $arr['dirs'], $arr['files']);
|
||||
}
|
||||
$response->data($arr);
|
||||
//error_log(__METHOD__."('$action',".array2string($selected).') returning '.array2string($arr));
|
||||
}
|
||||
|
@ -176,31 +176,57 @@ app.filemanager = AppJS.extend(
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if file would overwrite a file on server
|
||||
* Send names of uploaded files (again) to server, to process them: either copy to vfs or ask overwrite/rename
|
||||
*
|
||||
* @param upload
|
||||
* @param path_id
|
||||
* @Todo whole upload need to be modified to use server-side callback to move file in place,
|
||||
* if it does NOT overwrite anything, or send prompt to override / change filename back to client
|
||||
* @param _event
|
||||
* @param _file_count
|
||||
*/
|
||||
check_files: function(upload, path_id)
|
||||
upload: function(_event, _file_count)
|
||||
{
|
||||
alert('ToDo ;-)');
|
||||
/*var files = [];
|
||||
if (upload.files)
|
||||
if (_file_count)
|
||||
{
|
||||
for(var i = 0; i < upload.files.length; ++i)
|
||||
var widget = _event.data;
|
||||
var request = new egw_json_request('filemanager_ui::ajax_action', ['upload', widget.options.value, this.get_path()], this);
|
||||
widget.progress.remove();
|
||||
widget.set_value('');
|
||||
request.sendRequest(false, this._upload_callback, this);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback for server response to upload request:
|
||||
* - display message and refresh list
|
||||
* - ask use to confirm overwritting existing files or rename upload
|
||||
*
|
||||
* @param object _data values for attributes msg, files, ...
|
||||
*/
|
||||
_upload_callback: function(_data)
|
||||
{
|
||||
// give an error: EGW JSON Error: Internal JSON handler error
|
||||
// seems to be caused by upload being part of nextmatch namespace "nm"
|
||||
if (_data.msg) window.egw_refresh(_data.msg, this.appname);
|
||||
|
||||
var send_confirmation_back = false;
|
||||
for(var file in _data.uploaded)
|
||||
{
|
||||
if (_data.uploaded[file].confirm && !_data.uploaded[file].confirmed)
|
||||
{
|
||||
files.push(upload.files[i].name || upload.files[i].fileName);
|
||||
if (confirm(egw.lang('Overwrite %1?', _data.uploaded[file].name)))
|
||||
{
|
||||
send_confirmation_back = true;
|
||||
_data.uploaded[file].confirmed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delete _data.uploaded[file];
|
||||
}
|
||||
}
|
||||
else if (upload.value)
|
||||
if (send_confirmation_back)
|
||||
{
|
||||
files = upload.value;
|
||||
var request = new egw_json_request('filemanager_ui::ajax_action', ['upload', _data.uploaded, _data.path], this);
|
||||
request.sendRequest(false, this._upload_callback, this);
|
||||
}
|
||||
var path = document.getElementById(path_id ? path_id : upload.id.replace(/upload\]\[/,"nm][path"));
|
||||
|
||||
xajax_doXMLHTTP("filemanager_ui::ajax_check_upload_target",upload.id, files, path.value);*/
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* EGroupware - eTemplates for Application filemanager
|
||||
* http://www.egroupware.org
|
||||
* generated by soetemplate::dump4setup() 2013-04-12 17:55
|
||||
* generated by soetemplate::dump4setup() 2013-04-20 21:19
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package filemanager
|
||||
@ -37,7 +37,7 @@ $templ_data[] = array('name' => 'filemanager.index','template' => '','lang' => '
|
||||
width: 50ex
|
||||
}','modified' => '1365608331',);
|
||||
|
||||
$templ_data[] = array('name' => 'filemanager.index.header_left','template' => '','lang' => '','group' => '0','version' => '1.9.002','data' => 'a:1:{i:0;a:16:{s:4:"span";s:3:"all";s:4:"type";s:4:"hbox";s:4:"size";s:2:"13";i:1;a:4:{s:5:"label";s:2:"Up";s:7:"onclick";s:33:"app.filemanager.change_dir(\'..\');";s:4:"type";s:5:"image";s:4:"name";s:4:"goup";}i:2;a:4:{s:5:"label";s:25:"Go to your home directory";s:7:"onclick";s:32:"app.filemanager.change_dir(\'~\');";s:4:"type";s:5:"image";s:4:"name";s:6:"gohome";}i:3;a:6:{s:5:"label";s:4:"Path";s:8:"onchange";s:12:"return true;";s:4:"name";s:4:"path";s:4:"size";s:2:"80";s:4:"type";s:8:"vfs-name";s:4:"span";s:8:",address";}i:4;a:4:{s:5:"label";s:5:"Go to";s:4:"name";s:10:"button[go]";s:4:"type";s:6:"button";s:4:"size";s:9:"key_enter";}i:5;a:2:{s:4:"type";s:5:"image";s:4:"name";s:15:"buttonseparator";}i:6;a:6:{s:5:"label";s:13:"Edit settings";s:7:"onclick";s:28:"app.filemanager.editprefs();";s:4:"name";s:12:"button[edit]";s:4:"type";s:10:"buttononly";s:4:"size";s:4:"edit";s:4:"help";s:39:"Rename, change permissions or ownership";}i:7;a:5:{s:5:"label";s:16:"Create directory";s:7:"onclick";s:28:"app.filemanager.createdir();";s:4:"name";s:17:"button[createdir]";s:4:"type";s:10:"buttononly";s:4:"size";s:35:"button_createdir,createdir_disabled";}i:8;a:5:{s:5:"label";s:13:"Create a link";s:7:"onclick";s:26:"app.filemanager.symlink();";s:4:"name";s:15:"button[symlink]";s:4:"type";s:10:"buttononly";s:4:"size";s:18:"link,link_disabled";}i:9;a:4:{s:7:"onclick";s:31:"app.filemanager.paste(\'paste\');";s:4:"name";s:13:"button[paste]";s:4:"size";s:28:"editpaste,editpaste_disabled";s:4:"type";s:10:"buttononly";}i:10;a:4:{s:7:"onclick";s:35:"app.filemanager.paste(\'linkpaste\');";s:4:"name";s:17:"button[linkpaste]";s:4:"size";s:28:"linkpaste,linkpaste_disabled";s:4:"type";s:10:"buttononly";}i:11;a:4:{s:7:"onclick";s:35:"app.filemanager.paste(\'mailpaste\');";s:4:"name";s:17:"button[mailpaste]";s:4:"size";s:28:"mailpaste,mailpaste_disabled";s:4:"type";s:10:"buttononly";}i:12;a:4:{s:5:"label";s:11:"File a file";s:7:"onclick";s:171:"window.open(egw::link(\'/index.php\',\'menuaction=stylite.stylite_filemanager.upload\'),\'_blank\',\'dependent=yes,width=550,height=350,scrollbars=yes,status=yes\'); return false;";s:4:"type";s:6:"button";s:4:"size";s:6:"upload";}i:13;a:4:{s:8:"onchange";s:34:"app.filemanager.check_files(this);";s:4:"name";s:8:"upload[]";s:4:"type";s:4:"file";s:4:"help";s:42:"Select file to upload in current directory";}}}','size' => '','style' => '','modified' => '1365608384',);
|
||||
$templ_data[] = array('name' => 'filemanager.index.header_left','template' => '','lang' => '','group' => '0','version' => '1.9.002','data' => 'a:1:{i:0;a:16:{s:4:"span";s:3:"all";s:4:"type";s:4:"hbox";s:4:"size";s:2:"13";i:1;a:4:{s:5:"label";s:2:"Up";s:7:"onclick";s:33:"app.filemanager.change_dir(\'..\');";s:4:"type";s:5:"image";s:4:"name";s:4:"goup";}i:2;a:4:{s:5:"label";s:25:"Go to your home directory";s:7:"onclick";s:32:"app.filemanager.change_dir(\'~\');";s:4:"type";s:5:"image";s:4:"name";s:6:"gohome";}i:3;a:6:{s:5:"label";s:4:"Path";s:8:"onchange";s:12:"return true;";s:4:"name";s:4:"path";s:4:"size";s:2:"80";s:4:"type";s:8:"vfs-name";s:4:"span";s:8:",address";}i:4;a:4:{s:5:"label";s:5:"Go to";s:4:"name";s:10:"button[go]";s:4:"type";s:6:"button";s:4:"size";s:9:"key_enter";}i:5;a:2:{s:4:"type";s:5:"image";s:4:"name";s:15:"buttonseparator";}i:6;a:6:{s:5:"label";s:13:"Edit settings";s:7:"onclick";s:28:"app.filemanager.editprefs();";s:4:"name";s:12:"button[edit]";s:4:"type";s:10:"buttononly";s:4:"size";s:4:"edit";s:4:"help";s:39:"Rename, change permissions or ownership";}i:7;a:5:{s:5:"label";s:16:"Create directory";s:7:"onclick";s:28:"app.filemanager.createdir();";s:4:"name";s:17:"button[createdir]";s:4:"type";s:10:"buttononly";s:4:"size";s:35:"button_createdir,createdir_disabled";}i:8;a:5:{s:5:"label";s:13:"Create a link";s:7:"onclick";s:26:"app.filemanager.symlink();";s:4:"name";s:15:"button[symlink]";s:4:"type";s:10:"buttononly";s:4:"size";s:18:"link,link_disabled";}i:9;a:4:{s:7:"onclick";s:31:"app.filemanager.paste(\'paste\');";s:4:"name";s:13:"button[paste]";s:4:"size";s:28:"editpaste,editpaste_disabled";s:4:"type";s:10:"buttononly";}i:10;a:4:{s:7:"onclick";s:35:"app.filemanager.paste(\'linkpaste\');";s:4:"name";s:17:"button[linkpaste]";s:4:"size";s:28:"linkpaste,linkpaste_disabled";s:4:"type";s:10:"buttononly";}i:11;a:4:{s:7:"onclick";s:35:"app.filemanager.paste(\'mailpaste\');";s:4:"name";s:17:"button[mailpaste]";s:4:"size";s:28:"mailpaste,mailpaste_disabled";s:4:"type";s:10:"buttononly";}i:12;a:4:{s:5:"label";s:11:"File a file";s:7:"onclick";s:171:"window.open(egw::link(\'/index.php\',\'menuaction=stylite.stylite_filemanager.upload\'),\'_blank\',\'dependent=yes,width=550,height=350,scrollbars=yes,status=yes\'); return false;";s:4:"type";s:6:"button";s:4:"size";s:6:"upload";}i:13;a:3:{s:4:"name";s:6:"upload";s:4:"type";s:4:"file";s:4:"help";s:42:"Select file to upload in current directory";}}}','size' => '','style' => '','modified' => '1365608384',);
|
||||
|
||||
$templ_data[] = array('name' => 'filemanager.index.rows','template' => '','lang' => '','group' => '0','version' => '1.7.002','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:6:{s:2:"c1";s:2:"th";s:2:"c2";s:20:"row $row_cont[class]";s:1:"B";s:3:"30%";s:1:"D";s:3:"120";s:1:"E";s:3:"120";s:1:"K";s:2:"70";}i:1;a:11:{s:1:"A";a:4:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"Type";s:4:"name";s:4:"mime";s:5:"align";s:6:"center";}s:1:"B";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"Name";s:4:"name";s:4:"name";}s:1:"C";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"Size";s:4:"name";s:4:"size";}s:1:"D";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:8:"Modified";s:4:"name";s:5:"mtime";}s:1:"E";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:7:"Created";s:4:"name";s:5:"ctime";}s:1:"F";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:11:"Permissions";s:4:"name";s:4:"mode";}s:1:"G";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:4:"name";s:3:"uid";s:5:"label";s:5:"Owner";}s:1:"H";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:4:"name";s:3:"gid";s:5:"label";s:5:"Group";}s:1:"I";a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:7:"Comment";s:4:"name";s:7:"comment";}s:1:"J";a:3:{s:4:"type";s:22:"nextmatch-customfields";s:8:"readonly";s:1:"1";s:4:"name";s:12:"customfields";}s:1:"K";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:6:"2,,0,0";i:1;a:3:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:7:"Actions";s:4:"name";s:14:"legacy_actions";}i:2;a:8:{s:4:"type";s:6:"button";s:4:"size";s:5:"check";s:5:"label";s:9:"Check all";s:4:"name";s:9:"check_all";s:4:"help";s:9:"Check all";s:7:"onclick";s:98:"egw_globalObjectManager.getObjectById(\'filemanager.index.rows\').toggleAllSelected(); return false;";s:6:"needed";s:1:"1";s:5:"align";s:5:"right";}}}i:2;a:11:{s:1:"A";a:3:{s:4:"type";s:8:"vfs-mime";s:4:"name";s:4:"$row";s:5:"align";s:6:"center";}s:1:"B";a:4:{s:4:"type";s:8:"vfs-name";s:4:"name";s:12:"${row}[name]";s:7:"no_lang";s:1:"1";s:8:"readonly";s:1:"1";}s:1:"C";a:3:{s:4:"type";s:8:"vfs-size";s:4:"name";s:12:"${row}[size]";s:5:"align";s:5:"right";}s:1:"D";a:3:{s:4:"type";s:9:"date-time";s:4:"name";s:13:"${row}[mtime]";s:8:"readonly";s:1:"1";}s:1:"E";a:3:{s:4:"type";s:9:"date-time";s:4:"name";s:13:"${row}[ctime]";s:8:"readonly";s:1:"1";}s:1:"F";a:2:{s:4:"type";s:8:"vfs-mode";s:4:"name";s:12:"${row}[mode]";}s:1:"G";a:3:{s:4:"type";s:7:"vfs-uid";s:4:"name";s:11:"${row}[uid]";s:7:"no_lang";s:1:"1";}s:1:"H";a:3:{s:4:"type";s:7:"vfs-gid";s:4:"name";s:11:"${row}[gid]";s:7:"no_lang";s:1:"1";}s:1:"I";a:2:{s:4:"type";s:5:"label";s:4:"name";s:15:"${row}[comment]";}s:1:"J";a:3:{s:4:"type";s:17:"customfields-list";s:4:"name";s:4:"$row";s:4:"span";s:13:",customfields";}s:1:"K";a:7:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"4";i:1;a:6:{s:4:"type";s:6:"button";s:4:"size";s:4:"edit";s:5:"label";s:13:"Edit settings";s:4:"name";s:21:"edit[$row_cont[path]]";s:4:"help";s:39:"Rename, change permissions or ownership";s:7:"onclick";s:192:"window.open(egw::link(\'/index.php\',\'menuaction=filemanager.filemanager_ui.file&path=$row_cont[path]\'),\'fileprefs\',\'dependent=yes,width=495,height=425,scrollbars=yes,status=yes\'); return false;";}i:2;a:5:{s:4:"type";s:10:"buttononly";s:4:"size";s:12:"mail_post_to";s:4:"name";s:21:"mail[$row_cont[path]]";s:7:"onclick";s:43:"open_mail(\'$row_cont[path]\'); return false;";s:5:"align";s:6:"center";}i:3;a:7:{s:4:"type";s:6:"button";s:4:"name";s:23:"delete[$row_cont[path]]";s:4:"size";s:6:"delete";s:5:"label";s:6:"Delete";s:4:"help";s:29:"Delete this file or directory";s:7:"onclick";s:48:"return confirm(\'Delete this file or directory\');";s:5:"align";s:6:"center";}s:5:"align";s:5:"right";i:4;a:4:{s:4:"type";s:8:"checkbox";s:4:"name";s:9:"checked[]";s:5:"align";s:5:"right";s:4:"size";s:17:""$row_cont[path]"";}}}}s:4:"rows";i:2;s:4:"cols";i:11;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '','modified' => '1259329664',);
|
||||
|
||||
|
@ -68,7 +68,7 @@
|
||||
<buttononly id="button[linkpaste]" onclick="app.filemanager.paste('linkpaste');" options="linkpaste,linkpaste_disabled"/>
|
||||
<buttononly id="button[mailpaste]" onclick="app.filemanager.paste('mailpaste');" options="mailpaste,mailpaste_disabled"/>
|
||||
<button label="File a file" onclick="window.open(egw::link('/index.php','menuaction=stylite.stylite_filemanager.upload'),'_blank','dependent=yes,width=550,height=350,scrollbars=yes,status=yes'); return false;" image="upload"/>
|
||||
<file statustext="Select file to upload in current directory" id="upload[]" onchange="app.filemanager.check_files(this);"/>
|
||||
<file statustext="Select file to upload in current directory" id="upload"/>
|
||||
</hbox>
|
||||
</template>
|
||||
<template id="filemanager.index" template="" lang="" group="0" version="1.9.003">
|
||||
|
Loading…
Reference in New Issue
Block a user