1515use OC \Template \CSSResourceLocator ;
1616use OC \Template \JSConfigHelper ;
1717use OC \Template \JSResourceLocator ;
18+ use OC \Template \Template ;
1819use OCP \App \IAppManager ;
1920use OCP \AppFramework \Http \TemplateResponse ;
2021use OCP \Defaults ;
2526use OCP \IURLGenerator ;
2627use OCP \IUserSession ;
2728use OCP \L10N \IFactory ;
29+ use OCP \Server ;
2830use OCP \ServerVersion ;
2931use OCP \Support \Subscription \IRegistry ;
3032use OCP \Util ;
3133
32- class TemplateLayout extends \OC_Template {
33- private static $ versionHash = '' ;
34+ class TemplateLayout extends Template {
35+ private static string $ versionHash = '' ;
3436 /** @var string[] */
3537 private static $ cacheBusterCache = [];
3638
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 ;
4241
4342 private IConfig $ config ;
4443 private IAppManager $ appManager ;
4544 private InitialStateService $ initialState ;
4645 private INavigationManager $ navigationManager ;
4746
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);
5752
5853 // Add fallback theming variables if not rendered as user
5954 if ($ renderAs !== TemplateResponse::RENDER_AS_USER ) {
@@ -84,8 +79,7 @@ public function __construct($renderAs, $appId = '') {
8479 // Set body data-theme
8580 $ this ->assign ('enabledThemes ' , []);
8681 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);
8983 $ this ->assign ('enabledThemes ' , $ themesService ->getEnabledThemes ());
9084 }
9185
@@ -122,7 +116,7 @@ public function __construct($renderAs, $appId = '') {
122116 }
123117
124118 $ userDisplayName = false ;
125- $ user = \ OC :: $ server -> get (IUserSession::class)->getUser ();
119+ $ user = Server:: get (IUserSession::class)->getUser ();
126120 if ($ user ) {
127121 $ userDisplayName = $ user ->getDisplayName ();
128122 }
@@ -161,17 +155,15 @@ public function __construct($renderAs, $appId = '') {
161155 // Set body data-theme
162156 $ this ->assign ('enabledThemes ' , []);
163157 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);
166159 $ this ->assign ('enabledThemes ' , $ themesService ->getEnabledThemes ());
167160 }
168161
169162 // Set logo link target
170163 $ logoUrl = $ this ->config ->getSystemValueString ('logo_url ' , '' );
171164 $ this ->assign ('logoUrl ' , $ logoUrl );
172165
173- /** @var IRegistry $subscription */
174- $ subscription = \OCP \Server::get (IRegistry::class);
166+ $ subscription = Server::get (IRegistry::class);
175167 $ showSimpleSignup = $ this ->config ->getSystemValueBool ('simpleSignUpLink.shown ' , true );
176168 if ($ showSimpleSignup && $ subscription ->delegateHasValidSubscription ()) {
177169 $ showSimpleSignup = false ;
@@ -184,7 +176,7 @@ public function __construct($renderAs, $appId = '') {
184176 }
185177
186178 if ($ this ->appManager ->isEnabledForUser ('registration ' )) {
187- $ urlGenerator = \ OCP \ Server::get (IURLGenerator::class);
179+ $ urlGenerator = Server::get (IURLGenerator::class);
188180 $ signUpLink = $ urlGenerator ->getAbsoluteURL ('/index.php/apps/registration/ ' );
189181 }
190182
@@ -194,9 +186,10 @@ public function __construct($renderAs, $appId = '') {
194186 parent ::__construct ('core ' , 'layout.base ' );
195187 }
196188 // 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 );
200193
201194 $ lang = str_replace ('_ ' , '- ' , $ lang );
202195 $ this ->assign ('language ' , $ lang );
@@ -249,15 +242,17 @@ public function __construct($renderAs, $appId = '') {
249242 $ this ->append ('jsfiles ' , $ web . '/ ' . $ file . $ this ->getVersionHashSuffix ());
250243 }
251244
245+ $ request = \OCP \Server::get (IRequest::class);
246+
252247 try {
253- $ pathInfo = \ OC :: $ server -> getRequest () ->getPathInfo ();
248+ $ pathInfo = $ request ->getPathInfo ();
254249 } catch (\Exception $ e ) {
255250 $ pathInfo = '' ;
256251 }
257252
258253 // Do not initialise scss appdata until we have a fully installed instance
259254 // 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 )
261256 && !\OCP \Util::needUpgrade ()
262257 && $ pathInfo !== ''
263258 && !preg_match ('/^\/login/ ' , $ pathInfo )
@@ -291,7 +286,6 @@ public function __construct($renderAs, $appId = '') {
291286 }
292287 }
293288
294- $ request = \OCP \Server::get (IRequest::class);
295289 if ($ request ->isUserAgent ([Request::USER_AGENT_CLIENT_IOS , Request::USER_AGENT_SAFARI , Request::USER_AGENT_SAFARI_MOBILE ])) {
296290 // Prevent auto zoom with iOS but still allow user zoom
297291 // On chrome (and others) this does not work (will also disable user zoom)
0 commit comments