@@ -69,27 +69,27 @@ public function __construct(
6969 }
7070
7171 public function getName () {
72- return strip_tags ($ this ->config -> getAppValue ('theming ' , ' name ' , $ this ->name ));
72+ return strip_tags ($ this ->appConfig -> getValueString ('theming ' , ConfigLexicon:: INSTANCE_NAME , $ this ->name ));
7373 }
7474
7575 public function getHTMLName () {
76- return $ this ->config -> getAppValue ('theming ' , ' name ' , $ this ->name );
76+ return $ this ->appConfig -> getValueString ('theming ' , ConfigLexicon:: INSTANCE_NAME , $ this ->name );
7777 }
7878
7979 public function getTitle () {
80- return strip_tags ($ this ->config -> getAppValue ('theming ' , ' name ' , $ this ->title ));
80+ return strip_tags ($ this ->appConfig -> getValueString ('theming ' , ConfigLexicon:: INSTANCE_NAME , $ this ->title ));
8181 }
8282
8383 public function getEntity () {
84- return strip_tags ($ this ->config -> getAppValue ('theming ' , ' name ' , $ this ->entity ));
84+ return strip_tags ($ this ->appConfig -> getValueString ('theming ' , ConfigLexicon:: INSTANCE_NAME , $ this ->entity ));
8585 }
8686
8787 public function getProductName () {
88- return strip_tags ($ this ->config -> getAppValue ('theming ' , ' productName ' , $ this ->productName ));
88+ return strip_tags ($ this ->appConfig -> getValueString ('theming ' , ConfigLexicon:: PRODUCT_NAME , $ this ->productName ));
8989 }
9090
9191 public function getBaseUrl () {
92- return $ this ->config -> getAppValue ('theming ' , ' url ' , $ this ->url );
92+ return $ this ->appConfig -> getValueString ('theming ' , ConfigLexicon:: BASE_URL , $ this ->url );
9393 }
9494
9595 /**
@@ -98,19 +98,19 @@ public function getBaseUrl() {
9898 * @psalm-suppress InvalidReturnType
9999 */
100100 public function getSlogan (?string $ lang = null ) {
101- return \OCP \Util::sanitizeHTML ($ this ->config -> getAppValue ('theming ' , ' slogan ' , parent ::getSlogan ($ lang )));
101+ return \OCP \Util::sanitizeHTML ($ this ->appConfig -> getValueString ('theming ' , ConfigLexicon:: INSTANCE_SLOGAN , parent ::getSlogan ($ lang )));
102102 }
103103
104104 public function getImprintUrl () {
105- return (string )$ this ->config -> getAppValue ('theming ' , ' imprintUrl ' , '' );
105+ return (string )$ this ->appConfig -> getValueString ('theming ' , ConfigLexicon:: INSTANCE_IMPRINT_URL , '' );
106106 }
107107
108108 public function getPrivacyUrl () {
109- return (string )$ this ->config -> getAppValue ('theming ' , ' privacyUrl ' , '' );
109+ return (string )$ this ->appConfig -> getValueString ('theming ' , ConfigLexicon:: INSTANCE_PRIVACY_URL , '' );
110110 }
111111
112112 public function getDocBaseUrl () {
113- return (string )$ this ->config -> getAppValue ('theming ' , ' docBaseUrl ' , $ this ->docBaseUrl );
113+ return (string )$ this ->appConfig -> getValueString ('theming ' , ConfigLexicon:: DOC_BASE_URL , $ this ->docBaseUrl );
114114 }
115115
116116 public function getShortFooter () {
@@ -252,7 +252,7 @@ public function getDefaultColorBackground(): string {
252252 * @return string
253253 */
254254 public function getLogo ($ useSvg = true ): string {
255- $ logo = $ this ->config -> getAppValue ('theming ' , 'logoMime ' , '' );
255+ $ logo = $ this ->appConfig -> getValueString ('theming ' , 'logoMime ' , '' );
256256
257257 // short cut to avoid setting up the filesystem just to check if the logo is there
258258 //
@@ -270,18 +270,17 @@ public function getLogo($useSvg = true): string {
270270 }
271271 }
272272
273- $ cacheBusterCounter = $ this ->config ->getAppValue ('theming ' , 'cachebuster ' , '0 ' );
274-
273+ $ cacheBusterCounter = $ this ->appConfig ->getValueInt ('theming ' , ConfigLexicon::CACHE_BUSTER );
275274 if (!$ logo || !$ logoExists ) {
276275 if ($ useSvg ) {
277276 $ logo = $ this ->urlGenerator ->imagePath ('core ' , 'logo/logo.svg ' );
278277 } else {
279278 $ logo = $ this ->urlGenerator ->imagePath ('core ' , 'logo/logo.png ' );
280279 }
281- return $ logo . '?v= ' . $ cacheBusterCounter ;
280+ return $ logo . '?v= ' . ( string ) $ cacheBusterCounter ;
282281 }
283282
284- return $ this ->urlGenerator ->linkToRoute ('theming.Theming.getImage ' , [ 'key ' => 'logo ' , 'useSvg ' => $ useSvg , 'v ' => $ cacheBusterCounter ]);
283+ return $ this ->urlGenerator ->linkToRoute ('theming.Theming.getImage ' , [ 'key ' => 'logo ' , 'useSvg ' => $ useSvg , 'v ' => ( string ) $ cacheBusterCounter ]);
285284 }
286285
287286 /**
@@ -298,47 +297,47 @@ public function getBackground(bool $darkVariant = false): string {
298297 * @return string
299298 */
300299 public function getiTunesAppId () {
301- return $ this ->config -> getAppValue ('theming ' , 'iTunesAppId ' , $ this ->iTunesAppId );
300+ return $ this ->appConfig -> getValueString ('theming ' , 'iTunesAppId ' , $ this ->iTunesAppId );
302301 }
303302
304303 /**
305304 * @return string
306305 */
307306 public function getiOSClientUrl () {
308- return $ this ->config -> getAppValue ('theming ' , 'iOSClientUrl ' , $ this ->iOSClientUrl );
307+ return $ this ->appConfig -> getValueString ('theming ' , 'iOSClientUrl ' , $ this ->iOSClientUrl );
309308 }
310309
311310 /**
312311 * @return string
313312 */
314313 public function getAndroidClientUrl () {
315- return $ this ->config -> getAppValue ('theming ' , 'AndroidClientUrl ' , $ this ->AndroidClientUrl );
314+ return $ this ->appConfig -> getValueString ('theming ' , 'AndroidClientUrl ' , $ this ->AndroidClientUrl );
316315 }
317316
318317 /**
319318 * @return string
320319 */
321320 public function getFDroidClientUrl () {
322- return $ this ->config -> getAppValue ('theming ' , 'FDroidClientUrl ' , $ this ->FDroidClientUrl );
321+ return $ this ->appConfig -> getValueString ('theming ' , 'FDroidClientUrl ' , $ this ->FDroidClientUrl );
323322 }
324323
325324 /**
326325 * @return array scss variables to overwrite
327326 * @deprecated since Nextcloud 22 - https://github.com/nextcloud/server/issues/9940
328327 */
329328 public function getScssVariables () {
330- $ cacheBuster = $ this ->config -> getAppValue ('theming ' , ' cachebuster ' , ' 0 ' );
331- $ cache = $ this ->cacheFactory ->createDistributed ('theming- ' . $ cacheBuster . '- ' . $ this ->urlGenerator ->getBaseUrl ());
329+ $ cacheBuster = $ this ->appConfig -> getValueInt ('theming ' , ConfigLexicon:: CACHE_BUSTER );
330+ $ cache = $ this ->cacheFactory ->createDistributed ('theming- ' . ( string ) $ cacheBuster . '- ' . $ this ->urlGenerator ->getBaseUrl ());
332331 if ($ value = $ cache ->get ('getScssVariables ' )) {
333332 return $ value ;
334333 }
335334
336335 $ variables = [
337336 'theming-cachebuster ' => "' " . $ cacheBuster . "' " ,
338- 'theming-logo-mime ' => "' " . $ this ->config -> getAppValue ('theming ' , 'logoMime ' ) . "' " ,
339- 'theming-background-mime ' => "' " . $ this ->config -> getAppValue ('theming ' , 'backgroundMime ' ) . "' " ,
340- 'theming-logoheader-mime ' => "' " . $ this ->config -> getAppValue ('theming ' , 'logoheaderMime ' ) . "' " ,
341- 'theming-favicon-mime ' => "' " . $ this ->config -> getAppValue ('theming ' , 'faviconMime ' ) . "' "
337+ 'theming-logo-mime ' => "' " . $ this ->appConfig -> getValueString ('theming ' , 'logoMime ' ) . "' " ,
338+ 'theming-background-mime ' => "' " . $ this ->appConfig -> getValueString ('theming ' , 'backgroundMime ' ) . "' " ,
339+ 'theming-logoheader-mime ' => "' " . $ this ->appConfig -> getValueString ('theming ' , 'logoheaderMime ' ) . "' " ,
340+ 'theming-favicon-mime ' => "' " . $ this ->appConfig -> getValueString ('theming ' , 'faviconMime ' ) . "' "
342341 ];
343342
344343 $ variables ['image-logo ' ] = "url(' " . $ this ->imageManager ->getImageUrl ('logo ' ) . "') " ;
@@ -353,7 +352,7 @@ public function getScssVariables() {
353352 $ variables ['color-primary-element ' ] = $ this ->util ->elementColor ($ this ->getColorPrimary ());
354353 }
355354
356- if ($ this ->config -> getAppValue ('theming ' , 'backgroundMime ' , '' ) === 'backgroundColor ' ) {
355+ if ($ this ->appConfig -> getValueString ('theming ' , 'backgroundMime ' , '' ) === 'backgroundColor ' ) {
357356 $ variables ['image-login-plain ' ] = 'true ' ;
358357 }
359358
@@ -378,7 +377,6 @@ public function replaceImagePath($app, $image) {
378377 if ($ app === '' || $ app === 'files_sharing ' ) {
379378 $ app = 'core ' ;
380379 }
381- $ cacheBusterValue = $ this ->config ->getAppValue ('theming ' , 'cachebuster ' , '0 ' );
382380
383381 $ route = false ;
384382 if ($ image === 'favicon.ico ' && ($ this ->imageManager ->shouldReplaceIcons () || $ this ->getCustomFavicon () !== null )) {
@@ -420,8 +418,8 @@ protected function getCustomFavicon(): ?ISimpleFile {
420418 * Increases the cache buster key
421419 */
422420 public function increaseCacheBuster (): void {
423- $ cacheBusterKey = ( int ) $ this ->config -> getAppValue ('theming ' , ' cachebuster ' , ' 0 ' );
424- $ this ->config -> setAppValue ('theming ' , ' cachebuster ' , ( string )( $ cacheBusterKey + 1 ) );
421+ $ cacheBusterKey = $ this ->appConfig -> getValueInt ('theming ' , ConfigLexicon:: CACHE_BUSTER );
422+ $ this ->appConfig -> setValueInt ('theming ' , ConfigLexicon:: CACHE_BUSTER , $ cacheBusterKey + 1 );
425423 $ this ->cacheFactory ->createDistributed ('theming- ' )->clear ();
426424 $ this ->cacheFactory ->createDistributed ('imagePath ' )->clear ();
427425 }
@@ -433,7 +431,18 @@ public function increaseCacheBuster(): void {
433431 * @param string $value
434432 */
435433 public function set ($ setting , $ value ): void {
436- $ this ->appConfig ->setValueString ('theming ' , $ setting , $ value );
434+ switch ($ value ) {
435+ case ConfigLexicon::CACHE_BUSTER :
436+ $ this ->appConfig ->setValueInt ('theming ' , ConfigLexicon::CACHE_BUSTER , (int )$ value );
437+ break ;
438+ case ConfigLexicon::USER_THEMING_DISABLED :
439+ $ value = $ value === 'true ' || $ value === 'yes ' || $ value === '1 ' ;
440+ $ this ->appConfig ->setValueBool ('theming ' , ConfigLexicon::USER_THEMING_DISABLED , $ value );
441+ break ;
442+ default :
443+ $ this ->appConfig ->setValueString ('theming ' , $ setting , $ value );
444+ break ;
445+ }
437446 $ this ->increaseCacheBuster ();
438447 }
439448
@@ -443,9 +452,9 @@ public function set($setting, $value): void {
443452 public function undoAll (): void {
444453 // Remember the current cachebuster value, as we do not want to reset this value
445454 // Otherwise this can lead to caching issues as the value might be known to a browser already
446- $ cacheBusterKey = $ this ->config -> getAppValue ('theming ' , ' cachebuster ' , ' 0 ' );
447- $ this ->config -> deleteAppValues ('theming ' );
448- $ this ->config -> setAppValue ('theming ' , ' cachebuster ' , $ cacheBusterKey );
455+ $ cacheBusterKey = $ this ->appConfig -> getValueInt ('theming ' , ConfigLexicon:: CACHE_BUSTER );
456+ $ this ->appConfig -> deleteApp ('theming ' );
457+ $ this ->appConfig -> setValueInt ('theming ' , ConfigLexicon:: CACHE_BUSTER , $ cacheBusterKey );
449458 $ this ->increaseCacheBuster ();
450459 }
451460
@@ -456,7 +465,7 @@ public function undoAll(): void {
456465 * @return string default value
457466 */
458467 public function undo ($ setting ): string {
459- $ this ->config -> deleteAppValue ('theming ' , $ setting );
468+ $ this ->appConfig -> deleteKey ('theming ' , $ setting );
460469 $ this ->increaseCacheBuster ();
461470
462471 $ returnValue = '' ;
@@ -485,7 +494,7 @@ public function undo($setting): string {
485494 case 'background ' :
486495 case 'favicon ' :
487496 $ this ->imageManager ->delete ($ setting );
488- $ this ->config -> deleteAppValue ('theming ' , $ setting . 'Mime ' );
497+ $ this ->appConfig -> deleteKey ('theming ' , $ setting . 'Mime ' );
489498 break ;
490499 }
491500
@@ -523,6 +532,6 @@ public function getDefaultTextColorPrimary() {
523532 * Has the admin disabled user customization
524533 */
525534 public function isUserThemingDisabled (): bool {
526- return $ this ->appConfig ->getValueBool (Application::APP_ID , ' disable-user-theming ' );
535+ return $ this ->appConfig ->getValueBool (Application::APP_ID , ConfigLexicon:: USER_THEMING_DISABLED , false );
527536 }
528537}
0 commit comments