summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin <robin@Amaya.(none)>2010-04-19 19:46:42 +0200
committerRobin <robin@Amaya.(none)>2010-04-19 19:46:42 +0200
commit38bdf4083a6e0d90afb35ded0d67cab8a518b2ea (patch)
tree10a29805a025802c6dc12c2c65c18a48cb2742f7
parent6591740f5dd73969458de9a586790922fe6c27ea (diff)
downloadnextcloud-server-38bdf4083a6e0d90afb35ded0d67cab8a518b2ea.tar.gz
nextcloud-server-38bdf4083a6e0d90afb35ded0d67cab8a518b2ea.zip
same fixes, this time hopefully without merge conflict
-rw-r--r--files/delete.php10
-rw-r--r--files/get_files.php24
-rw-r--r--files/move.php35
-rw-r--r--files/new.php38
-rwxr-xr-ximg/arrow_down.pngbin134 -> 116 bytes
-rw-r--r--img/arrow_up.pngbin0 -> 112 bytes
-rw-r--r--img/icons/loading.gifbin0 -> 1844 bytes
-rwxr-xr-xinc/lib_base.php15
-rwxr-xr-xinc/lib_config.php157
-rwxr-xr-xinc/lib_files.php1
-rwxr-xr-xinc/templates/configform.php34
-rwxr-xr-xinc/templates/footer.php3
-rwxr-xr-xinc/templates/header.php6
-rwxr-xr-xindex.php4
-rw-r--r--js/filebrowser.js586
-rw-r--r--js/lib_ajax.js91
-rw-r--r--js/lib_drag.js350
-rwxr-xr-xjs/lib_event.js55
-rw-r--r--js/lib_files.js354
-rw-r--r--js/lib_xmlloader.js5
-rwxr-xr-xsettings/index.php1
21 files changed, 1349 insertions, 420 deletions
diff --git a/files/delete.php b/files/delete.php
index 1c660d97807..7d19a45a73a 100644
--- a/files/delete.php
+++ b/files/delete.php
@@ -25,10 +25,12 @@ require_once('../inc/lib_base.php');
$dir=$_GET['dir'];
$file=$_GET['file'];
if(isset($_SESSION['username']) and $_SESSION['username'] and strpos($dir,'..')===false){
- $file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file;
- if(is_file($file)){
- unlink($file);
- }
+ $file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file;
+ if(is_file($file)){
+ unlink($file);
+ }elseif(is_dir($file)){
+ rmdir($file);
+ }
}
?> \ No newline at end of file
diff --git a/files/get_files.php b/files/get_files.php
index 29f06d289d5..287b8cd453e 100644
--- a/files/get_files.php
+++ b/files/get_files.php
@@ -42,21 +42,23 @@ function return_bytes($val) {
header('Content-type: application/xml');
$dir=isset($_GET['dir'])?$_GET['dir']:'';
-$files=OC_FILES::getdirectorycontent($CONFIG_DATADIRECTORY.'/'.$dir);
-$dirname=$files[0]['directory'];
+$files=OC_FILES::getdirectorycontent(realpath($CONFIG_DATADIRECTORY.'/'.$dir));
+$dirname=(isset($files[0]))?$files[0]['directory']:'';
$dirname=substr($dirname,strrpos($dirname,'/'));
$max_upload=min(return_bytes(ini_get('post_max_size')),return_bytes(ini_get('upload_max_filesize')));
ob_clean();
echo "<?xml version='1.0' standalone='yes'?>\n";
echo "<dir name='$dirname' max_upload='$max_upload'>\n";
-foreach($files as $file){
- $attributes='';
- foreach($file as $name=>$data){
- $data=str_replace("'",'&#39;',$data);
- if (is_string($name)) $attributes.=" $name='$data'";
- }
- $attributes.=' date=\''.date($CONFIG_DATEFORMAT,$file['mtime']).'\'';
- echo "<file$attributes/>\n";
+if(is_array($files)){
+ foreach($files as $file){
+ $attributes='';
+ foreach($file as $name=>$data){
+ $data=str_replace("'",'&#39;',$data);
+ if (is_string($name)) $attributes.=" $name='$data'";
+ }
+ $attributes.=' date=\''.date($CONFIG_DATEFORMAT,$file['mtime']).'\'';
+ echo "<file$attributes/>\n";
+ }
}
-echo "</dir>";
+echo "\n</dir>";
?> \ No newline at end of file
diff --git a/files/move.php b/files/move.php
new file mode 100644
index 00000000000..7103662c4a2
--- /dev/null
+++ b/files/move.php
@@ -0,0 +1,35 @@
+<?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/>.
+*
+*/
+require_once('../inc/lib_base.php');
+
+$sourceDir=$_GET['sourcedir'];
+$targetDir=$_GET['targetdir'];
+$source=$_GET['source'];
+$target=$_GET['target'];
+if(isset($_SESSION['username']) and $_SESSION['username'] and strpos($sourceDir,'..')===false and strpos($source,'..')===false and strpos($targetDir,'..')===false and strpos($target,'..')===false){
+ $target=$CONFIG_DATADIRECTORY.'/'.$targetDir.'/'.$target.'/'.$source;
+ $source=$CONFIG_DATADIRECTORY.'/'.$sourceDir.'/'.$source;
+ rename($source,$target);
+}
+
+?> \ No newline at end of file
diff --git a/files/new.php b/files/new.php
new file mode 100644
index 00000000000..c5d5608a567
--- /dev/null
+++ b/files/new.php
@@ -0,0 +1,38 @@
+<?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/>.
+*
+*/
+require_once('../inc/lib_base.php');
+
+$dir=$_GET['dir'];
+$name=$_GET['name'];
+$type=$_GET['type'];
+if(isset($_SESSION['username']) and $_SESSION['username'] and strpos($dir,'..')===false and strpos($name,'..')===false){
+ $file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$name;
+ if($type=='dir'){
+ mkdir($file);
+ }elseif($type=='file'){
+ $fileHandle=fopen($file, 'w') or die("can't open file");
+ fclose($fileHandle);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/img/arrow_down.png b/img/arrow_down.png
index 0e0ab3c4c08..ecbca6ef606 100755
--- a/img/arrow_down.png
+++ b/img/arrow_down.png
Binary files differ
diff --git a/img/arrow_up.png b/img/arrow_up.png
new file mode 100644
index 00000000000..e2457c88838
--- /dev/null
+++ b/img/arrow_up.png
Binary files differ
diff --git a/img/icons/loading.gif b/img/icons/loading.gif
new file mode 100644
index 00000000000..40efb9be594
--- /dev/null
+++ b/img/icons/loading.gif
Binary files differ
diff --git a/inc/lib_base.php b/inc/lib_base.php
index 8c0c1ca606e..e4309261709 100755
--- a/inc/lib_base.php
+++ b/inc/lib_base.php
@@ -35,6 +35,9 @@ $SERVERROOT=substr(__FILE__,0,-17);
$DOCUMENTROOT=$_SERVER['DOCUMENT_ROOT'];
$count=strlen($DOCUMENTROOT);
$WEBROOT=substr($SERVERROOT,$count);
+if($WEBROOT{0}!=='/'){
+ $WEBROOT='/'.$WEBROOT;
+}
// set the right include path
set_include_path(get_include_path().PATH_SEPARATOR.$SERVERROOT.PATH_SEPARATOR.$SERVERROOT.'/inc'.PATH_SEPARATOR.$SERVERROOT.'/config');
@@ -42,11 +45,12 @@ set_include_path(get_include_path().PATH_SEPARATOR.$SERVERROOT.PATH_SEPARATOR.$S
// define default config values
$CONFIG_ADMINLOGIN='';
$CONFIG_ADMINPASSWORD='';
-$CONFIG_DATADIRECTORY=$SERVERROOT.$WEBROOT.'/data';
+$CONFIG_DATADIRECTORY=$SERVERROOT.'/data';
$CONFIG_HTTPFORCESSL=false;
$CONFIG_DATEFORMAT='j M Y G:i';
$CONFIG_DBNAME='owncloud';
$CONFIG_DBTYPE='sqlite';
+
// include the generated configfile
@include_once('config.php');
@@ -63,7 +67,6 @@ if(isset($CONFIG_HTTPFORCESSL) and $CONFIG_HTTPFORCESSL){
require_once('lib_files.php');
require_once('lib_log.php');
require_once('lib_config.php');
-require_once('lib_ocs.php');
// load plugins
$CONFIG_LOADPLUGINS='music';
@@ -247,6 +250,7 @@ class OC_DB {
*/
static function query($cmd) {
global $DOCUMENTROOT;
+ global $SERVERROOT;
global $DBConnection;
global $CONFIG_DBNAME;
global $CONFIG_DBHOST;
@@ -255,9 +259,9 @@ class OC_DB {
global $CONFIG_DBTYPE;
if(!isset($DBConnection)) {
if($CONFIG_DBTYPE=='sqlite'){
- $DBConnection = @new SQLiteDatabase($DOCUMENTROOT.'/'.$CONFIG_DBNAME);
+ $DBConnection = @new SQLiteDatabase($SERVERROOT.'/'.$CONFIG_DBNAME);
}elseif($CONFIG_DBTYPE=='mysql'){
- $DBConnection =@new mysqli($CONFIG_DBHOST, $CONFIG_DBUSER, $CONFIG_DBPASSWORD,$CONFIG_DBNAME);
+ $DBConnection = @new mysqli($CONFIG_DBHOST, $CONFIG_DBUSER, $CONFIG_DBPASSWORD,$CONFIG_DBNAME);
}
if (!$DBConnection) {
@ob_end_clean();
@@ -288,6 +292,7 @@ class OC_DB {
*/
static function multiquery($cmd) {
global $DOCUMENTROOT;
+ global $SERVERROOT;
global $DBConnection;
global $CONFIG_DBNAME;
global $CONFIG_DBTYPE;
@@ -296,7 +301,7 @@ class OC_DB {
global $CONFIG_DBPASSWORD;
if(!isset($DBConnection)) {
if($CONFIG_DBTYPE=='sqlite'){
- $DBConnection = @new SQLiteDatabase($DOCUMENTROOT.'/'.$CONFIG_DBNAME);
+ $DBConnection = new SQLiteDatabase($SERVERROOT.'/'.$CONFIG_DBNAME);
}elseif($CONFIG_DBTYPE=='mysql'){
$DBConnection = @new mysqli($CONFIG_DBHOST, $CONFIG_DBUSER, $CONFIG_DBPASSWORD,$CONFIG_DBNAME);
}
diff --git a/inc/lib_config.php b/inc/lib_config.php
index e3bce232f5e..a3270ab41b3 100755
--- a/inc/lib_config.php
+++ b/inc/lib_config.php
@@ -27,73 +27,102 @@ class OC_CONFIG{
global $CONFIG_DBUSER;
global $CONFIG_DBPASSWORD;
global $CONFIG_DBTYPE;
+ global $CONFIG_ADMINLOGIN;
+ global $CONFIG_ADMINPASSWORD;
if(isset($_POST['set_config'])){
//checkdata
- $error='';
- $FIRSTRUN=!isset($CONFIG_ADMINLOGIN);
- if(!$FIRSTRUN){
- if($_POST['currentpassword']!=$CONFIG_ADMINPASSWORD){
- $error.='wrong password';
- }
- }
-
- if(!isset($_POST['adminlogin']) or empty($_POST['adminlogin'])) $error.='admin login not set<br />';
- if(!isset($_POST['adminpassword']) or empty($_POST['adminpassword']) and $FIRSTRUN) $error.='admin password not set<br />';
- if(!isset($_POST['adminpassword2']) or empty($_POST['adminpassword2']) and $FIRSTRUN) $error.='retype admin password not set<br />';
- if(!isset($_POST['datadirectory']) or empty($_POST['datadirectory'])) $error.='data directory not set<br />';
- if(!isset($_POST['dateformat']) or empty($_POST['dateformat'])) $error.='dateformat not set<br />';
- if(!isset($_POST['dbname']) or empty($_POST['dbname'])) $error.='databasename not set<br />';
- if($_POST['adminpassword']<>$_POST['adminpassword2'] ) $error.='admin passwords are not the same<br />';
-
- if(!isset($_POST['adminpassword']) or empty($_POST['adminpassword']) and !$FIRSTRUN){
- $_POST['adminpassword']=$CONFIG_ADMINPASSWORD;
- }
- $dbtype=$_POST['dbtype'];
- if($dbtype=='mysql'){
- if(!isset($_POST['dbhost']) or empty($_POST['dbhost'])) $error.='database host not set<br />';
- if(!isset($_POST['dbuser']) or empty($_POST['dbuser'])) $error.='database user not set<br />';
- if($_POST['dbpassword']<>$_POST['dbpassword2'] ) $error.='database passwords are not the same<br />';
-
- }
- if(empty($error)) {
- //create/fill database
- $CONFIG_DBTYPE=$dbtype;
- $CONFIG_DBNAME=$_POST['dbname'];
- if($dbtype=='mysql'){
- $CONFIG_DBHOST=$_POST['dbhost'];
- $CONFIG_DBUSER=$_POST['dbuser'];
- $CONFIG_DBPASSWORD=$_POST['dbpassword'];
- }
- if(isset($_POST['createdatabase']) and $CONFIG_DBTYPE=='mysql'){
- self::createdatabase($_POST['dbadminuser'],$_POST['dbadminpwd']);
- }
- if(isset($_POST['filldb'])){
- self::filldatabase();
- }
-
- //storedata
- $config='<?php '."\n";
- $config.='$CONFIG_ADMINLOGIN=\''.$_POST['adminlogin']."';\n";
- $config.='$CONFIG_ADMINPASSWORD=\''.$_POST['adminpassword']."';\n";
- $config.='$CONFIG_DATADIRECTORY=\''.$_POST['datadirectory']."';\n";
- if(isset($_POST['forcessl'])) $config.='$CONFIG_HTTPFORCESSL=true'.";\n"; else $config.='$CONFIG_HTTPFORCESSL=false'.";\n";
- $config.='$CONFIG_DATEFORMAT=\''.$_POST['dateformat']."';\n";
- $config.='$CONFIG_DBTYPE=\''.$dbtype."';\n";
- $config.='$CONFIG_DBNAME=\''.$_POST['dbname']."';\n";
- if($dbtype=='mysql'){
- $config.='$CONFIG_DBHOST=\''.$_POST['dbhost']."';\n";
- $config.='$CONFIG_DBUSER=\''.$_POST['dbuser']."';\n";
- $config.='$CONFIG_DBPASSWORD=\''.$_POST['dbpassword']."';\n";
- }
- $config.='?> ';
-
- $filename=$SERVERROOT.'/config/config.php';
- file_put_contents($filename,$config);
- header("Location: ".$WEBROOT."/");
+ $error='';
+ $FIRSTRUN=empty($CONFIG_ADMINLOGIN);
+ if(!$FIRSTRUN){
+ if($_POST['currentpassword']!=$CONFIG_ADMINPASSWORD){
+ $error.='wrong password<br />';
+ }
+ }
+
+ if(!isset($_POST['adminlogin']) or empty($_POST['adminlogin'])) $error.='admin login not set<br />';
+ if((!isset($_POST['adminpassword']) or empty($_POST['adminpassword'])) and $FIRSTRUN) $error.='admin password not set<br />';
+ if((!isset($_POST['adminpassword2']) or empty($_POST['adminpassword2'])) and $FIRSTRUN) $error.='retype admin password not set<br />';
+ if(!isset($_POST['datadirectory']) or empty($_POST['datadirectory'])) $error.='data directory not set<br />';
+ if(!isset($_POST['dateformat']) or empty($_POST['dateformat'])) $error.='dateformat not set<br />';
+ if(!isset($_POST['dbname']) or empty($_POST['dbname'])) $error.='databasename not set<br />';
+ if($_POST['adminpassword']<>$_POST['adminpassword2'] ) $error.='admin passwords are not the same<br />';
+ $dbtype=$_POST['dbtype'];
+ if($dbtype=='mysql'){
+ if(!isset($_POST['dbhost']) or empty($_POST['dbhost'])) $error.='database host not set<br />';
+ if(!isset($_POST['dbuser']) or empty($_POST['dbuser'])) $error.='database user not set<br />';
+ if($_POST['dbpassword']<>$_POST['dbpassword2'] ) $error.='database passwords are not the same<br />';
+
+ }
+ if(!$FIRSTRUN){
+ if(!isset($_POST['adminpassword']) or empty($_POST['adminpassword'])){
+ $_POST['adminpassword']=$CONFIG_ADMINPASSWORD;
+ }
+ if(!isset($_POST['dbpassword']) or empty($_POST['dbpassword'])){
+ $_POST['dbpassword']=$CONFIG_DBPASSWORD;
+ }
+ }
+ if(empty($error)) {
+ //create/fill database
+ $CONFIG_DBTYPE=$dbtype;
+ $CONFIG_DBNAME=$_POST['dbname'];
+ if($dbtype=='mysql'){
+ $CONFIG_DBHOST=$_POST['dbhost'];
+ $CONFIG_DBUSER=$_POST['dbuser'];
+ $CONFIG_DBPASSWORD=$_POST['dbpassword'];
+ }
+ try{
+ if(isset($_POST['createdatabase']) and $CONFIG_DBTYPE=='mysql'){
+ self::createdatabase($_POST['dbadminuser'],$_POST['dbadminpwd']);
+ }
+ }catch(Exception $e){
+ $error.='error while trying to create the database<br/>';
+ }
+ if($CONFIG_DBTYPE=='sqlite'){
+ $f=@fopen($SERVERROOT.'/'.$CONFIG_DBNAME,'a+');
+ if(!$f){
+ $error.='path of sqlite database not writable by server<br/>';
+ }
+ }
+ try{
+ if(isset($_POST['filldb'])){
+ self::filldatabase();
+ }
+ }catch(Exception $e){
+ $error.='error while trying to fill the database<br/>';
+ }
+
+ //storedata
+ $config='<?php '."\n";
+ $config.='$CONFIG_ADMINLOGIN=\''.$_POST['adminlogin']."';\n";
+ $config.='$CONFIG_ADMINPASSWORD=\''.$_POST['adminpassword']."';\n";
+ $config.='$CONFIG_DATADIRECTORY=\''.$_POST['datadirectory']."';\n";
+ if(isset($_POST['forcessl'])) $config.='$CONFIG_HTTPFORCESSL=true'.";\n"; else $config.='$CONFIG_HTTPFORCESSL=false'.";\n";
+ $config.='$CONFIG_DATEFORMAT=\''.$_POST['dateformat']."';\n";
+ $config.='$CONFIG_DBTYPE=\''.$dbtype."';\n";
+ $config.='$CONFIG_DBNAME=\''.$_POST['dbname']."';\n";
+ if($dbtype=='mysql'){
+ $config.='$CONFIG_DBHOST=\''.$_POST['dbhost']."';\n";
+ $config.='$CONFIG_DBUSER=\''.$_POST['dbuser']."';\n";
+ $config.='$CONFIG_DBPASSWORD=\''.$_POST['dbpassword']."';\n";
+ }
+ $config.='?> ';
- }
- return($error);
+ $filename=$SERVERROOT.'/config/config.php';
+ if(empty($error)){
+ header("Location: ".$WEBROOT."/");
+ try{
+ file_put_contents($filename,$config);
+ }catch(Exception $e){
+ $error.='error while trying to save the configuration file<br/>';
+ return $error;
+ }
+ }else{
+ return $error;
+ }
+
+ }
+ return($error);
}
@@ -210,3 +239,5 @@ GRANT ALL PRIVILEGES ON `{$_POST['dbname']}` . * TO '{$_POST['dbuser']}';";
}
}
?>
+
+
diff --git a/inc/lib_files.php b/inc/lib_files.php
index 5ddf5a4e1f3..9c6cb25346a 100755
--- a/inc/lib_files.php
+++ b/inc/lib_files.php
@@ -89,6 +89,7 @@ class OC_FILES {
$content=array();
$dirs=array();
$file=array();
+ $files=array();
if (is_dir($directory)) {
if ($dh = opendir($directory)) {
while (($filename = readdir($dh)) !== false) {
diff --git a/inc/templates/configform.php b/inc/templates/configform.php
index 82a1efeee19..61217df2acf 100755
--- a/inc/templates/configform.php
+++ b/inc/templates/configform.php
@@ -1,5 +1,6 @@
<?php
global $FIRSTRUN;
+global $CONFIG_ERROR;
if(!isset($fillDB)) $fillDB=true;
if(!isset($CONFIG_DBHOST)) $CONFIG_DBHOST='localhost';
if(!isset($CONFIG_DBUSER)) $CONFIG_DBUSER='owncloud';
@@ -36,21 +37,16 @@ function dbtypechange(){
}
}
</script>
-<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
-<table cellpadding="5" cellspacing="5" border="0" class="loginform">
-<?php
- if(!$FIRSTRUN){?>
- <tr><td>current password</td><td><input type="password" name="currentpassword" size="30" class="formstyle"></input></td></tr>
- <?php
- }
-?>
<form method="post" enctype="multipart/form-data">
<table cellpadding="5" cellspacing="5" border="0" class="loginform">
<?php
- if(!$FIRSTRUN){?>
- <tr><td>current password</td><td><input type="password" name="currentpassword" size="30" class="formstyle"></input></td></tr>
- <?php
- }
+ if(!empty($CONFIG_ERROR) and !$FIRSTRUN){
+ echo "<tr><td colspan='3' class='error'>$CONFIG_ERROR</td></tr>";
+ }
+ if(!$FIRSTRUN){?>
+ <tr><td>current password</td><td><input type="password" name="currentpassword" size="30" class="formstyle"></input></td></tr>
+ <?php
+ }
?>
<tr><td>admin login:</td><td><input type="text" name="adminlogin" size="30" class="formstyle" value="<?php echo($CONFIG_ADMINLOGIN);?>"></input></td></tr>
<tr><td>admin password:</td><td><input type="password" name="adminpassword" size="30" class="formstyle"></input></td><td>(leave empty to keep current password)</td></tr>
@@ -60,14 +56,26 @@ function dbtypechange(){
<tr><td>date format:</td><td><input type="text" name="dateformat" size="30" class="formstyle" value='<?php echo($CONFIG_DATEFORMAT);?>'></input></td></tr>
<tr><td>database type:</td><td>
<select id='dbtype' name="dbtype" onchange='dbtypechange()'>
+<?php
+global $CONFIG_DBTYPE;
+if($CONFIG_DBTYPE=='sqlite'){
+?>
<option value="sqlite">SQLite</option>
<option value="mysql">MySQL</option>
+<?php
+}else{
+?>
+<option value="mysql">MySQL</option>
+<option value="sqlite">SQLite</option>
+<?php
+}
+?>
</select>
</td></tr>
<tr id='dbhost'><td>database host:</td><td><input type="text" name="dbhost" size="30" class="formstyle" value='<?php echo($CONFIG_DBHOST);?>'></input></td></tr>
<tr><td>database name:</td><td><input type="text" name="dbname" size="30" class="formstyle" value='<?php echo($CONFIG_DBNAME);?>'></input></td></tr>
<tr id='dbuser'><td>database user:</td><td><input type="text" name="dbuser" size="30" class="formstyle" value='<?php echo($CONFIG_DBUSER);?>'></input></td></tr>
-<tr id='dbpass'><td>database password:</td><td><input type="password" name="dbpassword" size="30" class="formstyle" value=''></input></td></tr>
+<tr id='dbpass'><td>database password:</td><td><input type="password" name="dbpassword" size="30" class="formstyle" value=''></input></td><td>(leave empty to keep current password)</td></tr>
<tr id='dbpass_retype'><td>retype database password:</td><td><input type="password" name="dbpassword2" size="30" class="formstyle" value=''></input></td></tr>
<tr id='dbcreaterow'><td>create database and user:</td><td><input id='dbcreate' type="checkbox" name="createdatabase" size="30" class="formstyle" value='1' <?php if($FIRSTRUN) echo 'checked'; ?> onchange='showDBAdmin()'></input></td></tr>
<tr id='dbAdminUser'><td>database administrative user:</td><td><input type="text" name="dbadminuser" size="30" class="formstyle" value='root'></input></td></tr>
diff --git a/inc/templates/footer.php b/inc/templates/footer.php
index 16b41d3e2e3..a7e2aa62052 100755
--- a/inc/templates/footer.php
+++ b/inc/templates/footer.php
@@ -4,7 +4,7 @@ global $WEBROOT;
</div>
<div class='foot'>
<div class='bar'><p class="hint">
-Hint: Mount it via webdav like this: <a href="webdav://'.<?php echo($_SERVER["HTTP_HOST"].$WEBROOT.'/webdav/owncloud.php');?>">webdav://<?php echo($_SERVER["HTTP_HOST"].$WEBROOT);?>/webdav/owncloud.php</a>
+Hint: Mount it via webdav like this: <a href="webdav://<?php echo($_SERVER["HTTP_HOST"].$WEBROOT.'/webdav/owncloud.php');?>">webdav://<?php echo($_SERVER["HTTP_HOST"].$WEBROOT);?>/webdav/owncloud.php</a>
</p></div>
<p class="footer">
<?php
@@ -13,4 +13,5 @@ Hint: Mount it via webdav like this: <a href="webdav://'.<?php echo($_SERVER["HT
</p>
</div>
</div>
+<!--<p id="debug">debug</p>-->
</body></html>
diff --git a/inc/templates/header.php b/inc/templates/header.php
index 1b318575b7e..c082ea8b3da 100755
--- a/inc/templates/header.php
+++ b/inc/templates/header.php
@@ -4,13 +4,14 @@
<head>
<title>ownCloud</title>
<base href="<?php echo($WEBROOT); ?>/"/>
- <link rel="stylesheet" type="text/css" href="<?php echo($WEBROOT)?>/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_timer.js'></script>
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/lib_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_files.js'></script>
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/lib_event.js'></script>
+ <script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/lib_drag.js'></script>
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/filebrowser.js'></script>
<?php
foreach(OC_UTIL::$scripts as $script){
@@ -25,12 +26,13 @@ foreach(OC_UTIL::$scripts as $script){
<div id='mainlayout'>
<div class='head'>
<?php
+global $CONFIG_ERROR;
echo('<h1><a id="owncloud-logo" href="'.$WEBROOT.'"><span>ownCloud</span></a></h1>');
// check if already configured. otherwise start configuration wizard
$error=OC_CONFIG::writeconfiglisener();
- echo $error;
+ $CONFIG_ERROR=$error;
if(empty($CONFIG_ADMINLOGIN)) {
global $FIRSTRUN;
$FIRSTRUN=true;
diff --git a/index.php b/index.php
index 6b0bcf63a4d..e755ab86237 100755
--- a/index.php
+++ b/index.php
@@ -28,7 +28,9 @@ if(isset($_GET['dir'])) $dir=$_GET['dir']; else $dir='';
if(isset($_GET['file'])) {
OC_FILES::get($dir,$_GET['file']);
-
+OC_FILES::get($dir,$_GET['file']);
+OC_FILES::get($dir,$_GET['file']);
+echo('heya');
}else{
OC_UTIL::addscript('js/ajax.js');
diff --git a/js/filebrowser.js b/js/filebrowser.js
index dac81327b69..f12cec44143 100644
--- a/js/filebrowser.js
+++ b/js/filebrowser.js
@@ -27,188 +27,367 @@ OC_FILES.browser.showInitial=function(){
if(loc.indexOf('#')!=-1){
dir=loc.substring(loc.indexOf('#')+1);
}
- OC_FILES.dir=dir;
- OC_FILES.getdirectorycontent(dir,OC_FILES.browser.show_callback);
+ OC_FILES.getdirectorycontent(dir,OC_FILES.browser.show_callback,true);
}
OC_FILES.browser.show=function(dir){
- if(!dir){
+ if(!dir || !dir.split){
dir='';
}
- OC_FILES.dir=dir;
OC_FILES.getdirectorycontent(dir,OC_FILES.browser.show_callback);
}
-OC_FILES.browser.show_callback=function(content){
- var dir=OC_FILES.dir
- var dirs=dir.split('/');
- var tr=null;
- var td=null;
- var img=null;
-
- body=document.getElementsByTagName('body').item(0);
- body.addEvent('onclick',OC_FILES.browser.hideallactions);
-
- //remove current content;
- var contentNode=document.getElementById('content');
- contentNode.className='center';
- if(contentNode.hasChildNodes()){
- while(contentNode.childNodes.length >=1){
- contentNode.removeChild(contentNode.firstChild);
- }
- }
- var table=document.createElement('table');
- table.className='browser';
- var tbody=document.createElement('tbody');
- var thead=document.createElement('thead');
- var tfoot=document.createElement('tfoot');
- table.appendChild(thead);
- table.appendChild(tbody);
- table.appendChild(tfoot);
-// table.setAttribute('cellpadding',6);
-
- // breadcrumb
- if(dirs.length>0) {
- tr=document.createElement('tr');
- thead.appendChild(tr);
- tr.className='breadcrumb';
- td=document.createElement('td');
- tr.appendChild(td);
- td.className='fileSelector'
- input=document.createElement('input');
- input.setAttribute('type','checkbox');
- input.setAttribute('name','fileSelector');
- input.setAttribute('value','select_all');
- input.setAttribute('id','select_all');
- input.addEvent('onclick',OC_FILES.selectAll);
- td.appendChild(input);
- td=document.createElement('td');
- tr.appendChild(td);
- td.className='breadcrumb';
- var a=document.createElement('a');
- td.appendChild(a);
- a.setAttribute('href','#');
- a.addEvent('onclick',OC_FILES.browser.show);
- a.appendChild(document.createTextNode('Home'));
- var currentdir='';
- for(var index=0;index<dirs.length;index++){
- d=dirs[index];
- currentdir=currentdir+'/'+d;
- if(d!=''){
- a=document.createElement('a');
- td.appendChild(a);
- a.setAttribute('href','#'+currentdir);
- a.addEvent('onclick',OC_FILES.browser.show,currentdir);
- img=document.createElement('img');
- a.appendChild(img);
- img.src=WEBROOT+'/img/arrow.png';
- a.appendChild(document.createTextNode(' ' +d));
- }
- }
- }
+OC_FILES.browser.breadcrumb=new Object();
+OC_FILES.browser.breadcrumb.node=null;
+OC_FILES.browser.breadcrumb.crumbs=Array();
+OC_FILES.browser.breadcrumb.show=function(parent,path){
+ if((!OC_FILES.browser.breadcrumb.node==parent && parent) || OC_FILES.browser.breadcrumb.node==null){
+ OC_FILES.browser.breadcrumb.clear();
+ OC_FILES.browser.breadcrumb.node=parent;
+ OC_FILES.browser.breadcrumb.add('Home','/');
+ }
+ var dirs=path.split('/');
+ var currentPath='/';
+ var paths=Array();
+ var currentPath;
+ if(dirs.length>0){
+ for(var i=0;i<dirs.length;i++){
+ dir=dirs[i];
+ if(dir){
+ currentPath+=dir+'/';
+ paths[currentPath]=true;
+ if(!OC_FILES.browser.breadcrumb.crumbs[currentPath]){
+ OC_FILES.browser.breadcrumb.add(dir,currentPath);
+ }
+ }
+ }
+ }
+ //remove all crumbs that are not part of our current path
+ for(currentPath in OC_FILES.browser.breadcrumb.crumbs){
+ if(!paths[currentPath] && currentPath!='/'){
+ OC_FILES.browser.breadcrumb.remove(currentPath);
+ }
+ }
+
+}
+OC_FILES.browser.breadcrumb.add=function(name,path){
+ var a=document.createElement('a');
+ var div=document.createElement('div');
+ OC_FILES.browser.breadcrumb.crumbs[path]=div;
+ div.className='breadcrumb';
+ a.setAttribute('href','#'+path);
+ a.addEvent('onclick',OC_FILES.browser.show,path);
+ img=document.createElement('img');
+ img.src=WEBROOT+'/img/arrow.png';
+ a.appendChild(document.createTextNode(' ' +name));
+ a.appendChild(img);
+ OC_FILES.files[path]=new OC_FILES.file('',path,'dir');
+ div.makeDropTarget();
+ div.file=OC_FILES.files[path];
+ div.addEvent('ondropon',OC_FILES.browser.handleDropOn);
+ div.appendChild(a);
+
+ OC_FILES.browser.breadcrumb.node.appendChild(div);
+}
+OC_FILES.browser.breadcrumb.remove=function(path){
+ if(OC_FILES.browser.breadcrumb.crumbs[path]){
+ var div=OC_FILES.browser.breadcrumb.crumbs[path];
+ div.parentNode.removeChild(div);
+ delete OC_FILES.browser.breadcrumb.crumbs[path];
+ }
+}
+OC_FILES.browser.breadcrumb.clear=function(){
+ for(path in OC_FILES.browser.breadcrumb.crumbs){
+ OC_FILES.browser.breadcrumb.remove(path);
+ }
+}
+
+OC_FILES.browser.files=new Object();
+OC_FILES.browser.files.fileNodes=Array();
+OC_FILES.browser.files.node=null;
+OC_FILES.browser.files.tbody=null;
+OC_FILES.browser.files.show=function(parent,fileList){
+ if(parent){
+ OC_FILES.browser.files.node=parent;
+ }
+ var table=document.createElement('table');
+ OC_FILES.browser.files.node.appendChild(table);
+ var tbody=document.createElement('tbody');
+ OC_FILES.browser.files.tbody=tbody;
+ table.appendChild(tbody);
+ table.setAttribute('cellpadding',6);
+ table.setAttribute('cellspacing',0);
+ if(fileList){
+ var name;
+ //remove files that no longer are in the folder
+ for(name in OC_FILES.browser.files.fileNodes){
+ if(!fileList[name]){
+ OC_FILES.browser.files.remove(name);
+ }
+ }
+ //add the files that arent in the list yet
+ for(name in fileList){
+ file=fileList[name];
+ if(!OC_FILES.browser.files.fileNodes[file.name]){
+ OC_FILES.browser.files.add(file.name,file.type,file.size,file.date);
+ }
+ }
+ }
+}
+OC_FILES.browser.files.add=function(name,type,size,date){
+ if(name){
+ if(!size) size=0;
+ if(!date) date=getTimeString();
+ OC_FILES.files[name]=new OC_FILES.file(OC_FILES.dir,name,type);
+ tr=document.createElement('tr');
+ OC_FILES.browser.files.fileNodes[name]=tr;
+ OC_FILES.browser.files.tbody.appendChild(tr);
+ tr.className='browserline';
+ td=document.createElement('td');
+ tr.appendChild(td);
+ td.className='fileSelector';
+ input=document.createElement('input');
+ input.setAttribute('type','checkbox');
+ input.setAttribute('name','fileSelector');
+ input.setAttribute('value',name);
+ td.appendChild(input);
+ tr.appendChild(OC_FILES.browser.showicon(type));
+ td=document.createElement('td');
+ tr.appendChild(td);
+ td.makeDropTarget();
+ td.addEvent('ondropon',OC_FILES.browser.handleDropOn);
+ td.className='nametext';
+ td.setAttribute('name',name);
+ td.setAttribute('id',name);
+ var fileObject=OC_FILES.files[name];
+ td.file=fileObject;
+ a=document.createElement('a');
+ td.appendChild(a);
+ a.appendChild(document.createTextNode(name));
+ a.addEvent('onclick',new callBack(fileObject.actions['default'],fileObject));
+ a.makeDraggable();
+ a.addEvent('ondrop',OC_FILES.browser.handleDrop);
+ if(type=='dir'){
+ td.setAttribute('colspan',2);
+ var dirname=name;
+ if(OC_FILES.dir[OC_FILES.dir.length-1]!='/'){
+ dirname='/'+name;
+ }
+ a.setAttribute('href','#'+OC_FILES.dir+dirname);
+ }else{
+ a.setAttribute('href','#'+OC_FILES.dir);
+ sizeTd=document.createElement('td');
+ tr.appendChild(sizeTd);
+ sizeTd.className='sizetext';
+ sizeTd.appendChild(document.createTextNode(sizeFormat(size)));
+ }
+ a=document.createElement('a');
+ var img=document.createElement('img');
+ td.appendChild(img);
+ img.className='file_actions';
+ img.alt=''
+ img.title='actions';
+ img.src=WEBROOT+'/img/arrow_down.png';
+ img.addEvent('onclick',OC_FILES.browser.showactions,name);
+ td=document.createElement('td');
+ tr.appendChild(td);
+ td.className='sizetext';
+ td.appendChild(document.createTextNode(date));
+ }
+}
+
+OC_FILES.browser.files.remove=function(name){
+ if(OC_FILES.browser.files.fileNodes[name]){
+ tr=OC_FILES.browser.files.fileNodes[name];
+ tr.parentNode.removeChild(tr);
+ delete OC_FILES.browser.files.fileNodes[name];
+ }
+
+}
+OC_FILES.browser.files.clear=function(){
+ for(name in OC_FILES.browser.files.fileNodes){
+ OC_FILES.browser.files.remove(name);
+ }
+}
- // files and directories
-
- var filesfound=false;
- var sizeTd=null;
- if(content){
+OC_FILES.browser.table=null;
+OC_FILES.browser.show_callback=function(content){
+ var dir=OC_FILES.dir
+ var tr=null;
+ var td=null;
+ var img=null;
+ if(!OC_FILES.browser.table){
+ body=document.getElementsByTagName('body').item(0);
+ body.addEvent('onclick',OC_FILES.browser.hideallactions);
+
+ //remove current content;
+ var contentNode=document.getElementById('content');
+ contentNode.className='center';
+ if(contentNode.hasChildNodes()){
+ while(contentNode.childNodes.length >=1){
+ contentNode.removeChild(contentNode.firstChild);
+ }
+ }
+ var table=document.createElement('table');
+ OC_FILES.browser.table=table;
+ table.className='browser';
+ var tbody=document.createElement('tbody');
+ var thead=document.createElement('thead');
+ var tfoot=document.createElement('tfoot');
+ table.appendChild(thead);
+ table.appendChild(tbody);
+ table.appendChild(tfoot);
+ OC_FILES.files=Array();
+ table.setAttribute('cellpadding',6);
+
+ tr=document.createElement('tr');
+ thead.appendChild(tr);
+ tr.className='breadcrumb';
+ td=document.createElement('td');
+ tr.appendChild(td);
+ input=document.createElement('input');
+ input.className='fileSelector'
+ input.setAttribute('type','checkbox');
+ input.setAttribute('name','fileSelector');
+ input.setAttribute('value','select_all');
+ input.setAttribute('id','select_all');
+ input.addEvent('onclick',OC_FILES.selectAll);
+ td.appendChild(input);
+ td.className='breadcrumb';
+ OC_FILES.browser.breadcrumb.show(td,dir);
+ // files and directories
tr=document.createElement('tr');
tbody.appendChild(tr);
td=document.createElement('td');
- td.setAttribute('colspan','6');
tr.appendChild(td);
div=document.createElement('div');
- td.appendChild(div);
div.className='fileList';
- div.setAttribute('style','max-height:'+(parseInt(document.body.clientHeight)-300)+'px;');
- table2=document.createElement('table');
- div.appendChild(table2);
- tbody2=document.createElement('tbody');
- table2.appendChild(tbody2);
- table2.setAttribute('cellpadding',6);
- table2.setAttribute('cellspacing',0);
- for(index in content){
- var file=content[index];
- if(file.name){
- file.name=file.name.replace('\'','');
- OC_FILES.files[file['name']]=new OC_FILES.file(dir,file['name'],file['type']);
- tr=document.createElement('tr');
- tbody2.appendChild(tr);
- tr.className='browserline';
- td=document.createElement('td');
- tr.appendChild(td);
- td.className='fileSelector';
- input=document.createElement('input');
- input.setAttribute('type','checkbox');
- input.setAttribute('name','fileSelector');
- input.setAttribute('value',file['name']);
- td.appendChild(input);
- tr.appendChild(OC_FILES.browser.showicon(file['type']));
- td=document.createElement('td');
- tr.appendChild(td);
- td.className='nametext';
- td.setAttribute('name',file['name']);
- td.setAttribute('id',file['name']);
- a=document.createElement('a');
- td.appendChild(a);
- a.appendChild(document.createTextNode(file['name']));
- var fileObject=OC_FILES.files[file['name']];
- a.addEvent('onclick',new callBack(fileObject.actions['default'],fileObject));
- if(file['type']=='dir'){
- td.setAttribute('colspan',2);
- a.setAttribute('href','#'+dir+'/'+file['name']);
- }else{
- a.setAttribute('href','#'+dir);
- sizeTd=document.createElement('td');
- tr.appendChild(sizeTd);
- sizeTd.className='sizetext';
- sizeTd.appendChild(document.createTextNode(sizeFormat(file['size'])));
- }
- a=document.createElement('a');
- var img=document.createElement('img');
- td.appendChild(img);
- img.className='file_actions';
- img.alt=''
- img.title='actions';
- img.src=WEBROOT+'/img/arrow_down.png';
- var name=file['name'];
- img.addEvent('onclick',OC_FILES.browser.showactions,name);
- td=document.createElement('td');
- tr.appendChild(td);
- td.className='sizetext';
- td.appendChild(document.createTextNode(file['date']));
- }
- }
- }
- tr=document.createElement('tr');
- tfoot.appendChild(tr);
- tr.className='utilityline';
- td=document.createElement('td');
- tr.appendChild(td);
- td.setAttribute('colspan','4');
- span=document.createElement('span');
- td.appendChild(span);
- dropdown=document.createElement('select');
- span.appendChild(dropdown);
- dropdown.setAttribute('id','selected_action');
- for(index in this.actions_selected){
- if(this.actions_selected[index].call){
+ td.appendChild(div);
+ OC_FILES.browser.files.show(div,content);
+ tr=document.createElement('tr');
+ tfoot.appendChild(tr);
+ tr.className='utilityline';
+ td=document.createElement('td');
+ tr.appendChild(td);
+ td.className='actionsSelected';
+ dropdown=document.createElement('select');
+ td.appendChild(dropdown);
+ dropdown.setAttribute('id','selected_action');
+ for(index in OC_FILES.actions_selected){
+ if(OC_FILES.actions_selected[index].call){
+ option=document.createElement('option');
+ dropdown.appendChild(option);
+ option.setAttribute('value',index);
+ option.appendChild(document.createTextNode(capitaliseFirstLetter(index)));
+ }
+ }
+ td.appendChild(document.createTextNode(' Selected '));
+ button=document.createElement('button');
+ td.appendChild(button);
+ button.appendChild(document.createTextNode('Go'));
+ button.addEvent('onclick',OC_FILES.action_selected);
+ div=document.createElement('div');
+ td.appendChild(div);
+ div.className='moreActionsButton';
+ OC_FILES.maxUpload=content['max_upload'];
+ var p=document.createElement('p');
+ div.appendChild(p);
+ p.appendChild(document.createTextNode('More Actions'));
+ div.setAttribute('id','moreActionsButton');
+ OC_FILES.browser.moreActionsShown=false;
+ p.addEvent('onclick',OC_FILES.browser.showMoreActions);
+ contentNode.appendChild(table);
+ }else{
+ OC_FILES.browser.breadcrumb.show(null,dir);
+ OC_FILES.browser.files.show(null,content);
+ }
+}
+
+OC_FILES.browser.handleDropOn=function(event,node){
+ var dropTargetFile=this.file;
+ var dropFile=node.parentNode.file;
+ if(dropTargetFile!=dropFile){
+ if(dropTargetFile.actions.dropOn && dropTargetFile.actions.dropOn.call){
+ dropTargetFile.actions.dropOn.call(dropTargetFile,dropFile);
+ }
+ return false;
+ }
+}
+
+OC_FILES.browser.handleDrop=function(event,node){
+ var dropTargetFile=node.file;
+ var dropFile=this.parentNode.file;
+ if(dropFile.actions.drop && dropFile.actions.drop.call){
+ dropFile.actions.drop.call(dropFile,dropTargetFile);
+ }
+ return false;
+}
+
+OC_FILES.browser.showMoreActions=function(){
+ if(!OC_FILES.browser.moreActionsList){
+ var div=document.createElement('div');
+ div.className='moreActionsList';
+ var table=document.createElement('table');
+ div.appendChild(table);
+ var tbody=document.createElement('tbody');
+ table.appendChild(tbody);
+ var tr=document.createElement('tr');
+ tbody.appendChild(tr);
+ var td=document.createElement('td');
+ tr.appendChild(td);
+ OC_FILES.browser.showuploader(OC_FILES.dir,td,OC_FILES.maxUpload);
+ tr=document.createElement('tr');
+ tbody.appendChild(tr);
+ td=document.createElement('td');
+ tr.appendChild(td);
+ var form=document.createElement('form');
+ td.appendChild(form);
+ form.appendChild(document.createTextNode('New '));
+ var dropdown=document.createElement('select');
+ form.appendChild(dropdown);
+ dropdown.setAttribute('id','newFileType');
+ var option=document.createElement('option');
+ dropdown.appendChild(option);
+ option.setAttribute('value','dir');
+ option.appendChild(document.createTextNode('Folder'));
option=document.createElement('option');
dropdown.appendChild(option);
- option.setAttribute('value',index);
- option.appendChild(document.createTextNode(capitaliseFirstLetter(index)));
+ option.setAttribute('value','file');
+ option.appendChild(document.createTextNode('File'));
+ form.appendChild(document.createTextNode(' '));
+ var input=document.createElement('input');
+ form.appendChild(input);
+ input.setAttribute('id','newFileName');
+ form.addEvent('onsubmit',OC_FILES.browser.newFile);
+ var submit=document.createElement('input');
+ form.appendChild(submit);
+ submit.type='submit';
+ submit.value='Create';
+ OC_FILES.browser.moreActionsList=div;
+ }else{
+ var div=OC_FILES.browser.moreActionsList;
}
+ var button=document.getElementById('moreActionsButton');
+ if(!OC_FILES.browser.moreActionsShown){
+ button.appendChild(div);
+ OC_FILES.browser.moreActionsShown=true;
+ button.className='moreActionsButton moreActionsButtonClicked';
+ }else{
+ OC_FILES.browser.moreActionsShown=false;
+ button.removeChild(div);
+ button.className='moreActionsButton';
}
- span.appendChild(document.createTextNode(' Selected '));
- button=document.createElement('button');
- span.appendChild(button);
- button.appendChild(document.createTextNode('Go'));
- button.addEvent('onclick',OC_FILES.action_selected);
- span=document.createElement('span');
- span.className='upload';
- td.appendChild(span);
- OC_FILES.browser.showuploader(dir,span,content['max_upload']);
- contentNode.appendChild(table);
+}
+
+OC_FILES.browser.newFile=function(event){
+ if(event.preventDefault){
+ event.preventDefault();
+ };
+ var typeSelect=document.getElementById('newFileType');
+ var type=typeSelect.options[typeSelect.selectedIndex].value;
+ var name=document.getElementById('newFileName').value;
+ OC_FILES.newFile(type,name,OC_FILES.dir);
+ return false;
}
OC_FILES.browser.showicon=function(filetype){
@@ -220,36 +399,42 @@ OC_FILES.browser.showicon=function(filetype){
img.setAttribute('height',16);
if(filetype=='dir'){
img.src=WEBROOT+'/img/icons/folder.png';
+ }else if(filetype=='incomplete'){
+ img.src=WEBROOT+'/img/icons/loading.gif';
}else{
img.src=WEBROOT+'/img/icons/other.png';
}
return td;
}
+OC_FILES.uploadIFrames=Array();
OC_FILES.browser.showuploader=function(dir,parent,max_upload){
- OC_FILES.uploadForm=document.createElement('form');
- OC_FILES.uploadForm.setAttribute('target','uploadIFrame');
- OC_FILES.uploadForm.setAttribute('action','files/upload.php?dir='+dir);
- OC_FILES.uploadForm.method='post';
- OC_FILES.uploadForm.setAttribute('enctype','multipart/form-data');
- OC_FILES.uploadIFrame=document.createElement('iframe');
- OC_FILES.uploadIFrame.className='hidden';
- OC_FILES.uploadIFrame.name='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');
- OC_FILES.uploadForm.appendChild(input);
- var file=document.createElement('input');
- file.name='file';
- file.setAttribute('id','fileSelector');
- file.setAttribute('type','file');
- file.addEvent('onchange',OC_FILES.upload,[dir]);
- OC_FILES.uploadForm.appendChild(document.createTextNode('Upload file: '));
- OC_FILES.uploadForm.appendChild(file);
- parent.appendChild(OC_FILES.uploadForm);
- parent.appendChild(OC_FILES.uploadIFrame);
+ var iframeId=OC_FILES.uploadIFrames.length
+ OC_FILES.uploadForm=document.createElement('form');
+ OC_FILES.uploadForm.setAttribute('target','uploadIFrame'+iframeId);
+ OC_FILES.uploadForm.setAttribute('action','files/upload.php?dir='+dir);
+ OC_FILES.uploadForm.method='post';
+ OC_FILES.uploadForm.setAttribute('enctype','multipart/form-data');
+ OC_FILES.uploadIFrames[iframeId]=document.createElement('iframe');
+ OC_FILES.uploadIFrames[iframeId].uploadParent=parent;
+ OC_FILES.uploadIFrames[iframeId].className='hidden';
+ OC_FILES.uploadIFrames[iframeId].name='uploadIFrame'+iframeId;
+ 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');
+ OC_FILES.uploadForm.appendChild(input);
+ var file=document.createElement('input');
+ file.name='file';
+ file.setAttribute('id','fileSelector');
+ file.setAttribute('type','file');
+ file.addEvent('onchange',OC_FILES.upload,[dir,iframeId]);
+ OC_FILES.uploadForm.appendChild(document.createTextNode('Upload file: '));
+ OC_FILES.uploadForm.appendChild(file);
+ parent.appendChild(OC_FILES.uploadForm);
+ var body=document.getElementsByTagName('body').item(0);
+ body.appendChild(OC_FILES.uploadIFrames[iframeId]);
}
OC_FILES.browser.show_rename=function(dir,file){
@@ -290,7 +475,7 @@ OC_FILES.browser.rename_cancel=function(file){
OC_FILES.browser.showactions=function(file,hide){
node=document.getElementById(file);
- if(node &&(node.actionsshown || hide)){
+ if(node &&(node.actionsshown || hide===true)){
if(node.actionsdiv){
node.removeChild(node.actionsdiv);
}
@@ -308,7 +493,7 @@ OC_FILES.browser.showactions=function(file,hide){
var file=OC_FILES.files[file]
var actions=file.actions;
for(name in actions){
- if(actions[name].call && name!='default'){
+ if(actions[name].call && name!='default' && name!='dropOn' && name!='drop'){
tr=document.createElement('tr');
tbody.appendChild(tr);
td=document.createElement('td');
@@ -341,17 +526,20 @@ OC_FILES.browser.hideallactions=function(){
OC_FILES.hideallenabled=true; //used to prevent browsers from hiding actionslists right after they are displayed;
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;
- }
- if(size.toFixed){
- size=size.toFixed(2);
- }
- return ''+size+' '+steps[step];
+ if(isNaN(size)){
+ return false;
+ }
+ var orig=size;
+ var steps=Array('B','KiB','MiB','GiB','TiB');
+ var step=0;
+ while(size>(1024*2)){
+ step++;
+ size=size/1024;
+ }
+ if(size.toFixed){
+ size=size.toFixed(2);
+ }
+ return ''+size+' '+steps[step];
}
OC_FILES.browser.showImage=function(dir,file){
diff --git a/js/lib_ajax.js b/js/lib_ajax.js
index 319875d40e7..6a2ae53ee32 100644
--- a/js/lib_ajax.js
+++ b/js/lib_ajax.js
@@ -75,7 +75,7 @@ OC_onload.run=function(){
//implement Node.prototype under IE
if(typeof Node=='undefined'){
- Node=new Object();
+ Node=function(){};
Node.prototype=new Object();
tmpObj=new Object();
@@ -86,8 +86,9 @@ if(typeof Node=='undefined'){
document.createElement=function(tagName){
// alert(tagName);
node=document.createElementNative(tagName);
- for(name in Node.prototype){
- node[name]=Node.prototype[name];
+ var proto=new Node()
+ for(name in proto){
+ node[name]=proto[name];
}
return node;
}
@@ -98,10 +99,10 @@ if(typeof Node=='undefined'){
node=node.item(0)
}
if(node.nodeType==1){
- for(name in Node.prototype){
-// node[name]=Node.prototype[name];
- eval('node.'+name+'=Node.prototype.'+name+';');
- }
+ var proto=new Node()
+ for(name in proto){
+ node[name]=proto[name];
+ }
if(node.hasChildNodes){
var childs=node.childNodes;
for(var i=0;i<childs.length;i++){
@@ -112,4 +113,80 @@ if(typeof Node=='undefined'){
}
OC_onload.add(new function(){addNodePrototype(document.documentElement);});
OC_onload.add(addNodePrototype,true);
+}
+
+function getStyle(x,styleProp)
+{
+ if (x.currentStyle){
+ alert(x.currentStyle);
+ var y = x.currentStyle[styleProp];
+ }else if (window.getComputedStyle){
+ var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
+ }
+ return y;
+}
+
+Node.prototype.getStyle=function(styleProp){
+ return getStyle(this,styleProp)
+}
+
+Node.prototype.clearNode=function(){
+ if (this.hasChildNodes() ){
+ while(this.childNodes.length>= 1){
+ this.removeChild(this.firstChild);
+ }
+ }
+}
+
+setDebug=function(text){
+ node=document.getElementById('debug');
+ if(node){
+ node.clearNode();
+ node.appendChild(document.createTextNode(text));
+ }
+}
+
+arrayMerge=function(array1,array2){
+ var array=Array();
+ for(i in array1){
+ array[i]=array1[i];
+ }
+ for(i in array2){
+ array[i]=array2[i];
+ }
+ return array;
+}
+
+if(!Math.sign){
+ Math.sign=function(x){
+ return x/Math.abs(x);
+ }
+}
+
+if(!Node.prototype.clearNode){
+ Node.prototype.clearNode=function(){
+ if(this.hasChildNodes()){
+ while(this.childNodes.length >=1){
+ this.removeChild(this.firstChild);
+ }
+ }
+ }
+}
+
+getTimeString=function(){
+ var date=new Date();
+ var months=new Array(12);
+ months[0]="Jan";
+ months[1]="Feb";
+ months[2]="Mar";
+ months[3]="Apr";
+ months[4]="May";
+ months[5]="Jun";
+ months[6]="Jul";
+ months[7]="Aug";
+ months[8]="Sep";
+ months[9]="Oct";
+ months[10]="Nov";
+ months[11]="Dec";
+ return date.getDate()+' '+months[date.getMonth()]+' '+date.getFullYear()+' '+date.getHours()+':'+date.getMinutes();
} \ No newline at end of file
diff --git a/js/lib_drag.js b/js/lib_drag.js
new file mode 100644
index 00000000000..bc6a8610500
--- /dev/null
+++ b/js/lib_drag.js
@@ -0,0 +1,350 @@
+/**
+* Javascript Drag&Drop - Modified for ownCloud
+*
+* @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/>.
+*
+*/
+
+position=function(x,y){
+ if(x)this.x=x;
+ if(y)this.y=y;
+ return this;
+}
+position.prototype={
+ x:0,
+ y:0,
+ add:function(pos2){
+ return new position(this.x+pos2.x,this.y+pos2.y);
+ },
+ substract:function(pos2){
+ return new position(this.x-pos2.x,this.y-pos2.y);
+ },toString:function(){
+ return 'x:'+this.x+',y:'+this.y;
+ },inside:function(pos2){
+ return Math.abs(this.x)<Math.abs(pos2.x) && Math.abs(this.y)<Math.abs(pos2.y) && Math.sign(this.x)==Math.sign(pos2.x) && Math.sign(this.y)==Math.sign(pos2.y);
+ },outside:function(pos2){
+ return !this.inside(pos2);
+ }
+}
+
+Node.prototype.drag=new Object
+/**
+ * is the node dragable
+ */
+Node.prototype.drag.dragable=false;
+/**
+ * Are we currently dragging the node
+ */
+Node.prototype.drag.active=false;
+/**
+ * Create a clone to drag around
+ */
+Node.prototype.drag.clone=true;
+/**
+ * The node we (visually drag around)
+ */
+Node.prototype.drag.node=false;
+/**
+ * can we drop nodes on this
+ */
+Node.prototype.drag.isDropTarget=false;
+/**
+ * our current drop target
+ */
+Node.prototype.drag.dropTarget=null;
+/**
+ * can we drop this node now
+ */
+Node.prototype.drag.dropable=false;
+/**
+ * function called when we are being dropped on a node
+ * @return bool
+ */
+Node.prototype.drag.onDrop=function(node){};
+/**
+ * function called when an node is dropped on us
+ * @param Node node
+ * @return bool
+ */
+Node.prototype.drag.onDropOn=function(node){};
+/**
+ * where did we start the drag
+ */
+Node.prototype.drag.startPosition=new position();
+/**
+ * where are we now
+ */
+Node.prototype.drag.position=new position();
+/**
+ * how big are we
+ */
+Node.prototype.drag.size=new position();
+/**
+ * where is the mouse
+ */
+Node.prototype.drag.mousePosition=new position();
+/**
+ * where is the mouse relative to our node
+ */
+Node.prototype.drag.mouseOffset=new position();
+
+document.drag=new Object();
+/**
+ * is there currently something dragged
+ */
+document.drag.active=false;
+/**
+ * what is currently being dragged
+ */
+document.drag.node=null;
+document.drag.dropTargets=Array();
+/**
+ * start the dragging. (onmousedown)
+ * @param Event event
+ */
+Node.prototype.drag.start=function(event){
+ if(!event)var event=window.event;
+ if(!this.drag.active && this.drag.dragable){
+ document.drag.active=true;
+ document.drag.node=this;
+ this.drag.active=true;
+ this.drag.position=this.getPosition();
+ this.drag.startPosition=this.getPosition();
+ this.drag.mousePosition=getMousePosition(event);
+ this.drag.mouseOffset=this.drag.mousePosition.substract(this.drag.position);
+ }
+}
+
+/**
+ * update the dragging. (onmousemove)
+ * @param Event event
+ */
+Node.prototype.drag.update=function(event){
+ if(!event)var event=window.event;
+ if(this.drag.active && this.drag.dragable){
+ this.drag.mousePosition=getMousePosition(event);
+ this.drag.position=this.drag.mousePosition.substract(this.drag.mouseOffset);
+ if(this.drag.clone && !this.drag.node){
+ this.drag.node=this.cloneNode(true);
+ this.drag.node.className='dragClone';
+ if(this.drag.node.hasAttribute('id')){
+ this.drag.node.setAttribute('id',this.drag.node.getAttribute('id')+'_dragClone');
+ }
+ document.getElementsByTagName('body').item(0).appendChild(this.drag.node);
+ }else if(!this.drag.node){
+ this.drag.node=this;
+ this.drag.node.style.position='absolute';
+ }
+ this.drag.node.style.left=this.drag.position.x+'px';
+ this.drag.node.style.top=this.drag.position.y+'px';
+ }
+ return true;
+}
+
+/**
+ * stop the dragging/drop. (onmouseup)
+ * @param Event event
+ * @return bool
+ */
+Node.prototype.drag.stop=function(event){
+ if(!event)var event=window.event;
+ if(this.drag.active && this.drag.dragable){
+ this.drag.active=false;
+ this.drag.mousePosition=getMousePosition(event);
+ this.drag.position=this.drag.mousePosition.substract(this.drag.mouseOffset);
+ if(this.drag.node){
+ this.drag.node.style.left=this.drag.position.x;
+ this.drag.node.style.top=this.drag.position.y;
+ }
+ var target;
+ this.drag.dropTarget=null;
+ this.drag.dropable=false;
+ for(var i=0;i<document.drag.dropTargets.length;i++){
+ target=document.drag.dropTargets[i];
+ target.drag.checkDropTarget.call(target,event);
+ }
+ if(this.drag.dropable && this.drag.dropTarget){
+ if(this.drag.onDrop){
+ this.drag.onDrop.call(this,event,this.drag.dropTarget);
+ this.triggerEvent.call(this,'ondrop',event,this.drag.dropTarget);
+ }
+ if(this.drag.dropTarget.drag.onDropOn){
+ this.drag.dropTarget.drag.onDropOn.call(this.drag.dropTarget,event,this);
+ this.drag.dropTarget.triggerEvent.call(this.drag.dropTarget,'ondropon',event,this);
+ }
+ }
+ if(this.drag.clone && this.drag.node){
+ this.drag.node.parentNode.removeChild(this.drag.node);
+ this.drag.node=null;
+ }
+ document.drag.active=false;
+ document.drag.node=null;
+ }
+}
+
+/**
+ * is there currently something being dragged over us
+ * @param Event event
+ */
+Node.prototype.drag.checkDropTarget=function(event){
+ if(this.drag.isDropTarget & document.drag.active){
+ mousePos=getMousePosition(event);
+ this.drag.position=this.getPosition();
+ this.drag.size=this.getSize(true);
+ var offSet=mousePos.substract(this.drag.position);
+ if(offSet.inside(this.drag.size)){
+ document.drag.node.drag.dropTarget=this;
+ document.drag.node.drag.dropable=true;
+ setDebug('ontarget');
+ }
+ }
+}
+
+/**
+ * called when the mouse is leaving a drop target
+ * @param Event event
+ */
+Node.prototype.drag.leaveDropTarget=function(event){
+ if(this.drag.isDropTarget & document.drag.active){
+ document.drag.node.drag.dropTarget=null;
+ document.drag.node.drag.dropable=false;
+ setDebug('offtarget');
+ }
+}
+/**
+ * initiate the node as drop target
+ */
+Node.prototype.drag.initDropTarget=function(){
+ this.drag.isDropTarget=true;
+ document.drag.dropTargets.push(this);
+}
+Node.prototype.makeDropTarget=function(){
+ this.drag.initDropTarget.call(this);
+}
+
+/**
+ * initiate the node as draggable
+ */
+Node.prototype.drag.init=function(){
+ this.drag.dragable=true;
+ this.drag.size.x=this.getStyle('width');
+ this.drag.size.y=this.getStyle('height');
+ this.addEvent('onmousedown',new callBack(this.drag.start,this));
+}
+Node.prototype.makeDraggable=function(){
+ this.drag.init.call(this);
+}
+
+/**
+ * update the dragging. (onmousemove)
+ * @param Event event
+ */
+document.drag.update=function(event){
+ var target;
+ if(document.drag.active && document.drag.node){
+ document.drag.node.drag.update.call(document.drag.node,event);
+ }
+ return false;
+}
+
+/**
+ * update the dragging. (onmousemove)
+ * @param Event event
+ */
+document.drag.stop=function(event){
+ if(document.drag.active && document.drag.node){
+ document.drag.node.drag.stop.call(document.drag.node,event);
+ }
+ return false;
+}
+document.events.add(document,'onmousemove',document.drag.update);
+document.events.add(document,'onmouseup',document.drag.stop);
+
+function getMousePosition(event){
+ var pos=new position();
+ if(!event)var event = window.event;
+ if(event.pageX||event.pageY){
+ pos.x=event.pageX;
+ pos.y=event.pageY;
+ }
+ else if(event.clientX||event.clientY){
+ pos.x=event.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
+ pos.y=event.clientY+document.body.scrollTop+document.documentElement.scrollTop;
+ }
+ return pos;
+}
+
+/**
+ * get our position
+ **/
+Node.prototype.getPosition=function(){
+ var pos=new position();
+ element=this;
+ do{
+ pos.y+=element.offsetTop;
+ pos.x+=element.offsetLeft;
+ }while(element=element.offsetParent);
+ return pos;
+}
+
+/**
+ * get our size
+* @param bool full (also include padding and border)
+ **/
+Node.prototype.getSize=function(full){
+ var pos=new position();
+ pos.y= parseInt(this.getStyle('height'));
+ pos.x= parseInt(this.getStyle('width'));
+ if(full){
+ var extraY=['border-size','padding-top','padding-bottom','border-size'];
+ var extraX=['border-size','padding-left','padding-right','border-size'];
+ var tmp;
+ for(var i=0;i<extraY.length;i++){
+ tmp=parseInt(this.getStyle(extraY[i]));
+ if(tmp){
+ pos.y+=tmp;
+ }
+ }
+ for(var i=0;i<extraX.length;i++){
+ tmp=parseInt(this.getStyle(extraX[i]));
+ if(tmp){
+ pos.x+=tmp;
+ }
+ }
+ }
+ return pos;
+}
+
+function mouseTest(event){
+ var pos=getMousePosition(event);
+ setDebug(pos.toString());
+}
+
+function testDrag(){
+ var node=document.getElementById('debug');
+// document.addEvent('onclick',getOffSet,[node]);
+ node.makeDropTarget();
+}
+
+function getOffSet(node,event){
+ var nodePos=node.getPosition();
+ var mousePos=getMousePosition(event);
+ return mousePos.substract(nodePos);
+}
+
+
+// OC_onload.add(testDrag); \ No newline at end of file
diff --git a/js/lib_event.js b/js/lib_event.js
index f8482402d09..f44a2049fb2 100755
--- a/js/lib_event.js
+++ b/js/lib_event.js
@@ -17,33 +17,80 @@ document.events.functions=Array();
document.events.args=Array();
document.events.add=function(element,type,func,args){
+ if(!element.eventCallBacks){
+ element.eventCallBacks=Array();
+ }
+ if(!element.eventCallBacks[type]){
+ element.eventCallBacks[type]=Array();
+ }
if(args){
- if(typeof args!='object' && typeof args!='Object'){
+ if(!args.push){
args=[args];
}
}
if(!args){
args=Array();
}
+ args.push('eventHolder');
+ args.push('argHolder');
if (type && element){
//wrap the function in a function, otherwise it won't work if func is actually a callBack
var funcId=document.events.functions.length;
document.events.functions[funcId]=func;
document.events.args[funcId]=args;
- eval('callback=function(event){result=document.events.functions['+funcId+'].apply(this,document.events.args['+funcId+']);if(result===false){if(event.preventDefault){event.preventDefault();}}};');
+ eval('var callback=function(event,arg){document.events.callback.call(this,'+funcId+',event,arg)};');
+ element.eventCallBacks[type].push(callback);
if(element.addEventListener){
var eventType=type;
if(eventType.substr(0,2)=='on'){
eventType=eventType.substr(2);
}
element.addEventListener(eventType,callback,false);
- }else{
+ }else if(element.attachEvent){
element.attachEvent(type,callback);
}
+ return callback;
+ }
+}
+document.events.remove=function(element,type,func){
+ if(element.removeEventListener){
+ if(type.substr(0,2)=='on'){
+ type=type.substr(2);
+ }
+ element.removeEventListener(type,func,false);
+ }else if(element.detachEvent){
+ element.detachEvent(type,func)
+ }
+}
+
+document.events.callback=function(funcId,event,arg){
+ if(!event)var event=window.event;
+ var args=document.events.args[funcId];
+ args[args.length-2]=event;
+ args[args.length-1]=arg;
+ result=document.events.functions[funcId].apply(this,args);
+ if(result===false){
+ if(event.preventDefault){
+ event.preventDefault();
+ };
+ }
+ return result;
+}
+
+document.events.trigger=function(element,type,event,args){
+ var callbacks=element.eventCallBacks[type];
+ for(var i=0;i<callbacks.length;i++){
+ callbacks[i].call(element,event,args);
}
}
Node.prototype.addEvent=function(type,func,arguments){
- document.events.add(this,type,func,arguments);
+ return document.events.add(this,type,func,arguments);
+}
+Node.prototype.removeEvent=function(type,func){
+ document.events.remove(this,type,func);
+}
+Node.prototype.triggerEvent=function(type,event,arg){
+ return document.events.trigger(this,type,event,arg);
} \ No newline at end of file
diff --git a/js/lib_files.js b/js/lib_files.js
index 443d440380e..c231af2f03f 100644
--- a/js/lib_files.js
+++ b/js/lib_files.js
@@ -20,92 +20,184 @@
*/
OC_FILES=new Object();
+
+OC_FILES.cache=new Object();
+
+OC_FILES.cache.files=Array();
+OC_FILES.cache.incomplete=Array();
+OC_FILES.cache.actions=new Object();
+
+OC_FILES.cache.actions.move=Array();
+OC_FILES.cache.actions.rename=Array();
+OC_FILES.cache.actions['new']=Array();
+OC_FILES.cache.actions['delete']=Array();
+OC_FILES.cache.actions.upload=Array();
+
+OC_FILES.cache.refresh=function(){
+ OC_FILES.getdirectorycontent(OC_FILES.dir,false,true);
+}
+
OC_FILES.xmlloader=new OCXMLLoader();
OC_FILES.getdirectorycontent_parse=function(req){
- var files=new Array();
- var response=req.responseXML;
- if(response){
- var dir=response.getElementsByTagName('dir').item(0);
- files['max_upload']=dir.getAttribute('max_upload');
- var fileElements=response.getElementsByTagName('file');
- if(fileElements.length>0){
- for(index=0;index<fileElements.length;index++){
-// for(index in fileElements){
- var file=new Array();
- var attributes=Array('size','name','type','directory','date');
- for(i in attributes){
- var name=attributes[i];
- file[name]=fileElements.item(index).getAttribute(name);
- }
- files[file.name]=file;
- }
- }
- if(OC_FILES.getdirectorycontent_callback){
- OC_FILES.getdirectorycontent_callback(files);
- }
- }
-}
-
-OC_FILES.getdirectorycontent=function(dir,callback){
- if(callback){
- OC_FILES.getdirectorycontent_callback=callback;
- }
- OC_FILES.xmlloader.setCallBack(OC_FILES.getdirectorycontent_parse);
- OC_FILES.xmlloader.load('files/get_files.php?dir='+dir);
+ var files=new Array();
+ var response=req.responseXML;
+ OC_FILES.cache.files=Array();
+ if(response){
+ var dir=response.getElementsByTagName('dir').item(0);
+ var fileElements=response.getElementsByTagName('file');
+ if(fileElements.length>0){
+ for(index=0;index<fileElements.length;index++){
+ var file=new Array();
+ var attributes=Array('size','name','type','directory','date');
+ for(i in attributes){
+ var name=attributes[i];
+ file[name]=fileElements.item(index).getAttribute(name);
+ }
+ files[file.name]=file;
+ }
+ }
+ OC_FILES.cache.files=files;
+ if(OC_FILES.cache.incomplete[OC_FILES.dir]){
+ files=arrayMerge(files,OC_FILES.cache.incomplete[OC_FILES.dir]);
+ }
+ files['max_upload']=dir.getAttribute('max_upload');
+ if(OC_FILES.getdirectorycontent_callback){
+ OC_FILES.getdirectorycontent_callback(files);
+ }
+ }
+}
+
+OC_FILES.getdirectorycontent=function(dir,callback,refresh){
+ if(refresh || OC_FILES.dir!=dir){
+ OC_FILES.dir=dir;
+ if(callback){
+ OC_FILES.getdirectorycontent_callback=callback;
+ }
+ OC_FILES.xmlloader.setCallBack(OC_FILES.getdirectorycontent_parse);
+ OC_FILES.xmlloader.load('files/get_files.php?dir='+dir);
+ }else{
+ var files=OC_FILES.cache.files
+ if(OC_FILES.cache.incomplete[OC_FILES.dir]){
+ files=arrayMerge(files,OC_FILES.cache.incomplete[OC_FILES.dir]);
+ }
+ callback(files);
+ }
}
OC_FILES.dir='';
-OC_FILES.upload=function(dir){
- OC_FILES.uploadIFrame.addEvent('onload',new callBack(OC_FILES.upload_callback,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;
- if(size>max_upload){
- new OCNotification('File to large',10000)
- return false;
- }
- }
- OC_FILES.uploadForm.submit();
+OC_FILES.upload=function(dir,iframeId){
+ var file=new Object;
+ var fileSelector=document.getElementById('fileSelector');
+ var max_upload=document.getElementById('max_upload').value;
+ var name=false;
+ if(fileSelector.files && fileSelector.files[0].fileName){
+ name=fileSelector.files[0].fileName;
+ }
+ if(fileSelector.files && fileSelector.files[0].fileSize){
+ var size=fileSelector.files[0].fileSize;
+ if(size>max_upload){
+ new OCNotification('File to large',10000)
+ return false;
+ }
+ }
+ file.dir=dir;
+ file.name=name;
+ file.type='file';
+ file.size=size;
+ file.iframeId=iframeId;
+ if(!OC_FILES.cache.incomplete[dir]){
+ OC_FILES.cache.incomplete[dir]=Array();
+ }
+ OC_FILES.cache.incomplete[dir][name]=Array();
+ OC_FILES.cache.incomplete[dir][name]['name']=name;
+ OC_FILES.cache.incomplete[dir][name]['type']='incomplete';
+ OC_FILES.cache.incomplete[dir][name]['size']=size;
+ OC_FILES.uploadIFrames[iframeId].file=file;
+ OC_FILES.uploadIFrames[iframeId].addEvent('onload',new callBack(OC_FILES.upload_callback,OC_FILES.uploadIFrames[iframeId]));
+ OC_FILES.browser.files.add(name,'incomplete',size);
+ OC_FILES.uploadForm.submit();
+ if(OC_FILES.uploadForm.parentElement){
+ OC_FILES.uploadForm.className='hidden';
+ OC_FILES.uploadForm.parentNode.removeChild(OC_FILES.uploadForm);
+ var body=document.getElementsByTagName('body').item(0);
+ body.appendChild(OC_FILES.uploadForm);
+ OC_FILES.uploadIFrames[iframeId].uploadForm=OC_FILES.uploadForm;
+ OC_FILES.browser.showuploader(OC_FILES.dir,OC_FILES.uploadIFrames[iframeId].uploadParent,OC_FILES.maxUpload)
+ }
}
-OC_FILES.upload_callback=function(dir){
- this.browser.show(dir);
+OC_FILES.upload_callback=function(iframeId){
+ var file=this.file;
+ if(OC_FILES.cache.incomplete[file.dir][file.name]){
+ OC_FILES.browser.files.remove(file.name);
+ OC_FILES.cache.files[file.name]=OC_FILES.cache.incomplete[file.dir][file.name]
+ delete OC_FILES.cache.incomplete[file.dir][file.name];
+ OC_FILES.cache.files[file.name]['type']=file.type;
+ this.uploadForm.parentNode.removeChild(this.uploadForm);
+ this.parentNode.removeChild(this);
+ delete OC_FILES.uploadIFrames[file.iframeId];
+ OC_FILES.browser.show(file.dir);
+ }
}
-OC_FILES.rename=function(dir,file){
- var item=document.getElementById(file+'_newname');
- var newname=item.value;
- if(newname==''){
- return false;
- }else if(file==newname){
- OC_FILES.browser.show(OC_FILES.dir);
- return false;
- }
- xmlloader=new OCXMLLoader();
- xmlloader.setCallBack(OC_FILES.rename_callback);
- xmlloader.load('files/rename.php?dir='+dir+'&file='+file+'&newname='+newname);
- return false;
+OC_FILES.rename=function(dir,file,event){
+ if(event && event.preventDefault){
+ event.preventDefault();
+ }
+ var item=document.getElementById(file+'_newname');
+ var newname=item.value;
+ if(newname==''){
+ return false;
+ }else if(file==newname){
+ OC_FILES.browser.show(OC_FILES.dir);
+ return false;
+ }
+ xmlloader=new OCXMLLoader();
+ xmlloader.setCallBack(OC_FILES.rename_callback);
+ xmlloader.arg=new Object;
+ xmlloader.arg.oldname=file;
+ xmlloader.arg.newname=newname;
+ xmlloader.arg.dir=dir;
+ xmlloader.arg.type=OC_FILES.cache.files[file]['type'];
+ xmlloader.load('files/rename.php?dir='+dir+'&file='+file+'&newname='+newname);
+ if(!OC_FILES.cache.incomplete[dir]){
+ OC_FILES.cache.incomplete[dir]=Array();
+ }
+ OC_FILES.cache.files[file]['type']='incomplete';
+ OC_FILES.cache.incomplete[dir][newname]=OC_FILES.cache.files[file];
+ OC_FILES.cache.incomplete[dir][newname]['name']=newname;
+ OC_FILES.browser.files.remove(file);
+ OC_FILES.browser.files.add(newname,'incomplete');
+ return false;
}
-OC_FILES.rename_callback=function(req){
- OC_FILES.browser.show(OC_FILES.dir);
+OC_FILES.rename_callback=function(req,file){
+ delete OC_FILES.cache.files[file.oldname]
+ OC_FILES.cache.files[file.newname]=OC_FILES.cache.incomplete[file.dir][file.newname];
+ delete OC_FILES.cache.incomplete[file.dir][file.newname];
+ OC_FILES.browser.files.remove(file.newname);
+ OC_FILES.cache.files[file.newname]['type']=file.type;
+ OC_FILES.browser.show(OC_FILES.dir);
}
OC_FILES.remove=function(dir,file){
- remove=confirm('remove file \''+file+'\'?');
- if(remove){
- xmlloader=new OCXMLLoader();
- xmlloader.setCallBack(OC_FILES.remove_callback);
- xmlloader.load('files/delete.php?dir='+dir+'&file='+file);
- }
+ remove=confirm('remove file \''+file+'\'?');
+ if(remove){
+ xmlloader=new OCXMLLoader();
+ xmlloader.setCallBack(OC_FILES.remove_callback);
+ xmlloader.arg=file;
+ xmlloader.load('files/delete.php?dir='+dir+'&file='+file);
+ OC_FILES.browser.files.remove(file);
+ delete OC_FILES.cache.files[file];
+ }
}
-OC_FILES.remove_callback=function(req){
- OC_FILES.browser.show(OC_FILES.dir);
+OC_FILES.remove_callback=function(req,name){
+// OC_FILES.browser.files.remove(name);
+// OC_FILES.browser.show(OC_FILES.dir);
}
OC_FILES.getSelected=function(){
@@ -119,6 +211,63 @@ OC_FILES.getSelected=function(){
return files;
}
+OC_FILES.newFile=function(type,name,dir){
+ xmlloader=new OCXMLLoader();
+ xmlloader.arg=new Object;
+ xmlloader.arg.name=name;
+ xmlloader.arg.dir=dir;
+ xmlloader.arg.type=type;
+ xmlloader.setCallBack(OC_FILES.new_callback);
+ xmlloader.load('files/new.php?type='+type+'&dir='+dir+'&name='+name);
+ if(!OC_FILES.cache.incomplete[dir]){
+ OC_FILES.cache.incomplete[dir]=Array();
+ }
+ OC_FILES.cache.incomplete[dir][name]=Array();
+ OC_FILES.cache.incomplete[dir][name]['name']=name;
+ OC_FILES.cache.incomplete[dir][name]['type']='incomplete';
+ OC_FILES.cache.incomplete[dir][name]['size']=0;
+ OC_FILES.browser.files.add(name,'incomplete');
+}
+
+OC_FILES.new_callback=function(req,file){
+ OC_FILES.cache.files[file.name]=OC_FILES.cache.incomplete[file.dir][file.name];
+ delete OC_FILES.cache.incomplete[file.dir][file.name];
+ OC_FILES.cache.files[file.name]['type']=file.type;
+ OC_FILES.browser.files.remove(name);
+ OC_FILES.browser.show(OC_FILES.dir);
+}
+
+OC_FILES.move=function(source,target,sourceDir,targetDir){
+ if(sourceDir!=targetDir || source!=target){
+ if(!OC_FILES.cache.incomplete[sourceDir]){
+ OC_FILES.cache.incomplete[sourceDir]=Array();
+ }
+ if(!OC_FILES.cache.incomplete[targetDir]){
+ OC_FILES.cache.incomplete[targetDir]=Array();
+ }
+ if(!OC_FILES.cache.incomplete[targetDir+'/'+target]){
+ OC_FILES.cache.incomplete[targetDir+'/'+target]=Array();
+ }
+ xmlloader=new OCXMLLoader();
+ xmlloader.arg=new Object;
+ xmlloader.arg.source=source;
+ xmlloader.arg.target=target;
+ xmlloader.arg.sourceDir=sourceDir;
+ xmlloader.arg.targetDir=targetDir;
+ xmlloader.arg.type=OC_FILES.cache.files[source]['type'];
+ OC_FILES.cache.files[source]['type']='incomplete';
+ OC_FILES.cache.incomplete[targetDir+'/'+target][source]=OC_FILES.cache.files[source]
+ xmlloader.setCallBack(OC_FILES.move_callback);
+ xmlloader.load('files/move.php?sourcedir='+sourceDir+'&targetdir='+targetDir+'&source='+source+'&target='+target);
+ }
+}
+
+OC_FILES.move_callback=function(req,file){
+ OC_FILES.cache.incomplete[file.targetDir+'/'+file.target][file.source]['type']=file.type;
+ delete OC_FILES.cache.files[file.source];
+ OC_FILES.browser.show(OC_FILES.dir);
+}
+
OC_FILES.selectAll=function(){
var value=document.getElementById('select_all').checked;
var nodes=document.getElementsByName('fileSelector');
@@ -161,31 +310,33 @@ OC_FILES.actions_selected['delete']=function(){
OC_FILES.files=Array();
OC_FILES.file=function(dir,file,type){
- this.type=type;
- this.file=file;
- this.dir=dir;
- this.actions=new Object();
- if(file.lastIndexOf('.')){
- this.extention=file.substr(file.lastIndexOf('.')+1);
- }else{
- this.extention;
- }
- for(index in OC_FILES.fileActions.all){
- if(OC_FILES.fileActions.all[index].call){
- this.actions[index]=OC_FILES.fileActions.all[index];
- }
- }
- if(OC_FILES.fileActions[this.type]){
- for(index in OC_FILES.fileActions[this.type]){
- if(OC_FILES.fileActions[this.type][index].call){
- this.actions[index]=OC_FILES.fileActions[this.type][index];
+ if(file){
+ this.type=type;
+ this.file=file;
+ this.dir=dir;
+ this.actions=new Object();
+ if(file.lastIndexOf('.')){
+ this.extention=file.substr(file.lastIndexOf('.')+1);
+ }else{
+ this.extention;
+ }
+ for(index in OC_FILES.fileActions.all){
+ if(OC_FILES.fileActions.all[index].call){
+ this.actions[index]=OC_FILES.fileActions.all[index];
}
}
- }
- if(OC_FILES.fileActions[this.extention]){
- for(index in OC_FILES.fileActions[this.extention]){
- if(OC_FILES.fileActions[this.extention][index].call){
- this.actions[index]=OC_FILES.fileActions[this.extention][index];
+ if(OC_FILES.fileActions[this.type]){
+ for(index in OC_FILES.fileActions[this.type]){
+ if(OC_FILES.fileActions[this.type][index].call){
+ this.actions[index]=OC_FILES.fileActions[this.type][index];
+ }
+ }
+ }
+ if(OC_FILES.fileActions[this.extention]){
+ for(index in OC_FILES.fileActions[this.extention]){
+ if(OC_FILES.fileActions[this.extention][index].call){
+ this.actions[index]=OC_FILES.fileActions[this.extention][index];
+ }
}
}
}
@@ -221,6 +372,10 @@ OC_FILES.fileActions.dir.open=function(){
}
OC_FILES.fileActions.dir['default']=OC_FILES.fileActions.dir.open;
+OC_FILES.fileActions.dir.dropOn=function(file){
+ OC_FILES.move(file.file,this.file,file.dir,this.dir);
+}
+
OC_FILES.fileActions.jpg=new Object()
OC_FILES.fileActions.jpg.show=function(){
@@ -233,21 +388,4 @@ OC_FILES.fileActions.jpg['default']=OC_FILES.fileActions.jpg.show;
OC_FILES.fileActions.jpeg=OC_FILES.fileActions.jpg
OC_FILES.fileActions.png=OC_FILES.fileActions.jpg
OC_FILES.fileActions.gif=OC_FILES.fileActions.jpg
-OC_FILES.fileActions.bmp=OC_FILES.fileActions.jpg
-
-function getStyle(el,styleProp)
-{
-// var x = document.getElementById(el);
- var x=el;
- if (x.currentStyle){
- alert(x.currentStyle);
- var y = x.currentStyle[styleProp];
- }else if (window.getComputedStyle){
- var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
- }
- return y;
-}
-
-Node.prototype.getStyle=function(styleProp){
- return getStyle(this,styleProp)
-} \ No newline at end of file
+OC_FILES.fileActions.bmp=OC_FILES.fileActions.jpg \ No newline at end of file
diff --git a/js/lib_xmlloader.js b/js/lib_xmlloader.js
index ce6fd824fc1..12ebfa474b6 100644
--- a/js/lib_xmlloader.js
+++ b/js/lib_xmlloader.js
@@ -38,6 +38,7 @@ OCXMLLoader.prototype={
request:'',
callBack:null,
async:true,
+ arg:null,
/**
* Loads an XML document
@@ -85,9 +86,9 @@ OCXMLLoader.prototype={
var HttpStatus=req.status;
if (HttpStatus==200 || HttpStatus==0){
//alert("response: "+this.req.responseText);
- this.callBack(this.req);
+ this.callBack(this.req,this.arg);
}else{
- this.errorCallBack(this.req);
+ this.errorCallBack(this.req,this.arg);
}
}
},
diff --git a/settings/index.php b/settings/index.php
index 7cdb993e45e..d5e7451d08b 100755
--- a/settings/index.php
+++ b/settings/index.php
@@ -21,6 +21,7 @@
*
*/
+$CONFIG_ERROR='';
require_once('../inc/lib_base.php');