1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* (c) Copyright Ascensio System SIA 2025. |
4
|
|
|
* |
5
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
6
|
|
|
* you may not use this file except in compliance with the License. |
7
|
|
|
* You may obtain a copy of the License at |
8
|
|
|
* |
9
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
10
|
|
|
* |
11
|
|
|
* Unless required by applicable law or agreed to in writing, software |
12
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
13
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14
|
|
|
* See the License for the specific language governing permissions and |
15
|
|
|
* limitations under the License. |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Plugin class for the Onlyoffice plugin. |
20
|
|
|
* |
21
|
|
|
* @author Asensio System SIA |
22
|
|
|
*/ |
23
|
|
|
class OnlyofficePlugin extends Plugin |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* OnlyofficePlugin name. |
27
|
|
|
*/ |
28
|
|
|
private string $pluginName = 'Onlyoffice'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* OnlyofficePlugin constructor. |
32
|
|
|
*/ |
33
|
|
|
protected function __construct() |
34
|
|
|
{ |
35
|
|
|
parent::__construct( |
36
|
|
|
'1.5.0', |
37
|
|
|
'Asensio System SIA', |
38
|
|
|
[ |
39
|
|
|
'enable_onlyoffice_plugin' => 'boolean', |
40
|
|
|
'document_server_url' => 'text', |
41
|
|
|
'jwt_secret' => 'text', |
42
|
|
|
'jwt_header' => 'text', |
43
|
|
|
'document_server_internal' => 'text', |
44
|
|
|
'storage_url' => 'text', |
45
|
|
|
] |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Create OnlyofficePlugin object. |
51
|
|
|
*/ |
52
|
|
|
public static function create(): OnlyofficePlugin |
53
|
|
|
{ |
54
|
|
|
static $result = null; |
55
|
|
|
|
56
|
|
|
return $result ?: $result = new self(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* This method installs the plugin tables. |
61
|
|
|
*/ |
62
|
|
|
public function install() |
63
|
|
|
{ |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* This method drops the plugin tables. |
68
|
|
|
*/ |
69
|
|
|
public function uninstall() |
70
|
|
|
{ |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Get link to plugin settings. |
75
|
|
|
* |
76
|
|
|
* @return string |
77
|
|
|
*/ |
78
|
|
|
public function getConfigLink() |
79
|
|
|
{ |
80
|
|
|
return api_get_path(WEB_PATH).'main/admin/configure_plugin.php?name='.$this->pluginName; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function get_name() |
84
|
|
|
{ |
85
|
|
|
return $this->pluginName; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public static function isExtensionAllowed(string $extension): bool |
89
|
|
|
{ |
90
|
|
|
$officeExtensions = [ |
91
|
|
|
'ppt', |
92
|
|
|
'pptx', |
93
|
|
|
'odp', |
94
|
|
|
'xls', |
95
|
|
|
'xlsx', |
96
|
|
|
'ods', |
97
|
|
|
'csv', |
98
|
|
|
'doc', |
99
|
|
|
'docx', |
100
|
|
|
'odt', |
101
|
|
|
'pdf', |
102
|
|
|
]; |
103
|
|
|
|
104
|
|
|
return in_array($extension, $officeExtensions); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|