Merge commit 'refs/merge-requests/12' of git://gitorious.org/owncloud/owncloud into integratio
This commit is contained in:
commit
bc8e899de1
6 changed files with 290 additions and 12 deletions
108
files/get_file.php
Normal file
108
files/get_file.php
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ownCloud - ajax frontend
|
||||||
|
*
|
||||||
|
* @author Robin Appelman
|
||||||
|
* @copyright 2010 Robin Appelman icewind1991@gmail.com
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
//not this file is for getting files themselves, get_files.php is for getting a list of files.
|
||||||
|
|
||||||
|
require_once('../inc/lib_base.php');
|
||||||
|
|
||||||
|
if(!function_exists('sys_get_temp_dir')) {
|
||||||
|
function sys_get_temp_dir() {
|
||||||
|
if( $temp=getenv('TMP') ) return $temp;
|
||||||
|
if( $temp=getenv('TEMP') ) return $temp;
|
||||||
|
if( $temp=getenv('TMPDIR') ) return $temp;
|
||||||
|
$temp=tempnam(__FILE__,'');
|
||||||
|
if (file_exists($temp)) {
|
||||||
|
unlink($temp);
|
||||||
|
return dirname($temp);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addDir($dir,$zip,$internalDir=''){
|
||||||
|
$dirname=basename($dir);
|
||||||
|
$zip->addEmptyDir($internalDir.$dirname);
|
||||||
|
$internalDir.=$dirname.='/';
|
||||||
|
$files=OC_FILES::getdirectorycontent($dir);
|
||||||
|
foreach($files as $file){
|
||||||
|
$filename=$file['name'];
|
||||||
|
$file=$dir.'/'.$filename;
|
||||||
|
if(is_file($file)){
|
||||||
|
$zip->addFile($file,$internalDir.$filename);
|
||||||
|
}elseif(is_dir($file)){
|
||||||
|
addDir($file,$zip,$internalDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$files=$_GET['files'];
|
||||||
|
$dir=(isset($_GET['dir']))?$_GET['dir']:'';
|
||||||
|
if(strstr($files,'..') or strstr($dir,'..')){
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
if(strpos($files,',')){
|
||||||
|
$files=explode(',',$files);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(is_array($files)){
|
||||||
|
$zip = new ZipArchive();
|
||||||
|
$filename = sys_get_temp_dir()."/ownCloud.zip";
|
||||||
|
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
|
||||||
|
exit("cannot open <$filename>\n");
|
||||||
|
}
|
||||||
|
foreach($files as $file){
|
||||||
|
$file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file;
|
||||||
|
if(is_file($file)){
|
||||||
|
$zip->addFile($file,basename($file));
|
||||||
|
}elseif(is_dir($file)){
|
||||||
|
addDir($file,$zip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$zip->close();
|
||||||
|
}elseif(is_dir($CONFIG_DATADIRECTORY.'/'.$dir.'/'.$files)){
|
||||||
|
$zip = new ZipArchive();
|
||||||
|
$filename = sys_get_temp_dir()."/ownCloud.zip";
|
||||||
|
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
|
||||||
|
exit("cannot open <$filename>\n");
|
||||||
|
}
|
||||||
|
$file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$files;
|
||||||
|
addDir($file,$zip);
|
||||||
|
$zip->close();
|
||||||
|
}else{
|
||||||
|
$zip=false;
|
||||||
|
$filename=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$files;
|
||||||
|
}
|
||||||
|
header('Content-Description: File Transfer');
|
||||||
|
header('Content-Type: application/octet-stream');
|
||||||
|
header('Content-Disposition: attachment; filename='.basename($filename));
|
||||||
|
header('Content-Transfer-Encoding: binary');
|
||||||
|
header('Expires: 0');
|
||||||
|
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||||
|
header('Pragma: public');
|
||||||
|
header('Content-Length: ' . filesize($filename));
|
||||||
|
ob_end_clean();
|
||||||
|
readfile($filename);
|
||||||
|
if($zip){
|
||||||
|
unlink($filename);
|
||||||
|
}
|
||||||
|
?>
|
|
@ -22,6 +22,22 @@
|
||||||
*/
|
*/
|
||||||
require_once('../inc/lib_base.php');
|
require_once('../inc/lib_base.php');
|
||||||
|
|
||||||
|
function return_bytes($val) {
|
||||||
|
$val = trim($val);
|
||||||
|
$last = strtolower($val[strlen($val)-1]);
|
||||||
|
switch($last) {
|
||||||
|
// The 'G' modifier is available since PHP 5.1.0
|
||||||
|
case 'g':
|
||||||
|
$val *= 1024;
|
||||||
|
case 'm':
|
||||||
|
$val *= 1024;
|
||||||
|
case 'k':
|
||||||
|
$val *= 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $val;
|
||||||
|
}
|
||||||
|
|
||||||
// header('Content-type: text/plain');
|
// header('Content-type: text/plain');
|
||||||
header('Content-type: application/xml');
|
header('Content-type: application/xml');
|
||||||
|
|
||||||
|
@ -29,9 +45,10 @@ $dir=isset($_GET['dir'])?$_GET['dir']:'';
|
||||||
$files=OC_FILES::getdirectorycontent($CONFIG_DATADIRECTORY.'/'.$dir);
|
$files=OC_FILES::getdirectorycontent($CONFIG_DATADIRECTORY.'/'.$dir);
|
||||||
$dirname=$files[0]['directory'];
|
$dirname=$files[0]['directory'];
|
||||||
$dirname=substr($dirname,strrpos($dirname,'/'));
|
$dirname=substr($dirname,strrpos($dirname,'/'));
|
||||||
|
$max_upload=min(return_bytes(ini_get('post_max_size')),return_bytes(ini_get('upload_max_filesize')));
|
||||||
ob_clean();
|
ob_clean();
|
||||||
echo "<?xml version='1.0' standalone='yes'?>\n";
|
echo "<?xml version='1.0' standalone='yes'?>\n";
|
||||||
echo "<dir name='$dirname'>\n";
|
echo "<dir name='$dirname' max_upload='$max_upload'>\n";
|
||||||
foreach($files as $file){
|
foreach($files as $file){
|
||||||
$attributes='';
|
$attributes='';
|
||||||
foreach($file as $name=>$data){
|
foreach($file as $name=>$data){
|
||||||
|
|
|
@ -83,7 +83,7 @@ $loginresult=OC_USER::loginlisener();
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class OC_USER {
|
class OC_USER {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if the login button is pressed and logg the user in
|
* check if the login button is pressed and logg the user in
|
||||||
*
|
*
|
||||||
|
@ -122,6 +122,16 @@ class OC_USER {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class OC_UTIL {
|
class OC_UTIL {
|
||||||
|
public static $scripts=array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add a javascript file
|
||||||
|
*
|
||||||
|
* @param url $url
|
||||||
|
*/
|
||||||
|
public static function addscript($url){
|
||||||
|
self::$scripts[]=$url;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* array to store all the optional navigation buttons of the plugins
|
* array to store all the optional navigation buttons of the plugins
|
||||||
|
|
|
@ -6,9 +6,15 @@
|
||||||
<base href="<?php echo($WEBROOT); ?>/"/>
|
<base href="<?php echo($WEBROOT); ?>/"/>
|
||||||
<link rel="stylesheet" type="text/css" href="css/default.php"/>
|
<link rel="stylesheet" type="text/css" href="css/default.php"/>
|
||||||
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/lib_ajax.js'></script>
|
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/lib_ajax.js'></script>
|
||||||
|
<!-- <script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/timer.js'></script> -->
|
||||||
|
<!-- <script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/notification.js'></script> -->
|
||||||
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/lib_xmlloader.js'></script>
|
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/lib_xmlloader.js'></script>
|
||||||
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/lib_files.js'></script>
|
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/lib_files.js'></script>
|
||||||
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/ajax.js'></script>
|
<?php
|
||||||
|
foreach(OC_UTIL::$scripts as $script){
|
||||||
|
echo("<script type='text/ecmascript' src='$WEBROOT/$script'></script>");
|
||||||
|
}
|
||||||
|
?>
|
||||||
<script type='text/ecmascript'>
|
<script type='text/ecmascript'>
|
||||||
var WEBROOT='<?php echo($WEBROOT)?>';
|
var WEBROOT='<?php echo($WEBROOT)?>';
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -31,7 +31,7 @@ if(isset($_GET['file'])) {
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
OC_UTIL::addscript('js/ajax.js');
|
||||||
OC_UTIL::showheader();
|
OC_UTIL::showheader();
|
||||||
|
|
||||||
OC_FILES::showbrowser($CONFIG_DATADIRECTORY,$dir);
|
OC_FILES::showbrowser($CONFIG_DATADIRECTORY,$dir);
|
||||||
|
|
153
js/lib_files.js
153
js/lib_files.js
|
@ -26,6 +26,8 @@ OC_FILES.getdirectorycontent_parse=function(req){
|
||||||
var files=new Array();
|
var files=new Array();
|
||||||
var response=req.responseXML;
|
var response=req.responseXML;
|
||||||
if(response){
|
if(response){
|
||||||
|
var dir=response.getElementsByTagName('dir').item(0);
|
||||||
|
files['max_upload']=dir.getAttribute('max_upload');
|
||||||
var fileElements=response.getElementsByTagName('file');
|
var fileElements=response.getElementsByTagName('file');
|
||||||
if(fileElements.length>0){
|
if(fileElements.length>0){
|
||||||
for(index in fileElements){
|
for(index in fileElements){
|
||||||
|
@ -144,12 +146,45 @@ OC_FILES.showbrowser_callback=function(content){
|
||||||
var filesfound=false;
|
var filesfound=false;
|
||||||
var sizeTd=null;
|
var sizeTd=null;
|
||||||
if(content){
|
if(content){
|
||||||
|
tr=document.createElement('tr');
|
||||||
|
tbody.appendChild(tr);
|
||||||
|
tr.className='browserline';
|
||||||
|
td=document.createElement('td');
|
||||||
|
tr.appendChild(td);
|
||||||
|
td.setAttribute('colspan','2');
|
||||||
|
input=document.createElement('input');
|
||||||
|
input.setAttribute('type','checkbox');
|
||||||
|
input.setAttribute('name','fileSelector');
|
||||||
|
input.setAttribute('value','select_all');
|
||||||
|
input.setAttribute('id','select_all');
|
||||||
|
input.setAttribute('onclick','OC_FILES.selectAll()');
|
||||||
|
td.appendChild(input);
|
||||||
|
td=document.createElement('td');
|
||||||
|
tr.appendChild(td);
|
||||||
|
td.className='nametext';
|
||||||
|
td.setAttribute('name','name');
|
||||||
|
td.appendChild(document.createTextNode('name'))
|
||||||
|
sizeTd=document.createElement('td');
|
||||||
|
tr.appendChild(sizeTd);
|
||||||
|
sizeTd.className='sizetext';
|
||||||
|
sizeTd.appendChild(document.createTextNode('size'));
|
||||||
|
td=document.createElement('td');
|
||||||
|
tr.appendChild(td);
|
||||||
|
td.className='sizetext';
|
||||||
|
td.appendChild(document.createTextNode('date'));
|
||||||
for(index in content){
|
for(index in content){
|
||||||
file=content[index];
|
file=content[index];
|
||||||
if(file.name){
|
if(file.name){
|
||||||
tr=document.createElement('tr');
|
tr=document.createElement('tr');
|
||||||
tbody.appendChild(tr);
|
tbody.appendChild(tr);
|
||||||
tr.className='browserline';
|
tr.className='browserline';
|
||||||
|
td=document.createElement('td');
|
||||||
|
tr.appendChild(td);
|
||||||
|
input=document.createElement('input');
|
||||||
|
input.setAttribute('type','checkbox');
|
||||||
|
input.setAttribute('name','fileSelector');
|
||||||
|
input.setAttribute('value',file['name']);
|
||||||
|
td.appendChild(input);
|
||||||
tr.appendChild(OC_FILES.showicon(file['type']));
|
tr.appendChild(OC_FILES.showicon(file['type']));
|
||||||
td=document.createElement('td');
|
td=document.createElement('td');
|
||||||
tr.appendChild(td);
|
tr.appendChild(td);
|
||||||
|
@ -167,7 +202,7 @@ OC_FILES.showbrowser_callback=function(content){
|
||||||
sizeTd=document.createElement('td');
|
sizeTd=document.createElement('td');
|
||||||
tr.appendChild(sizeTd);
|
tr.appendChild(sizeTd);
|
||||||
sizeTd.className='sizetext';
|
sizeTd.className='sizetext';
|
||||||
sizeTd.appendChild(document.createTextNode(file['size']+' bytes'));
|
sizeTd.appendChild(document.createTextNode(sizeFormat(file['size'])));
|
||||||
}
|
}
|
||||||
a=document.createElement('a');
|
a=document.createElement('a');
|
||||||
img=document.createElement('img');
|
img=document.createElement('img');
|
||||||
|
@ -176,8 +211,6 @@ OC_FILES.showbrowser_callback=function(content){
|
||||||
img.alt='rename'
|
img.alt='rename'
|
||||||
img.title='rename';
|
img.title='rename';
|
||||||
img.src=WEBROOT+'/img/icons/rename.png';
|
img.src=WEBROOT+'/img/icons/rename.png';
|
||||||
img.style.height='16px'
|
|
||||||
img.style.width='16px'
|
|
||||||
img.setAttribute('onclick','OC_FILES.rename(\''+dir+'\',\''+file['name']+'\')')
|
img.setAttribute('onclick','OC_FILES.rename(\''+dir+'\',\''+file['name']+'\')')
|
||||||
td=document.createElement('td');
|
td=document.createElement('td');
|
||||||
tr.appendChild(td);
|
tr.appendChild(td);
|
||||||
|
@ -192,8 +225,6 @@ OC_FILES.showbrowser_callback=function(content){
|
||||||
img.alt='delete'
|
img.alt='delete'
|
||||||
img.title='delete';
|
img.title='delete';
|
||||||
img.src=WEBROOT+'/img/icons/delete.png';
|
img.src=WEBROOT+'/img/icons/delete.png';
|
||||||
img.style.height='16px'
|
|
||||||
img.style.width='16px'
|
|
||||||
img.setAttribute('onclick','OC_FILES.remove(\''+dir+'\',\''+file['name']+'\')')
|
img.setAttribute('onclick','OC_FILES.remove(\''+dir+'\',\''+file['name']+'\')')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,15 +232,39 @@ OC_FILES.showbrowser_callback=function(content){
|
||||||
}
|
}
|
||||||
tr=document.createElement('tr');
|
tr=document.createElement('tr');
|
||||||
tbody.appendChild(tr);
|
tbody.appendChild(tr);
|
||||||
|
tr.className='utilrow';
|
||||||
|
td=document.createElement('td');
|
||||||
|
tr.appendChild(td);
|
||||||
|
td.setAttribute('colspan','6');
|
||||||
|
dropdown=document.createElement('select');
|
||||||
|
td.appendChild(dropdown);
|
||||||
|
dropdown.setAttribute('id','selected_action');
|
||||||
|
for(index in this.actions_selected){
|
||||||
|
if(this.actions_selected[index].call){
|
||||||
|
option=document.createElement('option');
|
||||||
|
dropdown.appendChild(option);
|
||||||
|
option.setAttribute('value',index);
|
||||||
|
option.appendChild(document.createTextNode(index));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
td.appendChild(document.createTextNode(' selected. '));
|
||||||
|
button=document.createElement('input');
|
||||||
|
td.appendChild(button);
|
||||||
|
button.setAttribute('type','button');
|
||||||
|
button.setAttribute('value','Go');
|
||||||
|
button.setAttribute('onclick','OC_FILES.action_selected()');
|
||||||
|
tr=document.createElement('tr');
|
||||||
|
tbody.appendChild(tr);
|
||||||
|
tr.className='utilrow';
|
||||||
td=document.createElement('td');
|
td=document.createElement('td');
|
||||||
tr.appendChild(td);
|
tr.appendChild(td);
|
||||||
td.className='upload';
|
td.className='upload';
|
||||||
td.setAttribute('colspan','5');
|
td.setAttribute('colspan','6');
|
||||||
this.showuploader(dir,td);
|
this.showuploader(dir,td,content['max_upload']);
|
||||||
contentNode.appendChild(files);
|
contentNode.appendChild(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
OC_FILES.showuploader=function(dir,parent){
|
OC_FILES.showuploader=function(dir,parent,max_upload){
|
||||||
this.uploadForm=document.createElement('form');
|
this.uploadForm=document.createElement('form');
|
||||||
this.uploadForm.setAttribute('target','uploadIFrame');
|
this.uploadForm.setAttribute('target','uploadIFrame');
|
||||||
this.uploadForm.setAttribute('action','files/upload.php?dir='+dir);
|
this.uploadForm.setAttribute('action','files/upload.php?dir='+dir);
|
||||||
|
@ -219,8 +274,15 @@ OC_FILES.showuploader=function(dir,parent){
|
||||||
this.uploadIFrame.className='hidden';
|
this.uploadIFrame.className='hidden';
|
||||||
this.uploadIFrame.name='uploadIFrame';
|
this.uploadIFrame.name='uploadIFrame';
|
||||||
parent.appendChild(this.uploadIFrame);
|
parent.appendChild(this.uploadIFrame);
|
||||||
|
var input=document.createElement('input');
|
||||||
|
input.setAttribute('type','hidden');
|
||||||
|
input.setAttribute('name','MAX_FILE_SIZE');
|
||||||
|
input.setAttribute('value',max_upload);
|
||||||
|
input.setAttribute('id','max_upload');
|
||||||
|
this.uploadForm.appendChild(input);
|
||||||
var file=document.createElement('input');
|
var file=document.createElement('input');
|
||||||
file.name='file';
|
file.name='file';
|
||||||
|
file.setAttribute('id','fileSelector');
|
||||||
file.setAttribute('type','file');
|
file.setAttribute('type','file');
|
||||||
file.setAttribute('onchange','OC_FILES.upload("'+dir+'")');
|
file.setAttribute('onchange','OC_FILES.upload("'+dir+'")');
|
||||||
this.uploadForm.appendChild(document.createTextNode('Upload file: '));
|
this.uploadForm.appendChild(document.createTextNode('Upload file: '));
|
||||||
|
@ -230,6 +292,16 @@ OC_FILES.showuploader=function(dir,parent){
|
||||||
|
|
||||||
OC_FILES.upload=function(dir){
|
OC_FILES.upload=function(dir){
|
||||||
OC_FILES.uploadIFrame.setAttribute('onload',"OC_FILES.upload_callback.call(OC_FILES,'"+dir+"')");
|
OC_FILES.uploadIFrame.setAttribute('onload',"OC_FILES.upload_callback.call(OC_FILES,'"+dir+"')");
|
||||||
|
var fileSelector=document.getElementById('fileSelector');
|
||||||
|
var max_upload=document.getElementById('max_upload').value;
|
||||||
|
if(fileSelector.files && fileSelector.files[0].fileSize){
|
||||||
|
var size=fileSelector.files[0].fileSize
|
||||||
|
// new OCNotification('size: '+size,1000);
|
||||||
|
if(size>max_upload){
|
||||||
|
// new OCNotification('Chosen file is to large',20000);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
OC_FILES.uploadForm.submit();
|
OC_FILES.uploadForm.submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,4 +375,69 @@ OC_FILES.remove=function(dir,file){
|
||||||
|
|
||||||
OC_FILES.remove_callback=function(req){
|
OC_FILES.remove_callback=function(req){
|
||||||
OC_FILES.showbrowser(OC_FILES.dir);
|
OC_FILES.showbrowser(OC_FILES.dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
OC_FILES.getSelected=function(){
|
||||||
|
var nodes=document.getElementsByName('fileSelector');
|
||||||
|
var files=Array();
|
||||||
|
for(index in nodes){
|
||||||
|
if(nodes[index].checked){
|
||||||
|
files[files.length]=nodes[index].value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
OC_FILES.selectAll=function(){
|
||||||
|
var value=document.getElementById('select_all').checked;
|
||||||
|
var nodes=document.getElementsByName('fileSelector');
|
||||||
|
for(index in nodes){
|
||||||
|
if(nodes[index].value){
|
||||||
|
nodes[index].checked=value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OC_FILES.action_selected=function(){
|
||||||
|
var dropdown=action=document.getElementById('selected_action');
|
||||||
|
var action=dropdown.options[dropdown.selectedIndex].value;
|
||||||
|
if(OC_FILES.actions_selected[action] && OC_FILES.actions_selected[action].call){
|
||||||
|
OC_FILES.actions_selected[action].call(OC_FILES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OC_FILES.actions_selected=new Object();
|
||||||
|
|
||||||
|
OC_FILES.actions_selected.download=function(){
|
||||||
|
files=OC_FILES.getSelected();
|
||||||
|
if(files.length==0){
|
||||||
|
return false;
|
||||||
|
}else if(files.length>1){
|
||||||
|
files.join(';');
|
||||||
|
}else{
|
||||||
|
files=files[0];
|
||||||
|
}
|
||||||
|
window.location=WEBROOT+'/files/get_file.php?dir='+OC_FILES.dir+'&files='+files;
|
||||||
|
}
|
||||||
|
|
||||||
|
OC_FILES.actions_selected['delete']=function(){
|
||||||
|
files=OC_FILES.getSelected();
|
||||||
|
for(index in files){
|
||||||
|
OC_FILES.remove(OC_FILES.dir,files[index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sizeFormat=function(size){
|
||||||
|
var orig=size;
|
||||||
|
var steps=Array('B','KiB','MiB','GiB','TiB');
|
||||||
|
var step=0;
|
||||||
|
while(size>(1024*2)){
|
||||||
|
step++;
|
||||||
|
size=size/1024;
|
||||||
|
}
|
||||||
|
// size=orig/(1024^(step+1));//recalculate the size in one time to minimalize rounding errors;
|
||||||
|
if(size.toFixed){
|
||||||
|
size=size.toFixed(2);
|
||||||
|
}
|
||||||
|
return ''+size+' '+steps[step];
|
||||||
}
|
}
|
Loading…
Reference in a new issue