forked from tbaddade/redaxo_sprog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.php
56 lines (46 loc) · 2.08 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
<?php
/**
* This file is part of the Sprog package.
*
* @author (c) Thomas Blum <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use \Sprog\Wildcard;
class_alias('\Sprog\Wildcard', 'Wildcard');
rex_perm::register('sprog[wildcard]', null, rex_perm::OPTIONS);
if (!rex::isBackend()) {
\rex_extension::register('OUTPUT_FILTER', '\Sprog\Extension::replaceWildcards');
}
if (rex::isBackend() && rex::getUser()) {
\rex_extension::register('CLANG_ADDED', '\Sprog\Extension::clangAdded');
\rex_extension::register('CLANG_DELETED', '\Sprog\Extension::clangDeleted');
rex_extension::register('PAGES_PREPARED', function () {
if (rex::getUser()->isAdmin()) {
if (\rex_be_controller::getCurrentPage() == 'sprog/settings') {
$func = rex_request('func', 'string');
if ($func == 'update') {
\rex_config::set('sprog', 'wildcard_clang_switch', rex_request('clang_switch', 'bool'));
}
}
}
if (rex::getUser()->isAdmin() || rex::getUser()->hasPerm('sprog[wildcard]')) {
$page = \rex_be_controller::getPageObject('sprog/wildcard');
if (Wildcard::isClangSwitchMode()) {
$clang_id = str_replace('clang', '', rex_be_controller::getCurrentPagePart(3));
$page->setSubPath(rex_path::addon('sprog', 'pages/wildcard.clang_switch.php'));
foreach (\rex_clang::getAll() as $id => $clang) {
if (rex::getUser()->getComplexPerm('clang')->hasPerm($id)) {
$page->addSubpage((new rex_be_page('clang' . $id, $clang->getName()))
->setSubPath(rex_path::addon('sprog', 'pages/wildcard.clang_switch.php'))
->setIsActive($id == $clang_id)
);
}
}
} else {
$page->setSubPath(rex_path::addon('sprog', 'pages/wildcard.clang_all.php'));
}
}
});
}