Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ONLYOFFICE/onlyoffice-nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'appinfo')
-rw-r--r--appinfo/app.php22
-rw-r--r--appinfo/application.php348
-rw-r--r--appinfo/info.xml4
-rw-r--r--appinfo/routes.php5
4 files changed, 219 insertions, 160 deletions
diff --git a/appinfo/app.php b/appinfo/app.php
deleted file mode 100644
index 7979d09..0000000
--- a/appinfo/app.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-/**
- *
- * (c) Copyright Ascensio System SIA 2021
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-namespace OCA\Onlyoffice\AppInfo;
-
-$app = \OC::$server->query(Application::class);
diff --git a/appinfo/application.php b/appinfo/application.php
index 087eb2c..26769ea 100644
--- a/appinfo/application.php
+++ b/appinfo/application.php
@@ -19,12 +19,23 @@
namespace OCA\Onlyoffice\AppInfo;
+use OC\EventDispatcher\SymfonyAdapter;
+
use OCP\AppFramework\App;
+use OCP\AppFramework\Bootstrap\IBootContext;
+use OCP\AppFramework\Bootstrap\IBootstrap;
+use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\Http\ContentSecurityPolicy;
+use OCP\Dashboard\RegisterWidgetEvent;
use OCP\DirectEditing\RegisterDirectEditorEvent;
-use OCP\Files\IMimeTypeDetector;
-use OCP\Util;
+use OCP\Files\Template\FileCreatedFromTemplateEvent;
+use OCP\Files\Template\ITemplateManager;
+use OCP\Files\Template\TemplateFileCreator;
+use OCP\IL10N;
use OCP\IPreview;
+use OCP\ITagManager;
+use OCP\Notification\IManager;
+use OCP\Util;
use OCA\Viewer\Event\LoadViewer;
@@ -36,9 +47,14 @@ use OCA\Onlyoffice\Controller\TemplateController;
use OCA\Onlyoffice\Crypt;
use OCA\Onlyoffice\DirectEditor;
use OCA\Onlyoffice\Hooks;
+use OCA\Onlyoffice\Notifier;
use OCA\Onlyoffice\Preview;
+use OCA\Onlyoffice\TemplateManager;
+use OCA\Onlyoffice\TemplateProvider;
+
+use Psr\Container\ContainerInterface;
-class Application extends App {
+class Application extends App implements IBootstrap {
/**
* Application configuration
@@ -61,181 +77,243 @@ class Application extends App {
$this->appConfig = new AppConfig($appName);
$this->crypt = new Crypt($this->appConfig);
+ }
- // Default script and style if configured
- $eventDispatcher = \OC::$server->getEventDispatcher();
- $eventDispatcher->addListener("OCA\Files::loadAdditionalScripts",
- function () {
- if (!empty($this->appConfig->GetDocumentServerUrl())
- && $this->appConfig->SettingsAreSuccessful()
- && $this->appConfig->isUserAllowedToUse()) {
- Util::addScript("onlyoffice", "desktop");
- Util::addScript("onlyoffice", "main");
- Util::addScript("onlyoffice", "template");
-
- if ($this->appConfig->GetSameTab()) {
- Util::addScript("onlyoffice", "listener");
- }
-
- Util::addStyle("onlyoffice", "main");
- Util::addStyle("onlyoffice", "template");
- }
- });
-
- if (class_exists(LoadViewer::class)) {
- $eventDispatcher->addListener(LoadViewer::class,
- function () {
- if (!empty($this->appConfig->GetDocumentServerUrl())
- && $this->appConfig->SettingsAreSuccessful()
- && $this->appConfig->isUserAllowedToUse()) {
- Util::addScript("onlyoffice", "viewer");
- Util::addScript("onlyoffice", "listener");
-
- Util::addStyle("onlyoffice", "viewer");
-
- $csp = new ContentSecurityPolicy();
- $csp->addAllowedFrameDomain("'self'");
- $cspManager = $this->getContainer()->getServer()->getContentSecurityPolicyManager();
- $cspManager->addDefaultPolicy($csp);
- }
- });
- }
-
- $eventDispatcher->addListener("OCA\Files_Sharing::loadAdditionalScripts",
- function () {
- if (!empty($this->appConfig->GetDocumentServerUrl())
- && $this->appConfig->SettingsAreSuccessful()) {
- Util::addScript("onlyoffice", "main");
-
- if ($this->appConfig->GetSameTab()) {
- Util::addScript("onlyoffice", "listener");
- }
-
- Util::addStyle("onlyoffice", "main");
- }
- });
-
+ public function register(IRegistrationContext $context): void {
require_once __DIR__ . "/../3rdparty/jwt/BeforeValidException.php";
require_once __DIR__ . "/../3rdparty/jwt/ExpiredException.php";
require_once __DIR__ . "/../3rdparty/jwt/SignatureInvalidException.php";
require_once __DIR__ . "/../3rdparty/jwt/JWT.php";
- $container = $this->getContainer();
-
- //todo: remove in v20
- $detector = $container->query(IMimeTypeDetector::class);
- $detector->getAllMappings();
- $detector->registerType("ott", "application/vnd.oasis.opendocument.text-template");
- $detector->registerType("ots", "application/vnd.oasis.opendocument.spreadsheet-template");
- $detector->registerType("otp", "application/vnd.oasis.opendocument.presentation-template");
-
- $previewManager = $container->query(IPreview::class);
- $previewManager->registerProvider(Preview::getMimeTypeRegex(), function() use ($container) {
- return $container->query(Preview::class);
+ $context->registerService("L10N", function (ContainerInterface $c) {
+ return $c->get("ServerContainer")->getL10N($c->get("AppName"));
});
- $container->registerService("L10N", function ($c) {
- return $c->query("ServerContainer")->getL10N($c->query("AppName"));
+ $context->registerService("RootStorage", function (ContainerInterface $c) {
+ return $c->get("ServerContainer")->getRootFolder();
});
- $container->registerService("RootStorage", function ($c) {
- return $c->query("ServerContainer")->getRootFolder();
+ $context->registerService("UserSession", function (ContainerInterface $c) {
+ return $c->get("ServerContainer")->getUserSession();
});
- $container->registerService("UserSession", function ($c) {
- return $c->query("ServerContainer")->getUserSession();
+ $context->registerService("UserManager", function (ContainerInterface $c) {
+ return $c->get("ServerContainer")->getUserManager();
});
- $container->registerService("UserManager", function ($c) {
- return $c->query("ServerContainer")->getUserManager();
+ $context->registerService("Logger", function (ContainerInterface $c) {
+ return $c->get("ServerContainer")->getLogger();
});
- $container->registerService("Logger", function ($c) {
- return $c->query("ServerContainer")->getLogger();
+ $context->registerService("URLGenerator", function (ContainerInterface $c) {
+ return $c->get("ServerContainer")->getURLGenerator();
});
- $container->registerService("URLGenerator", function ($c) {
- return $c->query("ServerContainer")->getURLGenerator();
+ $context->registerService("DirectEditor", function (ContainerInterface $c) {
+ return new DirectEditor(
+ $c->get("AppName"),
+ $c->get("URLGenerator"),
+ $c->get("L10N"),
+ $c->get("Logger"),
+ $this->appConfig,
+ $this->crypt
+ );
});
- if (class_exists("OCP\DirectEditing\RegisterDirectEditorEvent")) {
- $container->registerService("DirectEditor", function ($c) {
- return new DirectEditor(
- $c->query("AppName"),
- $c->query("URLGenerator"),
- $c->query("L10N"),
- $c->query("Logger"),
- $this->appConfig,
- $this->crypt
- );
- });
-
- $eventDispatcher->addListener(RegisterDirectEditorEvent::class,
- function (RegisterDirectEditorEvent $event) use ($container) {
- if (!empty($this->appConfig->GetDocumentServerUrl())
- && $this->appConfig->SettingsAreSuccessful()) {
- $editor = $container->query("DirectEditor");
- $event->register($editor);
- }
- });
- }
-
-
// Controllers
- $container->registerService("SettingsController", function ($c) {
+ $context->registerService("SettingsController", function (ContainerInterface $c) {
return new SettingsController(
- $c->query("AppName"),
- $c->query("Request"),
- $c->query("URLGenerator"),
- $c->query("L10N"),
- $c->query("Logger"),
+ $c->get("AppName"),
+ $c->get("Request"),
+ $c->get("URLGenerator"),
+ $c->get("L10N"),
+ $c->get("Logger"),
$this->appConfig,
$this->crypt
);
});
- $container->registerService("EditorController", function ($c) {
+ $context->registerService("EditorController", function (ContainerInterface $c) {
return new EditorController(
- $c->query("AppName"),
- $c->query("Request"),
- $c->query("RootStorage"),
- $c->query("UserSession"),
- $c->query("UserManager"),
- $c->query("URLGenerator"),
- $c->query("L10N"),
- $c->query("Logger"),
+ $c->get("AppName"),
+ $c->get("Request"),
+ $c->get("RootStorage"),
+ $c->get("UserSession"),
+ $c->get("UserManager"),
+ $c->get("URLGenerator"),
+ $c->get("L10N"),
+ $c->get("Logger"),
$this->appConfig,
$this->crypt,
- $c->query("IManager"),
- $c->query("Session")
+ $c->get("IManager"),
+ $c->get("Session"),
+ $c->get(ITagManager::class)
);
});
- $container->registerService("CallbackController", function ($c) {
+ $context->registerService("CallbackController", function (ContainerInterface $c) {
return new CallbackController(
- $c->query("AppName"),
- $c->query("Request"),
- $c->query("RootStorage"),
- $c->query("UserSession"),
- $c->query("UserManager"),
- $c->query("L10N"),
- $c->query("Logger"),
+ $c->get("AppName"),
+ $c->get("Request"),
+ $c->get("RootStorage"),
+ $c->get("UserSession"),
+ $c->get("UserManager"),
+ $c->get("L10N"),
+ $c->get("Logger"),
$this->appConfig,
$this->crypt,
- $c->query("IManager")
+ $c->get("IManager")
);
});
- $container->registerService("TemplateController", function ($c) {
+ $context->registerService("TemplateController", function (ContainerInterface $c) {
return new TemplateController(
- $c->query("AppName"),
- $c->query("Request"),
- $c->query("L10N"),
- $c->query("Logger")
+ $c->get("AppName"),
+ $c->get("Request"),
+ $c->get("L10N"),
+ $c->get("Logger"),
+ $c->get(IPreview::class)
);
});
+ if (interface_exists("OCP\Files\Template\ICustomTemplateProvider")) {
+ $context->registerTemplateProvider(TemplateProvider::class);
+ }
+
+ }
+
+ public function boot(IBootContext $context): void {
+
+ $context->injectFn(function (SymfonyAdapter $eventDispatcher) {
+
+ $eventDispatcher->addListener('OCA\Files::loadAdditionalScripts',
+ function() {
+ if (!empty($this->appConfig->GetDocumentServerUrl())
+ && $this->appConfig->SettingsAreSuccessful()
+ && $this->appConfig->isUserAllowedToUse()) {
+
+ Util::addScript("onlyoffice", "desktop");
+ Util::addScript("onlyoffice", "main");
+ Util::addScript("onlyoffice", "template");
+
+ if ($this->appConfig->GetSameTab()) {
+ Util::addScript("onlyoffice", "listener");
+ }
+
+ Util::addStyle("onlyoffice", "main");
+ Util::addStyle("onlyoffice", "template");
+ }
+ });
+
+ $eventDispatcher->addListener(LoadViewer::class,
+ function () {
+ if (!empty($this->appConfig->GetDocumentServerUrl())
+ && $this->appConfig->SettingsAreSuccessful()
+ && $this->appConfig->isUserAllowedToUse()) {
+ Util::addScript("onlyoffice", "viewer");
+ Util::addScript("onlyoffice", "listener");
+
+ Util::addStyle("onlyoffice", "viewer");
+
+ $csp = new ContentSecurityPolicy();
+ $csp->addAllowedFrameDomain("'self'");
+ $cspManager = $this->getContainer()->getServer()->getContentSecurityPolicyManager();
+ $cspManager->addDefaultPolicy($csp);
+ }
+ });
+
+ $eventDispatcher->addListener('OCA\Files_Sharing::loadAdditionalScripts',
+ function() {
+ if (!empty($this->appConfig->GetDocumentServerUrl())
+ && $this->appConfig->SettingsAreSuccessful()) {
+ Util::addScript("onlyoffice", "main");
+
+ if ($this->appConfig->GetSameTab()) {
+ Util::addScript("onlyoffice", "listener");
+ }
+
+ Util::addStyle("onlyoffice", "main");
+ }
+ });
+
+ $eventDispatcher->addListener(RegisterWidgetEvent::class,
+ function () {
+ if (!empty($this->appConfig->GetDocumentServerUrl())
+ && $this->appConfig->SettingsAreSuccessful()
+ && $this->appConfig->isUserAllowedToUse()) {
+ Util::addScript("onlyoffice", "desktop");
+ }
+ });
+
+ $container = $this->getContainer();
+
+ if (class_exists("OCP\Files\Template\FileCreatedFromTemplateEvent")) {
+ $eventDispatcher->addListener(FileCreatedFromTemplateEvent::class,
+ function (FileCreatedFromTemplateEvent $event) {
+ $template = $event->getTemplate();
+ if ($template === null) {
+ $targetFile = $event->getTarget();
+ $templateEmpty = TemplateManager::GetEmptyTemplate($targetFile->getName());
+ if ($templateEmpty) {
+ $targetFile->putContent($templateEmpty);
+ }
+ }
+ });
+ }
+
+ $previewManager = $container->query(IPreview::class);
+ $previewManager->registerProvider(Preview::getMimeTypeRegex(), function() use ($container) {
+ return $container->query(Preview::class);
+ });
+
+ $eventDispatcher->addListener(RegisterDirectEditorEvent::class,
+ function (RegisterDirectEditorEvent $event) use ($container) {
+ if (!empty($this->appConfig->GetDocumentServerUrl())
+ && $this->appConfig->SettingsAreSuccessful()) {
+ $editor = $container->query(DirectEditor::class);
+ $event->register($editor);
+ }
+ });
+
+ });
+
+ $context->injectFn(function (IManager $notificationsManager) {
+ $notificationsManager->registerNotifierService(Notifier::class);
+ });
+
+ if (class_exists("OCP\Files\Template\TemplateFileCreator")) {
+ $context->injectFn(function(ITemplateManager $templateManager, IL10N $trans, $appName) {
+ if (!empty($this->appConfig->GetDocumentServerUrl())
+ && $this->appConfig->SettingsAreSuccessful()
+ && $this->appConfig->isUserAllowedToUse()) {
+
+ $templateManager->registerTemplateFileCreator(function () use ($appName, $trans) {
+ $wordTemplate = new TemplateFileCreator($appName, $trans->t("Document"), ".docx");
+ $wordTemplate->addMimetype("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
+ $wordTemplate->setIconClass("icon-onlyoffice-new-docx");
+ $wordTemplate->setRatio(21/29.7);
+ return $wordTemplate;
+ });
+
+ $templateManager->registerTemplateFileCreator(function () use ($appName, $trans) {
+ $cellTemplate = new TemplateFileCreator($appName, $trans->t("Spreadsheet"), ".xlsx");
+ $cellTemplate->addMimetype("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ $cellTemplate->setIconClass("icon-onlyoffice-new-xlsx");
+ $cellTemplate->setRatio(21/29.7);
+ return $cellTemplate;
+ });
+
+ $templateManager->registerTemplateFileCreator(function () use ($appName, $trans) {
+ $slideTemplate = new TemplateFileCreator($appName, $trans->t("Presentation"), ".pptx");
+ $slideTemplate->addMimetype("application/vnd.openxmlformats-officedocument.presentationml.presentation");
+ $slideTemplate->setIconClass("icon-onlyoffice-new-pptx");
+ $slideTemplate->setRatio(16/9);
+ return $slideTemplate;
+ });
+ }
+ });
+ }
Hooks::connectHooks();
}
-}
+} \ No newline at end of file
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 05bf3e1..b835d8c 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -6,7 +6,7 @@
<description>ONLYOFFICE connector allows you to view, edit and collaborate on text documents, spreadsheets and presentations within Nextcloud using ONLYOFFICE Docs. This will create a new Edit in ONLYOFFICE action within the document library for Office documents. This allows multiple users to co-author documents in real time from the familiar web interface and save the changes back to your file storage.</description>
<licence>apache</licence>
<author mail="dev@onlyoffice.com" homepage="https://www.onlyoffice.com/">Ascensio System SIA</author>
- <version>6.4.2</version>
+ <version>7.1.0</version>
<namespace>Onlyoffice</namespace>
<types>
<filesystem/>
@@ -29,7 +29,7 @@
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-nextcloud/master/screenshots/new.png</screenshot>
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-nextcloud/master/screenshots/open.png</screenshot>
<dependencies>
- <nextcloud min-version="19" max-version="21"/>
+ <nextcloud min-version="20" max-version="22"/>
</dependencies>
<settings>
<admin>OCA\Onlyoffice\AdminSettings</admin>
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 42066e7..f4809fa 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -22,10 +22,13 @@ return [
["name" => "callback#download", "url" => "/download", "verb" => "GET"],
["name" => "callback#emptyfile", "url" => "/empty", "verb" => "GET"],
["name" => "callback#track", "url" => "/track", "verb" => "POST"],
- ["name" => "editor#loader", "url" => "/loader", "verb" => "GET"],
+ ["name" => "template#preview", "url" => "/preview", "verb" => "GET"],
["name" => "editor#create_new", "url" => "/new", "verb" => "GET"],
+ ["name" => "editor#download", "url" => "/downloadas", "verb" => "GET"],
["name" => "editor#index", "url" => "/{fileId}", "verb" => "GET"],
["name" => "editor#public_page", "url" => "/s/{shareToken}", "verb" => "GET"],
+ ["name" => "editor#users", "url" => "/ajax/users", "verb" => "GET"],
+ ["name" => "editor#mention", "url" => "/ajax/mention", "verb" => "POST"],
["name" => "editor#config", "url" => "/ajax/config/{fileId}", "verb" => "GET"],
["name" => "editor#create", "url" => "/ajax/new", "verb" => "POST"],
["name" => "editor#convert", "url" => "/ajax/convert", "verb" => "POST"],