-
Notifications
You must be signed in to change notification settings - Fork 55
/
boot.php
47 lines (40 loc) · 1.69 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
<?php
/**
* @var rex_addon $this
* @psalm-scope-this rex_addon
*/
rex_yform::addTemplatePath(rex_path::addon('yform', 'ytemplates'));
if (rex::isBackend() && rex::getUser()) {
/* @var $this rex_addon */
rex_view::addCssFile($this->getAssetsUrl('yform.css'));
rex_view::addCssFile($this->getAssetsUrl('yform-formbuilder.css'));
rex_extension::register('PACKAGES_INCLUDED', function () {
if ($this->getProperty('compile')) {
$compiler = new rex_scss_compiler();
$compiler->setRootDir($this->getPath('scss/'));
$compiler->setScssFile($this->getPath('scss/yform.scss'));
$compiler->setCssFile($this->getPath('assets/yform.css'));
$compiler->compile();
$compiler->setScssFile($this->getPath('scss/yform-formbuilder.scss'));
$compiler->setCssFile($this->getPath('assets/yform-formbuilder.css'));
$compiler->compile();
rex_dir::copy($this->getPath('assets'), $this->getAssetsPath()); // copy whole assets directory
}
});
rex_extension::register('PAGE_CHECKED', static function (rex_extension_point $ep) {
$page = rex_be_controller::getPageObject('yform');
if (!$page) {
return;
}
$subpages = $page->getSubpages();
if (isset($subpages['manager']) && rex::getUser()->isAdmin()) {
$manager = $subpages['manager'];
unset($subpages['manager']);
$subpages = array_merge(['manager' => $manager], $subpages);
$page->setSubpages($subpages);
}
if (!$subpages || 1 === count($subpages) && isset($subpages['manager'])) {
$page->setHidden(true);
}
});
}