Compare commits

..

8 Commits

18 changed files with 95 additions and 50 deletions

View File

@ -129,8 +129,8 @@ namespace OnlineEditorsExampleMVC.Helpers
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
+ "webeditor.ashx",
Query = "type=track"
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress)
+ "&fileName=" + HttpUtility.UrlEncode(fileName)
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress)
};
return callbackUrl.ToString();
}

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

@ -61,8 +61,8 @@ namespace OnlineEditorsExample
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
+ "webeditor.ashx";
callbackUrl.Query = "type=track"
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress)
+ "&fileName=" + HttpUtility.UrlEncode(FileName);
+ "&fileName=" + HttpUtility.UrlEncode(FileName)
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress);
return callbackUrl.ToString();
}
}

View File

@ -191,7 +191,7 @@ public class DocumentManager
{
String serverPath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
String hostAddress = CurUserHostAddress(null);
String query = "?type=track&userAddress=" + URLEncoder.encode(hostAddress) + "&fileName=" + URLEncoder.encode(fileName);
String query = "?type=track&fileName=" + URLEncoder.encode(fileName) + "&userAddress=" + URLEncoder.encode(hostAddress);
return serverPath + "/IndexServlet" + query;
}

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

@ -422,7 +422,11 @@ app.get("/editor", function (req, res) {
var key = docManager.getKey(fileName);
var url = docManager.getFileUri(fileName);
var mode = req.query.mode || "edit"; //mode: view/edit
var type = req.query.type || "desktop"; //type: embedded/mobile/desktop
var type = req.query.type || ""; //type: embedded/mobile/desktop
if (type == "") {
type = new RegExp(configServer.get("mobileRegEx"), "i").test(req.get('User-Agent')) ? "mobile" : "desktop";
}
var canEdit = configServer.get('editedDocs').indexOf(fileUtility.getFileExtension(fileName)) != -1;
var countVersion = 1;

View File

@ -24,6 +24,7 @@
"convertedDocs": [".doc", ".odt", ".xls", ".ods", ".ppt", ".pps", ".odp", ".rtf", ".mht", ".html", ".htm", ".epub"],
"storageFolder": "files",
"maxFileSize": 1073741824,
"mobileRegEx": "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino",
"static":[
{
"name": "/public",

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) {
@ -169,7 +169,7 @@ docManager.getServerUrl = function () {
docManager.getCallback = function (fileName) {
var server = docManager.getServerUrl();
var hostAddress = docManager.curUserHostAddress();
var handler = "/track?useraddress=" + encodeURIComponent(hostAddress) + "&filename=" + encodeURIComponent(fileName);
var handler = "/track?filename=" + encodeURIComponent(fileName) + "&useraddress=" + encodeURIComponent(hostAddress);
return server + handler;
};

View File

@ -96,6 +96,10 @@
innerAlert(event.data);
};
var onOutdatedVersion = function (event) {
location.reload(true);
};
var connectEditor = function () {
docEditor = new DocsAPI.DocEditor("iframeEditor",
@ -152,7 +156,8 @@
"onError": onError,
"onRequestHistory": onRequestHistory,
"onRequestHistoryData": onRequestHistoryData,
"onRequestHistoryClose": onRequestHistoryClose
"onRequestHistoryClose": onRequestHistoryClose,
"onOutdatedVersion": onOutdatedVersion,
}
});
};

View File

@ -145,7 +145,7 @@
<img class="icon-delete" src="images/delete-24.png" alt="Delete" title="Delete" /></a>
</td>
<td class="contentCells contentCells-icon">
<a href="editor?fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a href="editor?type=desktop&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-icon">
@ -154,12 +154,12 @@
</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">
<a href="editor?type=desktop&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">
<a href="editor?type=desktop&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>
</td>
<td class="contentCells contentCells-icon">

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,10 @@ $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['MOBILE_REGEX'] = "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino";
$GLOBALS['ExtsSpreadsheet'] = array(".xls", ".xlsx",
".ods", ".csv");

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,10 +69,11 @@
}
function getCallbackUrl($fileName) {
return serverPath() . '/'
return serverPath(TRUE) . '/'
. "webeditor-ajax.php"
. "?type=track&userAddress=" . getClientIp()
. "&fileName=" . urlencode($fileName);
. "?type=track"
. "&fileName=" . urlencode($fileName)
. "&userAddress=" . getClientIp();
}
?>
@ -145,6 +145,10 @@
innerAlert(event.data);
};
var onOutdatedVersion = function (event) {
location.reload(true);
};
var сonnectEditor = function () {
<?php
@ -153,14 +157,18 @@
}
?>
var user = [{id:"0","name":"Jonn Smith"}, {id:"1","name":"Mark Pottato"}, {id:"2","name":"Hamish Mitchell"}]["<?php echo $_GET["user"] ?>" || 0];
var user = [{id:"0","name":"Jonn Smith"}, {id:"1","name":"Mark Pottato"}, {id:"2","name":"Hamish Mitchell"}]["<?php echo $_GET["user"] ?>" || 0];
var type = "<?php echo ($_GET["type"] == "mobile" ? "mobile" : ($_GET["type"] == "embedded" ? "embedded" : ($_GET["type"] == "desktop" ? "desktop" : ""))) ?>";
if (type == "") {
type = new RegExp("<?php echo $GLOBALS['MOBILE_REGEX'] ?>", "i").test(window.navigator.userAgent) ? "mobile" : "desktop";
}
docEditor = new DocsAPI.DocEditor("iframeEditor",
{
width: "100%",
height: "100%",
type: "<?php echo ($_GET["type"] == "mobile" ? "mobile" : ($_GET["type"] == "embedded" ? "embedded" : "desktop")) ?>",
type: type,
documentType: "<?php echo getDocumentType($filename) ?>",
document: {
title: fileName,
@ -189,9 +197,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",
},
@ -208,6 +216,7 @@
'onDocumentStateChange': onDocumentStateChange,
'onRequestEditRights': onRequestEditRights,
'onError': onError,
'onOutdatedVersion': onOutdatedVersion,
}
});
};

View File

@ -184,7 +184,7 @@
echo ' </a>';
echo ' </td>';
echo ' <td class="contentCells contentCells-icon">';
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'" target="_blank">';
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'&type=desktop" target="_blank">';
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>';
@ -194,13 +194,13 @@
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 ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'&action=review&type=desktop" 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">';
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'&action=view&type=desktop" target="_blank">';
echo ' <img src="css/images/desktop-24.png" alt="Open in viewer for full size screens" title="Open in viewer for full size screens" /></a>';
echo ' </a>';
echo ' </td>';

View File

@ -58,7 +58,7 @@ if (isset($_GET["type"]) && !empty($_GET["type"])) { //Checks if type value exis
switch($type) { //Switch case for value of type
case "upload":
$response_array = upload();
$response_array['status'] = $response_array['error'] != NULL ? 'error' : 'success';
$response_array['status'] = isset($response_array['error']) ? 'error' : 'success';
die (json_encode($response_array));
case "convert":
$response_array = convert();
@ -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

@ -94,7 +94,7 @@ class DocumentHelper
def get_callback(file_name)
@@base_url + '/track?type=track&userAddress=' + cur_user_host_address(nil) + '&fileName=' + URI::encode(file_name)
@@base_url + '/track?type=track&fileName=' + URI::encode(file_name) + '&userAddress=' + cur_user_host_address(nil)
end

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,
},
});
};