forked from yakamara/redaxo_yrewrite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.inc.php
172 lines (129 loc) · 5.87 KB
/
config.inc.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
/**
* YREWRITE Addon
* @author jan.kristinus@yakamara.de
* @package redaxo4.5
*/
$mypage = 'yrewrite';
$REX['ADDON']['name'][$mypage] = 'YRewrite';
$REX['ADDON']['version'][$mypage] = '1.1.1';
$REX['ADDON']['author'][$mypage] = 'Jan Kristinus';
$REX['ADDON']['supportpage'][$mypage] = 'www.redaxo.org/de/forum';
$REX['PERM'][] = 'yrewrite[forward]';
$UrlRewriteBasedir = dirname(__FILE__);
require_once $UrlRewriteBasedir . '/classes/class.rex_yrewrite.inc.php';
require_once $UrlRewriteBasedir . '/classes/class.rex_yrewrite_scheme.inc.php';
require_once $UrlRewriteBasedir . '/classes/class.rex_yrewrite_forward.inc.php';
require_once $UrlRewriteBasedir . '/classes/class.rex_yrewrite_seo.inc.php';
rex_yrewrite::setScheme(new rex_yrewrite_scheme());
if ($REX['REDAXO']) {
$I18N->appendFile($REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/lang/');
// ----- content page - url manipulation
if ($REX['MOD_REWRITE'] !== false) {
rex_register_extension('PAGE_CONTENT_MENU', function ($params) {
global $REX, $I18N;
$class = '';
if ($params['mode'] == 'yrewrite_url') {
$class = 'class="rex-active"';
}
$page = '<a ' . $class . ' href="index.php?page=content&article_id=' . $params['article_id'] . '&mode=yrewrite_url&clang=' . $params['clang'] . '&ctype=' . rex_request('ctype') . '">' . $I18N->msg('yrewrite_mode_url') . '</a>';
array_splice($params['subject'], '-2', '-2', $page);
$class = '';
if ($params['mode'] == 'yrewrite_seo') {
$class = 'class="rex-active"';
}
$page = '<a ' . $class . ' href="index.php?page=content&article_id=' . $params['article_id'] . '&mode=yrewrite_seo&clang=' . $params['clang'] . '&ctype=' . rex_request('ctype') . '">' . $I18N->msg('yrewrite_mode_seo') . '</a>';
array_splice($params['subject'], '-2', '-2', $page);
array_pop($params['subject']);
$params['subject'][] = '<a href="' . rex_getUrl($params['article_id'], $params['clang']) . '" target="_blank">' . $I18N->msg('show') . '</a>';
return $params['subject'];
});
rex_register_extension('PAGE_CONTENT_OUTPUT', function ($params) {
global $REX, $I18N;
if ($params['mode'] == 'yrewrite_url') {
include $REX['INCLUDE_PATH'] . '/addons/yrewrite/pages/content_url.inc.php';
} else if ($params['mode'] == 'yrewrite_seo') {
include $REX['INCLUDE_PATH'] . '/addons/yrewrite/pages/content_seo.inc.php';
}
});
}
if( $REX['USER'] && $REX['USER']->isAdmin()) {
// ----- backend pages for domains und urls
$domainsPage = new rex_be_page($I18N->msg('yrewrite_domains'), array(
'page' => 'yrewrite',
'subpage' => ''
)
);
$domainsPage->setHref('index.php?page=yrewrite&subpage=');
$AliasDomainsPage = new rex_be_page($I18N->msg('yrewrite_alias_domains'), array(
'page' => 'yrewrite',
'subpage' => 'alias_domains'
)
);
$AliasDomainsPage->setHref('index.php?page=yrewrite&subpage=alias_domains');
$forwardPage = new rex_be_page($I18N->msg('yrewrite_forward'), array(
'page' => 'yrewrite',
'subpage' => 'forward'
)
);
$forwardPage->setHref('index.php?page=yrewrite&subpage=forward');
$setupPage = new rex_be_page($I18N->msg('yrewrite_setup'), array(
'page' => 'yrewrite',
'subpage' => 'setup'
)
);
$setupPage->setHref('index.php?page=yrewrite&subpage=setup');
$REX['ADDON']['pages'][$mypage] = array (
$domainsPage, $AliasDomainsPage, $forwardPage, $setupPage
);
} else if( $REX['USER'] && $REX['USER']->hasPerm("yrewrite[forward]")) {
// ----- backend pages for domains und urls
$forwardPage = new rex_be_page($I18N->msg('yrewrite_forward'), array(
'page' => 'yrewrite',
'subpage' => 'forward'
)
);
$forwardPage->setHref('index.php?page=yrewrite&subpage=forward');
$REX['ADDON']['pages'][$mypage] = array (
$forwardPage
);
}
}
if ($REX['MOD_REWRITE'] !== false && !$REX['SETUP']) {
rex_register_extension('ADDONS_INCLUDED', function ($params) {
global $REX;
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['REDAXO']) {
$extension = 'rex_yrewrite::generatePathFile';
$extensionPoints = array(
'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_register_extension($extensionPoint, $extension);
}
}
rex_register_extension('URL_REWRITE', 'rex_yrewrite::rewrite');
// get ARTICLE_ID from URL
if (!$REX['REDAXO']) {
rex_yrewrite::prepare();
}
}, '', REX_EXTENSION_EARLY);
if (rex_request("rex_yrewrite_func","string") == "sitemap") {
rex_register_extension('ADDONS_INCLUDED', function ($params) {
$sitemap = new rex_yrewrite_seo();
$sitemap->sendSitemap();
}, '', REX_EXTENSION_LATE);
}
rex_register_extension('YREWRITE_PREPARE', function ($params) {
return rex_yrewrite_forward::getForward($params);
});
}