1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2018, Roeland Jago Douma <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @author Roeland Jago Douma <[email protected]> |
6
|
|
|
* |
7
|
|
|
* @license GNU AGPL version 3 or any later version |
8
|
|
|
* |
9
|
|
|
* This program is free software: you can redistribute it and/or modify |
10
|
|
|
* it under the terms of the GNU Affero General Public License as |
11
|
|
|
* published by the Free Software Foundation, either version 3 of the |
12
|
|
|
* License, or (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU Affero General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU Affero General Public License |
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
21
|
|
|
* |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
namespace OCA\Richdocuments; |
25
|
|
|
|
26
|
|
|
use OCA\Richdocuments\Service\CapabilitiesService; |
27
|
|
|
use OCP\Capabilities\ICapability; |
28
|
|
|
use OCP\IL10N; |
29
|
|
|
|
30
|
|
|
class Capabilities implements ICapability { |
31
|
|
|
|
32
|
|
|
const MIMETYPES = [ |
33
|
|
|
'application/vnd.oasis.opendocument.text', |
34
|
|
|
'application/vnd.oasis.opendocument.spreadsheet', |
35
|
|
|
'application/vnd.oasis.opendocument.graphics', |
36
|
|
|
'application/vnd.oasis.opendocument.presentation', |
37
|
|
|
'application/vnd.lotus-wordpro', |
38
|
|
|
'application/vnd.visio', |
39
|
|
|
'application/vnd.ms-visio.drawing', |
40
|
|
|
'application/vnd.wordperfect', |
41
|
|
|
'application/msonenote', |
42
|
|
|
'application/msword', |
43
|
|
|
'application/rtf', |
44
|
|
|
'text/rtf', |
45
|
|
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document', |
46
|
|
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.template', |
47
|
|
|
'application/vnd.ms-word.document.macroEnabled.12', |
48
|
|
|
'application/vnd.ms-word.template.macroEnabled.12', |
49
|
|
|
'application/vnd.ms-excel', |
50
|
|
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
51
|
|
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.template', |
52
|
|
|
'application/vnd.ms-excel.sheet.macroEnabled.12', |
53
|
|
|
'application/vnd.ms-excel.template.macroEnabled.12', |
54
|
|
|
'application/vnd.ms-excel.addin.macroEnabled.12', |
55
|
|
|
'application/vnd.ms-excel.sheet.binary.macroEnabled.12', |
56
|
|
|
'application/vnd.ms-powerpoint', |
57
|
|
|
'application/vnd.openxmlformats-officedocument.presentationml.presentation', |
58
|
|
|
'application/vnd.openxmlformats-officedocument.presentationml.template', |
59
|
|
|
'application/vnd.openxmlformats-officedocument.presentationml.slideshow', |
60
|
|
|
'application/vnd.ms-powerpoint.addin.macroEnabled.12', |
61
|
|
|
'application/vnd.ms-powerpoint.presentation.macroEnabled.12', |
62
|
|
|
'application/vnd.ms-powerpoint.template.macroEnabled.12', |
63
|
|
|
'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', |
64
|
|
|
'text/csv' |
65
|
|
|
]; |
66
|
|
|
|
67
|
|
|
const MIMETYPES_OPTIONAL = [ |
68
|
|
|
'image/svg+xml', |
69
|
|
|
'application/pdf', |
70
|
|
|
'text/plain', |
71
|
|
|
'text/spreadsheet' |
72
|
|
|
]; |
73
|
|
|
|
74
|
|
|
/** @var IL10N */ |
75
|
|
|
private $l10n; |
76
|
|
|
/** @var AppConfig */ |
77
|
|
|
private $config; |
78
|
|
|
/** @var CapabilitiesService */ |
79
|
|
|
private $capabilitiesService; |
80
|
|
|
|
81
|
|
|
private $capabilities = null; |
82
|
|
|
|
83
|
|
|
public function __construct(IL10N $l10n, AppConfig $config, CapabilitiesService $capabilitiesService) { |
84
|
|
|
$this->l10n = $l10n; |
85
|
|
|
$this->config = $config; |
86
|
|
|
$this->capabilitiesService = $capabilitiesService; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function getCapabilities() { |
90
|
|
|
if (!$this->capabilities) { |
91
|
|
|
$collaboraCapabilities = $this->capabilitiesService->getCapabilities(); |
92
|
|
|
$this->capabilities = [ |
93
|
|
|
'richdocuments' => [ |
94
|
|
|
'version' => \OC::$server->getAppManager()->getAppVersion('richdocuments'), |
95
|
|
|
'mimetypes' => self::MIMETYPES, |
96
|
|
|
'mimetypesNoDefaultOpen' => self::MIMETYPES_OPTIONAL, |
97
|
|
|
'collabora' => $collaboraCapabilities, |
98
|
|
|
'direct_editing' => isset($collaboraCapabilities['hasMobileSupport']) ?: false, |
99
|
|
|
'templates' => isset($collaboraCapabilities['hasTemplateSaveAs']) || isset($collaboraCapabilities['hasTemplateSource']) ?: false, |
100
|
|
|
'productName' => isset($collaboraCapabilities['productName']) ? $collaboraCapabilities['productName'] : $this->l10n->t('Collabora Online'), |
101
|
|
|
'config' => [ |
102
|
|
|
'wopi_url' => $this->config->getAppValue('wopi_url'), |
103
|
|
|
'public_wopi_url' => $this->config->getAppValue('public_wopi_url'), |
104
|
|
|
'disable_certificate_verification' => $this->config->getAppValue('disable_certificate_verification'), |
105
|
|
|
'edit_groups' => $this->config->getAppValue('edit_groups'), |
106
|
|
|
'use_groups' => $this->config->getAppValue('use_groups'), |
107
|
|
|
'doc_format' => $this->config->getAppValue('doc_format'), |
108
|
|
|
'timeout' => $this->config->getAppValue('timeout'), |
109
|
|
|
|
110
|
|
|
] |
111
|
|
|
], |
112
|
|
|
]; |
113
|
|
|
} |
114
|
|
|
return $this->capabilities; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|