-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathLayoutHooks.php
More file actions
119 lines (99 loc) · 5.12 KB
/
Copy pathLayoutHooks.php
File metadata and controls
119 lines (99 loc) · 5.12 KB
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
<?php
namespace app\plugins\antragsgruen_sites;
use app\components\RequestContext;
use app\components\UrlHelper;
use app\controllers\Base;
use app\models\db\{Consultation, User};
use app\models\layoutHooks\Hooks;
use yii\helpers\Html;
class LayoutHooks extends Hooks
{
public function getStdNavbarHeader(string $before): string
{
/** @var Base $controller */
$controller = RequestContext::getWebApplication()->controller;
if ($controller->consultation) {
return $before;
}
$out = '<ul class="nav navbar-nav">';
$startLink = UrlHelper::createUrl('/antragsgruen_sites/manager/index');
$out .= '<li class="active">' . Html::a(\Yii::t('base', 'Home'), $startLink, ['aria-label' => \Yii::t('base', 'home_back')]) . '</li>';
$helpLink = UrlHelper::createUrl('/antragsgruen_sites/manager/help');
$helpTitle = \Yii::t('base', 'Help');
$out .= '<li>' . Html::a($helpTitle, $helpLink, ['id' => 'helpLink', 'aria-label' => $helpTitle]) . '</li>';
if (!User::getCurrentUser()) {
$loginUrl = UrlHelper::createUrl(['/user/login', 'backUrl' => RequestContext::getWebApplication()->request->url]);
$loginTitle = \Yii::t('base', 'menu_login');
$out .= '<li>' . Html::a($loginTitle, $loginUrl, ['id' => 'loginLink', 'rel' => 'nofollow', 'aria-label' => $loginTitle]) .
'</li>';
}
if (User::getCurrentUser()) {
$link = Html::a(
\Yii::t('base', 'menu_account'),
UrlHelper::createUrl('/user/myaccount'),
['id' => 'myAccountLink']
);
$out .= '<li>' . $link . '</li>';
$logoutUrl = UrlHelper::createUrl(['/user/logout', 'backUrl' => RequestContext::getWebApplication()->request->url]);
$logoutTitle = \Yii::t('base', 'menu_logout');
$out .= '<li>' . Html::a($logoutTitle, $logoutUrl, ['id' => 'logoutLink', 'aria-label' => $logoutTitle]) . '</li>';
}
if (\Yii::$app->language === 'de') {
$out .= '<li><a lang="en" id="enLink" href="https://motion.tools/" aria-label="This site in english" title="This site in english">🇬🇧</a></li>';
} else {
$out .= '<li><a lang="en" id="deLink" href="https://antragsgruen.de/" aria-label="This site in german" title="This site in german">🇩🇪</a></li>';
}
$out .= '</ul>';
return $out;
}
public function footerLine(string $before): string
{
/** @var Base $controller */
$controller = RequestContext::getWebApplication()->controller;
if ($controller->consultation) {
return $before;
}
$out = '<footer class="footer"><div class="container">';
$legalLink = UrlHelper::createUrl('/antragsgruen_sites/manager/legal');
$privacyLink = UrlHelper::createUrl('/antragsgruen_sites/manager/privacy');
$out .= '<a href="' . Html::encode($legalLink) . '" class="legal" id="legalLink">' .
\Yii::t('base', 'imprint') . '</a>
<a href="' . Html::encode($privacyLink) . '" class="privacy" id="privacyLink">' .
\Yii::t('base', 'privacy_statement') . '</a>';
$out .= '<span class="version">';
if (RequestContext::getWebApplication()->language === 'de') {
$ariaVersion = str_replace('%VERSION%', ANTRAGSGRUEN_VERSION, \Yii::t('base', 'aria_version_hint'));
$out .= '<a href="https://antragsgruen.de/" aria-label="' . \Yii::t('base', 'aria_antragsgruen') . '">Antragsgrün</a>, Version ' .
Html::a(Html::encode(ANTRAGSGRUEN_VERSION), ANTRAGSGRUEN_HISTORY_URL, ['aria-label' => $ariaVersion]);
} else {
$ariaVersion = str_replace('%VERSION%', ANTRAGSGRUEN_VERSION, \Yii::t('base', 'aria_version_hint'));
$out .= '<a href="https://motion.tools/" aria-label="' . \Yii::t('base', 'aria_antragsgruen') . '">Antragsgrün</a>, Version ' .
Html::a(Html::encode(ANTRAGSGRUEN_VERSION), ANTRAGSGRUEN_HISTORY_URL, ['aria-label' => $ariaVersion]);
}
$out .= '</span>';
$out .= '</div></footer>';
return $out;
}
public function getAdminIndexHint(string $before, Consultation $consultation): string
{
return $before . '<article class="adminCard adminCardSupport">
<header>
<h2>Verfügbarkeit, Support</h2>
</header>
<main>
Wenn für eine Veranstaltung eine garantierte Verfügbarkeit von Antragsgrün und professioneller Support
benötigt wird, setzt euch bitte frühzeitig <a href="https://antragsgruen.de/#support">mit uns in Kontakt</a>!
</main>
</article>';
}
public function endOfHead(string $before): string
{
if ($this->consultation) {
$cssFile = __DIR__ . '/consultationCss/consultation-' . $this->consultation->id . '.css';
if (file_exists($cssFile)) {
$before .= '<style>' . file_get_contents($cssFile) . '</style>';
}
}
return $before;
}
}