Compare commits

...

13 Commits

9 changed files with 61 additions and 30 deletions

View File

@ -545,7 +545,7 @@ app.get("/editor", function (req, res) {
var historyD = {
version: i,
key: keyVersion,
url: i == countVersion ? url : (docManager.getlocalFileUri(fileName, i) + "/prev" + fileUtility.getFileExtension(fileName)),
url: i == countVersion ? url : (docManager.getlocalFileUri(fileName, i, true) + "/prev" + fileUtility.getFileExtension(fileName)),
};
if (i > 1) {
historyD.previous = {
@ -595,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,

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

@ -148,11 +148,11 @@ 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();
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);
@ -162,12 +162,12 @@ docManager.getlocalFileUri = function (fileName, version) {
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 server = docManager.getServerUrl(true);
const hostAddress = docManager.curUserHostAddress();
const handler = "/track?filename=" + encodeURIComponent(fileName) + "&useraddress=" + encodeURIComponent(hostAddress);

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": {
@ -39,9 +39,9 @@
"feedback": true,
"forcesave": false,
"goback": {
"url": <%- editor.getServerUrl %>
"url": "<%- editor.backUrl %>"
}
},
"fileChoiceUrl": "<%= editor.fileChoiceUrl %>",
"fileChoiceUrl": "<%- editor.fileChoiceUrl %>",
"plugins": <%- editor.plugins %>
}

View File

@ -68,7 +68,7 @@
docEditor.refreshHistory(
{
currentVersion: "<%= file.version %>",
currentVersion: "<%- file.version %>",
history: historyObj
});
};
@ -107,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

@ -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");