-
Notifications
You must be signed in to change notification settings - Fork 4
/
boot.php
executable file
·68 lines (56 loc) · 2.54 KB
/
boot.php
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
62
63
64
65
66
67
68
<?php
/**
* @author FriendsOfRedaxo: Joachim Doerr https://github.com/joachimdoerr
* @package redaxo5
* @license MIT
*/
/** @var rex_addon $this */
// register permissions
if (rex::isBackend() && is_object(rex::getUser())) {
rex_perm::register('cke5_addon[]');
// remove productivity components if no licence provided
$page = $this->getProperty('page');
if (empty($this->getConfig('license_code'))) {
unset($page['subpages']['profiles']['subpages']['templates']);
unset($page['subpages']['profiles']['subpages']['slashes']);
}
$this->setProperty('page', $page);
// load assets
\Cke5\Provider\Cke5AssetsProvider::provideCke5ProfileEditData();
\Cke5\Provider\Cke5AssetsProvider::provideCke5PreviewData();
\Cke5\Provider\Cke5AssetsProvider::provideCke5BaseData();
\Cke5\Provider\Cke5AssetsProvider::provideCke5CustomData();
// Check REDAXO version
if (rex_version::compare(rex::getVersion(), '5.13.0-dev', '>=')) {
rex_view::addCssFile($this->getAssetsUrl('cke5_dark.css'));
$user = rex::requireUser();
// get user settings for theme
$themeType = $user->getValue('theme');
$theme = (!is_null($themeType) && $themeType !== '') ? $themeType : 'auto';
if (rex::getProperty('theme') === 'light') {
$theme = 'light';
}
if (rex::getProperty('theme') === 'dark') {
$theme = 'dark';
}
// set theme properties
rex_view::setJsProperty('cke5theme', $theme);
rex_view::setJsProperty('cke5darkcss', rex_url::addonAssets('cke5') . 'dark.css');
} else {
rex_view::setJsProperty('cke5theme', 'notheme');
}
if ($this->getConfig('updated') === true) {
\Cke5\Handler\Cke5ExtensionHandler::updateOrCreateProfiles();
$this->setConfig('updated', false);
}
// upload image
if (rex_request::request('cke5upload', 'bool') === true) {
\Cke5\Handler\Cke5UploadHandler::uploadCke5Img();
}
// register extension point actions
if (rex_be_controller::getCurrentPagePart(1) === 'cke5') {
rex_extension::register('PAGE_TITLE', ['\Cke5\Handler\Cke5ExtensionHandler', 'addIcon'], rex_extension::EARLY);
rex_extension::register('PAGES_PREPARED', ['\Cke5\Handler\Cke5ExtensionHandler', 'hiddenMain'], rex_extension::EARLY);
rex_extension::register(['REX_FORM_SAVED', 'REX_FORM_DELETED', 'CKE5_PROFILE_CLONE', 'CKE5_PROFILE_DELETE', 'CKE5_PROFILE_ADD', 'CKE5_PROFILE_UPDATED'], ['\Cke5\Handler\Cke5ExtensionHandler', 'createProfiles']);
}
}