-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathOverviewController.php
More file actions
61 lines (52 loc) · 1.77 KB
/
OverviewController.php
File metadata and controls
61 lines (52 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Richdocuments\Controller;
use OCA\Viewer\Event\LoadViewer;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IPreview;
use OCP\IRequest;
use OCP\Util;
class OverviewController extends Controller {
public function __construct(
string $appName,
IRequest $request,
private IEventDispatcher $eventDispatcher,
private IInitialState $initialState,
private IPreview $preview,
private IConfig $config,
private ?string $userId,
) {
parent::__construct($appName, $request);
}
/**
* @return TemplateResponse
*/
#[NoAdminRequired]
#[NoCSRFRequired]
public function index(): TemplateResponse {
Util::addScript('richdocuments', 'richdocuments-overview');
$this->initialState->provideInitialState('previewEnabled', $this->preview->isMimeSupported('application/vnd.oasis.opendocument.text'));
$this->initialState->provideInitialState('overview_config', [
'overview_grid_view' => $this->userId !== null
&& $this->config->getUserValue($this->userId, 'richdocuments', 'overview_grid_view', '0') === '1',
]);
// Viewer is pre-installed in production but may not be available in other environments
if (class_exists(LoadViewer::class)) {
$this->eventDispatcher->dispatchTyped(new LoadViewer());
}
return new TemplateResponse('richdocuments', 'overview', [
'id-app-content' => '#app-content-vue',
'id-app-navigation' => '#app-navigation-vue',
]);
}
}