Initial release v1.0.0
4
AUTHORS.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Authors
|
||||
|
||||
* Ascensio System SIA: <integration@onlyoffice.com>
|
||||
|
2
CHANGELOG.md
Normal file
@ -0,0 +1,2 @@
|
||||
owncloud-onlyoffice (1.0.0)
|
||||
* Initial release
|
77
README.md
Normal file
@ -0,0 +1,77 @@
|
||||
#  OwnCloud ONLYOFFICE integration app
|
||||
|
||||
This app enables users to edit office documents from [ownCloud](https://owncloud.com) using ONLYOFFICE Document Server. Currently the following document formats can be edited with this app: DOCX, XLSX, PPTX, TXT. The above mentioned formats are also available for viewing together with PDF and CSV. The edited files of the corresponding type can be converted into the Office Open XML formats: ODT, ODS, ODP, DOC, XLS, PPT, PPS, EPUB, RTF, HTML, HTM.
|
||||
|
||||
The app will create an item in the `new` (+) menu to create **Document**, **Spreadsheet**, **Presentation**. It will also create a new **Open in ONLYOFFICE** menu option within the document library for Office documents. This allows multiple users to collaborate in real time and to save back those changes to ownCloud.
|
||||
|
||||
|
||||
|
||||
## Installing ONLYOFFICE Document Server
|
||||
|
||||
You will need an instance of ONLYOFFICE Document Server that is resolvable and connectable both from ownCloud and any end clients (version 3.0 and later are supported for use with the app). If that is not the case, use the official ONLYOFFICE Document Server documetnations page: [Document Server for Linux](http://helpcenter.onlyoffice.com/server/linux/document/linux-installation.aspx). ONLYOFFICE Document Server must also be able to POST to ownCloud directly.
|
||||
|
||||
The easiest way to start an instance of ONLYOFFICE Document Server is to use [Docker](https://github.com/ONLYOFFICE/Docker-DocumentServer).
|
||||
|
||||
|
||||
|
||||
## Installing ownCloud ONLYOFFICE integration app
|
||||
|
||||
To start using ONLYOFFICE Document Server with ownCloud, the following steps must be performed:
|
||||
|
||||
1. Place ownCloud ONLYOFFICE integration app to your ownCloud server into the _/apps_ (or some other) directory, [used](https://doc.owncloud.org/server/9.0/admin_manual/installation/apps_management_installation.html#using-custom-app-directories) to connect applications:
|
||||
```
|
||||
cd apps/
|
||||
git clone https://github.com/ONLYOFFICE/onlyoffice-owncloud.git onlyoffice
|
||||
```
|
||||
|
||||
2. In ownCloud open the `~/index.php/settings/apps?category=disabled` page with _Not enabled_ apps by administrator and click _Enable_ for the **ONLYOFFICE** application.
|
||||
|
||||
|
||||
|
||||
## Configuring ownCloud ONLYOFFICE integration app
|
||||
|
||||
In ownCloud open the `~/index.php/settings/admin#onlyoffice` page with administrative settings for **ONLYOFFICE** section and enter the address
|
||||
|
||||
```
|
||||
https://<documentserver>
|
||||
```
|
||||
|
||||
Where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
|
||||
|
||||
|
||||
## How it works
|
||||
|
||||
The ONLYOFFICE integration follows the API documented here https://api.onlyoffice.com/editors/basic:
|
||||
|
||||
* When creating a new file, the user navigates to a document folder within ownCloud and clicks the **Document**, **Spreadsheet** or **Presentation* item in the _new_ (+) menu.
|
||||
|
||||
* The browser invokes the `create` method in the `/lib/Controller/EditorController.php` controller. This method adds the copy of the file from the assets folder to the folder the user is currently in.
|
||||
|
||||
* Or, when opening an existing file, the user navigates to it within ownCloud and selects the **Open in ONLYOFFICE** menu option.
|
||||
|
||||
* A new browser tab is opened and the `index` method of the `/lib/Controller/EditorController.php` controller is invoked.
|
||||
|
||||
* The app prepares a JSON object with the following properties:
|
||||
|
||||
* **url** - the URL that ONLYOFFICE Document Server uses to download the document;
|
||||
* **callback** - the URL that ONLYOFFICE Document Server informs about status of the document editing;
|
||||
* **documentServerUrl** - the URL that the client needs to reply to ONLYOFFICE Document Server (can be set at the administrative settings page);
|
||||
* **key** - the UUID+Modified Timestamp to instruct ONLYOFFICE Document Server whether to download the document again or not;
|
||||
* **fileName** - the document Title (name);
|
||||
* **userId** - the identification of the user;
|
||||
* **userName** - the name of the user.
|
||||
|
||||
* ownCloud takes this object and constructs a page from `templates/editor.php` template, filling in all of those values so that the client browser can load up the editor.
|
||||
|
||||
* The client browser makes a request for the javascript library from ONLYOFFICE Document Server and sends ONLYOFFICE Document Server the DocEditor configuration with the above properties.
|
||||
|
||||
* Then ONLYOFFICE Document Server downloads the document from ownCloud and the user begins editing.
|
||||
|
||||
* ONLYOFFICE Document Server sends a POST request to the _callback_ URL to inform ownCloud that a user is editing the document.
|
||||
|
||||
* When all users and client browsers are done with editing, they close the editing window.
|
||||
|
||||
* After 10 seconds of inactivity, ONLYOFFICE Document Server sends a POST to the _callback_ URL letting ownCloud know that the clients have finished editing the document and closed it.
|
||||
|
||||
* ownCloud downloads the new version of the document, replacing the old one.
|
36
appinfo/app.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Onlyoffice\AppInfo;
|
||||
|
||||
use OCP\App;
|
||||
|
||||
/**
|
||||
* Administration settings
|
||||
*/
|
||||
App::registerAdmin("onlyoffice", "settings");
|
||||
|
||||
$app = new Application();
|
125
appinfo/application.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Onlyoffice\AppInfo;
|
||||
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\Util;
|
||||
|
||||
use OCA\Onlyoffice\AppConfig;
|
||||
use OCA\Onlyoffice\Controller\CallbackController;
|
||||
use OCA\Onlyoffice\Controller\EditorController;
|
||||
use OCA\Onlyoffice\Controller\SettingsController;
|
||||
use OCA\Onlyoffice\Crypt;
|
||||
|
||||
class Application extends App {
|
||||
|
||||
/**
|
||||
* Application configuration
|
||||
*
|
||||
* @var OCA\Onlyoffice\AppConfig
|
||||
*/
|
||||
public $appConfig;
|
||||
|
||||
/**
|
||||
* Hash generator
|
||||
*
|
||||
* @var OCA\Onlyoffice\Crypt
|
||||
*/
|
||||
public $crypt;
|
||||
|
||||
public function __construct(array $urlParams = []) {
|
||||
$appName = "onlyoffice";
|
||||
|
||||
parent::__construct($appName, $urlParams);
|
||||
|
||||
$this->appConfig = new AppConfig($appName);
|
||||
$this->crypt = new Crypt($this->appConfig);
|
||||
|
||||
// Default script and style if configured
|
||||
if (!empty($this->appConfig->GetDocumentServerUrl()))
|
||||
{
|
||||
$url = \OC::$server->getRequest()->server["REQUEST_URI"];
|
||||
|
||||
if (isset($url)) {
|
||||
if (preg_match("%/apps/files(/.*)?%", $url)) {
|
||||
Util::addScript($appName, "main");
|
||||
Util::addStyle($appName, "main");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$container = $this->getContainer();
|
||||
|
||||
$container->registerService("L10N", function($c) {
|
||||
return $c->query("ServerContainer")->getL10N($c->query("AppName"));
|
||||
});
|
||||
|
||||
$container->registerService("RootStorage", function($c) {
|
||||
return $c->query("ServerContainer")->getRootFolder();
|
||||
});
|
||||
|
||||
$container->registerService("UserSession", function($c) {
|
||||
return $c->query("ServerContainer")->getUserSession();
|
||||
});
|
||||
|
||||
|
||||
// Controllers
|
||||
$container->registerService("SettingsController", function($c) {
|
||||
return new SettingsController(
|
||||
$c->query("AppName"),
|
||||
$c->query("Request"),
|
||||
$this->appConfig
|
||||
);
|
||||
});
|
||||
|
||||
$container->registerService("EditorController", function($c) {
|
||||
return new EditorController(
|
||||
$c->query("AppName"),
|
||||
$c->query("Request"),
|
||||
$c->query("RootStorage"),
|
||||
$c->query("UserSession")->getUser(),
|
||||
$c->query("ServerContainer")->getURLGenerator(),
|
||||
$c->query("L10N"),
|
||||
$this->appConfig,
|
||||
$this->crypt
|
||||
);
|
||||
});
|
||||
|
||||
$container->registerService("CallbackController", function($c) {
|
||||
return new CallbackController(
|
||||
$c->query("AppName"),
|
||||
$c->query("Request"),
|
||||
$c->query("RootStorage"),
|
||||
$c->query("UserSession"),
|
||||
$c->query("ServerContainer")->getUserManager(),
|
||||
$c->query("L10N"),
|
||||
$this->appConfig,
|
||||
$this->crypt
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
28
appinfo/info.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0"?>
|
||||
<info>
|
||||
<id>onlyoffice</id>
|
||||
<name>Onlyoffice</name>
|
||||
<summary>ownCloud ONLYOFFICE integration app</summary>
|
||||
<description>ONLYOFFICE integration app enables users to edit Office documents within ONLYOFFICE from OwnCloud. This will create a new Open in ONLYOFFICE action within the document library for Office documents. This allows multiple users to collaborate in real time and to save back those changes to OwnCloud.</description>
|
||||
<licence>AGPL</licence>
|
||||
<author>Ascensio System SIA</author>
|
||||
<version>1.0.0</version>
|
||||
<namespace>Onlyoffice</namespace>
|
||||
<types>
|
||||
<filesystem/>
|
||||
</types>
|
||||
<documentation>
|
||||
<admin>https://api.onlyoffice.com/editors/owncloud</admin>
|
||||
</documentation>
|
||||
<category>tool</category>
|
||||
<website>https://www.onlyoffice.com</website>
|
||||
<bugs>https://github.com/ONLYOFFICE/onlyoffice-owncloud/issues</bugs>
|
||||
<repository type="git">https://github.com/ONLYOFFICE/onlyoffice-owncloud.git</repository>
|
||||
<screenshot small-thumbnail="https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-owncloud/master/screenshots/main_small.png">https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-owncloud/master/screenshots/main.png</screenshot>
|
||||
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-owncloud/master/screenshots/new.png</screenshot>
|
||||
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-owncloud/master/screenshots/open.png</screenshot>
|
||||
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-owncloud/master/screenshots/settings.png</screenshot>
|
||||
<dependencies>
|
||||
<owncloud min-version="9.0" max-version="9.1" />
|
||||
</dependencies>
|
||||
</info>
|
37
appinfo/routes.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
return [
|
||||
"routes" => [
|
||||
["name" => "callback#download", "url" => "/download", "verb" => "GET"],
|
||||
["name" => "callback#track", "url" => "/track", "verb" => "POST"],
|
||||
["name" => "editor#index", "url" => "/{fileId}", "verb" => "GET"],
|
||||
["name" => "editor#create", "url" => "/ajax/new", "verb" => "POST"],
|
||||
["name" => "editor#convert", "url" => "/ajax/convert", "verb" => "POST"],
|
||||
["name" => "settings#settings", "url" => "/ajax/settings", "verb" => "PUT"],
|
||||
["name" => "settings#formats", "url" => "/ajax/settings", "verb" => "GET"],
|
||||
]
|
||||
];
|
BIN
assets/new.docx
Normal file
BIN
assets/new.pptx
Normal file
BIN
assets/new.xlsx
Normal file
256
controller/callbackcontroller.php
Normal file
@ -0,0 +1,256 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Onlyoffice\Controller;
|
||||
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\Files\File;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
|
||||
use OCA\Onlyoffice\AppConfig;
|
||||
use OCA\Onlyoffice\Crypt;
|
||||
use OCA\Onlyoffice\DocumentService;
|
||||
use OCA\Onlyoffice\DownloadResponse;
|
||||
use OCA\Onlyoffice\ErrorResponse;
|
||||
|
||||
/**
|
||||
* Callback handler for the document server.
|
||||
* Download the file without authentication.
|
||||
* Save the file without authentication.
|
||||
*/
|
||||
class CallbackController extends Controller {
|
||||
|
||||
/**
|
||||
* Root folder
|
||||
*
|
||||
* @var IRootFolder
|
||||
*/
|
||||
private $root;
|
||||
|
||||
/**
|
||||
* User session
|
||||
*
|
||||
* @var IUserSession
|
||||
*/
|
||||
private $userSession;
|
||||
|
||||
/**
|
||||
* User manager
|
||||
*
|
||||
* @var IUserManager
|
||||
*/
|
||||
private $userManager;
|
||||
|
||||
/**
|
||||
* l10n service
|
||||
*
|
||||
* @var IL10N
|
||||
*/
|
||||
private $trans;
|
||||
|
||||
/**
|
||||
* Application configuration
|
||||
*
|
||||
* @var OCA\Onlyoffice\AppConfig
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* Hash generator
|
||||
*
|
||||
* @var OCA\Onlyoffice\Crypt
|
||||
*/
|
||||
private $crypt;
|
||||
|
||||
/**
|
||||
* Status of the document
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $_trackerStatus = array(
|
||||
0 => "NotFound",
|
||||
1 => "Editing",
|
||||
2 => "MustSave",
|
||||
3 => "Corrupted",
|
||||
4 => "Closed"
|
||||
);
|
||||
|
||||
/**
|
||||
* @param string $AppName application name
|
||||
* @param IRequest $request request object
|
||||
* @param IRootFolder $root root folder
|
||||
* @param IUserSession $userSession user session
|
||||
* @param IUserManager $userManager user manager
|
||||
* @param IL10N $l10n l10n service
|
||||
* @param OCA\Onlyoffice\Crypt $crypt hash generator
|
||||
*/
|
||||
public function __construct($AppName,
|
||||
IRequest $request,
|
||||
IRootFolder $root,
|
||||
IUserSession $userSession,
|
||||
IUserManager $userManager,
|
||||
IL10N $trans,
|
||||
AppConfig $config,
|
||||
Crypt $crypt
|
||||
) {
|
||||
parent::__construct($AppName, $request);
|
||||
|
||||
$this->root = $root;
|
||||
$this->userSession = $userSession;
|
||||
$this->userManager = $userManager;
|
||||
$this->trans = $trans;
|
||||
$this->config = $config;
|
||||
$this->crypt = $crypt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Downloading file by the document service
|
||||
*
|
||||
* @param string $doc - verification token with the file identifier
|
||||
*
|
||||
* @return OCA\Onlyoffice\DownloadResponse
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
* @CORS
|
||||
*/
|
||||
public function download($doc) {
|
||||
|
||||
$hashData = $this->crypt->ReadHash($doc);
|
||||
if ($hashData === NULL) {
|
||||
return new ErrorResponse(Http::STATUS_FORBIDDEN, $this->trans->t("Access deny"));
|
||||
}
|
||||
if ($hashData->action !== "download") {
|
||||
return new ErrorResponse(Http::STATUS_BAD_REQUEST, $this->trans->t("Invalid request"));
|
||||
}
|
||||
|
||||
$fileId = $hashData->fileId;
|
||||
$ownerId = $hashData->ownerId;
|
||||
|
||||
$files = $this->root->getUserFolder($ownerId)->getById($fileId);
|
||||
if(empty($files)) {
|
||||
return new ErrorResponse(Http::STATUS_NOT_FOUND, $this->trans->t("Files not found"));
|
||||
}
|
||||
$file = $files[0];
|
||||
|
||||
if (! $file instanceof File) {
|
||||
return new ErrorResponse(Http::STATUS_NOT_FOUND, $this->trans->t("File not found"));
|
||||
}
|
||||
|
||||
try {
|
||||
return new DownloadResponse($file);
|
||||
} catch(\OCP\Files\NotPermittedException $e) {
|
||||
return new ErrorResponse(Http::STATUS_FORBIDDEN, $this->trans->t("Not permitted"));
|
||||
}
|
||||
return new ErrorResponse(Http::STATUS_INTERNAL_SERVER_ERROR, $this->trans->t("Download failed"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle request from the document server with the document status information
|
||||
*
|
||||
* @param string $doc - verification token with the file identifier
|
||||
* @param array $users - the list of the identifiers of the users
|
||||
* @param string $key - the edited document identifier
|
||||
* @param string $url - the link to the edited document to be saved
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
* @CORS
|
||||
*/
|
||||
public function track($doc, $users, $key, $status, $url) {
|
||||
|
||||
$hashData = $this->crypt->ReadHash($doc);
|
||||
if ($hashData === NULL) {
|
||||
return ["message" => $this->trans->t("Access deny")];
|
||||
}
|
||||
if ($hashData->action !== "track") {
|
||||
return ["message" => $this->trans->t("Invalid request")];
|
||||
}
|
||||
|
||||
$trackerStatus = $this->_trackerStatus[$status];
|
||||
|
||||
$error = 1;
|
||||
switch ($trackerStatus) {
|
||||
case "MustSave":
|
||||
case "Corrupted":
|
||||
|
||||
$fileId = $hashData->fileId;
|
||||
$ownerId = $hashData->ownerId;
|
||||
|
||||
$files = $this->root->getUserFolder($ownerId)->getById($fileId);
|
||||
if(empty($files)) {
|
||||
return ["message" => $this->trans->t("Files not found")];
|
||||
}
|
||||
$file = $files[0];
|
||||
|
||||
if (! $file instanceof File) {
|
||||
return ["message" => $this->trans->t("File not found")];
|
||||
}
|
||||
|
||||
$fileName = $file->getName();
|
||||
$curExt = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
$downloadExt = strtolower(pathinfo($url, PATHINFO_EXTENSION));
|
||||
|
||||
if ($downloadExt !== $curExt) {
|
||||
$documentService = new DocumentService($this->trans, $this->config);
|
||||
$key = DocumentService::GenerateRevisionId($fileId . $url);
|
||||
|
||||
try {
|
||||
$newFileUri;
|
||||
$documentService->GetConvertedUri($url, $downloadExt, $curExt, $key, FALSE, $newFileUri);
|
||||
$url = $newFileUri;
|
||||
} catch (\Exception $e) {
|
||||
return ["message" => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
if (($newData = file_get_contents($url))) {
|
||||
|
||||
$this->userSession->setUser($this->userManager->get($users[0]));
|
||||
|
||||
$file->putContent($newData);
|
||||
$error = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case "Editing":
|
||||
$error = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return ["error" => $error];
|
||||
}
|
||||
}
|
419
controller/editorcontroller.php
Normal file
@ -0,0 +1,419 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Onlyoffice\Controller;
|
||||
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AutoloadNotAllowedException;
|
||||
use OCP\Files\FileInfo;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUser;
|
||||
|
||||
use OC\Files\Filesystem;
|
||||
use OC\Files\View;
|
||||
use OC\User\NoUserException;
|
||||
|
||||
use OCA\Files\Helper;
|
||||
use OCA\Files_Versions\Storage;
|
||||
|
||||
use OCA\Onlyoffice\AppConfig;
|
||||
use OCA\Onlyoffice\Crypt;
|
||||
use OCA\Onlyoffice\DocumentService;
|
||||
|
||||
/**
|
||||
* Controller with the main functions
|
||||
*/
|
||||
class EditorController extends Controller {
|
||||
|
||||
/**
|
||||
* Current user
|
||||
*
|
||||
* @var IUser
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Root folder
|
||||
*
|
||||
* @var IRootFolder
|
||||
*/
|
||||
private $root;
|
||||
|
||||
/**
|
||||
* Url generator service
|
||||
*
|
||||
* @var IURLGenerator
|
||||
*/
|
||||
private $urlGenerator;
|
||||
|
||||
/**
|
||||
* l10n service
|
||||
*
|
||||
* @var IL10N
|
||||
*/
|
||||
private $trans;
|
||||
|
||||
/**
|
||||
* Application configuration
|
||||
*
|
||||
* @var OCA\Onlyoffice\AppConfig
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* Hash generator
|
||||
*
|
||||
* @var OCA\Onlyoffice\Crypt
|
||||
*/
|
||||
private $crypt;
|
||||
|
||||
/**
|
||||
* @param string $AppName application name
|
||||
* @param IRequest $request request object
|
||||
* @param IRootFolder $root root folder
|
||||
* @param IUser $user current user
|
||||
* @param IURLGenerator $urlGenerator url generator service
|
||||
* @param IL10N $l10n l10n service
|
||||
* @param OCA\Onlyoffice\AppConfig $config application configuration
|
||||
* @param OCA\Onlyoffice\Crypt $crypt hash generator
|
||||
*/
|
||||
public function __construct($AppName,
|
||||
IRequest $request,
|
||||
IRootFolder $root,
|
||||
IUser $user,
|
||||
IURLGenerator $urlGenerator,
|
||||
IL10N $trans,
|
||||
AppConfig $config,
|
||||
Crypt $crypt
|
||||
) {
|
||||
parent::__construct($AppName, $request);
|
||||
|
||||
$this->user = $user;
|
||||
$this->root = $root;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->trans = $trans;
|
||||
$this->config = $config;
|
||||
$this->crypt = $crypt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new file in folder
|
||||
*
|
||||
* @param string $name - file name
|
||||
* @param string $dir - folder path
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function create($name, $dir) {
|
||||
|
||||
$userId = $this->user->getUID();
|
||||
$userFolder = $this->root->getUserFolder($userId);
|
||||
$folder = $userFolder->get($dir);
|
||||
|
||||
if ($folder === NULL) {
|
||||
return ["error" => $this->trans->t("The required folder was not found")];
|
||||
}
|
||||
if (!$folder->isCreatable()) {
|
||||
return ["error" => $this->trans->t("You don't have enough permission to create")];
|
||||
}
|
||||
|
||||
$name = $userFolder->getNonExistingName($name);
|
||||
$filePath = $dir . DIRECTORY_SEPARATOR . $name;
|
||||
$ext = strtolower("." . pathinfo($filePath, PATHINFO_EXTENSION));
|
||||
$templatePath = dirname(__DIR__) . DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "new" . $ext;
|
||||
|
||||
$template = file_get_contents($templatePath);
|
||||
if (!$template) {
|
||||
return ["error" => $this->trans->t("Template not found")];
|
||||
}
|
||||
|
||||
$view = Filesystem::getView();
|
||||
if (!$view->file_put_contents($filePath, $template)) {
|
||||
return ["error" => $this->trans->t("Can't create file")];
|
||||
}
|
||||
|
||||
$fileInfo = $view->getFileInfo($filePath);
|
||||
|
||||
if ($fileInfo === false) {
|
||||
return ["error" => $this->trans->t("File not found")];
|
||||
}
|
||||
|
||||
$result = Helper::formatFileInfo($fileInfo);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Conversion file to Office Open XML format
|
||||
*
|
||||
* @param integer $fileId - file identifier
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function convert($fileId) {
|
||||
list ($file, $error) = $this->getFile($fileId);
|
||||
|
||||
if (isset($error)) {
|
||||
return ["error" => $error];
|
||||
}
|
||||
|
||||
$fileName = $file->getName();
|
||||
$ext = pathinfo($fileName, PATHINFO_EXTENSION);
|
||||
$format = $this->config->formats[$ext];
|
||||
if (!isset($format)) {
|
||||
return ["error" => $this->trans->t("Format do not supported")];
|
||||
}
|
||||
|
||||
if(!isset($format["conv"]) || $format["conv"] !== TRUE) {
|
||||
return ["error" => $this->trans->t("Conversion not required")];
|
||||
}
|
||||
|
||||
$internalExtension = "docx";
|
||||
switch ($format["type"]) {
|
||||
case "spreadsheet":
|
||||
$internalExtension = "xlsx";
|
||||
break;
|
||||
case "presentation":
|
||||
$internalExtension = "pptx";
|
||||
break;
|
||||
}
|
||||
|
||||
$newFileUri;
|
||||
$documentService = new DocumentService($this->trans, $this->config);
|
||||
$key = $this->getKey($file);
|
||||
$fileUrl = $this->getUrl($file);
|
||||
try {
|
||||
$documentService->GetConvertedUri($fileUrl, $ext, $internalExtension, $key, FALSE, $newFileUri);
|
||||
} catch (\Exception $e) {
|
||||
return ["error" => $e->getMessage()];
|
||||
}
|
||||
|
||||
$userId = $this->user->getUID();
|
||||
$folder = $file->getParent();
|
||||
if (!$folder->isCreatable()) {
|
||||
$folder = $this->root->getUserFolder($userId);
|
||||
}
|
||||
$pattern = "/^\\" . DIRECTORY_SEPARATOR . $userId . "\\" . DIRECTORY_SEPARATOR . "files/";
|
||||
$newFolderPath = preg_replace($pattern, "", $folder->getPath());
|
||||
|
||||
$fileNameWithoutExt = substr($fileName, 0, strlen($fileName) - strlen($ext) - 1);
|
||||
$newFileName = $folder->getNonExistingName($fileNameWithoutExt . "." . $internalExtension);
|
||||
|
||||
$newFilePath = $newFolderPath . DIRECTORY_SEPARATOR . $newFileName;
|
||||
|
||||
if (($newData = file_get_contents($newFileUri)) === FALSE){
|
||||
return ["error" => $this->trans->t("Failed download converted file")];
|
||||
}
|
||||
|
||||
$view = Filesystem::getView();
|
||||
if (!$view->file_put_contents($newFilePath, $newData)) {
|
||||
return ["error" => $this->trans->t("Can't create file")];
|
||||
}
|
||||
|
||||
$fileInfo = $view->getFileInfo($newFilePath);
|
||||
|
||||
if ($fileInfo === false) {
|
||||
return ["error" => $this->trans->t("File not found")];
|
||||
}
|
||||
|
||||
$result = Helper::formatFileInfo($fileInfo);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print editor section
|
||||
*
|
||||
* @param integer $fileId - file identifier
|
||||
*
|
||||
* @return TemplateResponse
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function index($fileId) {
|
||||
$params = $this->getParam($fileId);
|
||||
|
||||
$response = new TemplateResponse($this->appName, "editor", $params);
|
||||
|
||||
$csp = new ContentSecurityPolicy();
|
||||
$csp->allowInlineScript(true);
|
||||
|
||||
$documentServerUrl = $params["documentServerUrl"];
|
||||
if (isset($documentServerUrl) && !empty($documentServerUrl)) {
|
||||
$csp->addAllowedScriptDomain($documentServerUrl);
|
||||
$csp->addAllowedFrameDomain($documentServerUrl);
|
||||
}
|
||||
$response->setContentSecurityPolicy($csp);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collecting the file parameters for the document service
|
||||
*
|
||||
* @param integer $fileId - file identifier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getParam($fileId) {
|
||||
list ($file, $error) = $this->getFile($fileId);
|
||||
|
||||
if (isset($error)) {
|
||||
return ["error" => $error];
|
||||
}
|
||||
|
||||
$fileName = $file->getName();
|
||||
$ext = pathinfo($fileName, PATHINFO_EXTENSION);
|
||||
$format = $this->config->formats[$ext];
|
||||
if (!isset($format)) {
|
||||
return ["error" => $this->trans->t("Format do not supported")];
|
||||
}
|
||||
|
||||
$documentServerUrl = $this->config->GetDocumentServerUrl();
|
||||
|
||||
if (empty($documentServerUrl)) {
|
||||
return ["error" => $this->trans->t("ONLYOFFICE app not configured. Please contact admin")];
|
||||
}
|
||||
|
||||
$userId = $this->user->getUID();
|
||||
$ownerId = $file->getOwner()->getUID();
|
||||
try {
|
||||
$this->root->getUserFolder($ownerId);
|
||||
} catch (NoUserException $e) {
|
||||
$ownerId = $userId;
|
||||
}
|
||||
|
||||
$fileId = $file->getId();
|
||||
$hashCallback = $this->crypt->GetHash(["fileId" => $fileId, "ownerId" => $ownerId, "action" => "track"]);
|
||||
$fileUrl = $this->getUrl($file);
|
||||
$key = $this->getKey($file);
|
||||
|
||||
$canEdit = isset($format["edit"]) && $format["edit"];
|
||||
|
||||
$params = [
|
||||
"documentServerUrl" => $documentServerUrl,
|
||||
|
||||
"callback" => ($file->isUpdateable() && $canEdit ? $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.track", ["doc" => $hashCallback]) : NULL),
|
||||
"fileName" => $fileName,
|
||||
"key" => DocumentService::GenerateRevisionId($key),
|
||||
"url" => $fileUrl,
|
||||
"userId" => $userId,
|
||||
"userName" => $this->user->getDisplayName(),
|
||||
"documentType" => $format["type"]
|
||||
];
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting file by identifier
|
||||
*
|
||||
* @param integer $fileId - file identifier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getFile($fileId) {
|
||||
if (empty($fileId)) {
|
||||
return [NULL, $this->trans->t("FileId is empty")];
|
||||
}
|
||||
|
||||
$files = $this->root->getById($fileId);
|
||||
if(empty($files)) {
|
||||
return [NULL, $this->trans->t("File not found")];
|
||||
}
|
||||
$file = $files[0];
|
||||
|
||||
if (!$file->isReadable()) {
|
||||
return [NULL, $this->trans->t("You do not have enough permissions to view the file")];
|
||||
}
|
||||
return [$file, NULL];
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate unique document identifier
|
||||
*
|
||||
* @param \OCP\Files\File - file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getKey($file) {
|
||||
$fileId = $file->getId();
|
||||
|
||||
$ownerId = $file->getOwner()->getUID();
|
||||
try {
|
||||
$this->root->getUserFolder($ownerId);
|
||||
} catch (NoUserException $e) {
|
||||
$ownerId = $this->user->getUID();
|
||||
}
|
||||
|
||||
$key = $fileId . $file->getMtime();
|
||||
|
||||
$ownerView = new View('/'.$ownerId.'/files');
|
||||
$filePath = $ownerView->getPath($fileId);
|
||||
$versions = "";
|
||||
try {
|
||||
$versions = Storage::getVersions($ownerId, $filePath);
|
||||
} catch (AutoloadNotAllowedException $e) {
|
||||
}
|
||||
|
||||
$countVersions = count($versions);
|
||||
if ($countVersions > 0) {
|
||||
$key = $key . $countVersions;
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate secure link to download document
|
||||
*
|
||||
* @param \OCP\Files\File - file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getUrl($file) {
|
||||
$fileId = $file->getId();
|
||||
|
||||
$ownerId = $file->getOwner()->getUID();
|
||||
try {
|
||||
$this->root->getUserFolder($ownerId);
|
||||
} catch (NoUserException $e) {
|
||||
$ownerId = $userId;
|
||||
}
|
||||
|
||||
$hashUrl = $this->crypt->GetHash(["fileId" => $fileId, "ownerId" => $ownerId, "action" => "download"]);
|
||||
|
||||
$fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.download", ["doc" => $hashUrl]);
|
||||
return $fileUrl;
|
||||
}
|
||||
}
|
93
controller/settingscontroller.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Onlyoffice\Controller;
|
||||
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\IRequest;
|
||||
|
||||
use OCA\Onlyoffice\AppConfig;
|
||||
|
||||
/**
|
||||
* Settings controller for the administration page
|
||||
*/
|
||||
class SettingsController extends Controller {
|
||||
|
||||
/**
|
||||
* Application configuration
|
||||
*
|
||||
* @var OCA\Onlyoffice\AppConfig
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @param string $AppName application name
|
||||
* @param IRequest $request request object
|
||||
* @param OCA\Onlyoffice\AppConfig $config application configuration
|
||||
*/
|
||||
public function __construct($AppName,
|
||||
IRequest $request,
|
||||
AppConfig $config
|
||||
) {
|
||||
parent::__construct($AppName, $request);
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print config section
|
||||
*
|
||||
* @return TemplateResponse
|
||||
*/
|
||||
public function index() {
|
||||
$data = [ "documentserver" => $this->config->GetDocumentServerUrl()];
|
||||
return new TemplateResponse($this->appName, "settings", $data, "blank");
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the document server address
|
||||
*
|
||||
* @param string $documentserver application name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function settings($documentserver) {
|
||||
$this->config->SetDocumentServerUrl($documentserver);
|
||||
return [ "documentserver" => $this->config->GetDocumentServerUrl()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get supported formats
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function formats(){
|
||||
return $this->config->formats;
|
||||
}
|
||||
}
|
32
css/editor.css
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
#app > iframe {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#iframeEditor.error {
|
||||
color: red;
|
||||
}
|
34
css/main.css
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
.onlyoffice-new-docx {
|
||||
background-image: url("../img/new-docx.svg");
|
||||
}
|
||||
.onlyoffice-new-xlsx {
|
||||
background-image: url("../img/new-xlsx.svg");
|
||||
}
|
||||
.onlyoffice-new-pptx {
|
||||
background-image: url("../img/new-pptx.svg");
|
||||
}
|
36
css/settings.css
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
.section-onlyoffice h2 {
|
||||
display: inline;
|
||||
}
|
||||
.onlyoffice-header {
|
||||
margin-top: 16px;
|
||||
}
|
||||
.section-onlyoffice input {
|
||||
display: block;
|
||||
margin: 6px 0 4px;
|
||||
width: 250px;
|
||||
}
|
18
img/app.svg
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 32 32" style="enable-background:new 0 0 32 32;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{opacity:0.42;fill:#FFFFFF;enable-background:new ;}
|
||||
.st1{opacity:0.72;fill:#FFFFFF;enable-background:new ;}
|
||||
.st2{fill:#FFFFFF;}
|
||||
</style>
|
||||
<g id="XMLID_5_">
|
||||
<path id="XMLID_3_" class="st0" d="M13.8,30.3L1,24.2c-1.2-0.5-1.2-1.3,0-1.8l4.3-2.2l8.5,4c1.2,0.5,2.8,0.5,4,0l8.5-4l4.5,2.2
|
||||
c1.2,0.5,1.2,1.3,0,1.8l-12.8,6.1C16.7,30.8,14.9,30.8,13.8,30.3L13.8,30.3z"/>
|
||||
<path id="XMLID_2_" class="st1" d="M13.8,23L1,16.9c-1.2-0.5-1.2-1.3,0-1.8l4.5-2.2l8.5,4c1.2,0.5,2.8,0.5,4,0l8.6-4l4.5,2
|
||||
c1.2,0.5,1.2,1.3,0,1.8l-12.9,6.1C16.7,23.5,14.9,23.5,13.8,23L13.8,23z"/>
|
||||
<path id="XMLID_1_" class="st2" d="M13.8,15.8L1,9.6c-1.2-0.5-1.2-1.3,0-1.8l12.8-6.1c1.2-0.5,2.8-0.5,4,0l12.8,6.1
|
||||
c1.2,0.5,1.2,1.3,0,1.8l-12.8,6.1C16.7,16.2,14.9,16.2,13.8,15.8L13.8,15.8z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
17
img/btn-edit.svg
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{opacity:0.42;enable-background:new ;}
|
||||
.st1{opacity:0.72;enable-background:new ;}
|
||||
</style>
|
||||
<g id="XMLID_5_">
|
||||
<path id="XMLID_3_" class="st0" d="M6.9,15.2l-6.4-3.1c-0.6-0.2-0.6-0.7,0-0.9l2.2-1.1l4.2,2c0.6,0.2,1.4,0.2,2,0l4.2-2l2.2,1.1
|
||||
c0.6,0.2,0.6,0.7,0,0.9L9,15.2C8.4,15.4,7.5,15.4,6.9,15.2L6.9,15.2z"/>
|
||||
<path id="XMLID_2_" class="st1" d="M6.9,11.5L0.5,8.5c-0.6-0.2-0.6-0.7,0-0.9l2.2-1.1l4.2,2c0.6,0.2,1.4,0.2,2,0l4.3-2l2.2,1
|
||||
c0.6,0.2,0.6,0.7,0,0.9L9,11.4C8.4,11.8,7.5,11.8,6.9,11.5L6.9,11.5z"/>
|
||||
<path id="XMLID_1_" d="M6.9,7.9L0.5,4.8c-0.6-0.2-0.6-0.7,0-0.9l6.4-3.1c0.6-0.2,1.4-0.2,2,0l6.4,3.1c0.6,0.2,0.6,0.7,0,0.9
|
||||
L8.9,7.9C8.4,8.1,7.5,8.1,6.9,7.9L6.9,7.9z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.0 KiB |
23
img/new-docx.svg
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 40.3 (33839) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>ownCloud-icon-doc-16x16</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
<path d="M7.92893219,1.77635684e-15 L0.995577499,1.77635684e-15 C0.444836974,1.77635684e-15 0,0.450780073 0,1.00684547 L0,12.9931545 C0,13.5500512 0.445735229,14 0.995577499,14 L10.0044225,14 C10.555163,14 11,13.5492199 11,12.9931545 L11,3.07106781 L7.92893219,4.99600361e-16 Z" id="path-1"></path>
|
||||
</defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Artboard" transform="translate(-24.000000, -26.000000)">
|
||||
<g id="Group-Copy" transform="translate(26.000000, 27.000000)">
|
||||
<g id="Rectangle-3">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use id="Mask" fill="#5A7DC9" xlink:href="#path-1"></use>
|
||||
<rect fill="#1F4FB7" mask="url(#mask-2)" x="7" y="-2" width="6" height="6" rx="2"></rect>
|
||||
</g>
|
||||
<path d="M2,8 L9,8 L9,9 L2,9 L2,8 Z M2,6 L9,6 L9,7 L2,7 L2,6 Z M2,10 L9,10 L9,11 L2,11 L2,10 Z" id="Combined-Shape" fill="#FFFFFF"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
23
img/new-pptx.svg
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 40.3 (33839) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>ownCloud-icon-pres-16x16</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
<path d="M7.92893219,8.8817842e-16 L0.995577499,8.8817842e-16 C0.444836974,8.8817842e-16 0,0.450780073 0,1.00684547 L0,12.9931545 C0,13.5500512 0.445735229,14 0.995577499,14 L10.0044225,14 C10.555163,14 11,13.5492199 11,12.9931545 L11,3.07106781 L7.92893219,4.99600361e-16 Z" id="path-1"></path>
|
||||
</defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Artboard" transform="translate(-70.000000, -26.000000)">
|
||||
<g id="Group-Copy-2" transform="translate(72.000000, 27.000000)">
|
||||
<g id="Rectangle-3">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use id="Mask" fill="#DD682B" xlink:href="#path-1"></use>
|
||||
<rect fill="#AA3E06" mask="url(#mask-2)" x="7" y="-2" width="6" height="6" rx="2"></rect>
|
||||
</g>
|
||||
<path d="M2,6 L9,6 L9,11 L2,11 L2,6 Z M3,7 L8,7 L8,10 L3,10 L3,7 Z" id="Combined-Shape" fill="#FFFFFF"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
23
img/new-xlsx.svg
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 40.3 (33839) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>ownCloud-icon-ss-16x16</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
<path d="M7.92893219,-8.8817842e-16 L0.995577499,-8.8817842e-16 C0.444836974,-8.8817842e-16 0,0.450780073 0,1.00684547 L0,12.9931545 C0,13.5500512 0.445735229,14 0.995577499,14 L10.0044225,14 C10.555163,14 11,13.5492199 11,12.9931545 L11,3.07106781 L7.92893219,-1.94289029e-15 Z" id="path-1"></path>
|
||||
</defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Artboard" transform="translate(-47.000000, -26.000000)">
|
||||
<g id="Group" transform="translate(49.000000, 27.000000)">
|
||||
<g id="Rectangle-3">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use id="Mask" fill="#95AF57" xlink:href="#path-1"></use>
|
||||
<rect fill="#688524" mask="url(#mask-2)" x="7" y="-2" width="6" height="6" rx="2"></rect>
|
||||
</g>
|
||||
<path d="M2,6 L9,6 L9,11 L2,11 L2,6 Z M3,7 L5,7 L5,8 L3,8 L3,7 Z M3,9 L5,9 L5,10 L3,10 L3,9 Z M6,9 L8,9 L8,10 L6,10 L6,9 Z M6,7 L8,7 L8,8 L6,8 L6,7 Z" id="Combined-Shape" fill="#FFFFFF"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
72
js/editor.js
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
(function ($, OCA) {
|
||||
|
||||
OCA.Onlyoffice = _.extend({}, OCA.Onlyoffice);
|
||||
if (!OCA.Onlyoffice.AppName) {
|
||||
OCA.Onlyoffice = {
|
||||
AppName: "onlyoffice"
|
||||
};
|
||||
}
|
||||
|
||||
OCA.Onlyoffice.OpenEditor = function (data) {
|
||||
if (typeof DocsAPI === "undefined" && !data.error.length) {
|
||||
data.error = t(OCA.Onlyoffice.AppName, "ONLYOFFICE app not configured. Please contact admin");
|
||||
}
|
||||
|
||||
if (data.error.length) {
|
||||
$("#iframeEditor").text(data.error).addClass("error");
|
||||
return;
|
||||
}
|
||||
|
||||
var ext = (data.title || "").toLowerCase().split(".").pop();
|
||||
|
||||
var config = {
|
||||
"document": {
|
||||
"fileType": ext,
|
||||
"key": data.key,
|
||||
"title": data.title,
|
||||
"url": data.url
|
||||
},
|
||||
"documentType": data.documentType,
|
||||
"editorConfig": {
|
||||
"callbackUrl": (data.callbackUrl ? data.callbackUrl : null),
|
||||
"lang": "en-US",
|
||||
"mode": (data.callbackUrl ? "edit" : "view"),
|
||||
"user": {
|
||||
"id": data.userId,
|
||||
"name": data.userName
|
||||
}
|
||||
},
|
||||
"height": "100%",
|
||||
"type": "desktop",
|
||||
"width": "100%"
|
||||
};
|
||||
|
||||
var docEditor = new DocsAPI.DocEditor("iframeEditor", config);
|
||||
};
|
||||
|
||||
})(jQuery, OCA);
|
194
js/main.js
Normal file
@ -0,0 +1,194 @@
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
(function (OCA) {
|
||||
|
||||
OCA.Onlyoffice = _.extend({}, OCA.Onlyoffice);
|
||||
if (!OCA.Onlyoffice.AppName) {
|
||||
OCA.Onlyoffice = {
|
||||
AppName: "onlyoffice"
|
||||
};
|
||||
}
|
||||
|
||||
OCA.Onlyoffice.CreateFile = function (name, fileList) {
|
||||
var dir = fileList.getCurrentDirectory();
|
||||
|
||||
var winEditor = window.open("");
|
||||
if (winEditor) {
|
||||
winEditor.document.write(t(OCA.Onlyoffice.AppName, "Loading, please wait."));
|
||||
winEditor.document.close();
|
||||
}
|
||||
|
||||
$.post(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/new"),
|
||||
{
|
||||
name: name,
|
||||
dir: dir
|
||||
},
|
||||
function onSuccess(response) {
|
||||
if (response.error) {
|
||||
winEditor.close();
|
||||
var row = OC.Notification.show(response.error);
|
||||
setTimeout(function () {
|
||||
OC.Notification.hide(row);
|
||||
}, 3000);
|
||||
return;
|
||||
}
|
||||
|
||||
fileList.add(response, { animate: true });
|
||||
OCA.Onlyoffice.OpenEditor(response.id, winEditor);
|
||||
|
||||
var row = OC.Notification.show(t(OCA.Onlyoffice.AppName, "File created"));
|
||||
setTimeout(function () {
|
||||
OC.Notification.hide(row);
|
||||
}, 3000);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
OCA.Onlyoffice.OpenEditor = function (fileId, winEditor) {
|
||||
var url = OC.generateUrl("/apps/" + OCA.Onlyoffice.AppName + "/{fileId}",
|
||||
{
|
||||
fileId: fileId
|
||||
});
|
||||
|
||||
if (winEditor && winEditor.location) {
|
||||
winEditor.location.href = url;
|
||||
} else {
|
||||
winEditor = window.open(url, "_blank");
|
||||
}
|
||||
};
|
||||
|
||||
OCA.Onlyoffice.FileClick = function (context, attr) {
|
||||
var fileInfoModel = context.fileInfoModel;
|
||||
var fileList = context.fileList;
|
||||
if (!attr.conv) {
|
||||
OCA.Onlyoffice.OpenEditor(fileInfoModel.id);
|
||||
return;
|
||||
}
|
||||
|
||||
OC.dialogs.confirm(t(OCA.Onlyoffice.AppName, "The document file you open will be converted to the Office Open XML format for faster viewing and editing."),
|
||||
t(OCA.Onlyoffice.AppName, "Convert and open document"),
|
||||
function (convert) {
|
||||
if (!convert) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.post(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/convert"),
|
||||
{
|
||||
fileId: fileInfoModel.id
|
||||
},
|
||||
function onSuccess(response) {
|
||||
if (response.error) {
|
||||
var row = OC.Notification.show(response.error);
|
||||
setTimeout(function () {
|
||||
OC.Notification.hide(row);
|
||||
}, 3000);
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.parentId == fileList.dirInfo.id) {
|
||||
fileList.add(response, { animate: true });
|
||||
}
|
||||
|
||||
var row = OC.Notification.show(t(OCA.Onlyoffice.AppName, "File created"));
|
||||
setTimeout(function () {
|
||||
OC.Notification.hide(row);
|
||||
}, 3000);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
OCA.Onlyoffice.FileList = {
|
||||
attach: function (fileList) {
|
||||
if (fileList.id == "trashbin") {
|
||||
return;
|
||||
}
|
||||
|
||||
$.get(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/settings"),
|
||||
function onSuccess(mimes) {
|
||||
|
||||
OCA.Onlyoffice.mimes = mimes;
|
||||
$.each(mimes, function (ext, attr) {
|
||||
fileList.fileActions.registerAction({
|
||||
name: "onlyofficeOpen",
|
||||
displayName: t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"),
|
||||
mime: attr.mime,
|
||||
permissions: OC.PERMISSION_READ,
|
||||
icon: function () {
|
||||
return OC.imagePath(OCA.Onlyoffice.AppName, "btn-edit");
|
||||
},
|
||||
actionHandler: function (fileName, context) {
|
||||
OCA.Onlyoffice.FileClick(context, attr);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
OCA.Onlyoffice.NewFileMenu = {
|
||||
attach: function (menu) {
|
||||
var fileList = menu.fileList;
|
||||
|
||||
if (fileList.id !== "files") {
|
||||
return;
|
||||
}
|
||||
|
||||
menu.addMenuEntry({
|
||||
id: "onlyofficeDocx",
|
||||
displayName: t(OCA.Onlyoffice.AppName, "Document"),
|
||||
iconClass: "onlyoffice-new-docx",
|
||||
fileType: "docx",
|
||||
actionHandler: function (name) {
|
||||
OCA.Onlyoffice.CreateFile(name + ".docx", fileList);
|
||||
}
|
||||
});
|
||||
|
||||
menu.addMenuEntry({
|
||||
id: "onlyofficeXlsx",
|
||||
displayName: t(OCA.Onlyoffice.AppName, "Spreadsheet"),
|
||||
iconClass: "onlyoffice-new-xlsx",
|
||||
fileType: "xlsx",
|
||||
actionHandler: function (name) {
|
||||
OCA.Onlyoffice.CreateFile(name + ".xlsx", fileList);
|
||||
}
|
||||
});
|
||||
|
||||
menu.addMenuEntry({
|
||||
id: "onlyofficePpts",
|
||||
displayName: t(OCA.Onlyoffice.AppName, "Presentation"),
|
||||
iconClass: "onlyoffice-new-pptx",
|
||||
fileType: "pptx",
|
||||
actionHandler: function (name) {
|
||||
OCA.Onlyoffice.CreateFile(name + ".pptx", fileList);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
})(OCA);
|
||||
|
||||
OC.Plugins.register("OCA.Files.FileList", OCA.Onlyoffice.FileList);
|
||||
OC.Plugins.register("OCA.Files.NewFileMenu", OCA.Onlyoffice.NewFileMenu);
|
63
js/settings.js
Normal file
@ -0,0 +1,63 @@
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
(function ($, OC) {
|
||||
|
||||
$(document).ready(function () {
|
||||
OCA.Onlyoffice = _.extend({}, OCA.Onlyoffice);
|
||||
if (!OCA.Onlyoffice.AppName) {
|
||||
OCA.Onlyoffice = {
|
||||
AppName: "onlyoffice"
|
||||
};
|
||||
}
|
||||
|
||||
$("#onlyofficeSave").click(function () {
|
||||
var docServiceUrlApi = $("#docServiceUrlApi").val().trim();
|
||||
|
||||
$.ajax({
|
||||
method: "PUT",
|
||||
url: OC.generateUrl("apps/onlyoffice/ajax/settings"),
|
||||
data: { documentserver: docServiceUrlApi },
|
||||
success: function onSuccess(response) {
|
||||
if (response && response.documentserver != null) {
|
||||
$("#docServiceUrlApi").val(response.documentserver);
|
||||
var row = OC.Notification.show(t(OCA.Onlyoffice.AppName, "Settings have been successfully updated"));
|
||||
setTimeout(function () {
|
||||
OC.Notification.hide(row);
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#docServiceUrlApi").keypress(function (e) {
|
||||
var code = e.keyCode || e.which;
|
||||
if (code === 13) {
|
||||
$("#onlyofficeSave").click();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
})(jQuery, OC);
|
151
lib/appconfig.php
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Onlyoffice;
|
||||
|
||||
use OCP\IConfig;
|
||||
|
||||
/**
|
||||
* Application configutarion
|
||||
*
|
||||
* @package OCA\Onlyoffice
|
||||
*/
|
||||
class AppConfig {
|
||||
|
||||
/**
|
||||
* Application name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $appName;
|
||||
|
||||
/**
|
||||
* Config service
|
||||
*
|
||||
* @var OCP\IConfig
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* The config key for the document server address
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_documentserver = "DocumentServerUrl";
|
||||
|
||||
/**
|
||||
* The config key for the secret key
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_cryptSecret = "skey";
|
||||
|
||||
/**
|
||||
* @param string $AppName application name
|
||||
*/
|
||||
public function __construct($AppName) {
|
||||
|
||||
$this->appName = $AppName;
|
||||
$this->config = \OC::$server->getConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the document service address to the application configuration
|
||||
*
|
||||
* @param string $documentServer - document service address
|
||||
*/
|
||||
public function SetDocumentServerUrl($documentServer) {
|
||||
$documentServer = rtrim(trim($documentServer), "/");
|
||||
$this->config->setAppValue($this->appName, $this->_documentserver, $documentServer);
|
||||
$this->DropSKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the document service address from the application configuration
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetDocumentServerUrl() {
|
||||
return $this->config->getAppValue($this->appName, $this->_documentserver, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the secret key from the application configuration
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetSKey() {
|
||||
$skey = $this->config->getAppValue($this->appName, $this->_cryptSecret, "");
|
||||
if (empty($skey)) {
|
||||
$skey = number_format(round(microtime(true) * 1000), 0, ".", "");
|
||||
$this->config->setAppValue($this->appName, $this->_cryptSecret, $skey);
|
||||
}
|
||||
return $skey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regenerate the secret key
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function DropSKey() {
|
||||
$skey = $this->config->getAppValue($this->appName, $this->_cryptSecret, "");
|
||||
if (!empty($skey)) {
|
||||
$skey = number_format(round(microtime(true) * 1000), 0, ".", "");
|
||||
$this->config->setAppValue($this->appName, $this->_cryptSecret, $skey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Additional data about formats
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $formats = [
|
||||
"docx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "type" => "text", "edit" => true ],
|
||||
"xlsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "type" => "spreadsheet", "edit" => true ],
|
||||
"pptx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", "type" => "presentation", "edit" => true ],
|
||||
"ppsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "type" => "presentation", "edit" => true ],
|
||||
"txt" => [ "mime" => "text/plain", "type" => "text", "edit" => true ],
|
||||
"csv" => [ "mime" => "text/csv", "type" => "spreadsheet"/*, "edit" => true*/ ],
|
||||
"odt" => [ "mime" => "application/vnd.oasis.opendocument.text", "type" => "text", "conv" => true ],
|
||||
"ods" => [ "mime" => "application/vnd.oasis.opendocument.spreadsheet", "type" => "spreadsheet", "conv" => true ],
|
||||
"odp" => [ "mime" => "application/vnd.oasis.opendocument.presentation", "type" => "presentation", "conv" => true ],
|
||||
"doc" => [ "mime" => "application/msword", "type" => "text", "conv" => true ],
|
||||
"xls" => [ "mime" => "application/vnd.ms-excel", "type" => "spreadsheet", "conv" => true ],
|
||||
"ppt" => [ "mime" => "application/vnd.ms-powerpoint", "type" => "presentation", "conv" => true ],
|
||||
"pps" => [ "mime" => "application/vnd.ms-powerpoint", "type" => "presentation", "conv" => true ],
|
||||
"epub" => [ "mime" => "application/epub+zip", "type" => "text", "conv" => true ],
|
||||
"rtf" => [ "mime" => "text/rtf", "type" => "text", "type" => "text", "conv" => true ],
|
||||
"mht" => [ "mime" => "message/rfc822", "conv" => true ],
|
||||
"html" => [ "mime" => "text/html", "type" => "text", "conv" => true ],
|
||||
"htm" => [ "mime" => "text/html", "type" => "text", "conv" => true ],
|
||||
"xps" => [ "mime" => "application/vnd.ms-xpsdocument", "type" => "text" ],
|
||||
"pdf" => [ "mime" => "application/pdf", "type" => "text" ],
|
||||
"djvu" => [ "mime" => "image/vnd.djvu", "type" => "text" ]
|
||||
];
|
||||
}
|
104
lib/crypt.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Onlyoffice;
|
||||
|
||||
use OCA\Onlyoffice\AppConfig;
|
||||
|
||||
/**
|
||||
* Hash generator
|
||||
*
|
||||
* @package OCA\Onlyoffice
|
||||
*/
|
||||
class Crypt {
|
||||
|
||||
/**
|
||||
* The secret key from the application configuration
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $skey;
|
||||
|
||||
/**
|
||||
* @param OCA\Onlyoffice\AppConfig $config application configutarion
|
||||
*/
|
||||
public function __construct(AppConfig $appConfig) {
|
||||
$this->skey = $appConfig->GetSKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate base64 hash for the object
|
||||
*
|
||||
* @param array $object - object to signature hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetHash($object) {
|
||||
$primaryKey = json_encode($object);
|
||||
$hash = $this->SignatureCreate($primaryKey);
|
||||
return $hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an object from the base64 hash
|
||||
*
|
||||
* @param string $hash - base64 hash
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function ReadHash($hash) {
|
||||
$result = NULL;
|
||||
if ($hash === NULL) {
|
||||
return $result;
|
||||
}
|
||||
try {
|
||||
$payload = base64_decode($hash);
|
||||
$payloadParts = explode("?", $payload);
|
||||
|
||||
$encode = base64_encode( hash( "sha256", ($payloadParts[1] . $this->skey), true ) );
|
||||
|
||||
if ($payloadParts[0] === $encode) {
|
||||
$result = json_decode($payloadParts[1]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate base64 hash for the object
|
||||
*
|
||||
* @param string $primary_key - string to the signature hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function SignatureCreate($primary_key) {
|
||||
$payload = base64_encode( hash( "sha256", ($primary_key . $this->skey), true ) ) . "?" . $primary_key;
|
||||
$base64Str = base64_encode($payload);
|
||||
|
||||
return $base64Str;
|
||||
}
|
||||
}
|
247
lib/documentservice.php
Normal file
@ -0,0 +1,247 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Onlyoffice;
|
||||
|
||||
use OCP\IL10N;
|
||||
|
||||
use OCA\Onlyoffice\AppConfig;
|
||||
|
||||
/**
|
||||
* Class service connector to Document Service
|
||||
*
|
||||
* @package OCA\Onlyoffice
|
||||
*/
|
||||
class DocumentService {
|
||||
|
||||
/**
|
||||
* l10n service
|
||||
*
|
||||
* @var IL10N
|
||||
*/
|
||||
private $trans;
|
||||
|
||||
/**
|
||||
* Application configuration
|
||||
*
|
||||
* @var OCA\Onlyoffice\AppConfig
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @param OCA\Onlyoffice\AppConfig $config application configutarion
|
||||
*/
|
||||
public function __construct(IL10N $trans, AppConfig $appConfig) {
|
||||
$this->trans = $trans;
|
||||
$this->config = $appConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translation key to a supported form.
|
||||
*
|
||||
* @param string $expected_key Expected key
|
||||
*
|
||||
* @return Supported key
|
||||
*/
|
||||
public static function GenerateRevisionId($expected_key) {
|
||||
if (strlen($expected_key) > 20) {
|
||||
$expected_key = crc32( $expected_key);
|
||||
}
|
||||
$key = preg_replace("[^0-9-.a-zA-Z_=]", "_", $expected_key);
|
||||
$key = substr($key, 0, min(array(strlen($key), 20)));
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method is to convert the file to the required format
|
||||
*
|
||||
* @param string $document_uri - Uri for the document to convert
|
||||
* @param string $from_extension - Document extension
|
||||
* @param string $to_extension - Extension to which to convert
|
||||
* @param string $document_revision_id - Key for caching on service
|
||||
* @param bool $is_async - Perform conversions asynchronously
|
||||
* @param string $converted_document_uri - Uri to the converted document
|
||||
*
|
||||
* @return The percentage of completion of conversion
|
||||
*/
|
||||
function GetConvertedUri($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async, &$converted_document_uri) {
|
||||
$converted_document_uri = "";
|
||||
$responceFromConvertService = $this->SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async);
|
||||
|
||||
$errorElement = $responceFromConvertService->Error;
|
||||
if ($errorElement->count() > 0) {
|
||||
$this->ProcessConvServResponceError($errorElement."");
|
||||
}
|
||||
|
||||
$isEndConvert = $responceFromConvertService->EndConvert;
|
||||
$percent = $responceFromConvertService->Percent . "";
|
||||
|
||||
if ($isEndConvert !== NULL && strtolower($isEndConvert) === "true") {
|
||||
$converted_document_uri = $responceFromConvertService->FileUrl;
|
||||
$percent = 100;
|
||||
} else if ($percent >= 100) {
|
||||
$percent = 99;
|
||||
}
|
||||
|
||||
return $percent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request for conversion to a service
|
||||
*
|
||||
* @param string $document_uri - Uri for the document to convert
|
||||
* @param string $from_extension - Document extension
|
||||
* @param string $to_extension - Extension to which to convert
|
||||
* @param string $document_revision_id - Key for caching on service
|
||||
* @param bool - $is_async - Perform conversions asynchronously
|
||||
*
|
||||
* @return Xml document request result of conversion
|
||||
*/
|
||||
function SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async) {
|
||||
if (empty($from_extension)) {
|
||||
$path_parts = pathinfo($document_uri);
|
||||
$from_extension = $path_parts["extension"];
|
||||
}
|
||||
|
||||
$title = basename($document_uri);
|
||||
if (empty($title)) {
|
||||
$title = $document_revision_id . $from_extension;
|
||||
}
|
||||
|
||||
if (empty($document_revision_id)) {
|
||||
$document_revision_id = $document_uri;
|
||||
}
|
||||
|
||||
$document_revision_id = self::GenerateRevisionId($document_revision_id);
|
||||
|
||||
$documentServerUrl = $this->config->GetDocumentServerUrl();
|
||||
|
||||
if (empty($documentServerUrl)) {
|
||||
throw new \Exception($this->trans->t("ONLYOFFICE app not configured. Please contact admin"));
|
||||
}
|
||||
|
||||
$urlToConverter = $documentServerUrl . "/ConvertService.ashx";
|
||||
|
||||
$data = json_encode(
|
||||
array(
|
||||
"async" => $is_async,
|
||||
"url" => $document_uri,
|
||||
"outputtype" => trim($to_extension, "."),
|
||||
"filetype" => trim($from_extension, "."),
|
||||
"title" => $title,
|
||||
"key" => $document_revision_id
|
||||
)
|
||||
);
|
||||
|
||||
$response_xml_data;
|
||||
$countTry = 0;
|
||||
|
||||
$opts = array("http" => array(
|
||||
"method" => "POST",
|
||||
"timeout" => "120000",
|
||||
"header"=> "Content-type: application/json\r\n",
|
||||
"content" => $data
|
||||
)
|
||||
);
|
||||
|
||||
if (substr($urlToConverter, 0, strlen("https")) === "https") {
|
||||
$opts["ssl"] = array( "verify_peer" => FALSE );
|
||||
}
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
$ServiceConverterMaxTry = 3;
|
||||
while ($countTry < $ServiceConverterMaxTry) {
|
||||
$countTry = $countTry + 1;
|
||||
$response_xml_data = file_get_contents($urlToConverter, FALSE, $context);
|
||||
if ($response_xml_data !== false){ break; }
|
||||
}
|
||||
|
||||
if ($countTry === $ServiceConverterMaxTry) {
|
||||
throw new \Exception ($this->trans->t("Bad Request or timeout error"));
|
||||
}
|
||||
|
||||
libxml_use_internal_errors(true);
|
||||
if (!function_exists("simplexml_load_file")) {
|
||||
throw new \Exception($this->trans->t("Server can't read xml"));
|
||||
}
|
||||
$response_data = simplexml_load_string($response_xml_data);
|
||||
if (!$response_data) {
|
||||
$exc = $this->trans->t("Bad Response. Errors: ");
|
||||
foreach(libxml_get_errors() as $error) {
|
||||
$exc = $exc . "\t" . $error->message;
|
||||
}
|
||||
throw new \Exception ($exc);
|
||||
}
|
||||
|
||||
return $response_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an error code table
|
||||
*
|
||||
* @param string $errorCode - Error code
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function ProcessConvServResponceError($errorCode) {
|
||||
$errorMessageTemplate = $this->trans->t("Error occurred in the document service: ");
|
||||
$errorMessage = "";
|
||||
|
||||
switch ($errorCode) {
|
||||
case -8:
|
||||
$errorMessage = $errorMessageTemplate . "Error document VKey";
|
||||
break;
|
||||
case -7:
|
||||
$errorMessage = $errorMessageTemplate . "Error document request";
|
||||
break;
|
||||
case -6:
|
||||
$errorMessage = $errorMessageTemplate . "Error database";
|
||||
break;
|
||||
case -5:
|
||||
$errorMessage = $errorMessageTemplate . "Error unexpected guid";
|
||||
break;
|
||||
case -4:
|
||||
$errorMessage = $errorMessageTemplate . "Error download error";
|
||||
break;
|
||||
case -3:
|
||||
$errorMessage = $errorMessageTemplate . "Error convertation error";
|
||||
break;
|
||||
case -2:
|
||||
$errorMessage = $errorMessageTemplate . "Error convertation timeout";
|
||||
break;
|
||||
case -1:
|
||||
$errorMessage = $errorMessageTemplate . "Error convertation unknown";
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
$errorMessage = $errorMessageTemplate . "ErrorCode = " . $errorCode;
|
||||
break;
|
||||
}
|
||||
|
||||
throw new \Exception($errorMessage);
|
||||
}
|
||||
}
|
64
lib/downloadresponse.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Onlyoffice;
|
||||
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\Files\File;
|
||||
|
||||
/**
|
||||
* A renderer for the file
|
||||
*
|
||||
* @package OCA\Onlyoffice
|
||||
*/
|
||||
class DownloadResponse extends Response {
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* @param OCP\Files\File $file the file to be downloaded
|
||||
*/
|
||||
public function __construct(File $file) {
|
||||
$this->setStatus(Http::STATUS_OK);
|
||||
$this->content = $file->getContent();
|
||||
|
||||
$this->addHeader("Content-type", $file->getMimeType() . "; charset=utf-8");
|
||||
$this->addHeader("Content-Disposition", "attachment; filename*=UTF-8''" . rawurlencode($file->getName()) . "; filename=\"" . rawurlencode($file->getName()) . "\"");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rendered file
|
||||
*
|
||||
* @return string the file
|
||||
*/
|
||||
public function render() {
|
||||
return $this->content;
|
||||
}
|
||||
}
|
61
lib/errorresponse.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Onlyoffice;
|
||||
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\AppFramework\Http;
|
||||
|
||||
/**
|
||||
* A renderer for error
|
||||
*
|
||||
* @package OCA\Onlyoffice
|
||||
*/
|
||||
class ErrorResponse extends Response {
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $message;
|
||||
|
||||
/**
|
||||
* @param int $statusCode the HTTP status code, defaults to 200
|
||||
* @param string $message error description
|
||||
*/
|
||||
public function __construct($statusCode = Http::STATUS_OK, $message = NULL) {
|
||||
$this->setStatus($statusCode);
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rendered file
|
||||
*
|
||||
* @return string the file
|
||||
*/
|
||||
public function render() {
|
||||
return $this->message;
|
||||
}
|
||||
}
|
BIN
screenshots/icon.png
Normal file
After Width: | Height: | Size: 990 B |
BIN
screenshots/main.png
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
screenshots/main_small.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
screenshots/new.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
screenshots/open.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
screenshots/settings.png
Normal file
After Width: | Height: | Size: 26 KiB |
39
settings.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Onlyoffice;
|
||||
|
||||
use OCP\User;
|
||||
|
||||
use OCA\Onlyoffice\AppInfo\Application;
|
||||
|
||||
User::checkAdminUser();
|
||||
|
||||
$app = new Application();
|
||||
$container = $app->getContainer();
|
||||
$response = $container->query("\OCA\Onlyoffice\Controller\SettingsController")->index();
|
||||
|
||||
return $response->render();
|
56
templates/editor.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
style("onlyoffice", "editor");
|
||||
script("onlyoffice", "editor");
|
||||
?>
|
||||
|
||||
<div id="app">
|
||||
|
||||
<div id="iframeEditor"></div>
|
||||
|
||||
<?php if (!empty($_["documentServerUrl"])) {
|
||||
print_unescaped("<script src=\"") .
|
||||
p($_["documentServerUrl"]) .
|
||||
print_unescaped("/web-apps/apps/api/documents/api.js\" type=\"text/javascript\"></script>");
|
||||
} ?>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
OCA.Onlyoffice.OpenEditor ({
|
||||
error: "<?php empty($_["error"]) ? "" : p($_["error"]) ?>",
|
||||
|
||||
callbackUrl: "<?php print_unescaped($_["callback"]) ?>",
|
||||
key: "<?php p($_["key"]) ?>",
|
||||
title: "<?php p($_["fileName"]) ?>",
|
||||
url: "<?php print_unescaped($_["url"]) ?>",
|
||||
userId: "<?php p($_["userId"]) ?>",
|
||||
userName: "<?php p($_["userName"]) ?>",
|
||||
documentType: "<?php p($_["documentType"]) ?>",
|
||||
});
|
||||
</script>
|
||||
|
||||
</div>
|
41
templates/settings.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
||||
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
||||
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
||||
*
|
||||
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
||||
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
||||
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
||||
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
||||
* in every copy of the program you distribute.
|
||||
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
*/
|
||||
|
||||
style("onlyoffice", "settings");
|
||||
script("onlyoffice", "settings");
|
||||
?>
|
||||
<div class="section section-onlyoffice">
|
||||
<h2>ONLYOFFICE</h2>
|
||||
<a target="_blank" class="icon-info svg" title="" href="https://api.onlyoffice.com/editors/owncloud" data-original-title="<?php p($l->t("Documentation")) ?>"></a>
|
||||
|
||||
<p><?php p($l->t("ONLYOFFICE Document Service Location specifies the address of the server with the document services installed. Please change the '<documentserver>' for the server address in the below line.")) ?></p>
|
||||
|
||||
<p class="onlyoffice-header"><?php p($l->t("Document Editing Service Address")) ?></p>
|
||||
<input id="docServiceUrlApi" value="<?php p($_["documentserver"]) ?>" placeholder="https://<documentserver>" type="text">
|
||||
|
||||
<br />
|
||||
<a id="onlyofficeSave" class="button"><?php p($l->t("Save")) ?></a>
|
||||
</div>
|