forked from yakamara/redaxo_yrewrite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.php
114 lines (90 loc) · 3.87 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* YREWRITE Addon.
*
* @author jan.kristinus@yakamara.de
*
* @package redaxo\yrewrite
*
* @var rex_addon $this
*/
if(!rex::isBackend()) {
$path = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/') . '/';
rex_url::init(new rex_path_default_provider($path, "redaxo", false));
}
rex_extension::register('PACKAGES_INCLUDED', function ($params) {
rex_yrewrite::init();
if (rex_request('rex_yrewrite_func', 'string') == 'robots') {
$robots = new rex_yrewrite_seo();
$robots->sendRobotsTxt();
}
// if anything changes -> refresh PathFile
if (rex::isBackend()) {
$extensionPoints = [
'CAT_ADDED', 'CAT_UPDATED', 'CAT_DELETED', 'CAT_STATUS',
'ART_ADDED', 'ART_UPDATED', 'ART_DELETED', 'ART_STATUS',
/*'CLANG_ADDED',*/ 'CLANG_UPDATED', /*'CLANG_DELETED',*/
/*'ARTICLE_GENERATED'*/
//'ALL_GENERATED'
];
foreach ($extensionPoints as $extensionPoint) {
rex_extension::register($extensionPoint, function (rex_extension_point $ep) {
$params = $ep->getParams();
$params['subject'] = $ep->getSubject();
$params['extension_point'] = $ep->getName();
rex_yrewrite::generatePathFile($params);
});
}
}
//rex_extension::register('ALL_GENERATED', 'rex_yrewrite::init');
rex_extension::register('URL_REWRITE', function (rex_extension_point $ep) {
$params = $ep->getParams();
$params['subject'] = $ep->getSubject();
return rex_yrewrite::rewrite($params);
});
// get ARTICLE_ID from URL
if (!rex::isBackend()) {
rex_yrewrite::prepare();
}
if (rex::isBackend()) {
rex_extension::register('STRUCTURE_CONTENT_SIDEBAR', function (rex_extension_point $ep) {
$params = $ep->getParams();
$subject = $ep->getSubject();
$panel = include(rex_path::addon('yrewrite','pages/content.yrewrite_url.php'));
$fragment = new rex_fragment();
$fragment->setVar('title', '<i class="rex-icon rex-icon-info"></i> ' . rex_i18n::msg('yrewrite_rewriter'), false);
$fragment->setVar('body', $panel, false);
$fragment->setVar('article_id', $params["article_id"], false);
$fragment->setVar('collapse', true);
$fragment->setVar('collapsed', false);
$content = $fragment->parse('core/page/section.php');
return $subject.$content;
});
rex_extension::register('STRUCTURE_CONTENT_SIDEBAR', function (rex_extension_point $ep) {
$params = $ep->getParams();
$subject = $ep->getSubject();
$panel = include(rex_path::addon('yrewrite','pages/content.yrewrite_seo.php'));
$fragment = new rex_fragment();
$fragment->setVar('title', '<i class="rex-icon rex-icon-info"></i> ' . rex_i18n::msg('yrewrite_rewriter_seo'), false);
$fragment->setVar('body', $panel, false);
$fragment->setVar('article_id', $params["article_id"], false);
$fragment->setVar('clang', $params["clang"], false);
$fragment->setVar('ctype', $params["ctype"], false);
$fragment->setVar('collapse', true);
$fragment->setVar('collapsed', false);
$content = $fragment->parse('core/page/section.php');
return $subject.$content;
});
}
}, rex_extension::EARLY);
if (rex_request('rex_yrewrite_func', 'string') == 'sitemap') {
rex_extension::register('PACKAGES_INCLUDED', function ($params) {
$sitemap = new rex_yrewrite_seo();
$sitemap->sendSitemap();
}, rex_extension::LATE);
}
rex_extension::register('YREWRITE_PREPARE', function (rex_extension_point $ep) {
$params = $ep->getParams();
$params['subject'] = $ep->getSubject();
return rex_yrewrite_forward::getForward($params);
});