: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @class elFinder command "open"
* Enter folder or open files in new windows
* @author Dmitry (dio) Levashov
(elFinder.prototype.commands.open = function() {
this.alwaysEnabled = true;
this.noChangeDirOnRemovedCwd = true;
var arg = e.data && e.data.file? [ e.data.file ]: void(0);
if (self.getstate(arg) === 0) {
'select enable disable reload' : function(e) { this.update(e.type == 'disable' ? -1 : void(0)); }
pattern : 'ctrl+down numpad_enter'+(fm.OS != 'mac' && ' enter')
this.getstate = function(select) {
var sel = this.files(select),
filter = function(files) {
return jQuery.grep(files, function(file) {
fres = fres && file.mime == 'directory' || ! file.read ? false : true;
: (cnt && !fm.UA.Mobile) ? (jQuery.grep(sel, function(file) { return file.mime == 'directory' || ! file.read ? false : true;}).length == cnt ? 0 : -1) : -1;
this.exec = function(hashes, cOpts) {
var dfrd = jQuery.Deferred().fail(function(error) { error && fm.error(error); }),
files = this.files(hashes),
thash = (typeof cOpts == 'object')? cOpts.thash : false,
into = opts.into || 'window',
file, url, s, w, imgW, imgH, winW, winH, reg, link, html5dl, inline,
if (thash || (cnt == 1 && (file = files[0]) && file.mime == 'directory')) {
if (!thash && file && !file.read) {
return dfrd.reject(['errOpen', file.name, 'errPerm']);
if (fm.keyState.ctrlKey && (fm.keyState.shiftKey || typeof fm.options.getFileCallback !== 'function')) {
if (fm.getCommand('opennew')) {
return fm.exec('opennew', [thash? thash : file.hash]);
data : {cmd : 'open', target : thash || file.hash},
notify : {type : 'open', cnt : 1, hideCnt : true},
files = jQuery.grep(files, function(file) { return file.mime != 'directory' ? true : false; });
// nothing to open or files and folders selected - do nothing
if (cnt != files.length) {
var doOpen = function() {
var openCB = function(url) {
var link = jQuery('<a rel="noopener">').hide().appendTo(jQuery('body'));
if (fm.UA.Mobile || !inline) {
link.attr('download', file.name);
link.attr('target', '_blank');
link.attr('href', url).get(0).click();
return dfrd.reject('errPopup');
getOnly = (typeof opts.method === 'string' && opts.method.toLowerCase() === 'get');
&& url.indexOf(fm.options.url) === 0
&& Object.keys(fm.customData).length
// Since playback by POST request can not be done in Chrome, media allows GET request
&& !file.mime.match(/^(?:video|audio)/)
// Send request as 'POST' method to hide custom data at location bar
// set window size for image if set
imgW = winW = Math.round(2 * screen.availWidth / 3);
imgH = winH = Math.round(2 * screen.availHeight / 3);
if (parseInt(file.width) && parseInt(file.height)) {
imgW = parseInt(file.width);
imgH = parseInt(file.height);
if (winW >= imgW && winH >= imgH) {
if ((imgW - winW) > (imgH - winH)) {
winH = Math.round(imgH * (winW / imgW));
winW = Math.round(imgW * (winH / imgH));
w = 'width='+winW+',height='+winH;
wnd = window.open(url, target, w + ',top=50,left=50,scrollbars=yes,resizable=yes,titlebar=no');
wnd = window.open('about:blank', target);
return dfrd.reject('errPopup');
var form = document.createElement("form");
form.action = fm.options.url;
form.style.display = 'none';
var params = Object.assign({}, fm.customData, {
_t: file.ts || parseInt(+new Date()/1000)
jQuery.each(params, function(key, val)
var input = document.createElement("input");
document.body.appendChild(form);
} else if (into !== 'window') {
jQuery(wnd).trigger('focus');
reg = new RegExp(fm.option('dispInlineRegex'), 'i');
html5dl = (typeof jQuery('<a>').get(0).download === 'string');
target = 'elf_open_window';
return dfrd.reject(['errOpen', file.name, 'errPerm']);
inline = (reg && file.mime.match(reg));
fm.openUrl(file.hash, !inline, openCB);
return dfrd.resolve(hashes);
text : ['openMultiConfirm', cnt + ''],
callback : function() { doOpen(); }
buttons : (fm.getCommand('zipdl') && fm.isCommandEnabled('zipdl', fm.cwd().hash))? [
fm.exec('download', hashes);
selAct = fm.storage('selectAction') || opts.selectAction;
jQuery.each(selAct.split('/'), function() {
var cmdName = this.valueOf();
if (cmdName !== 'open' && (cmd = fm.getCommand(cmdName)) && cmd.enabled()) {
return fm.exec(cmd.name);
}).prototype = { forceLoad : true }; // this is required command