-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
48 lines (37 loc) · 1.23 KB
/
install.php
File metadata and controls
48 lines (37 loc) · 1.23 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
<?php
declare(strict_types=1);
namespace FriendsOfRedaxo\AceEditor;
use Exception;
use rex_addon;
use rex_functional_exception;
use rex_i18n;
use rex_url;
use ZipArchive;
$addon = rex_addon::get('aceeditor');
/* Ace-Editor-Assets entpacken */
$message = '';
$zipArchive = new ZipArchive();
// use path relative to __DIR__ to get correct path in update temp dir
$path = __DIR__ . '/assets/vendor/aceeditor.zip';
try {
if (true === $zipArchive->open($path)
&& $zipArchive->extractTo($addon->getAssetsPath('vendor/'))
) {
$zipArchive->close();
} else {
$message = rex_i18n::msg('aceeditor_error_unzip') . '<br>' . $path;
}
} catch (Exception $exception) {
$message = rex_i18n::msg('aceeditor_error_unzip') . '<br>' . $path;
$message .= '<br>' . $exception->getMessage();
}
if (!$addon->hasConfig('theme')) {
$addon->setConfig('theme', 'eclipse');
}
if (!$addon->hasConfig('darktheme')) {
$addon->setConfig('darktheme', 'dracula');
}
if ('' !== $message) {
throw new rex_functional_exception($message);
}
$addon->setProperty('successmsg', rex_i18n::rawMsg('aceeditor_success_message', '<a href="' . rex_url::backendPage('system/aceeditor') . '">' . $addon->i18n('aceeditor_title') . '</a>'));