mirror of
https://github.com/Studio-42/elFinder.git
synced 2026-06-19 07:37:19 +00:00
[cmd:edit:zoho] fix #2777 to show warning when editing items that can not be written anonymously
This commit is contained in:
+11
-7
@@ -365,18 +365,18 @@
|
||||
}
|
||||
|
||||
/* edit area */
|
||||
.ui-dialog .ui-dialog-content.elfinder-edit-editor {
|
||||
.elfinder-dialog-edit .ui-dialog-content.elfinder-edit-editor {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.ui-dialog .ui-dialog-content.elfinder-edit-editor .elfinder-edit-imageeditor {
|
||||
.elfinder-dialog-edit .ui-dialog-content.elfinder-edit-editor .elfinder-edit-imageeditor {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
max-height: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.ui-dialog .ui-dialog-content.elfinder-edit-editor .elfinder-edit-imageeditor * {
|
||||
.elfinder-dialog-edit .ui-dialog-content.elfinder-edit-editor .elfinder-edit-imageeditor * {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
@@ -397,7 +397,7 @@
|
||||
margin-bottom: -20em;
|
||||
}
|
||||
|
||||
.std42-dialog .ui-dialog-buttonpane .elfinder-dialog-confirm-encoding {
|
||||
.elfinder-dialog-edit .ui-dialog-buttonpane .elfinder-dialog-confirm-encoding {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.ui-dialog-buttonpane .ui-icon {
|
||||
.elfinder-dialog-edit .ui-dialog-buttonpane .ui-icon {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@@ -427,11 +427,15 @@
|
||||
font-size: 16pt;
|
||||
}
|
||||
|
||||
.elfinder-dialog .elfinder-edit-spinner .elfinder-spinner,
|
||||
.elfinder-dialog .elfinder-edit-spinner .elfinder-spinner-text {
|
||||
.elfinder-dialog-edit .elfinder-edit-spinner .elfinder-spinner,
|
||||
.elfinder-dialog-edit .elfinder-edit-spinner .elfinder-spinner-text {
|
||||
float: none;
|
||||
}
|
||||
|
||||
.elfinder-dialog-edit .elfinder-toast > div {
|
||||
width: 280px;
|
||||
}
|
||||
|
||||
.elfinder-edit-onlineconvert-button {
|
||||
display: inline-block;
|
||||
width: 180px;
|
||||
|
||||
@@ -85,3 +85,13 @@
|
||||
background-color: #7DC6DB;
|
||||
color: #046580;
|
||||
}
|
||||
|
||||
.elfinder .elfinder-toast > .toast-warning button.ui-button {
|
||||
background-color: #dd8c1a;
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
.elfinder .elfinder-toast > .toast-warning button.ui-button.ui-state-hover {
|
||||
background-color: #e7ae5e;
|
||||
color: #422a07;
|
||||
}
|
||||
|
||||
@@ -1995,6 +1995,7 @@
|
||||
init : function(id, file, dum, fm) {
|
||||
var ta = this,
|
||||
ifm = $(this).hide(),
|
||||
uiToast = fm.getUI('toast'),
|
||||
spnr = $('<div class="elfinder-edit-spinner elfinder-edit-zohoeditor"/>')
|
||||
.html('<span class="elfinder-spinner-text">' + fm.i18n('nowLoading') + '</span><span class="elfinder-spinner"/>')
|
||||
.appendTo(ifm.parent()),
|
||||
@@ -2033,6 +2034,20 @@
|
||||
});
|
||||
|
||||
ifm.attr('src', data.zohourl).show().css(opts.css);
|
||||
if (data.warning) {
|
||||
uiToast.appendTo(ta.closest('.ui-dialog'));
|
||||
fm.toast({
|
||||
msg: fm.i18n(data.warning),
|
||||
mode: 'warning',
|
||||
timeOut: 0,
|
||||
onHidden: function() {
|
||||
uiToast.children().length === 1 && uiToast.appendTo(fm.getUI());
|
||||
},
|
||||
button: {
|
||||
text: 'btnYes'
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
data.error && fm.error(data.error);
|
||||
ta.elfinderdialog('destroy');
|
||||
@@ -2166,7 +2181,6 @@
|
||||
Hash: 'txt'
|
||||
},
|
||||
link : '<div class="elfinder-edit-onlineconvert-link"><a href="https://www.online-convert.com" target="_blank"><span class="elfinder-button-icon"></span>ONLINE-CONVERT.COM</a></div>',
|
||||
toastWidth : 280,
|
||||
useTabs : ($.fn.tabs && !fm.UA.iOS)? true : false // Can't work on iOS, I don't know why.
|
||||
}, mOpts);
|
||||
},
|
||||
@@ -2470,7 +2484,6 @@
|
||||
msg: fm.i18n(res.message),
|
||||
mode: 'error',
|
||||
timeOut: 5000,
|
||||
width: set.toastWidth,
|
||||
onHidden: function() {
|
||||
uiToast.children().length === 1 && uiToast.appendTo(fm.getUI());
|
||||
}
|
||||
@@ -2480,7 +2493,6 @@
|
||||
msg: fm.i18n('editorConvNoApi'),
|
||||
mode: 'warning',
|
||||
timeOut: 3000,
|
||||
width: set.toastWidth,
|
||||
onHidden: function() {
|
||||
uiToast.children().length === 1 && uiToast.appendTo(fm.getUI());
|
||||
open(cat, con);
|
||||
@@ -2566,8 +2578,7 @@
|
||||
fm.toast({
|
||||
msg: fm.i18n('editorConvNeedUpload'),
|
||||
mode: 'info',
|
||||
timeOut: 10000,
|
||||
width: set.toastWidth,
|
||||
timeOut: 15000,
|
||||
onHidden: function() {
|
||||
uiToast.children().length === 1 && uiToast.appendTo(fm.getUI());
|
||||
},
|
||||
|
||||
@@ -492,6 +492,7 @@
|
||||
'author' : 'Author', // from v2.1.43 added 19.10.2018
|
||||
'email' : 'Email', // from v2.1.43 added 19.10.2018
|
||||
'license' : 'License', // from v2.1.43 added 19.10.2018
|
||||
'exportToSave' : 'This item can\'t be saved. To avoid losing the edits you need to export to your PC.', // from v2.1.44 added 1.12.2018
|
||||
|
||||
/********************************** mimetypes **********************************/
|
||||
'kindUnknown' : 'Unknown',
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* English translation
|
||||
* @author Troex Nevelin <troex@fury.scancode.ru>
|
||||
* @author Naoki Sawada <hypweb+elfinder@gmail.com>
|
||||
* @version 2018-10-19
|
||||
* @version 2018-12-01
|
||||
*/
|
||||
// elfinder.en.js is integrated into elfinder.(full|min).js by jake build
|
||||
if (typeof elFinder === 'function' && elFinder.prototype.i18) {
|
||||
@@ -479,6 +479,7 @@ if (typeof elFinder === 'function' && elFinder.prototype.i18) {
|
||||
'author' : 'Author', // from v2.1.43 added 19.10.2018
|
||||
'email' : 'Email', // from v2.1.43 added 19.10.2018
|
||||
'license' : 'License', // from v2.1.43 added 19.10.2018
|
||||
'exportToSave' : 'This item can\'t be saved. To avoid losing the edits you need to export to your PC.', // from v2.1.44 added 1.12.2018
|
||||
|
||||
/********************************** mimetypes **********************************/
|
||||
'kindUnknown' : 'Unknown',
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Japanese translation
|
||||
* @author Tomoaki Yoshida <info@yoshida-studio.jp>
|
||||
* @author Naoki Sawada <hypweb+elfinder@gmail.com>
|
||||
* @version 2018-10-19
|
||||
* @version 2018-12-01
|
||||
*/
|
||||
(function(root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
@@ -486,6 +486,7 @@
|
||||
'author' : '作者', // from v2.1.43 added 19.10.2018
|
||||
'email' : 'Email', // from v2.1.43 added 19.10.2018
|
||||
'license' : 'ライセンス', // from v2.1.43 added 19.10.2018
|
||||
'exportToSave' : 'このアイテムは保存できません。 編集内容を失わないようにするには、PCにエクスポートする必要があります。', // from v2.1.44 added 1.12.2018
|
||||
|
||||
/********************************** mimetypes **********************************/
|
||||
'kindUnknown' : '不明',
|
||||
|
||||
@@ -4,7 +4,7 @@ class elFinderEditorZohoOffice extends elFinderEditor
|
||||
{
|
||||
private static $curlTimeout = 20;
|
||||
|
||||
protected $allowed = array('init', 'save');
|
||||
protected $allowed = array('init', 'save', 'chk');
|
||||
|
||||
private $urls = array(
|
||||
'writer' => 'https://writer.zoho.com/writer/remotedoc.im',
|
||||
@@ -46,6 +46,24 @@ class elFinderEditorZohoOffice extends elFinderEditor
|
||||
$fp = $cfile = null;
|
||||
$hash = $this->args['target'];
|
||||
if (($srcVol = $this->elfinder->getVolume($hash)) && ($file = $srcVol->file($hash))) {
|
||||
$cdata = empty($this->args['cdata']) ? '' : $this->args['cdata'];
|
||||
$cookie = $this->elfinder->getFetchCookieFile();
|
||||
$save = false;
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, elFinder::getConnectorUrl().'?cmd=editor&name=ZohoOffice&method=chk&args[target]='.rawurlencode($hash).$cdata);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
if ($cookie) {
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
|
||||
}
|
||||
$res = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($res) {
|
||||
if ($data = json_decode($res, true)) {
|
||||
$save = !empty($data['cansave']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($size = $file['size']) {
|
||||
$src = $srcVol->open($hash);
|
||||
$fp = tmpfile();
|
||||
@@ -68,7 +86,6 @@ class elFinderEditorZohoOffice extends elFinderEditor
|
||||
if (!$format) {
|
||||
$format = substr($file['name'], strrpos($file['name'], '.') * -1);
|
||||
}
|
||||
$cdata = empty($this->args['cdata']) ? '' : $this->args['cdata'];
|
||||
$lang = $this->args['lang'];
|
||||
if ($lang === 'jp') {
|
||||
$lang = 'ja';
|
||||
@@ -81,9 +98,11 @@ class elFinderEditorZohoOffice extends elFinderEditor
|
||||
'filename' => $file['name'],
|
||||
'id' => $hash,
|
||||
'format' => $format,
|
||||
'lang' => $lang,
|
||||
'saveurl' => elFinder::getConnectorUrl().'?cmd=editor&name=ZohoOffice&method=save'.$cdata,
|
||||
'lang' => $lang
|
||||
);
|
||||
if ($save) {
|
||||
$data['saveurl'] = elFinder::getConnectorUrl().'?cmd=editor&name=ZohoOffice&method=save'.$cdata;
|
||||
}
|
||||
if ($cfile) {
|
||||
$data['content'] = $cfile;
|
||||
}
|
||||
@@ -105,7 +124,12 @@ class elFinderEditorZohoOffice extends elFinderEditor
|
||||
list(, $url) = explode('URL=', $res);
|
||||
preg_match('/URL=([^\s]+)/', $res, $m);
|
||||
|
||||
return array('zohourl' => $m[1]);
|
||||
$ret = array('zohourl' => $m[1]);
|
||||
if (!$save) {
|
||||
$ret['warning'] = 'exportToSave';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
} else {
|
||||
$error = $res;
|
||||
}
|
||||
@@ -133,4 +157,16 @@ class elFinderEditorZohoOffice extends elFinderEditor
|
||||
}
|
||||
return array('raw' => true, 'error' => '', 'header' => 'HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
|
||||
public function chk()
|
||||
{
|
||||
$hash = $this->args['target'];
|
||||
$res = false;
|
||||
if ($volume = $this->elfinder->getVolume($hash)) {
|
||||
if ($file = $volume->file($hash)) {
|
||||
$res = (bool)$file['write'];
|
||||
}
|
||||
}
|
||||
return array('cansave' => $res);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4341,6 +4341,19 @@ class elFinder {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fetch cookie file for curl.
|
||||
*
|
||||
* @return string The fetch cookie file.
|
||||
*/
|
||||
public function getFetchCookieFile() {
|
||||
$file = '';
|
||||
if ($tmpDir = $this->getTempDir()) {
|
||||
$file = $tmpDir . '/.elFinderAnonymousCookie';
|
||||
}
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call curl_exec() with supported redirect on `safe_mode` or `open_basedir`
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user