forked from tbaddade/redaxo_url
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.php
91 lines (78 loc) · 3.76 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* This file is part of the Url 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 Url\ExtensionPointManager;
use Url\Generator;
use Url\Profile;
use Url\Seo;
use Url\Url;
use Url\UrlManager;
$addon = rex_addon::get('url');
Generator::boot();
if (null !== Url::getRewriter()) {
Url::getRewriter()->articleIdNotFound();
}
rex_extension::register('PACKAGES_INCLUDED', function (\rex_extension_point $epPackagesIncluded) {
// if anything changes -> refresh PathFile
$extensionPoints = [
'ART_ADDED', 'ART_DELETED', 'ART_MOVED', 'ART_STATUS', 'ART_UPDATED',
'CAT_ADDED', 'CAT_DELETED', 'CAT_MOVED', 'CAT_STATUS', 'CAT_UPDATED',
'CLANG_ADDED', 'CLANG_DELETED','CLANG_UPDATED',
//'CACHE_DELETED',
'REX_FORM_SAVED',
'YFORM_SAVED',
'YFORM_DATA_ADDED', 'YFORM_DATA_DELETED', 'YFORM_DATA_UPDATED', 'YFORM_DATA_STATUS_CHANGED',
];
foreach ($extensionPoints as $extensionPoint) {
rex_extension::register($extensionPoint, function (\rex_extension_point $ep) {
$manager = new ExtensionPointManager($ep);
$generator = new Generator($manager);
$generator->execute();
}, rex_extension::LATE);
}
// kreatif: if moved down to this position to exectue extension point also in frontend
if (rex::isBackend() && rex::getUser()) {
$profileArticleIds = Profile::getAllArticleIds();
// Profilartikel nicht löschen
// Manipulation des löschen Links
rex_extension::register('OUTPUT_FILTER', function (\rex_extension_point $ep) use($profileArticleIds) {
$subject = $ep->getSubject();
foreach ($profileArticleIds as $id) {
$regexp = '@<a.*?href="index\.php\?page=structure[^>]*category-id='.$id.'&[^>]*rex-api-call=category_delete[^>]*>([^&]*)<\/a>@';
if (preg_match($regexp, $subject, $matches)) {
$subject = str_replace($matches[0], '<span class="text-muted" title="'.rex_i18n::msg('url_generator_structure_disallow_to_delete_category').'">'.$matches[1].'</span>', $subject);
}
$regexp = '@<a[^>]*href="index\.php\?page=structure[^>]*article_id='.$id.'&[^>]*rex-api-call=article_delete[^>]*>([^&]*)<\/a>@';
if (preg_match($regexp, $subject, $matches)) {
$subject = str_replace($matches[0], '<span class="text-muted" title="'.rex_i18n::msg('url_generator_structure_disallow_to_delete_article').'">'.$matches[1].'</span>', $subject);
}
}
return $subject;
});
// Profilartikel - löschen nicht erlauben
$rexApiCall = rex_request(rex_api_function::REQ_CALL_PARAM, 'string', '');
if (($rexApiCall == 'category_delete' && in_array(rex_request('category-id', 'int'), $profileArticleIds)) ||
($rexApiCall == 'article_delete' && in_array(rex_request('article_id', 'int'), $profileArticleIds))) {
$_REQUEST[rex_api_function::REQ_CALL_PARAM] = '';
rex_extension::register('PAGE_TITLE_SHOWN', function (\rex_extension_point $ep) {
$subject = $ep->getSubject();
$ep->setSubject(rex_view::error(rex_i18n::msg('url_generator_rex_api_delete')).$subject);
});
}
}
else {
\rex_extension::register('OUTPUT_FILTER', [Generator::class, 'replaceLinks']);
}
}, rex_extension::EARLY);
rex_extension::register('URL_REWRITE', function (\rex_extension_point $ep) {
return UrlManager::getRewriteUrl($ep);
}, rex_extension::EARLY);
if (rex::isBackend() && rex::getUser()) {
rex_view::addCssFile($addon->getAssetsUrl('styles.css'));
}