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

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2021-11-28 19:49:28 +0300
committerJulius Härtl <jus@bitgrid.net>2021-11-29 20:33:50 +0300
commit6551749b8627b2da1eca3bd07947175f4cffadfb (patch)
tree08e89417cb57cbe8c1989cf57861a66744845aca
parentcaf8284d4f2494f8a4d4461efa29212b2e2eba67 (diff)
Introduce Nextcloud Office branding
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--lib/Controller/DirectViewController.php11
-rw-r--r--lib/Controller/DocumentController.php17
-rw-r--r--lib/Service/CapabilitiesService.php22
-rw-r--r--lib/Service/InitialStateService.php (renamed from lib/Controller/TDocumentInitialState.php)45
-rw-r--r--lib/Settings/Admin.php54
-rw-r--r--lib/Settings/Personal.php64
-rw-r--r--lib/Settings/Section.php39
-rw-r--r--src/components/AdminSettings.vue16
8 files changed, 153 insertions, 115 deletions
diff --git a/lib/Controller/DirectViewController.php b/lib/Controller/DirectViewController.php
index 514a7716..1ca76d0f 100644
--- a/lib/Controller/DirectViewController.php
+++ b/lib/Controller/DirectViewController.php
@@ -26,6 +26,7 @@ use OCA\Richdocuments\AppConfig;
use OCA\Richdocuments\Db\Direct;
use OCA\Richdocuments\Db\DirectMapper;
use OCA\Richdocuments\Service\FederationService;
+use OCA\Richdocuments\Service\InitialStateService;
use OCA\Richdocuments\TemplateManager;
use OCA\Richdocuments\TokenManager;
use OCP\AppFramework\Controller;
@@ -35,7 +36,6 @@ use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
-use OCP\AppFramework\Services\IInitialState;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
@@ -45,7 +45,6 @@ use OCP\ILogger;
use OCP\IRequest;
class DirectViewController extends Controller {
- use TDocumentInitialState;
/** @var IRootFolder */
private $rootFolder;
@@ -71,7 +70,7 @@ class DirectViewController extends Controller {
/** @var ILogger */
private $logger;
- /** @var IInitialState */
+ /** @var InitialStateService */
private $initialState;
public function __construct(
@@ -80,7 +79,7 @@ class DirectViewController extends Controller {
IRootFolder $rootFolder,
TokenManager $tokenManager,
DirectMapper $directMapper,
- IInitialState $initialState,
+ InitialStateService $initialState,
IConfig $config,
AppConfig $appConfig,
TemplateManager $templateManager,
@@ -179,7 +178,7 @@ class DirectViewController extends Controller {
'direct' => true,
];
- $this->provideDocumentInitialState($wopi);
+ $this->initialState->provideDocument($wopi);
$response = new TemplateResponse('richdocuments', 'documents', $params, 'base');
$policy = new ContentSecurityPolicy();
$policy->allowInlineScript(true);
@@ -235,7 +234,7 @@ class DirectViewController extends Controller {
$params['token'] = $token;
$params['urlsrc'] = $urlSrc;
- $this->provideDocumentInitialState($wopi);
+ $this->initialState->provideDocument($wopi);
$response = new TemplateResponse('richdocuments', 'documents', $params, 'base');
$policy = new ContentSecurityPolicy();
$policy->allowInlineScript(true);
diff --git a/lib/Controller/DocumentController.php b/lib/Controller/DocumentController.php
index c946c66c..0658d89f 100644
--- a/lib/Controller/DocumentController.php
+++ b/lib/Controller/DocumentController.php
@@ -11,16 +11,14 @@
namespace OCA\Richdocuments\Controller;
-use OCA\Richdocuments\AppInfo\Application;
-use OCA\Richdocuments\Db\Wopi;
use OCA\Richdocuments\Events\BeforeFederationRedirectEvent;
use OCA\Richdocuments\Service\FederationService;
+use OCA\Richdocuments\Service\InitialStateService;
use OCA\Richdocuments\TokenManager;
use \OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\RedirectResponse;
-use OCP\AppFramework\Services\IInitialState;
use OCP\Constants;
use OCP\Files\File;
use OCP\Files\Folder;
@@ -44,7 +42,6 @@ use OCP\Share\IManager;
use OC\Files\Type\TemplateManager;
class DocumentController extends Controller {
- use TDocumentInitialState;
/** @var string */
private $uid;
@@ -68,7 +65,7 @@ class DocumentController extends Controller {
private $templateManager;
/** @var FederationService */
private $federationService;
- /** @var IInitialState */
+ /** @var InitialStateService */
private $initialState;
const ODT_TEMPLATE_PATH = '/assets/odttemplate.odt';
@@ -89,7 +86,7 @@ class DocumentController extends Controller {
\OCA\Richdocuments\TemplateManager $templateManager,
FederationService $federationService,
Helper $helper,
- IInitialState $initialState
+ InitialStateService $initialState
) {
parent::__construct($appName, $request);
$this->uid = $UserId;
@@ -237,7 +234,7 @@ class DocumentController extends Controller {
$encryptionManager->getEncryptionModule()->update($absPath, $owner, $accessList);
}
- $this->provideDocumentInitialState($wopi);
+ $this->initialState->provideDocument($wopi);
$response = new TemplateResponse('richdocuments', 'documents', $params, 'base');
$this->setupPolicy($response);
return $response;
@@ -295,7 +292,7 @@ class DocumentController extends Controller {
'userId' => $this->uid
];
- $this->provideDocumentInitialState($wopi);
+ $this->initialState->provideDocument($wopi);
$response = new TemplateResponse('richdocuments', 'documents', $params, 'base');
$this->setupPolicy($response);
return $response;
@@ -353,7 +350,7 @@ class DocumentController extends Controller {
$params['token'] = $token;
$params['urlsrc'] = $urlSrc;
- $this->provideDocumentInitialState($wopi);
+ $this->initialState->provideDocument($wopi);
$response = new TemplateResponse('richdocuments', 'documents', $params, 'base');
$this->setupPolicy($response);
return $response;
@@ -472,7 +469,7 @@ class DocumentController extends Controller {
'userId' => $remoteWopi->getEditorUid() ? ($remoteWopi->getEditorUid() . '@' . $remoteServer) : null,
];
- $this->provideDocumentInitialState($wopi);
+ $this->initialState->provideDocument($wopi);
$response = new TemplateResponse('richdocuments', 'documents', $params, 'base');
$remoteWopi = $this->domainOnly($this->appConfig->getAppValue('wopi_url'));
$policy = new ContentSecurityPolicy();
diff --git a/lib/Service/CapabilitiesService.php b/lib/Service/CapabilitiesService.php
index 3d18c957..51adc424 100644
--- a/lib/Service/CapabilitiesService.php
+++ b/lib/Service/CapabilitiesService.php
@@ -23,11 +23,13 @@
namespace OCA\Richdocuments\Service;
+use OCA\Richdocuments\AppInfo\Application;
use OCP\App\IAppManager;
use OCP\Http\Client\IClientService;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IConfig;
+use OCP\IL10N;
class CapabilitiesService {
@@ -39,16 +41,19 @@ class CapabilitiesService {
private $cache;
/** @var IAppManager */
private $appManager;
+ /** @var IL10N */
+ private $l10n;
/** @var array */
private $capabilities;
- public function __construct(IConfig $config, IClientService $clientService, ICacheFactory $cacheFactory, IAppManager $appManager) {
+ public function __construct(IConfig $config, IClientService $clientService, ICacheFactory $cacheFactory, IAppManager $appManager, IL10N $l10n) {
$this->config = $config;
$this->clientService = $clientService;
$this->cache = $cacheFactory->createDistributed('richdocuments');
$this->appManager = $appManager;
+ $this->l10n = $l10n;
}
public function getCapabilities() {
@@ -72,6 +77,11 @@ class CapabilitiesService {
return $this->capabilities;
}
+ public function hasNextcloudBranding(): bool {
+ $productVersion = $this->getCapabilities()['productVersion'] ?? '0.0.0.0';
+ return version_compare($productVersion, '21.11', '>=');
+ }
+
public function hasDrawSupport(): bool {
$productVersion = $this->getCapabilities()['productVersion'] ?? '0.0.0.0';
return version_compare($productVersion, '6.4.7', '>=');
@@ -85,6 +95,16 @@ class CapabilitiesService {
return $this->getCapabilities()['hasTemplateSource'] ?? false;
}
+ public function getProductName(): string {
+ $theme = $this->config->getAppValue(Application::APPNAME, 'theme', 'nextcloud');
+
+ if (isset($this->capabilitites['productName']) && $theme !== 'nextcloud') {
+ return $this->capabilitites['productName'];
+ }
+
+ return $this->l10n->t('Nextcloud Office');
+ }
+
public function clear(): void {
$this->cache->remove('capabilities');
}
diff --git a/lib/Controller/TDocumentInitialState.php b/lib/Service/InitialStateService.php
index 5c8d9e0f..ff85ec4e 100644
--- a/lib/Controller/TDocumentInitialState.php
+++ b/lib/Service/InitialStateService.php
@@ -23,14 +23,52 @@
declare(strict_types=1);
-namespace OCA\Richdocuments\Controller;
+namespace OCA\Richdocuments\Service;
use OCA\Richdocuments\AppInfo\Application;
use OCA\Richdocuments\Db\Wopi;
+use OCP\AppFramework\Services\IInitialState;
+use OCP\IConfig;
-trait TDocumentInitialState {
+class InitialStateService {
+
+ /** @var IInitialState */
+ private $initialState;
+
+ /** @var CapabilitiesService */
+ private $capabilitiesService;
+
+ /** @var IConfig */
+ private $config;
+
+ /** @var bool */
+ private $hasProvidedCapabilities = false;
+
+ public function __construct(
+ IInitialState $initialState,
+ CapabilitiesService $capabilitiesService,
+ IConfig $config
+ ) {
+ $this->initialState = $initialState;
+ $this->capabilitiesService = $capabilitiesService;
+ $this->config = $config;
+ }
+
+ public function provideCapabilities(): void {
+ if ($this->hasProvidedCapabilities) {
+ return;
+ }
+
+ $this->initialState->provideInitialState('productName', $this->capabilitiesService->getProductName());
+ $this->initialState->provideInitialState('hasDrawSupport', $this->capabilitiesService->hasDrawSupport());
+ $this->initialState->provideInitialState('hasNextcloudBranding', $this->capabilitiesService->hasNextcloudBranding());
+
+ $this->hasProvidedCapabilities = true;
+ }
+
+ public function provideDocument(Wopi $wopi): void {
+ $this->provideCapabilities();
- private function provideDocumentInitialState(Wopi $wopi): void {
$this->initialState->provideInitialState('wopi', $wopi);
$this->initialState->provideInitialState('theme', $this->config->getAppValue(Application::APPNAME, 'theme', 'nextcloud'));
$this->initialState->provideInitialState('uiDefaults', [
@@ -44,5 +82,4 @@ trait TDocumentInitialState {
\OC::$server->getURLGenerator()->getAbsoluteURL(\OC::$server->getThemingDefaults()->getLogo())
: false));
}
-
}
diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php
index 01fea6bd..e67fe5f3 100644
--- a/lib/Settings/Admin.php
+++ b/lib/Settings/Admin.php
@@ -24,8 +24,9 @@
namespace OCA\Richdocuments\Settings;
use OCA\Richdocuments\AppConfig;
-use OCA\Richdocuments\Capabilities;
+use OCA\Richdocuments\Service\CapabilitiesService;
use OCA\Richdocuments\Service\DemoService;
+use OCA\Richdocuments\Service\InitialStateService;
use OCA\Richdocuments\TemplateManager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
@@ -42,38 +43,33 @@ class Admin implements ISettings {
/** @var TemplateManager */
private $manager;
- /** @var array */
- private $capabilities;
+ /** @var CapabilitiesService */
+ private $capabilitiesService;
/** @var DemoService */
private $demoService;
- /**
- * Admin template settings
- *
- * @param IConfig $config
- * @param TemplateManager $manager
- * @param Capabilities $capabilities
- */
+ /** @var InitialStateService */
+ private $initialState;
+
public function __construct(
- IConfig $config,
- AppConfig $appConfig,
- TemplateManager $manager,
- Capabilities $capabilities,
- DemoService $demoService
+ IConfig $config,
+ AppConfig $appConfig,
+ TemplateManager $manager,
+ CapabilitiesService $capabilitiesService,
+ DemoService $demoService,
+ InitialStateService $initialStateService
) {
$this->config = $config;
$this->appConfig = $appConfig;
$this->manager = $manager;
- $this->capabilities = $capabilities->getCapabilities()['richdocuments'];
+ $this->capabilitiesService = $capabilitiesService;
$this->demoService = $demoService;
+ $this->initialState = $initialStateService;
}
- /**
- * @return TemplateResponse
- */
- public function getForm() {
- $demoServers = [];
+ public function getForm() {
+ $this->initialState->provideCapabilities();
return new TemplateResponse(
'richdocuments',
'admin',
@@ -88,30 +84,22 @@ class Admin implements ISettings {
'canonical_webroot' => $this->config->getAppValue('richdocuments', 'canonical_webroot'),
'disable_certificate_verification' => $this->config->getAppValue('richdocuments', 'disable_certificate_verification', '') === 'yes',
'templates' => $this->manager->getSystemFormatted(),
- 'templatesAvailable' => array_key_exists('templates', $this->capabilities) && $this->capabilities['templates'],
+ 'templatesAvailable' => $this->capabilitiesService->hasTemplateSaveAs() || $this->capabilitiesService->hasTemplateSource(),
'settings' => $this->appConfig->getAppSettings(),
'demo_servers' => $this->demoService->fetchDemoServers(),
'web_server' => strtolower($_SERVER['SERVER_SOFTWARE']),
'os_family' => PHP_VERSION_ID >= 70200 ? PHP_OS_FAMILY : PHP_OS,
'platform' => php_uname('m')
- ]
+ ],
],
'blank'
);
}
- /**
- * @return string the section ID, e.g. 'sharing'
- */
+
public function getSection() {
return 'richdocuments';
}
- /**
- * @return int whether the form should be rather on the top or bottom of
- * the admin section. The forms are arranged in ascending order of the
- * priority values. It is required to return a value between 0 and 100.
- *
- * keep the server setting at the top, right after "server settings"
- */
+
public function getPriority() {
return 0;
}
diff --git a/lib/Settings/Personal.php b/lib/Settings/Personal.php
index 3aa80803..bdbb8371 100644
--- a/lib/Settings/Personal.php
+++ b/lib/Settings/Personal.php
@@ -23,55 +23,59 @@
namespace OCA\Richdocuments\Settings;
-use OCA\Richdocuments\Capabilities;
-use OCA\Richdocuments\TemplateManager;
+use OCA\Richdocuments\Service\CapabilitiesService;
+use OCA\Richdocuments\Service\InitialStateService;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\Settings\ISettings;
class Personal implements ISettings {
+ /** @var IConfig Config */
private $config;
+
+ /** @var CapabilitiesService */
+ private $capabilitiesService;
+
+ /** @var InitialStateService */
+ private $initialState;
+
+ /** @var string */
private $userId;
- private $capabilities;
- public function __construct(IConfig $config, Capabilities $capabilities, $userId) {
+ public function __construct(IConfig $config, CapabilitiesService $capabilitiesService, InitialStateService $initialStateService, $userId) {
$this->config = $config;
- $this->capabilities = $capabilities->getCapabilities()['richdocuments'];
+ $this->capabilitiesService = $capabilitiesService;
+ $this->initialState = $initialStateService;
$this->userId = $userId;
}
- /**
- * @return TemplateResponse
- */
+ /** @psalm-suppress InvalidNullableReturnType */
public function getForm() {
- if (array_key_exists('templates', $this->capabilities) && $this->capabilities['templates'] === true) {
- return new TemplateResponse(
- 'richdocuments',
- 'personal',
- [
- 'templateFolder' => $this->config->getUserValue($this->userId, 'richdocuments', 'templateFolder', '')
- ],
- 'blank'
- );
+ if (!$this->capabilitiesService->hasTemplateSaveAs() && !$this->capabilitiesService->hasTemplateSource()) {
+ /** @psalm-suppress NullableReturnStatement */
+ return null;
}
+
+ $this->initialState->provideCapabilities();
+ return new TemplateResponse(
+ 'richdocuments',
+ 'personal',
+ [
+ 'templateFolder' => $this->config->getUserValue($this->userId, 'richdocuments', 'templateFolder', '')
+ ],
+ 'blank'
+ );
}
- /**
- * @return string the section ID, e.g. 'sharing'
- */
+
public function getSection() {
- // Only show the personal section if templates are available
- if (array_key_exists('templates', $this->capabilities) && $this->capabilities['templates'] === true) {
- return 'richdocuments';
+ if (!$this->capabilitiesService->hasTemplateSaveAs() && !$this->capabilitiesService->hasTemplateSource()) {
+ return null;
}
+
+ return 'richdocuments';
}
- /**
- * @return int whether the form should be rather on the top or bottom of
- * the admin section. The forms are arranged in ascending order of the
- * priority values. It is required to return a value between 0 and 100.
- *
- * keep the server setting at the top, right after "server settings"
- */
+
public function getPriority() {
return 0;
}
diff --git a/lib/Settings/Section.php b/lib/Settings/Section.php
index 14349ac2..68650233 100644
--- a/lib/Settings/Section.php
+++ b/lib/Settings/Section.php
@@ -23,54 +23,41 @@
namespace OCA\Richdocuments\Settings;
-use OCA\Richdocuments\Capabilities;
+use OCA\Richdocuments\Service\CapabilitiesService;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Settings\IIconSection;
class Section implements IIconSection {
- /** @var IL10N */
- private $l10n;
+
/** @var IURLGenerator */
private $url;
- /** @var Capabilities */
+ /** @var CapabilitiesService */
private $capabilitites;
+ /** @var IL10N */
+ private $l10n;
- /**
- * @param IL10N $l
- * @param IURLGenerator $url
- */
- public function __construct(IL10N $l10n, IURLGenerator $url, Capabilities $capabilities) {
- $this->l10n = $l10n;
+ public function __construct(IURLGenerator $url, CapabilitiesService $capabilities, IL10N $l10n) {
$this->url = $url;
$this->capabilitites = $capabilities;
+ $this->l10n = $l10n;
}
- /**
- * {@inheritdoc}
- */
+
public function getID() {
return 'richdocuments';
}
- /**
- * {@inheritdoc}
- */
+
public function getName() {
- $capabilitites = $this->capabilitites->getCapabilities();
- if (isset($capabilitites['richdocuments']['productName'])) {
- return $capabilitites['richdocuments']['productName'];
+ if ($this->capabilitites->hasNextcloudBranding()) {
+ return $this->l10n->t('Office');
}
- return $this->l10n->t('Collabora Online');
+ return $this->capabilitites->getProductName();
}
- /**
- * {@inheritdoc}
- */
+
public function getPriority() {
return 75;
}
- /**
- * {@inheritdoc}
- */
public function getIcon() {
return $this->url->imagePath('richdocuments', 'app-dark.svg');
}
diff --git a/src/components/AdminSettings.vue b/src/components/AdminSettings.vue
index 75a0e7de..3d00c48c 100644
--- a/src/components/AdminSettings.vue
+++ b/src/components/AdminSettings.vue
@@ -23,8 +23,9 @@
<template>
<div>
<div class="section">
- <h2>Collabora Online</h2>
- <p>{{ t('richdocuments', 'Collabora Online is a powerful LibreOffice-based online office suite with collaborative editing, which supports all major documents, spreadsheet and presentation file formats and works together with all modern browsers.') }}</p>
+ <h2>{{ productName }}</h2>
+ <p v-if="hasNextcloudBranding">{{ t('richdocuments', 'Nextcloud Office is a powerful Collabora Online based online office suite with collaborative editing, which supports all major documents, spreadsheet and presentation file formats and works together with all modern browsers.') }}</p>
+ <p v-else>{{ t('richdocuments', 'Collabora Online is a powerful LibreOffice-based online office suite with collaborative editing, which supports all major documents, spreadsheet and presentation file formats and works together with all modern browsers.') }}</p>
<div v-if="settings.wopi_url && settings.wopi_url !== ''">
<div v-if="serverError == 2 && isNginx && serverMode === 'builtin'" id="security-warning-state-failure">
@@ -62,6 +63,7 @@
:disabled="updating">
<label for="customserver">{{ t('richdocuments', 'Use your own server') }}</label><br>
<p class="option-inline">
+ <em>{{ t('richdocuments', 'Nextcloud Office requires a seperate server running Collabora Online to provide editing capabilities.') }}</em>
<em>{{ t('richdocuments', 'Collabora Online requires a seperate server acting as a WOPI-like Client to provide editing capabilities.') }}</em>
</p>
<div v-if="serverMode === 'custom'" class="option-inline">
@@ -211,7 +213,7 @@
<SettingsCheckbox :value="settings.use_groups !== null"
:label="t('richdocuments', 'Restrict usage to specific groups')"
- :hint="t('richdocuments', 'Collabora Online is enabled for all users by default. When this setting is active, only members of the specified groups can use it.')"
+ :hint="t('richdocuments', '{productName} is enabled for all users by default. When this setting is active, only members of the specified groups can use it.', { productName })"
:disabled="updating"
@input="updateUseGroups">
<SettingsSelectGroup v-if="settings.use_groups !== null"
@@ -224,7 +226,7 @@
<SettingsCheckbox :value="settings.edit_groups !== null"
:label="t('richdocuments', 'Restrict edit to specific groups')"
- hint="All users can edit documents with Collabora Online by default. When this setting is active, only the members of the specified groups can edit and the others can only view documents.')"
+ :hint="t('richdocuments', 'All users can edit documents with {productName} by default. When this setting is active, only the members of the specified groups can edit and the others can only view documents.', { productName })"
:disabled="updating"
@input="updateEditGroups">
<SettingsSelectGroup v-if="settings.edit_groups !== null"
@@ -343,6 +345,8 @@
<script>
import Vue from 'vue'
+import { loadState } from '@nextcloud/initial-state'
+import { generateUrl } from '@nextcloud/router'
import Multiselect from '@nextcloud/vue/dist/Components/Multiselect'
import Modal from '@nextcloud/vue/dist/Components/Modal'
import axios from '@nextcloud/axios'
@@ -351,7 +355,6 @@ import SettingsInputText from './SettingsInputText'
import SettingsSelectTag from './SettingsSelectTag'
import SettingsSelectGroup from './SettingsSelectGroup'
import SettingsExternalApps from './SettingsExternalApps'
-import { generateUrl } from '@nextcloud/router'
const SERVER_STATE_OK = 0
const SERVER_STATE_LOADING = 1
@@ -377,6 +380,9 @@ export default {
},
data() {
return {
+ productName: loadState('richdocuments', 'productName', 'Nextcloud Office'),
+ hasNextcloudBranding: loadState('richdocuments', 'hasNextcloudBranding', true),
+
serverMode: '',
serverError: Object.values(OC.getCapabilities().richdocuments.collabora).length > 0 ? SERVER_STATE_OK : SERVER_STATE_CONNECTION_ERROR,
hostErrors: [window.location.host === 'localhost' || window.location.host === '127.0.0.1', window.location.protocol !== 'https:', false],