Edit File by line
/home/barbar84/www/wp-conte.../plugins/file-man.../applicat.../library/js/commands
File: archive.js
/**
[0] Fix | Delete
* @class elFinder command "archive"
[1] Fix | Delete
* Archive selected files
[2] Fix | Delete
*
[3] Fix | Delete
* @author Dmitry (dio) Levashov
[4] Fix | Delete
**/
[5] Fix | Delete
elFinder.prototype.commands.archive = function() {
[6] Fix | Delete
"use strict";
[7] Fix | Delete
var self = this,
[8] Fix | Delete
fm = self.fm,
[9] Fix | Delete
mimes = [],
[10] Fix | Delete
dfrd;
[11] Fix | Delete
[12] Fix | Delete
this.variants = [];
[13] Fix | Delete
[14] Fix | Delete
this.disableOnSearch = false;
[15] Fix | Delete
[16] Fix | Delete
this.nextAction = {};
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Update mimes on open/reload
[20] Fix | Delete
*
[21] Fix | Delete
* @return void
[22] Fix | Delete
**/
[23] Fix | Delete
fm.bind('open reload', function() {
[24] Fix | Delete
self.variants = [];
[25] Fix | Delete
$.each((mimes = fm.option('archivers')['create'] || []), function(i, mime) {
[26] Fix | Delete
self.variants.push([mime, fm.mime2kind(mime)]);
[27] Fix | Delete
});
[28] Fix | Delete
self.change();
[29] Fix | Delete
});
[30] Fix | Delete
[31] Fix | Delete
this.getstate = function(select) {
[32] Fix | Delete
var sel = this.files(select),
[33] Fix | Delete
cnt = sel.length,
[34] Fix | Delete
chk = (cnt && ! fm.isRoot(sel[0]) && (fm.file(sel[0].phash) || {}).write),
[35] Fix | Delete
filter = function(files) {
[36] Fix | Delete
var fres = true;
[37] Fix | Delete
return $.grep(files, function(f) {
[38] Fix | Delete
fres = fres && f.read && f.hash.indexOf(cwdId) === 0 ? true : false;
[39] Fix | Delete
return fres;
[40] Fix | Delete
});
[41] Fix | Delete
},
[42] Fix | Delete
cwdId;
[43] Fix | Delete
[44] Fix | Delete
if (chk && fm.searchStatus.state > 1) {
[45] Fix | Delete
if (chk = (cnt === filter(sel).length)) {
[46] Fix | Delete
cwdId = fm.cwd().volumeid;
[47] Fix | Delete
}
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
return chk && !this._disabled && mimes.length && (cnt || (dfrd && dfrd.state() == 'pending')) ? 0 : -1;
[51] Fix | Delete
};
[52] Fix | Delete
[53] Fix | Delete
this.exec = function(hashes, type) {
[54] Fix | Delete
var files = this.files(hashes),
[55] Fix | Delete
cnt = files.length,
[56] Fix | Delete
mime = type || mimes[0],
[57] Fix | Delete
cwd = fm.file(files[0].phash) || null,
[58] Fix | Delete
error = ['errArchive', 'errPerm', 'errCreatingTempDir', 'errFtpDownloadFile', 'errFtpUploadFile', 'errFtpMkdir', 'errArchiveExec', 'errExtractExec', 'errRm'],
[59] Fix | Delete
i, open;
[60] Fix | Delete
[61] Fix | Delete
dfrd = $.Deferred().fail(function(error) {
[62] Fix | Delete
error && fm.error(error);
[63] Fix | Delete
});
[64] Fix | Delete
[65] Fix | Delete
if (! (cnt && mimes.length && $.inArray(mime, mimes) !== -1)) {
[66] Fix | Delete
return dfrd.reject();
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
if (!cwd.write) {
[70] Fix | Delete
return dfrd.reject(error);
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
for (i = 0; i < cnt; i++) {
[74] Fix | Delete
if (!files[i].read) {
[75] Fix | Delete
return dfrd.reject(error);
[76] Fix | Delete
}
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
self.mime = mime;
[80] Fix | Delete
self.prefix = ((cnt > 1)? 'Archive' : files[0].name) + (fm.option('archivers')['createext']? '.' + fm.option('archivers')['createext'][mime] : '');
[81] Fix | Delete
self.data = {targets : self.hashes(hashes), type : mime};
[82] Fix | Delete
[83] Fix | Delete
if (fm.cwd().hash !== cwd.hash) {
[84] Fix | Delete
open = fm.exec('open', cwd.hash).done(function() {
[85] Fix | Delete
fm.one('cwdrender', function() {
[86] Fix | Delete
fm.selectfiles({files : hashes});
[87] Fix | Delete
dfrd = $.proxy(fm.res('mixin', 'make'), self)();
[88] Fix | Delete
});
[89] Fix | Delete
});
[90] Fix | Delete
} else {
[91] Fix | Delete
fm.selectfiles({files : hashes});
[92] Fix | Delete
dfrd = $.proxy(fm.res('mixin', 'make'), self)();
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
return dfrd;
[96] Fix | Delete
};
[97] Fix | Delete
[98] Fix | Delete
};
[99] Fix | Delete
[100] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function