This repository has been archived by the owner on May 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboot.php
61 lines (53 loc) · 2.9 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
<?php
// Add status for locked articles and categories
if (rex::isBackend()) {
rex_extension::register(['ART_STATUS_TYPES', 'CAT_STATUS_TYPES'], function (rex_extension_point $ep) {
$subject = $ep->getSubject();
$subject[] = array(rex_i18n::msg('locked_locked'), 'rex-offline', 'fa fa-exclamation-triangle');
$ep->setSubject($subject);
return $ep->getSubject();
});
if (rex_addon::get('quick_navigation')->isAvailable()) {
rex_view::addCssFile($this->getAssetsUrl('locked_gn.css'));
}
}
// redirect to not foundArticle if not logged in or preview parameter not set.
if (rex::isFrontend()) {
rex_extension::register('PACKAGES_INCLUDED', function () {
if (rex_category::getCurrent() != null) {
$cat = rex_category::getCurrent();
if ($cat->getClosest(fn (rex_category $cat) => 2 == $cat->getValue('status')) && rex_request('preview', 'string', '') != 'id-' . rex_article::getCurrent()->getId() && !rex_backend_login::hasSession()) {
rex_response::setStatus(rex_response::HTTP_MOVED_TEMPORARILY);
rex_redirect(rex_article::getNotfoundArticleId(), rex_clang::getCurrentId());
}
}
if (rex_article::getCurrent() instanceof rex_article && rex_request('preview', 'string', '') != 'id-' . rex_article::getCurrent()->getId() && rex_article::getCurrent()->getValue('status') == 2 && !rex_backend_login::hasSession()) {
rex_response::setStatus(rex_response::HTTP_MOVED_TEMPORARILY);
rex_redirect(rex_article::getNotfoundArticleId(), rex_clang::getCurrentId());
}
}, rex_extension::LATE);
}
if (rex::isBackend()) {
$catclocked = false;
$cat = rex_category::getCurrent();
if ($cat && $cat->getClosest(fn (rex_category $cat) => 2 == $cat->getValue('status')))
{
$catclocked = true;
}
$art = rex_article::getCurrent();
if (($art && $art->getValue('status') == 2) || true == $catclocked) {
rex_extension::register('STRUCTURE_CONTENT_SIDEBAR', function (rex_extension_point $ep) {
$params = $ep->getParams();
$subject = $ep->getSubject();
$panel = '<div class="alert alert-info">'.rex_i18n::msg('locked_share').'<br><strong>' . rex_yrewrite::getFullUrlByArticleId($params["article_id"]) . '?preview=id-' . rex_article::getCurrent()->getId() . '</strong></div>';
$fragment = new rex_fragment();
$fragment->setVar('title', '<i class="fa fa-exclamation-triangle" style="color: red"></i> '.rex_i18n::msg('locked_info'), 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;
});
}
}