|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the TYPO3 CMS project. |
|
7
|
|
|
* |
|
8
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
9
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
10
|
|
|
* of the License, or any later version. |
|
11
|
|
|
* |
|
12
|
|
|
* For the full copyright and license information, please read the |
|
13
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
14
|
|
|
* |
|
15
|
|
|
* The TYPO3 project - inspiring people to share! |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
namespace TYPO3\CMS\Backend\View; |
|
19
|
|
|
|
|
20
|
|
|
use Psr\Log\LoggerAwareInterface; |
|
21
|
|
|
use Psr\Log\LoggerAwareTrait; |
|
22
|
|
|
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; |
|
23
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
24
|
|
|
use TYPO3\CMS\Core\Utility\PathUtility; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Provide styling for backend authentication forms, customized via extension configuration. |
|
28
|
|
|
* |
|
29
|
|
|
* @internal |
|
30
|
|
|
*/ |
|
31
|
|
|
class AuthenticationStyleInformation implements LoggerAwareInterface |
|
32
|
|
|
{ |
|
33
|
|
|
use LoggerAwareTrait; |
|
34
|
|
|
|
|
35
|
|
|
protected array $backendExtensionConfiguration; |
|
36
|
|
|
|
|
37
|
|
|
public function __construct(ExtensionConfiguration $extensionConfiguration) |
|
38
|
|
|
{ |
|
39
|
|
|
$this->backendExtensionConfiguration = (array)$extensionConfiguration->get('backend'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function getBackgroundImageStyles(): string |
|
43
|
|
|
{ |
|
44
|
|
|
$backgroundImage = (string)($this->backendExtensionConfiguration['loginBackgroundImage'] ?? ''); |
|
45
|
|
|
if ($backgroundImage === '') { |
|
46
|
|
|
return ''; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
$backgroundImageUri = $this->getUriForFileName($backgroundImage); |
|
50
|
|
|
if ($backgroundImageUri === '') { |
|
51
|
|
|
$this->logger->warning( |
|
52
|
|
|
'The configured TYPO3 backend login background image "' . htmlspecialchars($backgroundImageUri) . |
|
53
|
|
|
'" can\'t be resolved. Please check if the file exists and the extension is activated.' |
|
54
|
|
|
); |
|
55
|
|
|
return ''; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
return ' |
|
59
|
|
|
.typo3-login-carousel-control.right, |
|
60
|
|
|
.typo3-login-carousel-control.left, |
|
61
|
|
|
.panel-login { border: 0; } |
|
62
|
|
|
.typo3-login { background-image: url("' . $backgroundImageUri . '"); } |
|
63
|
|
|
.typo3-login-footnote { background-color: #000000; color: #ffffff; opacity: 0.5; } |
|
64
|
|
|
'; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getHighlightColorStyles(): string |
|
68
|
|
|
{ |
|
69
|
|
|
$highlightColor = (string)($this->backendExtensionConfiguration['loginHighlightColor'] ?? ''); |
|
70
|
|
|
if ($highlightColor === '') { |
|
71
|
|
|
return ''; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
return ' |
|
75
|
|
|
.btn-login.disabled, .btn-login[disabled], fieldset[disabled] .btn-login, |
|
76
|
|
|
.btn-login.disabled:hover, .btn-login[disabled]:hover, fieldset[disabled] .btn-login:hover, |
|
77
|
|
|
.btn-login.disabled:focus, .btn-login[disabled]:focus, fieldset[disabled] .btn-login:focus, |
|
78
|
|
|
.btn-login.disabled.focus, .btn-login[disabled].focus, fieldset[disabled] .btn-login.focus, |
|
79
|
|
|
.btn-login.disabled:active, .btn-login[disabled]:active, fieldset[disabled] .btn-login:active, |
|
80
|
|
|
.btn-login.disabled.active, .btn-login[disabled].active, fieldset[disabled] .btn-login.active, |
|
81
|
|
|
.btn-login:hover, .btn-login:focus, .btn-login:active, |
|
82
|
|
|
.btn-login:active:hover, .btn-login:active:focus, |
|
83
|
|
|
.btn-login { background-color: ' . $highlightColor . '; } |
|
84
|
|
|
.panel-login .panel-body { border-color: ' . $highlightColor . '; } |
|
85
|
|
|
'; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function getFooterNote(): string |
|
89
|
|
|
{ |
|
90
|
|
|
$footerNote = (string)($this->backendExtensionConfiguration['loginFootnote'] ?? ''); |
|
91
|
|
|
if ($footerNote === '') { |
|
92
|
|
|
return ''; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
return strip_tags(trim($footerNote)); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function getLogo(): string |
|
99
|
|
|
{ |
|
100
|
|
|
$logo = ($this->backendExtensionConfiguration['loginLogo'] ?? ''); |
|
101
|
|
|
if ($logo === '') { |
|
102
|
|
|
return ''; |
|
103
|
|
|
} |
|
104
|
|
|
$logoUri = $this->getUriForFileName($logo); |
|
105
|
|
|
if ($logoUri === '') { |
|
106
|
|
|
$this->logger->warning( |
|
107
|
|
|
'The configured TYPO3 backend login logo "' . htmlspecialchars($logoUri) . |
|
108
|
|
|
'" can\'t be resolved. Please check if the file exists and the extension is activated.' |
|
109
|
|
|
); |
|
110
|
|
|
return ''; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
return $logoUri; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
public function getLogoAlt(): string |
|
117
|
|
|
{ |
|
118
|
|
|
$logoAlt = trim((string)($this->backendExtensionConfiguration['loginLogoAlt'] ?? '')); |
|
119
|
|
|
if ($logoAlt === '') { |
|
120
|
|
|
trigger_error( |
|
121
|
|
|
'Login logo without alt-text is not accessible and will fall back to "TYPO3 CMS logo" in v12. Configure alt-text in the backend extension.', |
|
122
|
|
|
E_USER_DEPRECATED |
|
123
|
|
|
); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
return $logoAlt; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
public function getDefaultLogo(): string |
|
130
|
|
|
{ |
|
131
|
|
|
// Use TYPO3 logo depending on highlight color |
|
132
|
|
|
$logo = ((string)($this->backendExtensionConfiguration['loginHighlightColor'] ?? '') !== '') |
|
133
|
|
|
? 'EXT:backend/Resources/Public/Images/typo3_black.svg' |
|
134
|
|
|
: 'EXT:backend/Resources/Public/Images/typo3_orange.svg'; |
|
135
|
|
|
|
|
136
|
|
|
return $this->getUriForFileName($logo); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
public function getDefaultLogoStyles(): string |
|
140
|
|
|
{ |
|
141
|
|
|
return '.typo3-login-logo .typo3-login-image { max-width: 150px; height:100%;}'; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
public function getSupportingImages(): array |
|
145
|
|
|
{ |
|
146
|
|
|
return [ |
|
147
|
|
|
'capslock' => $this->getUriForFileName('EXT:backend/Resources/Public/Images/icon_capslock.svg'), |
|
148
|
|
|
'typo3' => $this->getUriForFileName('EXT:backend/Resources/Public/Images/typo3_orange.svg'), |
|
149
|
|
|
]; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* Returns the uri of a relative reference, resolves the "EXT:" prefix |
|
154
|
|
|
* (way of referring to files inside extensions) and checks that the file is inside |
|
155
|
|
|
* the project root of the TYPO3 installation |
|
156
|
|
|
* |
|
157
|
|
|
* @param string $filename The input filename/filepath to evaluate |
|
158
|
|
|
* @return string Returns the filename of $filename if valid, otherwise blank string. |
|
159
|
|
|
* @internal |
|
160
|
|
|
*/ |
|
161
|
|
|
protected function getUriForFileName(string $filename): string |
|
162
|
|
|
{ |
|
163
|
|
|
// Check if it's already a URL |
|
164
|
|
|
if (preg_match('/^(https?:)?\/\//', $filename)) { |
|
165
|
|
|
return $filename; |
|
166
|
|
|
} |
|
167
|
|
|
$absoluteFilename = GeneralUtility::getFileAbsFileName(ltrim($filename, '/')); |
|
168
|
|
|
$filename = ''; |
|
169
|
|
|
if ($absoluteFilename !== '' && @is_file($absoluteFilename)) { |
|
170
|
|
|
$filename = PathUtility::getAbsoluteWebPath($absoluteFilename); |
|
171
|
|
|
} |
|
172
|
|
|
return $filename; |
|
173
|
|
|
} |
|
174
|
|
|
} |
|
175
|
|
|
|