-
Notifications
You must be signed in to change notification settings - Fork 14
/
offline.php
201 lines (181 loc) · 7.34 KB
/
offline.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php
/**
* @package Lightning
*
* @copyright Copyright (C) 2020 JoomJunk. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\AuthenticationHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
/** @var Joomla\CMS\Document\HtmlDocument $this */
$wa = $this->getWebAssetManager();
$twofactormethods = AuthenticationHelper::getTwoFactorMethods();
$extraButtons = AuthenticationHelper::getLoginButtons('form-login');
$app = Factory::getApplication();
// Template params
$themeSwitcher = (boolean)$this->params->get('theme-switcher', 1);
$fontAwesome = (boolean)$this->params->get('font-awesome-thats-actually-rather-shit', 1);
$googleFont = $this->params->get('google-font', '');
$faviconPath = (boolean)$this->params->get('favicon-override', 0)
? Uri::root()
: 'templates/' . $this->template . '/favicon';
// Load switcher CSS
if ($themeSwitcher)
{
$wa->useStyle('switch.css');
}
// Load assets
$wa->usePreset('template.lightning')
->useStyle('template.lightning.user')
->useScript('template.lightning.user');
// Font Awesome
if ($fontAwesome)
{
$wa->useStyle('fontawesome.css');
}
// Google font
if ($googleFont !== '')
{
$fontFamily = str_replace(' ', '+', $googleFont);
$this->getPreloadManager()->preconnect('https://fonts.googleapis.com', ['crossorigin' => 'anonymous']);
$this->getPreloadManager()->preconnect('https://fonts.gstatic.com', ['crossorigin' => 'anonymous']);
$this->addHeadLink('https://fonts.googleapis.com/css2?family=' . $fontFamily . '&display=swap', 'stylesheet', 'rel');
$wa->addInlineStyle(':root {
--hiq-font-family-base: "' . $googleFont . '";
}');
}
// Load switcher JS
// This should be loaded even if the themeSwitcher is disabled, so that the system preference will still dictate the theme
$wa->useScript('switch.js');
// Logo file or site title param
$sitename = htmlspecialchars($app->get('sitename'), ENT_QUOTES, 'UTF-8');
$logo = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 508.928 508.928" height="50"><path fill="hsl(210, 100%, 50%)" d="M403.712 201.04H256.288L329.792 0 105.216 307.888H252.64l-73.504 201.04z"/></svg>';
if ($this->params->get('logoFile'))
{
$logo = '<img src="' . Uri::root() . '/' . htmlspecialchars($this->params->get('logoFile'), ENT_QUOTES, 'UTF-8') . '" alt="' . $sitename . '">';
}
elseif ($this->params->get('logoSvg'))
{
$logo = $this->params->get('logoSvg');
}
elseif ($this->params->get('siteTitle'))
{
$logo = '<span title="' . $sitename . '">' . htmlspecialchars($this->params->get('siteTitle'), ENT_COMPAT, 'UTF-8') . '</span>';
}
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');
$this->setMetaData('theme-color', '#ffffff');
$imageLayout = new FileLayout('lightning.favicon');
$imageLayout->render([
'path' => $faviconPath,
]);
?>
<!DOCTYPE html>
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<jdoc:include type="metas" />
<jdoc:include type="styles" />
<jdoc:include type="scripts" />
</head>
<body class="site-grid site">
<div class="grid-child container-header full-width">
<header class="header">
<nav class="grid-child navbar">
<div class="navbar-brand">
<?php if (!empty($logo)) : ?>
<a href="<?php echo $this->baseurl; ?>/">
<?php echo $logo; ?>
<span class="sr-only"><?php echo Text::_('TPL_LIGHTNING_LOGO_LABEL'); ?></span>
</a>
<?php endif; ?>
</div>
<?php if ($themeSwitcher) : ?>
<div class="color-scheme-switch" id="color-scheme-switch">
<input type="radio" name="color-scheme-switch" value="is-light" class="color-scheme-switch-radio" aria-label="Light color scheme">
<input type="radio" name="color-scheme-switch" value="is-system" class="color-scheme-switch-radio" aria-label="System color scheme">
<input type="radio" name="color-scheme-switch" value="is-dark" class="color-scheme-switch-radio" aria-label="Dark color scheme">
<label class="color-scheme-switch-label" for="color-scheme-switch"></label>
</div>
<?php endif; ?>
</nav>
</header>
<div class="grid-child container-component">
<div class="container">
<h1><?php echo $sitename; ?></h1>
<?php if ($app->get('offline_image')) : ?>
<?php echo HTMLHelper::_('image', $app->get('offline_image'), $sitename, [], false, 0); ?>
<?php endif; ?>
<?php if ($app->get('display_offline_message', 1) == 1 && str_replace(' ', '', $app->get('offline_message')) != '') : ?>
<p><?php echo $app->get('offline_message'); ?></p>
<?php elseif ($app->get('display_offline_message', 1) == 2) : ?>
<p><?php echo Text::_('JOFFLINE_MESSAGE'); ?></p>
<?php endif; ?>
<div>
<jdoc:include type="message" />
<form action="<?php echo Route::_('index.php', true); ?>" method="post" id="form-login">
<fieldset>
<p>
<label for="username"><?php echo Text::_('JGLOBAL_USERNAME'); ?></label>
<input name="username" id="username" type="text">
</p>
<p>
<label for="password"><?php echo Text::_('JGLOBAL_PASSWORD'); ?></label>
<input name="password" id="password" type="password">
</p>
<?php if (count($twofactormethods) > 1) : ?>
<p>
<label for="secretkey"><?php echo Text::_('JGLOBAL_SECRETKEY'); ?></label>
<input name="secretkey" id="secretkey" type="text">
</p>
<?php endif; ?>
<?php foreach($extraButtons as $button):
$dataAttributeKeys = array_filter(array_keys($button), function ($key) {
return substr($key, 0, 5) == 'data-';
});
?>
<div class="mod-login__submit form-group">
<button type="button"
class="btn btn-secondary btn-block mt-4 <?php echo $button['class'] ?? '' ?>"
<?php foreach ($dataAttributeKeys as $key): ?>
<?php echo $key ?>="<?php echo $button[$key] ?>"
<?php endforeach; ?>
<?php if ($button['onclick']): ?>
onclick="<?php echo $button['onclick'] ?>"
<?php endif; ?>
title="<?php echo Text::_($button['label']) ?>"
id="<?php echo $button['id'] ?>"
>
<?php if (!empty($button['icon'])): ?>
<span class="<?php echo $button['icon'] ?>"></span>
<?php elseif (!empty($button['image'])): ?>
<?php echo HTMLHelper::_('image', $button['image'], Text::_($button['tooltip'] ?? ''), [
'class' => 'icon',
], true) ?>
<?php elseif (!empty($button['svg'])): ?>
<?php echo $button['svg']; ?>
<?php endif; ?>
<?php echo Text::_($button['label']) ?>
</button>
</div>
<?php endforeach; ?>
<p>
<button type="submit" name="Submit"><?php echo Text::_('JLOGIN'); ?></button>
<p>
<input type="hidden" name="option" value="com_users">
<input type="hidden" name="task" value="user.login">
<input type="hidden" name="return" value="<?php echo base64_encode(Uri::base()); ?>">
<?php echo HTMLHelper::_('form.token'); ?>
</fieldset>
</form>
</div>
</div>
</div>
</div>
</body>
</html>