Skip to content

Commit

Permalink
Merge branch 'experimental' of github.com:Studio-42/elFinder into exp…
Browse files Browse the repository at this point in the history
…erimental

Conflicts:
	elfinder-src.php.html
	js/jquery.waterfall.js
  • Loading branch information
troex committed Jul 4, 2011
2 parents 30c2ab9 + 83d24ef commit 4f81b7b
Show file tree
Hide file tree
Showing 23 changed files with 198 additions and 196 deletions.
32 changes: 16 additions & 16 deletions connectors/php/connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,22 +217,22 @@ function validName($name) {
// 'locked' => false,
// 'hidden' => true
// ),
array(
'pattern' => '/folder$/',
'read' => false
// 'write' => false
),
array(
'pattern' => '/folder-23$/',
'write' => false
),
array(
'pattern' => '/\/folder42$/',
'write' => false,
'read' => false,
// 'hidden' => true,
'locked' => true
)
// array(
// 'pattern' => '/folder$/',
// 'read' => false
// // 'write' => false
// ),
// array(
// 'pattern' => '/folder-23$/',
// 'write' => false
// ),
// array(
// 'pattern' => '/\/folder42$/',
// 'write' => false,
// 'read' => false,
// // 'hidden' => true,
// 'locked' => true
// )
),
),
array(
Expand Down
2 changes: 1 addition & 1 deletion connectors/php/elFinderConnector.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function run() {
* @author Dmitry (dio) Levashov
**/
protected function output(array $data) {
$header = isset($data['header']) ? $data['header'] : /*'Content-Type: text/html; charset=utf-8'*/ 'Content-Type: application/json';
$header = isset($data['header']) ? $data['header'] : 'Content-Type: text/html; charset=utf-8' /*'Content-Type: application/json'*/;
unset($data['header']);
// debug($header);
// exit();
Expand Down
11 changes: 9 additions & 2 deletions connectors/php/elFinderVolumeLocalFileSystem.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ protected function _readlink($path) {
if (!($target = @readlink($path))) {
return false;
}

// echo "path: $path<br>";
// echo "raw : $target<br>";
if (substr($target, 0, 1) == '/') {
$root = realpath($this->root);
if (strpos($target, $root.DIRECTORY_SEPARATOR) === 0) {
Expand All @@ -386,7 +387,13 @@ protected function _readlink($path) {
} else {
$target = $this->_normpath(dirname($path).DIRECTORY_SEPARATOR.$target);
}

// echo "norm $target<br>";
if (file_exists($target) && $target != dirname($path) && $this->_inpath($target, $this->root)) {
// echo "ok<br>";
return $target;
}
// echo "failed<br>";
return false;
return file_exists($target) && $target != $this->root && $this->_inpath($target, $this->root) ? $target : false;
}

Expand Down
4 changes: 3 additions & 1 deletion css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
height:16px;
background-image:url(../img/toolbar.png);
background-repeat:no-repeat;
background-position:0 -570px;
background-position:0 -528px;
}

.elfinder-symlink { }

/* noaccess */
.elfinder-na .elfinder-perms { background-position:0 -96px; }

Expand Down
2 changes: 1 addition & 1 deletion css/cwd.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

/* permissions/symlink markers */
.elfinder-cwd-view-icons .elfinder-perms { bottom:4px; right:2px; }
.elfinder-cwd-view-icons .elfinder-symlink { top:50%; left:0px; }
.elfinder-cwd-view-icons .elfinder-symlink { bottom:6px; left:0px; }

/* icon/thumbnail */
.elfinder-cwd-icon {
Expand Down
11 changes: 5 additions & 6 deletions elfinder-src.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
<script src="js/i18n/elfinder.ru.js" type="text/javascript" charset="utf-8"></script>

<script src="js/proxy/elFinderSupportVer1.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.waterfall.js" type="text/javascript" charset="utf-8"></script>


<style type="text/css">
Expand Down Expand Up @@ -119,11 +118,11 @@

var f1 = $('#finder').elfinder({
url : 'connectors/php/connector.php',
transport : new elFinderSupportVer1(),
getFileCallback : function(files, fm) {
console.log(files);
// fm.destroy()
},
// transport : new elFinderSupportVer1(),
// getFileCallback : function(files, fm) {
// console.log(files);
// // fm.destroy()
// },
handlers : {
load : function(e, fm) {
// fm.error('All your base belongs to us >_<')
Expand Down
Binary file modified img/src/toolbar.pxm
Binary file not shown.
Binary file modified img/toolbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion js/commands/archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ elFinder.prototype.commands.archive = function() {
});

this.getstate = function() {

return mimes.length && fm.selected().length && fm.cwd().write ? 0 : -1;
}

Expand Down Expand Up @@ -57,7 +58,7 @@ elFinder.prototype.commands.archive = function() {
}

return fm.request({
data : {cmd : 'archive', targets : this.hashes(hashes), type : mime, current : cwd.hash},
data : {cmd : 'archive', targets : this.hashes(hashes), type : mime},
notify : {type : 'archive', cnt : 1},
syncOnFail : true
});
Expand Down
7 changes: 6 additions & 1 deletion js/commands/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ elFinder.prototype.commands.download = function() {
var sel = this.fm.selected(),
cnt = sel.length;

return fm.newAPI && cnt && cnt == filter(sel).length ? 0 : -1;
return cnt && cnt == filter(sel).length ? 0 : -1;
}

this.exec = function(hashes) {
Expand All @@ -33,6 +33,11 @@ elFinder.prototype.commands.download = function() {
dfrd = $.Deferred(),
iframe, i, url;

if (fm.oldAPI) {
fm.error(fm.res('error', 'cmdsupport'));
return dfrd.reject();
}

base += base.indexOf('?') === -1 ? '?' : '&';

for (i = 0; i < files.length; i++) {
Expand Down
13 changes: 0 additions & 13 deletions js/commands/duplicate.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ elFinder.prototype.commands.duplicate = function() {
return dfrd;
}

if (fm.oldAPI) {
$.each(files, function(i, file) {
args.push(function() {
return fm.request({
data : {cmd : 'duplicate', target : file.hash, current : file.phash},
notify : {type : 'copy', cnt : 1}
});
});
});

return fm.waterfall.apply(null, args);
}

return fm.request({
data : {cmd : 'duplicate', targets : this.hashes(hashes)},
notify : {type : 'copy', cnt : cnt}
Expand Down
2 changes: 1 addition & 1 deletion js/commands/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ elFinder.prototype.commands.extract = function() {
}

fm.request({
data : {cmd : 'extract', target : file.hash, current : file.phash},
data : {cmd : 'extract', target : file.hash},
notify : {type : 'extract', cnt : 1},
syncOnFail : true
})
Expand Down
4 changes: 2 additions & 2 deletions js/commands/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ elFinder.prototype.commands.info = function() {

if (!file.read) {
size = fm.i18n('unknown');
} else if (file.mime != 'directory' || fm.oldAPI) {
} else if (file.mime != 'directory') {
size = fm.formatSize(file.size);
} else {
size = tpl.spinner.replace('{text}', fm.i18n('Calculating'));
Expand All @@ -72,7 +72,7 @@ elFinder.prototype.commands.info = function() {
content.push(row.replace(l, fm.i18n('Size')).replace(v, size));
file.linkTo && content.push(row.replace(l, fm.i18n('Alias for')).replace(v, file.linkTo));
content.push(row.replace(l, fm.i18n('Path')).replace(v, fm.escape(fm.path(file.hash))));
content.push(row.replace(l, 'URL').replace(v, '<a href="'+fm.url(file.hash)+'" target="_blank">'+file.name+'</a>'));
file.read && content.push(row.replace(l, 'URL').replace(v, '<a href="'+fm.url(file.hash)+'" target="_blank">'+file.name+'</a>'));
file.dim && content.push(row.replace(l, fm.i18n('Dimensions')).replace(v, file.dim));
content.push(row.replace(l, fm.i18n('Modified')).replace(v, fm.formatDate(file.date)));
content.push(row.replace(l, fm.i18n('Permissions')).replace(v, fm.formatPermissions(file)));
Expand Down
40 changes: 8 additions & 32 deletions js/commands/paste.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,46 +121,22 @@ elFinder.prototype.commands.paste = function() {
var files = $.map(files, function(file) { return !file.remove ? file : null } ),
cnt = files.length,
groups = {},
args = [];
args = [],
src;

if (!cnt) {
return dfrd.resolve();
}

if (fm.oldAPI) {
$.each(files, function(i, file) {
if (!groups[file.phash]) {
groups[file.phash] = [];
}

groups[file.phash].push(file.hash);
});

$.each(groups, function(src, targets) {
args.push(function() {
return fm.request({
data : {cmd : 'paste', current : fm.cwd().hash, src : src, dst : dst.hash, targets : targets, cut : cut ? 1 : 0},
notify : {type : cut ? 'move' : 'copy', cnt : targets.length}
});
});
});


// fm.log(fm.waterfall)
return $.waterfall.apply(null, args)
.fail(function(error) {
dfrd.reject(error);
})
.done(function() {
dfrd.resolve.apply(dfrd, Array.prototype.slice.apply(arguments));
});
}

// new API
src = files[0].phash;
files = $.map(files, function(f) { return f.hash});

fm.request({
data : {cmd : 'paste', dst : dst.hash, targets : files, cut : cut ? 1 : 0},
data : {cmd : 'paste', dst : dst.hash, targets : files, cut : cut ? 1 : 0, src : src},
notify : {type : cut ? 'move' : 'copy', cnt : cnt}
})
.always(function() {
fm.unlockfiles({files : files});
});
}
;
Expand Down
14 changes: 4 additions & 10 deletions js/commands/quicklook.plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,14 @@ elFinder.prototype.commands.quicklook.plugins = [
});

jqxhr = fm.request({
options : {dataType : 'html'},
data : {cmd : fm.oldAPI ? 'open' : 'file', target : file.hash, current : file.phash},
preventDefault : true,
raw : true
data : {cmd : 'get', target : file.hash, current : file.phash},
preventDefault : true
})
.done(function(data) {
ql.hideinfo();
doc = $('<iframe class="elfinder-quicklook-preview-html"/>').appendTo(preview)[0].contentWindow.document;
doc.open();
doc.write(data);
doc.write(data.content);
doc.close();
});
}
Expand Down Expand Up @@ -131,11 +129,7 @@ elFinder.prototype.commands.quicklook.plugins = [
});

jqxhr = fm.request({
data : {
cmd : fm.oldAPI ? 'fread' : 'get',
target : file.hash,
current : file.phash // old api
},
data : {cmd : 'get', target : file.hash },
preventDefault : true
})
.done(function(data) {
Expand Down
4 changes: 1 addition & 3 deletions js/commands/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ elFinder.prototype.commands.rename = function() {
parent = input.parent();

if (parent.length) {
// fm.log(name).log(file.name).log(name.length).log(file.name.length)
// return dfrd.reject();
if (name == file.name) {
return dfrd.reject();
}
Expand All @@ -75,7 +73,7 @@ elFinder.prototype.commands.rename = function() {
parent.html(fm.escape(name));
fm.lockfiles({files : [file.hash]});
fm.request({
data : {cmd : 'rename', target : file.hash, name : name, current : file.phash},
data : {cmd : 'rename', target : file.hash, name : name},
notify : {type : 'rename', cnt : 1}
})
.fail(function(error) {
Expand Down
2 changes: 1 addition & 1 deletion js/commands/rm.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ elFinder.prototype.commands.rm = function() {
callback : function() {
fm.lockfiles({files : files});
fm.request({
data : {cmd : 'rm', targets : files, current : fm.cwd().hash}, // current - for old api
data : {cmd : 'rm', targets : files},
notify : {type : 'rm', cnt : cnt},
preventFail : true
})
Expand Down
2 changes: 1 addition & 1 deletion js/commands/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ elFinder.prototype.commands.search = function() {
* @return Number
**/
this.getstate = function() {
return this.fm.oldAPI ? -1 : 0;
return 0;
}

/**
Expand Down
Loading

0 comments on commit 4f81b7b

Please sign in to comment.