Compare commits

...

22 Commits

Author SHA1 Message Date
80b081883e Fix Bug 34711 - css iPhone4s 2017-04-27 15:46:19 +03:00
7c71d42975 Fix download link for custom EXAMPLE_URL (Issue #24) 2017-04-25 19:28:43 +03:00
a52d5cb3be Fix Bug 33758 - replacing address for document server (exampleUrl) 2017-04-25 18:30:39 +03:00
a9d261a0ad Fix Bug 34620 - resize on mobile 2017-04-25 17:55:45 +03:00
5dea4c77a9 Fix Bug 34739 - encode ' 2017-04-25 17:42:51 +03:00
8eb017b092 nodejs: plugins new format 2017-04-25 17:08:04 +03:00
dd346a380e Merge tag 'v4.3.2' into develop
v4.3.2 v4.3.2
2017-04-17 14:59:31 +03:00
61497a8da7 Merge branch 'hotfix/v4.3.2' 2017-04-17 14:59:29 +03:00
34d568bdbc Fix goback button 2017-04-06 18:42:18 +03:00
905084dc52 Fix goback button 2017-04-06 17:22:13 +03:00
e00b662660 Merge tag 'v4.3.0' into develop
v4.3.0
2017-04-03 12:58:54 +03:00
5ded3f6135 Merge branch 'release/v4.3.0' 2017-04-03 12:58:44 +03:00
a096e96b29 Fix Bug 34518 - "Uncaught SyntaxError: Unexpected token }" 2017-03-27 14:31:58 +03:00
b452a171d1 nodejs: append dependencies 2017-03-21 10:40:03 +03:00
282ea78799 Merge pull request #22 from ONLYOFFICE/feature/forcesave
Feature/forcesave
2017-03-16 15:58:38 +03:00
4824373678 nodejs: forcesave configuration for new sсheme editing 2017-03-16 15:57:07 +03:00
df8a575d75 ignore vscode 2017-03-16 15:54:40 +03:00
e023ec3bb7 nodejs: download forcesaved file, delete forcesaved file after saving 2017-03-16 14:53:12 +03:00
535ba03cdf nodejs: download file via handler 2017-03-16 14:36:34 +03:00
f5d416e371 nodejs: forcesave to history directory 2017-03-16 14:03:22 +03:00
931e05a175 nodejs: jwt for historyData 2017-03-15 17:54:04 +03:00
293919bb6e nodejs: new arguments in setHistoryData 2017-03-15 17:46:34 +03:00
12 changed files with 273 additions and 148 deletions

1
.gitignore vendored
View File

@ -8,4 +8,5 @@
/web/documentserver-example/nodejs/node_modules
/web/documentserver-example/nodejs/public/files
/web/documentserver-example/nodejs/config/local.json
**/.vscode/
**/.idea

View File

@ -33,6 +33,7 @@ const syncRequest = require("sync-request");
const jwt = require('jsonwebtoken');
const config = require('config');
const configServer = config.get('server');
const mime = require("mime");
const docManager = require("./helpers/docManager");
const documentService = require("./helpers/documentService");
const fileUtility = require("./helpers/fileUtility");
@ -115,6 +116,26 @@ app.get("/", function (req, res) {
}
});
app.get("/download", function(req, res) {
docManager.init(__dirname, req, res);
var fileName = fileUtility.getFileName(req.query.fileName);
var userAddress = docManager.curUserHostAddress();
var path = docManager.forcesavePath(fileName, userAddress, false);
if (path == "") {
path = docManager.storagePath(fileName, userAddress);
}
res.setHeader("Content-Length", fileSystem.statSync(path).size);
res.setHeader("Content-Type", mime.lookup(path));
res.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
var filestream = fileSystem.createReadStream(path);
filestream.pipe(res);
});
app.post("/upload", function (req, res) {
docManager.init(__dirname, req, res);
@ -301,7 +322,7 @@ app.post("/track", function (req, res) {
var processTrack = function (response, body, fileName, userAddress) {
var processSave = function (downloadUri, body, fileName, userAddress, resp, newVersion) {
var processSave = function (downloadUri, body, fileName, userAddress, resp) {
var curExt = fileUtility.getFileExtension(fileName);
var downloadExt = fileUtility.getFileExtension(downloadUri);
@ -309,8 +330,8 @@ app.post("/track", function (req, res) {
var key = documentService.generateRevisionId(downloadUri);
try {
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function(dUri){
processSave(dUri, body, fileName, userAddress, resp, newVersion)
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function (dUri) {
processSave(dUri, body, fileName, userAddress, resp)
});
return;
} catch (ex) {
@ -323,40 +344,80 @@ app.post("/track", function (req, res) {
var path = docManager.storagePath(fileName, userAddress);
if (newVersion) {
var historyPath = docManager.historyPath(fileName, userAddress);
if (historyPath == "") {
historyPath = docManager.historyPath(fileName, userAddress, true);
docManager.createDirectory(historyPath);
}
var count_version = docManager.countVersion(historyPath);
version = count_version + 1;
versionPath = docManager.versionPath(fileName, userAddress, version);
docManager.createDirectory(versionPath);
var downloadZip = body.changesurl;
if (downloadZip) {
var path_changes = docManager.diffPath(fileName, userAddress, version);
var diffZip = syncRequest("GET", downloadZip);
fileSystem.writeFileSync(path_changes, diffZip.getBody());
}
var changeshistory = body.changeshistory || JSON.stringify(body.history);
if (changeshistory) {
var path_changes_json = docManager.changesPath(fileName, userAddress, version);
fileSystem.writeFileSync(path_changes_json, changeshistory);
}
var path_key = docManager.keyPath(fileName, userAddress, version);
fileSystem.writeFileSync(path_key, body.key);
var path_prev = docManager.prevFilePath(fileName, userAddress, version);
fileSystem.writeFileSync(path_prev, fileSystem.readFileSync(path));
var historyPath = docManager.historyPath(fileName, userAddress);
if (historyPath == "") {
historyPath = docManager.historyPath(fileName, userAddress, true);
docManager.createDirectory(historyPath);
}
var count_version = docManager.countVersion(historyPath);
version = count_version + 1;
versionPath = docManager.versionPath(fileName, userAddress, version);
docManager.createDirectory(versionPath);
var downloadZip = body.changesurl;
if (downloadZip) {
var path_changes = docManager.diffPath(fileName, userAddress, version);
var diffZip = syncRequest("GET", downloadZip);
fileSystem.writeFileSync(path_changes, diffZip.getBody());
}
var changeshistory = body.changeshistory || JSON.stringify(body.history);
if (changeshistory) {
var path_changes_json = docManager.changesPath(fileName, userAddress, version);
fileSystem.writeFileSync(path_changes_json, changeshistory);
}
var path_key = docManager.keyPath(fileName, userAddress, version);
fileSystem.writeFileSync(path_key, body.key);
var path_prev = docManager.prevFilePath(fileName, userAddress, version);
fileSystem.writeFileSync(path_prev, fileSystem.readFileSync(path));
var file = syncRequest("GET", downloadUri);
fileSystem.writeFileSync(path, file.getBody());
var forcesavePath = docManager.forcesavePath(fileName, userAddress, false);
if (forcesavePath != "") {
fileSystem.unlinkSync(forcesavePath);
}
} catch (ex) {
console.log(ex);
}
response.write("{\"error\":0}");
response.end();
};
var processForceSave = function (downloadUri, body, fileName, userAddress, resp) {
var curExt = fileUtility.getFileExtension(fileName);
var downloadExt = fileUtility.getFileExtension(downloadUri);
if (downloadExt != curExt) {
var key = documentService.generateRevisionId(downloadUri);
try {
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function (dUri) {
processForceSave(dUri, body, fileName, userAddress, resp)
});
return;
} catch (ex) {
console.log(ex);
fileName = docManager.getCorrectName(fileUtility.getFileName(fileName, true) + downloadExt, userAddress)
}
}
try {
var path = docManager.storagePath(fileName, userAddress);
var forcesavePath = docManager.forcesavePath(fileName, userAddress, false);
if (forcesavePath == "") {
forcesavePath = docManager.forcesavePath(fileName, userAddress, true);
}
var file = syncRequest("GET", downloadUri);
fileSystem.writeFileSync(forcesavePath, file.getBody());
} catch (ex) {
console.log(ex);
}
@ -378,10 +439,11 @@ app.post("/track", function (req, res) {
}
}
} else if (body.status == 2 || body.status == 3 //MustSave, Corrupted
|| body.status == 6 || body.status == 7) { //MustForceSave, CorruptedForceSave
var newVersion = (body.status == 2 || body.status == 3);
processSave(body.url, body, fileName, userAddress, response, newVersion);
} else if (body.status == 2 || body.status == 3) { //MustSave, Corrupted
processSave(body.url, body, fileName, userAddress, response);
return;
} else if (body.status == 6 || body.status == 7) { //MustForceSave, CorruptedForceSave
processForceSave(body.url, body, fileName, userAddress, response);
return;
}
@ -437,8 +499,7 @@ app.get("/editor", function (req, res) {
var fileExt = req.query.fileExt;
var history = [];
var prevUrl = [];
var diff = [];
var historyData = [];
var lang = docManager.getLang();
var userid = req.query.userid ? req.query.userid : "uid-1";
var name = req.query.name ? req.query.name : "Jonn Smith";
@ -452,7 +513,7 @@ app.get("/editor", function (req, res) {
}
var userAddress = docManager.curUserHostAddress();
fileName = fileUtility.getFileName(req.query.fileName);
var fileName = fileUtility.getFileName(req.query.fileName);
var key = docManager.getKey(fileName);
var url = docManager.getFileUri(fileName);
var mode = req.query.mode || "edit"; //mode: view/edit
@ -466,33 +527,55 @@ app.get("/editor", function (req, res) {
var countVersion = 1;
var historyPath = docManager.historyPath(fileName, userAddress);
changes = null;
var changes = null;
var keyVersion = key;
if (historyPath != '') {
countVersion = docManager.countVersion(historyPath) + 1;
var prevPath = docManager.getlocalFileUri(fileName, 1) + "/prev" + fileUtility.getFileExtension(fileName);
var diffPath = null;
for (var i = 1; i < countVersion; i++) {
var keyPath = docManager.keyPath(fileName, userAddress, i);
var keyVersion = "" + fileSystem.readFileSync(keyPath);
for (var i = 1; i <= countVersion; i++) {
if (i < countVersion) {
var keyPath = docManager.keyPath(fileName, userAddress, i);
keyVersion = "" + fileSystem.readFileSync(keyPath);
} else {
keyVersion = key;
}
history.push(docManager.getHistory(fileName, changes, keyVersion, i));
prevUrl.push(prevPath);
prevPath = docManager.getlocalFileUri(fileName, i) + "/prev" + fileUtility.getFileExtension(fileName);
diff.push(diffPath);
diffPath = docManager.getlocalFileUri(fileName, i) + "/diff.zip";
var changesFile = docManager.changesPath(fileName, userAddress, i);
var changes = docManager.getChanges(changesFile);
var historyD = {
version: i,
key: keyVersion,
url: i == countVersion ? url : (docManager.getlocalFileUri(fileName, i, true) + "/prev" + fileUtility.getFileExtension(fileName)),
};
if (i > 1) {
historyD.previous = {
key: historyData[i-2].key,
url: historyData[i-2].url,
};
historyD.changesUrl = docManager.getlocalFileUri(fileName, i-1) + "/diff.zip";
}
historyData.push(historyD);
if (i < countVersion) {
var changesFile = docManager.changesPath(fileName, userAddress, i);
changes = docManager.getChanges(changesFile);
}
}
prevUrl.push(prevPath);
diff.push(diffPath);
} else {
prevUrl.push(url);
history.push(docManager.getHistory(fileName, changes, keyVersion, countVersion));
historyData.push({
version: countVersion,
key: key,
url: url
});
}
if (cfgSignatureEnable) {
for (var i = 0; i < historyData.length; i++) {
historyData[i].token = jwt.sign(historyData[i], cfgSignatureSecret, {expiresIn: cfgSignatureSecretExpiresIn});
}
}
history.push(docManager.getHistory(fileName, changes, key, countVersion));
var argss = {
apiUrl: siteUrl + configServer.get('apiUrl'),
@ -512,7 +595,7 @@ app.get("/editor", function (req, res) {
isEdit: canEdit && mode != "review",
mode: canEdit && mode != "view" ? "edit" : "view",
canBackToFolder: type != "embedded",
getServerUrl: type == "embedded" ? null : "\"" + docManager.getServerUrl() + "\"",
backUrl: docManager.getServerUrl(),
curUserHostAddress: docManager.curUserHostAddress(),
lang: lang,
userid: userid,
@ -521,10 +604,7 @@ app.get("/editor", function (req, res) {
plugins: JSON.stringify(plugins)
},
history: history,
setHistoryData: {
url: prevUrl,
changesUrl: diff
}
historyData: historyData
};
if (cfgSignatureEnable) {

View File

@ -19,6 +19,7 @@
"tempStorageUrl": "ResourceService.ashx",
"apiUrl": "web-apps/apps/api/documents/api.js",
"preloaderUrl": "web-apps/apps/api/documents/cache-scripts.html",
"exampleUrl": null,
"viewedDocs": [".ppt", ".pps", ".odp", ".pdf", ".djvu", ".epub", ".xps"],
"editedDocs": [".docx", ".doc", ".odt", ".xlsx", ".xls", ".ods", ".csv", ".pptx", ".ppsx", ".rtf", ".txt", ".mht", ".html", ".htm"],
"convertedDocs": [".doc", ".odt", ".xls", ".ods", ".ppt", ".pps", ".odp", ".rtf", ".mht", ".html", ".htm", ".epub"],
@ -42,7 +43,6 @@
}
},
"plugins": {
"url": "",
"pluginsData": []
}
}

View File

@ -79,30 +79,30 @@ docManager.getLang = function () {
docManager.getCustomParams = function () {
let params = "";
const userid = docManager.req.query.userid;
const userid = docManager.req.query.userid;
params += (userid ? "&userid=" + userid : "");
const name = docManager.req.query.name;
const name = docManager.req.query.name;
params += (name ? "&name=" + name : "");
const lang = docManager.req.query.lang;
const lang = docManager.req.query.lang;
params += (lang ? "&lang=" + docManager.getLang() : "");
const fileName = docManager.req.query.fileName;
const fileName = docManager.req.query.fileName;
params += (fileName ? "&fileName=" + fileName : "");
const mode = docManager.req.query.mode;
const mode = docManager.req.query.mode;
params += (mode ? "&mode=" + mode : "");
const type = docManager.req.query.type;
const type = docManager.req.query.type;
params += (type ? "&type=" + type : "");
return params;
};
docManager.getCorrectName = function (fileName, userAddress) {
const baseName = fileUtility.getFileName(fileName, true);
const ext = fileUtility.getFileExtension(fileName);
const baseName = fileUtility.getFileName(fileName, true);
const ext = fileUtility.getFileExtension(fileName);
let name = baseName + ext;
let index = 1;
@ -125,14 +125,14 @@ docManager.createDemo = function (demoName, userid, username) {
};
docManager.saveFileData = function (fileName, userid, username) {
const userAddress = docManager.curUserHostAddress();
const date_create = fileSystem.statSync(docManager.storagePath(fileName)).mtime;
const minutes = (date_create.getMinutes() < 10 ? '0' : '') + date_create.getMinutes().toString();
const month = (date_create.getMonth() < 10 ? '0' : '') + (parseInt(date_create.getMonth().toString()) + 1);
const sec = (date_create.getSeconds() < 10 ? '0' : '') + date_create.getSeconds().toString();
const date_format = date_create.getFullYear() + "-" + month + "-" + date_create.getDate() + " " + date_create.getHours() + ":" + minutes + ":" + sec;
const userAddress = docManager.curUserHostAddress();
const date_create = fileSystem.statSync(docManager.storagePath(fileName)).mtime;
const minutes = (date_create.getMinutes() < 10 ? '0' : '') + date_create.getMinutes().toString();
const month = (date_create.getMonth() < 10 ? '0' : '') + (parseInt(date_create.getMonth().toString()) + 1);
const sec = (date_create.getSeconds() < 10 ? '0' : '') + date_create.getSeconds().toString();
const date_format = date_create.getFullYear() + "-" + month + "-" + date_create.getDate() + " " + date_create.getHours() + ":" + minutes + ":" + sec;
const file_info = docManager.historyPath(fileName, userAddress, true);
const file_info = docManager.historyPath(fileName, userAddress, true);
this.createDirectory(file_info);
fileSystem.writeFileSync(path.join(file_info, fileName + ".txt"), date_format + "," + userid + "," + username);
@ -148,28 +148,28 @@ docManager.getFileData = function (fileName, userAddress) {
};
docManager.getFileUri = function (fileName) {
return docManager.getlocalFileUri(fileName);
return docManager.getlocalFileUri(fileName, 0, true);
};
docManager.getlocalFileUri = function (fileName, version) {
const serverPath = docManager.getServerUrl();
const storagePath = storageFolder.length ? storageFolder + "/" : "";
const hostAddress = docManager.curUserHostAddress();
const url = serverPath + "/" + storagePath + hostAddress + "/" + encodeURIComponent(fileName);
docManager.getlocalFileUri = function (fileName, version, forDocumentServer) {
const serverPath = docManager.getServerUrl(forDocumentServer);
const storagePath = storageFolder.length ? storageFolder + "/" : "";
const hostAddress = docManager.curUserHostAddress();
const url = serverPath + "/" + storagePath + hostAddress + "/" + encodeURIComponent(fileName);
if (!version) {
return url;
}
return url + "-history/" + version;
};
docManager.getServerUrl = function () {
return docManager.getProtocol() + "://" + docManager.req.get("host");
docManager.getServerUrl = function (forDocumentServer) {
return (forDocumentServer && !!configServer.get("exampleUrl")) ? configServer.get("exampleUrl") : (docManager.getProtocol() + "://" + docManager.req.get("host"));
};
docManager.getCallback = function (fileName) {
const server = docManager.getServerUrl();
const hostAddress = docManager.curUserHostAddress();
const handler = "/track?filename=" + encodeURIComponent(fileName) + "&useraddress=" + encodeURIComponent(hostAddress);
const server = docManager.getServerUrl(true);
const hostAddress = docManager.curUserHostAddress();
const handler = "/track?filename=" + encodeURIComponent(fileName) + "&useraddress=" + encodeURIComponent(hostAddress);
return server + handler;
};
@ -181,6 +181,23 @@ docManager.storagePath = function (fileName, userAddress) {
return path.join(directory, fileName);
};
docManager.forcesavePath = function (fileName, userAddress, create) {
let directory = path.join(docManager.dir, "public", storageFolder, docManager.curUserHostAddress(userAddress));
if (!this.existsSync(directory)) {
return "";
}
directory = path.join(directory, fileName + "-history");
if (!create && !this.existsSync(directory)) {
return "";
}
this.createDirectory(directory);
directory = path.join(directory, fileName);
if (!create && !this.existsSync(directory)) {
return "";
}
return directory;
};
docManager.historyPath = function (fileName, userAddress, create) {
let directory = path.join(docManager.dir, "public", storageFolder, docManager.curUserHostAddress(userAddress));
if (!this.existsSync(directory)) {
@ -194,7 +211,7 @@ docManager.historyPath = function (fileName, userAddress, create) {
};
docManager.versionPath = function (fileName, userAddress, version) {
const historyPath = docManager.historyPath(fileName, userAddress, true);
const historyPath = docManager.historyPath(fileName, userAddress, true);
return path.join(historyPath, "" + version);
};
@ -219,20 +236,19 @@ docManager.changesUser = function (fileName, userAddress, version) {
};
docManager.getStoredFiles = function () {
const directory = path.join(docManager.dir, "public", storageFolder, docManager.curUserHostAddress());
const directory = path.join(docManager.dir, "public", storageFolder, docManager.curUserHostAddress());
this.createDirectory(directory);
const result = [];
const storedFiles = fileSystem.readdirSync(directory);
const result = [];
const storedFiles = fileSystem.readdirSync(directory);
for (let i = 0; i < storedFiles.length; i++) {
const stats = fileSystem.lstatSync(path.join(directory, storedFiles[i]));
const stats = fileSystem.lstatSync(path.join(directory, storedFiles[i]));
if (!stats.isDirectory()) {
const time = stats.mtime.getTime();
const item = {
const time = stats.mtime.getTime();
const item = {
time: time,
name: storedFiles[i],
url: docManager.getlocalFileUri(storedFiles[i]),
documentType: fileUtility.getFileType(storedFiles[i])
};
@ -281,17 +297,17 @@ docManager.getInternalExtension = function (fileType) {
};
docManager.getKey = function (fileName) {
const userAddress = docManager.curUserHostAddress();
const userAddress = docManager.curUserHostAddress();
let key = userAddress + docManager.getlocalFileUri(fileName);
let historyPath = docManager.historyPath(fileName, userAddress);
let historyPath = docManager.historyPath(fileName, userAddress);
if (historyPath != ""){
key += docManager.countVersion(historyPath);
}
historyPath = docManager.historyPath(fileName, userAddress, true);
/*historyPath = docManager.historyPath(fileName, userAddress, true);
const stat = fileSystem.statSync(historyPath);
key += stat.mtime.toString();
key += stat.mtime.toString();*/
return documentService.generateRevisionId(key);
};
@ -327,8 +343,8 @@ docManager.getHistory = function (fileName, content, keyVersion, version) {
const userAddress = docManager.curUserHostAddress();
const username = content ? (oldVersion ? contentJson.username : contentJson.user.name) : (docManager.getFileData(fileName, userAddress))[2];
const userid = content ? (oldVersion ? contentJson.userid : contentJson.user.id) : (docManager.getFileData(fileName, userAddress))[1];
const created = content ? (oldVersion ? contentJson.date : contentJson.created) : (docManager.getFileData(fileName, userAddress))[0];
const userid = content ? (oldVersion ? contentJson.userid : contentJson.user.id) : (docManager.getFileData(fileName, userAddress))[1];
const created = content ? (oldVersion ? contentJson.date : contentJson.created) : (docManager.getFileData(fileName, userAddress))[0];
const res = (content && !oldVersion) ? content : {changes: content};
res.key = keyVersion;
res.version = version;
@ -342,20 +358,20 @@ docManager.getHistory = function (fileName, content, keyVersion, version) {
};
docManager.cleanFolderRecursive = function (folder, me) {
if (fileSystem.existsSync(folder)) {
const files = fileSystem.readdirSync(folder);
files.forEach((file) => {
const curPath = path.join(folder, file);
if (fileSystem.lstatSync(curPath).isDirectory()) {
this.cleanFolderRecursive(curPath, true);
} else {
fileSystem.unlinkSync(curPath);
}
});
if (me) {
fileSystem.rmdirSync(folder);
}
}
if (fileSystem.existsSync(folder)) {
const files = fileSystem.readdirSync(folder);
files.forEach((file) => {
const curPath = path.join(folder, file);
if (fileSystem.lstatSync(curPath).isDirectory()) {
this.cleanFolderRecursive(curPath, true);
} else {
fileSystem.unlinkSync(curPath);
}
});
if (me) {
fileSystem.rmdirSync(folder);
}
}
};
module.exports = docManager;

View File

@ -23,6 +23,7 @@
"jsonwebtoken": "^7.1.9",
"jwa": "^1.1.4",
"log4js": "^0.6.38",
"mime": "^1.3.4",
"serve-favicon": "~2.3.0",
"sync-request": "^4.0.1",
"urllib": "^2.20.0",

View File

@ -116,6 +116,7 @@ label .checkbox {
background-image: url("../images/file_pptx.png");
}
.create-sample {
display: inline-block;
margin-left: 75px;
}
.button, .button:visited, .button:hover, .button:active {

View File

@ -1,35 +1,35 @@
"width": "100%",
"height": "100%",
"type": "<%= editor.type %>",
"documentType": "<%= editor.documentType %>",
"token": "<%= editor.token %>",
"type": "<%- editor.type %>",
"documentType": "<%- editor.documentType %>",
"token": "<%- editor.token %>",
"document": {
"title": "<%= file.name %>",
"url": "<%= file.uri %>",
"fileType": "<%= file.ext %>",
"key": "<%= editor.key %>",
"title": "<%- file.name %>",
"url": "<%- file.uri %>",
"fileType": "<%- file.ext %>",
"key": "<%- editor.key %>",
"info": {
"author": "Me",
"created": "<%= file.created %>"
"created": "<%- file.created %>"
},
"permissions": {
"download": true,
"edit": "<%= editor.isEdit %>",
"edit": "<%- editor.isEdit %>",
"review": true
}
},
"editorConfig": {
"mode": "<%= editor.mode %>",
"lang": "<%= editor.lang %>",
"mode": "<%- editor.mode %>",
"lang": "<%- editor.lang %>",
"callbackUrl": "<%- editor.callbackUrl %>",
"user": {
"id": "<%= editor.userid %>",
"name": "<%= editor.name %>"
"id": "<%- editor.userid %>",
"name": "<%- editor.name %>"
},
"embedded": {
"saveUrl": "<%= file.uri %>",
"embedUrl": "<%= file.uri %>",
"shareUrl": "<%= file.uri %>",
"saveUrl": "<%- file.uri %>",
"embedUrl": "<%- file.uri %>",
"shareUrl": "<%- file.uri %>",
"toolbarDocked": "top"
},
"customization": {
@ -37,10 +37,11 @@
"chat": true,
"comments": true,
"feedback": true,
"forcesave": false,
"goback": {
"url": <%- editor.getServerUrl %>
"url": "<%- editor.backUrl %>"
}
},
"fileChoiceUrl": "<%= editor.fileChoiceUrl %>",
"fileChoiceUrl": "<%- editor.fileChoiceUrl %>",
"plugins": <%- editor.plugins %>
}

View File

@ -68,21 +68,16 @@
docEditor.refreshHistory(
{
currentVersion: "<%= file.version %>",
currentVersion: "<%- file.version %>",
history: historyObj
});
};
var onRequestHistoryData = function (data) {
var version = data.data;
var url_arr = "<%= setHistoryData.url %>".split(",");
var changesUrl_arr = "<%= setHistoryData.changesUrl %>".split(",");
var historyData = <%- JSON.stringify(historyData) %> || null;
docEditor.setHistoryData({
version: version,
url: url_arr[version - 1] != "" ? url_arr[version - 1] : null,
changesUrl: changesUrl_arr[version - 1] != "" ? changesUrl_arr[version - 1] : null
});
docEditor.setHistoryData(historyData[version-1]);
};
var onRequestHistoryClose = function (event){
@ -112,12 +107,25 @@
"onOutdatedVersion": onOutdatedVersion,
}
});
fixSize();
};
var fixSize = function () {
var wrapEl = document.getElementsByClassName("form");
if (wrapEl.length) {
wrapEl[0].style.height = screen.availHeight + "px";
window.scrollTo(0, -1);
wrapEl[0].style.height = window.innerHeight + "px";
}
};
if (window.addEventListener) {
window.addEventListener("load", connectEditor);
window.addEventListener("resize", fixSize);
} else if (window.attachEvent) {
window.attachEvent("onload", connectEditor);
window.attachEvent("onresize", fixSize);
}
</script>

View File

@ -138,8 +138,8 @@
<tr class="tableRow" title="<%=storedFiles[i].name%>">
<td class="contentCells">
<a class="stored-edit <%= storedFiles[i].documentType %>" href="editor?fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<span title="<%= storedFiles[i].url %>"><%= storedFiles[i].name %></span></a>
<a href="<%= storedFiles[i].url %>">
<span title="<%= storedFiles[i].name %>"><%= storedFiles[i].name %></span></a>
<a href="download?fileName=<%= encodeURIComponent(storedFiles[i].name) %>">
<img class="icon-download" src="images/download-24.png" alt="Download" title="Download" /></a>
<a class="delete-file" data="<%= encodeURIComponent(storedFiles[i].name) %>">
<img class="icon-delete" src="images/delete-24.png" alt="Delete" title="Delete" /></a>

View File

@ -232,7 +232,6 @@ function getStoredFiles() {
$dat = filemtime($directory . DIRECTORY_SEPARATOR . $fileName);
$result[$dat] = (object) array(
"name" => $fileName,
"url" => FileUri($fileName),
"documentType" => getDocumentType($fileName)
);
}

View File

@ -176,7 +176,7 @@
echo ' <a class="stored-edit '.$storeFile->documentType.'" href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'" target="_blank">';
echo ' <span title="'.$storeFile->name.'">'.$storeFile->name.'</span>';
echo ' </a>';
echo ' <a href="'.$storeFile->url.'">';
echo ' <a href="webeditor-ajax.php?type=download&filename='.$storeFile->name.'">';
echo ' <img class="icon-download" src="css/images/download-24.png" alt="Download" title="Download" /></a>';
echo ' </a>';
echo ' <a class="delete-file" data="'.$storeFile->name.'">';

View File

@ -60,6 +60,9 @@ if (isset($_GET["type"]) && !empty($_GET["type"])) { //Checks if type value exis
$response_array = upload();
$response_array['status'] = isset($response_array['error']) ? 'error' : 'success';
die (json_encode($response_array));
case "download":
download();
exit;
case "convert":
$response_array = convert();
$response_array['status'] = 'success';
@ -124,6 +127,21 @@ function upload() {
return $result;
}
function download() {
$fileName = $_GET["filename"];
$filePath = getStoragePath($fileName);
if (!file_exists($filePath)) {
http_response_code(404);
return;
}
header("Content-Length: " . filesize($filePath));
header("Content-Type: " . mime_content_type($fileName));
header("Content-Disposition: attachment; filename=\"".basename($filePath)."\"");
readfile($filePath);
}
function track() {
sendlog("Track START", "logs/webedior-ajax.log");
sendlog("_GET params: " . serialize( $_GET ), "logs/webedior-ajax.log");