15
15
use OC \Template \CSSResourceLocator ;
16
16
use OC \Template \JSConfigHelper ;
17
17
use OC \Template \JSResourceLocator ;
18
+ use OC \Template \Template ;
18
19
use OCP \App \IAppManager ;
19
20
use OCP \AppFramework \Http \TemplateResponse ;
20
21
use OCP \Defaults ;
25
26
use OCP \IURLGenerator ;
26
27
use OCP \IUserSession ;
27
28
use OCP \L10N \IFactory ;
29
+ use OCP \Server ;
28
30
use OCP \ServerVersion ;
29
31
use OCP \Support \Subscription \IRegistry ;
30
32
use OCP \Util ;
31
33
32
- class TemplateLayout extends \OC_Template {
33
- private static $ versionHash = '' ;
34
+ class TemplateLayout extends Template {
35
+ private static string $ versionHash = '' ;
34
36
/** @var string[] */
35
37
private static $ cacheBusterCache = [];
36
38
37
- /** @var CSSResourceLocator|null */
38
- public static $ cssLocator = null ;
39
-
40
- /** @var JSResourceLocator|null */
41
- public static $ jsLocator = null ;
39
+ public static ?CSSResourceLocator $ cssLocator = null ;
40
+ public static ?JSResourceLocator $ jsLocator = null ;
42
41
43
42
private IConfig $ config ;
44
43
private IAppManager $ appManager ;
45
44
private InitialStateService $ initialState ;
46
45
private INavigationManager $ navigationManager ;
47
46
48
- /**
49
- * @param string $renderAs
50
- * @param string $appId application id
51
- */
52
- public function __construct ($ renderAs , $ appId = '' ) {
53
- $ this ->config = \OCP \Server::get (IConfig::class);
54
- $ this ->appManager = \OCP \Server::get (IAppManager::class);
55
- $ this ->initialState = \OCP \Server::get (InitialStateService::class);
56
- $ this ->navigationManager = \OCP \Server::get (INavigationManager::class);
47
+ public function __construct (string $ renderAs , string $ appId = '' ) {
48
+ $ this ->config = Server::get (IConfig::class);
49
+ $ this ->appManager = Server::get (IAppManager::class);
50
+ $ this ->initialState = Server::get (InitialStateService::class);
51
+ $ this ->navigationManager = Server::get (INavigationManager::class);
57
52
58
53
// Add fallback theming variables if not rendered as user
59
54
if ($ renderAs !== TemplateResponse::RENDER_AS_USER ) {
@@ -84,8 +79,7 @@ public function __construct($renderAs, $appId = '') {
84
79
// Set body data-theme
85
80
$ this ->assign ('enabledThemes ' , []);
86
81
if ($ this ->appManager ->isEnabledForUser ('theming ' ) && class_exists ('\OCA\Theming\Service\ThemesService ' )) {
87
- /** @var \OCA\Theming\Service\ThemesService */
88
- $ themesService = \OC ::$ server ->get (\OCA \Theming \Service \ThemesService::class);
82
+ $ themesService = Server::get (\OCA \Theming \Service \ThemesService::class);
89
83
$ this ->assign ('enabledThemes ' , $ themesService ->getEnabledThemes ());
90
84
}
91
85
@@ -122,7 +116,7 @@ public function __construct($renderAs, $appId = '') {
122
116
}
123
117
124
118
$ userDisplayName = false ;
125
- $ user = \ OC :: $ server -> get (IUserSession::class)->getUser ();
119
+ $ user = Server:: get (IUserSession::class)->getUser ();
126
120
if ($ user ) {
127
121
$ userDisplayName = $ user ->getDisplayName ();
128
122
}
@@ -161,17 +155,15 @@ public function __construct($renderAs, $appId = '') {
161
155
// Set body data-theme
162
156
$ this ->assign ('enabledThemes ' , []);
163
157
if ($ this ->appManager ->isEnabledForUser ('theming ' ) && class_exists ('\OCA\Theming\Service\ThemesService ' )) {
164
- /** @var \OCA\Theming\Service\ThemesService $themesService */
165
- $ themesService = \OC ::$ server ->get (\OCA \Theming \Service \ThemesService::class);
158
+ $ themesService = Server::get (\OCA \Theming \Service \ThemesService::class);
166
159
$ this ->assign ('enabledThemes ' , $ themesService ->getEnabledThemes ());
167
160
}
168
161
169
162
// Set logo link target
170
163
$ logoUrl = $ this ->config ->getSystemValueString ('logo_url ' , '' );
171
164
$ this ->assign ('logoUrl ' , $ logoUrl );
172
165
173
- /** @var IRegistry $subscription */
174
- $ subscription = \OCP \Server::get (IRegistry::class);
166
+ $ subscription = Server::get (IRegistry::class);
175
167
$ showSimpleSignup = $ this ->config ->getSystemValueBool ('simpleSignUpLink.shown ' , true );
176
168
if ($ showSimpleSignup && $ subscription ->delegateHasValidSubscription ()) {
177
169
$ showSimpleSignup = false ;
@@ -184,7 +176,7 @@ public function __construct($renderAs, $appId = '') {
184
176
}
185
177
186
178
if ($ this ->appManager ->isEnabledForUser ('registration ' )) {
187
- $ urlGenerator = \ OCP \ Server::get (IURLGenerator::class);
179
+ $ urlGenerator = Server::get (IURLGenerator::class);
188
180
$ signUpLink = $ urlGenerator ->getAbsoluteURL ('/index.php/apps/registration/ ' );
189
181
}
190
182
@@ -194,9 +186,10 @@ public function __construct($renderAs, $appId = '') {
194
186
parent ::__construct ('core ' , 'layout.base ' );
195
187
}
196
188
// Send the language, locale, and direction to our layouts
197
- $ lang = \OC ::$ server ->get (IFactory::class)->findLanguage ();
198
- $ locale = \OC ::$ server ->get (IFactory::class)->findLocale ($ lang );
199
- $ direction = \OC ::$ server ->getL10NFactory ()->getLanguageDirection ($ lang );
189
+ $ l10nFactory = Server::get (IFactory::class);
190
+ $ lang = $ l10nFactory ->findLanguage ();
191
+ $ locale = $ l10nFactory ->findLocale ($ lang );
192
+ $ direction = $ l10nFactory ->getLanguageDirection ($ lang );
200
193
201
194
$ lang = str_replace ('_ ' , '- ' , $ lang );
202
195
$ this ->assign ('language ' , $ lang );
@@ -249,15 +242,17 @@ public function __construct($renderAs, $appId = '') {
249
242
$ this ->append ('jsfiles ' , $ web . '/ ' . $ file . $ this ->getVersionHashSuffix ());
250
243
}
251
244
245
+ $ request = \OCP \Server::get (IRequest::class);
246
+
252
247
try {
253
- $ pathInfo = \ OC :: $ server -> getRequest () ->getPathInfo ();
248
+ $ pathInfo = $ request ->getPathInfo ();
254
249
} catch (\Exception $ e ) {
255
250
$ pathInfo = '' ;
256
251
}
257
252
258
253
// Do not initialise scss appdata until we have a fully installed instance
259
254
// Do not load scss for update, errors, installation or login page
260
- if (\ OC :: $ server -> getSystemConfig ()-> getValue ('installed ' , false )
255
+ if ($ this -> config -> getSystemValueBool ('installed ' , false )
261
256
&& !\OCP \Util::needUpgrade ()
262
257
&& $ pathInfo !== ''
263
258
&& !preg_match ('/^\/login/ ' , $ pathInfo )
@@ -291,7 +286,6 @@ public function __construct($renderAs, $appId = '') {
291
286
}
292
287
}
293
288
294
- $ request = \OCP \Server::get (IRequest::class);
295
289
if ($ request ->isUserAgent ([Request::USER_AGENT_CLIENT_IOS , Request::USER_AGENT_SAFARI , Request::USER_AGENT_SAFARI_MOBILE ])) {
296
290
// Prevent auto zoom with iOS but still allow user zoom
297
291
// On chrome (and others) this does not work (will also disable user zoom)
0 commit comments