Skip to content
Prev Previous commit
Load UIMode from config
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Nov 10, 2021
commit 632081c0412392f6d5cba9275212ec3d1981fbc0
50 changes: 18 additions & 32 deletions lib/Controller/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace OCA\Richdocuments\Controller;

use OCA\Richdocuments\AppInfo\Application;
use OCA\Richdocuments\Db\Wopi;
use OCA\Richdocuments\Events\BeforeFederationRedirectEvent;
use OCA\Richdocuments\Service\FederationService;
Expand Down Expand Up @@ -48,7 +49,7 @@ class DocumentController extends Controller {
/** @var IL10N */
private $l10n;
/** @var IConfig */
private $settings;
private $config;
/** @var AppConfig */
private $appConfig;
/** @var ILogger */
Expand All @@ -65,28 +66,16 @@ class DocumentController extends Controller {
private $templateManager;
/** @var FederationService */
private $federationService;
/** @var Helper */
private $helper;
/** @var IInitialState */
private $initialState;

const ODT_TEMPLATE_PATH = '/assets/odttemplate.odt';

/**
* @param string $appName
* @param IRequest $request
* @param IConfig $settings
* @param AppConfig $appConfig
* @param IL10N $l10n
* @param IManager $shareManager
* @param TokenManager $tokenManager
* @param IRootFolder $rootFolder
* @param ISession $session
* @param string $UserId
* @param ILogger $logger
*/

public function __construct(
$appName,
IRequest $request,
IConfig $settings,
IConfig $config,
AppConfig $appConfig,
IL10N $l10n,
IManager $shareManager,
Expand All @@ -103,7 +92,7 @@ public function __construct(
parent::__construct($appName, $request);
$this->uid = $UserId;
$this->l10n = $l10n;
$this->settings = $settings;
$this->config = $config;
$this->appConfig = $appConfig;
$this->shareManager = $shareManager;
$this->tokenManager = $tokenManager;
Expand All @@ -112,7 +101,6 @@ public function __construct(
$this->logger = $logger;
$this->templateManager = $templateManager;
$this->federationService = $federationService;
$this->helper = $helper;
$this->initialState = $initialState;
}

Expand Down Expand Up @@ -194,13 +182,11 @@ private function setupPolicy($response) {
private function provideDocumentInitialState(Wopi $wopi) {
$this->initialState->provideInitialState('wopi', $wopi);
$this->initialState->provideInitialState('uiDefaults', [
'UIMode' => 'classic'
'UIMode' => $this->config->getAppValue(Application::APPNAME, 'uiDefaults-UIMode', 'classic')
]);

$config = \OC::$server->getConfig();
$logoSet = $config->getAppValue('theming', 'logoheaderMime', '') !== '';
$logoSet = $this->config->getAppValue('theming', 'logoheaderMime', '') !== '';
if (!$logoSet) {
$logoSet = $config->getAppValue('theming', 'logoMime', '') !== '';
$logoSet = $this->config->getAppValue('theming', 'logoMime', '') !== '';
}
$this->initialState->provideInitialState('theming-customLogo', ($logoSet ?
\OC::$server->getURLGenerator()->getAbsoluteURL(\OC::$server->getThemingDefaults()->getLogo())
Expand Down Expand Up @@ -243,11 +229,11 @@ public function index($fileId, $path = null) {
$params = [
'permissions' => $item->getPermissions(),
'title' => $item->getName(),
'fileId' => $item->getId() . '_' . $this->settings->getSystemValue('instanceid'),
'fileId' => $item->getId() . '_' . $this->config->getSystemValue('instanceid'),
'token' => $token,
'urlsrc' => $urlSrc,
'path' => $folder->getRelativePath($item->getPath()),
'instanceId' => $this->settings->getSystemValue('instanceid'),
'instanceId' => $this->config->getSystemValue('instanceid'),
'canonical_webroot' => $this->appConfig->getAppValue('canonical_webroot'),
'userId' => $this->uid
];
Expand Down Expand Up @@ -307,7 +293,7 @@ public function createFromTemplate($templateId, $fileName, $dir) {
$template = $this->templateManager->get($templateId);
list($urlSrc, $wopi) = $this->tokenManager->getTokenForTemplate($template, $this->uid, $file->getId());

$wopiFileId = $wopi->getFileid() . '_' . $this->settings->getSystemValue('instanceid');
$wopiFileId = $wopi->getFileid() . '_' . $this->config->getSystemValue('instanceid');

$params = [
'permissions' => $template->getPermissions(),
Expand All @@ -316,7 +302,7 @@ public function createFromTemplate($templateId, $fileName, $dir) {
'token' => $wopi->getToken(),
'urlsrc' => $urlSrc,
'path' => $userFolder->getRelativePath($file->getPath()),
'instanceId' => $this->settings->getSystemValue('instanceid'),
'instanceId' => $this->config->getSystemValue('instanceid'),
'canonical_webroot' => $this->appConfig->getAppValue('canonical_webroot'),
'userId' => $this->uid
];
Expand Down Expand Up @@ -368,9 +354,9 @@ public function publicPage($shareToken, $fileName, $fileId) {
$params = [
'permissions' => $share->getPermissions(),
'title' => $item->getName(),
'fileId' => $item->getId() . '_' . $this->settings->getSystemValue('instanceid'),
'fileId' => $item->getId() . '_' . $this->config->getSystemValue('instanceid'),
'path' => '/',
'instanceId' => $this->settings->getSystemValue('instanceid'),
'instanceId' => $this->config->getSystemValue('instanceid'),
'canonical_webroot' => $this->appConfig->getAppValue('canonical_webroot'),
'userId' => $this->uid,
];
Expand Down Expand Up @@ -489,11 +475,11 @@ public function remote($shareToken, $remoteServer, $remoteServerToken, $filePath
$params = [
'permissions' => $permissions,
'title' => $node->getName(),
'fileId' => $node->getId() . '_' . $this->settings->getSystemValue('instanceid'),
'fileId' => $node->getId() . '_' . $this->config->getSystemValue('instanceid'),
'token' => $token,
'urlsrc' => $urlSrc,
'path' => '/',
'instanceId' => $this->settings->getSystemValue('instanceid'),
'instanceId' => $this->config->getSystemValue('instanceid'),
'canonical_webroot' => $this->appConfig->getAppValue('canonical_webroot'),
'userId' => $remoteWopi->getEditorUid() ? ($remoteWopi->getEditorUid() . '@' . $remoteServer) : null,
];
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/coolParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const generateCSSVarTokens = () => {
'--color-border': '--co-border',
'--color-border-dark': '--co-border-dark',
'--border-radius-pill': '--co-border-radius-pill',
'--font-face': '--loleaflet-font',
'--font-face': '--loleaflet-font:--mobile-font:--vex-font:--jquery-ui-font:--docs-font',
'--image-logoheader': '--co-image-logo',
}
let str = ''
Expand Down