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

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-07-09 20:55:15 +0300
committerJulius Härtl <jus@bitgrid.net>2020-07-10 08:58:40 +0300
commit759d6799bc1758498008494f4074b372f5259729 (patch)
tree8c7d0572ad86f6a44ea37eb6d1dc0333422a1dfc /lib/Listeners
parent81689d3fc14cefad8b9952c16f126441e595883a (diff)
Use IBootstrap for the app bootstrap
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/Listeners')
-rw-r--r--lib/Listeners/FilesLoadAdditionalScriptsListener.php69
-rw-r--r--lib/Listeners/FilesSharingLoadAdditionalScriptsListener.php62
-rw-r--r--lib/Listeners/LoadViewerListener.php40
-rw-r--r--lib/Listeners/RegisterDirectEditorEventListener.php47
4 files changed, 218 insertions, 0 deletions
diff --git a/lib/Listeners/FilesLoadAdditionalScriptsListener.php b/lib/Listeners/FilesLoadAdditionalScriptsListener.php
new file mode 100644
index 000000000..c49c6f88e
--- /dev/null
+++ b/lib/Listeners/FilesLoadAdditionalScriptsListener.php
@@ -0,0 +1,69 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2020 Morris Jobke <hey@morrisjobke.de>
+ *
+ * @author Morris Jobke <hey@morrisjobke.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Text\Listeners;
+
+use OCA\Files\Event\LoadAdditionalScriptsEvent;
+use OCA\Text\AppInfo\Application;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventListener;
+use OCP\IConfig;
+use OCP\IInitialStateService;
+use OCP\IUserSession;
+
+class FilesLoadAdditionalScriptsListener implements IEventListener {
+ /** @var IConfig */
+ protected $config;
+ /** @var IInitialStateService */
+ protected $initialStateService;
+ /** @var IUserSession */
+ protected $userSession;
+
+ public function __construct(IConfig $config, IInitialStateService $initialStateService, IUserSession $userSession) {
+ $this->config = $config;
+ $this->initialStateService = $initialStateService;
+ $this->userSession = $userSession;
+ }
+
+ public function handle(Event $event): void {
+ if (!$event instanceof LoadAdditionalScriptsEvent) {
+ return;
+ }
+
+ \OCP\Util::addScript('text', 'files');
+ \OCP\Util::addStyle('text', 'icons');
+
+ $this->initialStateService->provideInitialState(
+ Application::APP_NAME,
+ 'workspace_available',
+ $this->config->getAppValue(Application::APP_NAME, 'workspace_available', '1') === '1'
+ );
+ $this->initialStateService->provideInitialState(
+ Application::APP_NAME,
+ 'workspace_enabled',
+ $this->config->getUserValue($this->userSession->getUser()->getUID(), Application::APP_NAME, 'workspace_enabled', '1') === '1'
+ );
+ }
+}
diff --git a/lib/Listeners/FilesSharingLoadAdditionalScriptsListener.php b/lib/Listeners/FilesSharingLoadAdditionalScriptsListener.php
new file mode 100644
index 000000000..bf097ddb4
--- /dev/null
+++ b/lib/Listeners/FilesSharingLoadAdditionalScriptsListener.php
@@ -0,0 +1,62 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2020 Morris Jobke <hey@morrisjobke.de>
+ *
+ * @author Morris Jobke <hey@morrisjobke.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Text\Listeners;
+
+use OCA\Text\AppInfo\Application;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventListener;
+use OCP\IConfig;
+use OCP\IInitialStateService;
+use OCP\IUserSession;
+
+class FilesSharingLoadAdditionalScriptsListener implements IEventListener {
+ /** @var IConfig */
+ protected $config;
+ /** @var IInitialStateService */
+ protected $initialStateService;
+ /** @var IUserSession */
+ protected $userSession;
+
+ public function __construct(IConfig $config, IInitialStateService $initialStateService, IUserSession $userSession) {
+ $this->config = $config;
+ $this->initialStateService = $initialStateService;
+ $this->userSession = $userSession;
+ }
+
+ public function handle(Event $event): void {
+ if (!$this->userSession->isLoggedIn()) {
+ return;
+ }
+ \OCP\Util::addScript('text', 'public');
+ \OCP\Util::addStyle('text', 'icons');
+
+ $this->initialStateService->provideInitialState(
+ Application::APP_NAME,
+ 'workspace_available',
+ $this->config->getAppValue(Application::APP_NAME, 'workspace_available', '1') === '1'
+ );
+ }
+}
diff --git a/lib/Listeners/LoadViewerListener.php b/lib/Listeners/LoadViewerListener.php
new file mode 100644
index 000000000..291384afd
--- /dev/null
+++ b/lib/Listeners/LoadViewerListener.php
@@ -0,0 +1,40 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2020 Morris Jobke <hey@morrisjobke.de>
+ *
+ * @author Morris Jobke <hey@morrisjobke.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Text\Listeners;
+
+use OCA\Viewer\Event\LoadViewer;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventListener;
+
+class LoadViewerListener implements IEventListener {
+ public function handle(Event $event): void {
+ if (!$event instanceof LoadViewer) {
+ return;
+ }
+ \OCP\Util::addScript('text', 'viewer');
+ \OCP\Util::addStyle('text', 'icons');
+ }
+}
diff --git a/lib/Listeners/RegisterDirectEditorEventListener.php b/lib/Listeners/RegisterDirectEditorEventListener.php
new file mode 100644
index 000000000..77770d991
--- /dev/null
+++ b/lib/Listeners/RegisterDirectEditorEventListener.php
@@ -0,0 +1,47 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2020 Morris Jobke <hey@morrisjobke.de>
+ *
+ * @author Morris Jobke <hey@morrisjobke.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Text\Listeners;
+
+use OCA\Text\DirectEditing\TextDirectEditor;
+use OCP\DirectEditing\RegisterDirectEditorEvent;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventListener;
+
+class RegisterDirectEditorEventListener implements IEventListener {
+ /** @var TextDirectEditor */
+ protected $editor;
+
+ public function __construct(TextDirectEditor $editor) {
+ $this->editor = $editor;
+ }
+
+ public function handle(Event $event): void {
+ if (!$event instanceof RegisterDirectEditorEvent) {
+ return;
+ }
+ $event->register($this->editor);
+ }
+}