Compare commits

..

8 Commits

18 changed files with 96 additions and 49 deletions

View File

@ -78,6 +78,10 @@
innerAlert(event.data);
};
var onOutdatedVersion = function (event) {
location.reload(true);
};
var сonnectEditor = function () {
docEditor = new DocsAPI.DocEditor("iframeEditor",
@ -135,6 +139,7 @@
'onDocumentStateChange': onDocumentStateChange,
'onRequestEditRights': onRequestEditRights,
'onError': onError,
'onOutdatedVersion': onOutdatedVersion,
}
});
};

View File

@ -71,6 +71,10 @@
innerAlert(event.data);
};
var onOutdatedVersion = function (event) {
location.reload(true);
};
var сonnectEditor = function () {
docEditor = new DocsAPI.DocEditor("iframeEditor",
@ -127,7 +131,8 @@
'onReady': onReady,
'onDocumentStateChange': onDocumentStateChange,
'onRequestEditRights': onRequestEditRights,
'onError': onError
'onError': onError,
'onOutdatedVersion': onOutdatedVersion,
}
});
};

View File

@ -72,6 +72,10 @@
innerAlert(event.data);
};
var onOutdatedVersion = function (event) {
location.reload(true);
};
var сonnectEditor = function () {
docEditor = new DocsAPI.DocEditor("iframeEditor",
@ -129,6 +133,7 @@
"onDocumentStateChange": onDocumentStateChange,
'onRequestEditRights': onRequestEditRights,
"onError": onError,
"onOutdatedVersion": onOutdatedVersion,
}
});
};

View File

@ -412,7 +412,7 @@ app.get("/editor", function (req, res) {
if (fileExt != null) {
var fileName = docManager.createDemo((req.query.sample ? "sample." : "new.") + fileExt, userid, name);
var redirectPath = docManager.getProtocol() + "://" + docManager.req.get("host") + "/editor?fileName=" + encodeURIComponent(fileName) + docManager.getCustomParams();
var redirectPath = docManager.getServerUrl() + "/editor?fileName=" + encodeURIComponent(fileName) + docManager.getCustomParams();
res.redirect(redirectPath);
return;
}
@ -469,7 +469,7 @@ app.get("/editor", function (req, res) {
documentType: fileUtility.getFileType(fileName),
key: key,
callbackUrl: docManager.getCallback(fileName),
isEdit: canEdit,
isEdit: canEdit && mode != "review",
mode: canEdit && mode != "view" ? "edit" : "view",
canBackToFolder: type != "embedded",
getServerUrl: docManager.getServerUrl(),

View File

@ -139,12 +139,12 @@ docManager.saveFileData = function (fileName, userid, username) {
};
docManager.getFileData = function (fileName, userAddress) {
var file_info = docManager.historyPath(fileName, userAddress, true);
if (!this.existsSync(file_info)) {
const history = path.join(docManager.historyPath(fileName, userAddress, true), fileName + ".txt");
if (!this.existsSync(history)) {
return ["2016-01-01", "uid-1", "John Smith"];
}
return ((fileSystem.readFileSync(path.join(file_info, fileName + ".txt"))).toString()).split(",");
return ((fileSystem.readFileSync(history)).toString()).split(",");
};
docManager.getFileUri = function (fileName) {
@ -152,7 +152,7 @@ docManager.getFileUri = function (fileName) {
};
docManager.getlocalFileUri = function (fileName, version) {
var serverPath = docManager.getProtocol() + "://" + docManager.req.get("host");
var serverPath = docManager.getServerUrl();
var storagePath = storageFolder.length ? storageFolder + "/" : "";
var hostAddress = docManager.curUserHostAddress();
var url = serverPath + "/" + storagePath + hostAddress + "/" + encodeURIComponent(fileName);
@ -167,7 +167,7 @@ docManager.getServerUrl = function () {
};
docManager.getCallback = function (fileName) {
var server = docManager.getProtocol() + "://" + docManager.req.get("host");
var server = docManager.getServerUrl();
var hostAddress = docManager.curUserHostAddress();
var handler = "/track?useraddress=" + encodeURIComponent(hostAddress) + "&filename=" + encodeURIComponent(fileName);

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B

View File

@ -288,7 +288,7 @@ footer {
background-repeat: no-repeat;
display: inline-block;
height: 16px;
max-width: 450px;
max-width: 250px;
margin-bottom: -6px;
overflow: hidden;
padding: 8px 0 1px 34px;

View File

@ -96,6 +96,10 @@
innerAlert(event.data);
};
var onOutdatedVersion = function (event) {
location.reload(true);
};
var connectEditor = function () {
docEditor = new DocsAPI.DocEditor("iframeEditor",
@ -114,8 +118,9 @@
created: new Date().toDateString()
},
permissions: {
download: true,
edit: "<%= editor.isEdit %>" == "true",
download: true
review: true,
}
},
editorConfig: {
@ -138,7 +143,7 @@
comments: true,
feedback: true,
goback: {
url: ("<%= editor.type %>" == "embedded" ? null : "<%= editor.getServerUrl %>")
url: "<%= editor.getServerUrl %>"
}
},
fileChoiceUrl: "<%= editor.fileChoiceUrl %>",
@ -151,7 +156,8 @@
"onError": onError,
"onRequestHistory": onRequestHistory,
"onRequestHistoryData": onRequestHistoryData,
"onRequestHistoryClose": onRequestHistoryClose
"onRequestHistoryClose": onRequestHistoryClose,
"onOutdatedVersion": onOutdatedVersion,
}
});
};

View File

@ -129,7 +129,7 @@
<thead>
<tr class="tableHeader">
<td class="tableHeaderCell tableHeaderCellFileName">Filename</td>
<td colspan="2" class="tableHeaderCell contentCells-shift">Editors</td>
<td colspan="3" class="tableHeaderCell contentCells-shift">Editors</td>
<td colspan="3" class="tableHeaderCell">Viewers</td>
</tr>
</thead>
@ -137,7 +137,7 @@
<% for (var i = 0; i < storedFiles.length; i++) { %>
<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">
<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 %>">
<img class="icon-download" src="images/download-24.png" alt="Download" title="Download" /></a>
@ -148,10 +148,16 @@
<a href="editor?fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<img src="images/desktop-24.png" alt="Open in editor for full size screens" title="Open in editor for full size screens" /></a>
</td>
<td class="contentCells contentCells-shift contentCells-icon">
<td class="contentCells contentCells-icon">
<a href="editor?type=mobile&mode=edit&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<img src="images/mobile-24.png" alt="Open in editor for mobile devices" title="Open in editor for mobile devices" /></a>
</td>
<td class="contentCells contentCells-shift contentCells-icon">
<% if (storedFiles[i].documentType == "text") { %>
<a href="editor?mode=review&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<img src="images/review-24.png" alt="Open in editor for review" title="Open in editor for review" /></a>
<% } %>
</td>
<td class="contentCells contentCells-icon">
<a href="editor?mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<img src="images/desktop-24.png" alt="Open in viewer for full size screens" title="Open in viewer for full size screens" /></a>

View File

@ -142,8 +142,10 @@ function getClientIp() {
return $ipaddress;
}
function serverPath() {
return 'http://' . $_SERVER['HTTP_HOST'];
function serverPath($forDocumentServer) {
return $forDocumentServer && isset($GLOBALS['EXAMPLE_URL']) && $GLOBALS['EXAMPLE_URL'] != ""
? $GLOBALS['EXAMPLE_URL']
: ('http://' . $_SERVER['HTTP_HOST']);
}
function getCurUserHostAddress($userAddress = NULL) {
@ -223,35 +225,35 @@ function getStoredFiles() {
}
$cdir = scandir($directory);
foreach ($cdir as $key => $fileName)
{
if (!in_array($fileName,array(".","..")))
{
if (!is_dir($directory . DIRECTORY_SEPARATOR . $fileName))
{
$result[] = (object) array(
'name' => $fileName,
'url' => FileUri($fileName),
'documentType' => getDocumentType($fileName)
);
$result = array();
foreach($cdir as $key => $fileName) {
if (!in_array($fileName,array(".", ".."))) {
if (!is_dir($directory . DIRECTORY_SEPARATOR . $fileName)) {
$dat = filemtime($directory . DIRECTORY_SEPARATOR . $fileName);
$result[$dat] = (object) array(
"name" => $fileName,
"url" => FileUri($fileName),
"documentType" => getDocumentType($fileName)
);
}
}
}
return $result;
ksort($result);
return array_reverse($result);
}
function getVirtualPath() {
function getVirtualPath($forDocumentServer) {
$storagePath = trim(str_replace(array('/','\\'), '/', $GLOBALS['STORAGE_PATH']), '/');
$storagePath = $storagePath != "" ? $storagePath . '/' : "";
$virtPath = serverPath() . '/' . $storagePath . getCurUserHostAddress() . '/';
$virtPath = serverPath($forDocumentServer) . '/' . $storagePath . getCurUserHostAddress() . '/';
sendlog("getVirtualPath virtPath: " . $virtPath, "logs/common.log");
return $virtPath;
}
function FileUri($file_name) {
$uri = getVirtualPath() . $file_name;
function FileUri($file_name, $forDocumentServer) {
$uri = getVirtualPath($forDocumentServer) . $file_name;
return $uri;
}

View File

@ -18,6 +18,8 @@ $GLOBALS['DOC_SERV_API_URL'] = "https://doc.onlyoffice.com/web-apps/apps/api/doc
$GLOBALS['DOC_SERV_PRELOADER_URL'] = "https://doc.onlyoffice.com/web-apps/apps/api/documents/cache-scripts.html";
$GLOBALS['EXAMPLE_URL'] = "";
$GLOBALS['ExtsSpreadsheet'] = array(".xls", ".xlsx",
".ods", ".csv");

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B

View File

@ -291,7 +291,7 @@ footer {
background-repeat: no-repeat;
display: inline-block;
height: 16px;
max-width: 450px;
max-width: 250px;
margin-bottom: -6px;
overflow: hidden;
padding: 8px 0 1px 34px;

View File

@ -31,7 +31,6 @@
require_once( dirname(__FILE__) . '/functions.php' );
$filename;
$fileuri;
$externalUrl = $_GET["fileUrl"];
if (!empty($externalUrl))
@ -53,8 +52,8 @@
exit;
}
$fileuri = FileUri($filename);
$fileuri = FileUri($filename, true);
$fileuriUser = FileUri($filename);
function tryGetDefaultByType($createExt) {
$demoName = ($_GET["sample"] ? "demo." : "new.") . $createExt;
@ -70,7 +69,7 @@
}
function getCallbackUrl($fileName) {
return serverPath() . '/'
return serverPath(TRUE) . '/'
. "webeditor-ajax.php"
. "?type=track&userAddress=" . getClientIp()
. "&fileName=" . urlencode($fileName);
@ -145,6 +144,10 @@
innerAlert(event.data);
};
var onOutdatedVersion = function (event) {
location.reload(true);
};
var сonnectEditor = function () {
<?php
@ -174,8 +177,9 @@
},
permissions: {
edit: <?php echo (in_array(strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION)), $GLOBALS['DOC_SERV_EDITED']) ? "true" : "false") ?>,
download: true,
edit: <?php echo (in_array(strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION)), $GLOBALS['DOC_SERV_EDITED']) && $_GET["action"] != "review" ? "true" : "false") ?>,
review: true
}
},
editorConfig: {
@ -188,9 +192,9 @@
user: user,
embedded: {
saveUrl: "<?php echo $fileuri ?>",
embedUrl: "<?php echo $fileuri ?>",
shareUrl: "<?php echo $fileuri ?>",
saveUrl: "<?php echo $fileuriUser ?>",
embedUrl: "<?php echo $fileuriUser ?>",
shareUrl: "<?php echo $fileuriUser ?>",
toolbarDocked: "top",
},
@ -207,6 +211,7 @@
'onDocumentStateChange': onDocumentStateChange,
'onRequestEditRights': onRequestEditRights,
'onError': onError,
'onOutdatedVersion': onOutdatedVersion,
}
});
};

View File

@ -249,8 +249,8 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi
if (!function_exists('simplexml_load_file')){
throw new Exception("Server can't read xml");
}
$data = simplexml_load_string($response_xml_data);
if (!$data) {
$response_data = simplexml_load_string($response_xml_data);
if (!$response_data) {
$exc = "Bad Response. Errors: ";
foreach(libxml_get_errors() as $error) {
$exc = $exc . "\t" . $error->message;
@ -258,7 +258,7 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi
throw new Exception ($exc);
}
return $data;
return $response_data;
}

View File

@ -163,7 +163,7 @@
<thead>
<tr class="tableHeader">
<td class="tableHeaderCell tableHeaderCellFileName">Filename</td>
<td colspan="2" class="tableHeaderCell contentCells-shift">Editors</td>
<td colspan="3" class="tableHeaderCell contentCells-shift">Editors</td>
<td colspan="3" class="tableHeaderCell">Viewers</td>
</tr>
</thead>
@ -188,10 +188,16 @@
echo ' <img src="css/images/desktop-24.png" alt="Open in editor for full size screens" title="Open in editor for full size screens" /></a>';
echo ' </a>';
echo ' </td>';
echo ' <td class="contentCells contentCells-shift contentCells-icon">';
echo ' <td class="contentCells contentCells-icon">';
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'&type=mobile" target="_blank">';
echo ' <img src="css/images/mobile-24.png" alt="Open in editor for mobile devices" title="Open in editor for mobile devices" /></a>';
echo ' </a>';
echo ' <td class="contentCells contentCells-shift contentCells-icon">';
if ($storeFile->documentType == "text") {
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'&action=review" target="_blank">';
echo ' <img src="css/images/review-24.png" alt="Open in editor for review" title="Open in editor for review" /></a>';
echo ' </a>';
}
echo ' </td>';
echo ' <td class="contentCells contentCells-icon">';
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'&action=view" target="_blank">';

View File

@ -201,8 +201,8 @@ function convert() {
if (in_array("." + $extension, $GLOBALS['DOC_SERV_CONVERT']) && $internalExtension != "") {
$fileUri = $_GET["fileUri"];
if ($fileUri == "") {
$fileUri = FileUri($fileName);
if ($fileUri == NULL || $fileUri == "") {
$fileUri = FileUri($fileName, TRUE);
}
$key = getDocEditorKey($fileName);

View File

@ -34,6 +34,10 @@
innerAlert(event.data);
};
var onOutdatedVersion = function (event) {
location.reload(true);
};
var сonnectEditor = function () {
docEditor = new DocsAPI.DocEditor("iframeEditor",
@ -90,6 +94,7 @@
'onReady': onReady,
'onDocumentStateChange': onDocumentStateChange,
'onError': onError,
'onOutdatedVersion': onOutdatedVersion,
},
});
};