From 1752fed15ce5d8d2859f9b50fda1f45b16f2e98d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Mittelst=C3=A4dt?= Date: Wed, 2 Apr 2025 11:32:16 +0200 Subject: [PATCH] Do not override custom theme values with app values. --- apps/theming/lib/ThemingDefaults.php | 48 ++++++++++++++++++++++------ lib/private/legacy/OC_Defaults.php | 16 +++++++++- 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 42c96557ba76e..735a762cd2057 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -67,27 +67,45 @@ public function __construct( $this->docBaseUrl = parent::getDocBaseUrl(); } - public function getName() { + public function getName(): string { + if (parent::themeExist('getName')) { + return $this->name; + } return strip_tags($this->config->getAppValue('theming', 'name', $this->name)); } - public function getHTMLName() { + public function getHTMLName(): string { + if (parent::themeExist('getHTMLName')) { + return parent::getHTMLName(); + } return $this->config->getAppValue('theming', 'name', $this->name); } - public function getTitle() { + public function getTitle() : string { + if (parent::themeExist('getTitle')) { + return strip_tags($this->title); + } return strip_tags($this->config->getAppValue('theming', 'name', $this->title)); } - public function getEntity() { + public function getEntity() : string { + if (parent::themeExist('getEntity')) { + return $this->entity; + } return strip_tags($this->config->getAppValue('theming', 'name', $this->entity)); } - public function getProductName() { + public function getProductName() : string { + if (parent::themeExist("getProductName")) { + return strip_tags($this->productName); + } return strip_tags($this->config->getAppValue('theming', 'productName', $this->productName)); } - public function getBaseUrl() { + public function getBaseUrl() : string { + if (parent::themeExist('getBaseUrl')) { + return $this->url; + } return $this->config->getAppValue('theming', 'url', $this->url); } @@ -96,19 +114,31 @@ public function getBaseUrl() { * @psalm-suppress InvalidReturnStatement * @psalm-suppress InvalidReturnType */ - public function getSlogan(?string $lang = null) { + public function getSlogan(?string $lang = null) : string { + if (parent::themeExist('getSlogan')) { + return \OCP\Util::sanitizeHTML(parent::getSlogan($lang)); + } return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', parent::getSlogan($lang))); } - public function getImprintUrl() { + public function getImprintUrl() : string { + if (parent::themeExist('getImprintUrl')) { + return parent::getImprintUrl(); + } return (string)$this->config->getAppValue('theming', 'imprintUrl', ''); } - public function getPrivacyUrl() { + public function getPrivacyUrl() : string { + if (parent::themeExist('getPrivacyUrl')) { + return parent::getPrivacyUrl(); + } return (string)$this->config->getAppValue('theming', 'privacyUrl', ''); } public function getDocBaseUrl() { + if (parent::themeExist('getDocBaseUrl')) { + return $this->docBaseUrl; + } return (string)$this->config->getAppValue('theming', 'docBaseUrl', $this->docBaseUrl); } diff --git a/lib/private/legacy/OC_Defaults.php b/lib/private/legacy/OC_Defaults.php index f7015a1863a42..ca282c48143ca 100644 --- a/lib/private/legacy/OC_Defaults.php +++ b/lib/private/legacy/OC_Defaults.php @@ -65,7 +65,7 @@ public function __construct() { /** * @param string $method */ - private function themeExist($method) { + protected function themeExist($method) { if (isset($this->theme) && method_exists($this->theme, $method)) { return true; } @@ -332,4 +332,18 @@ public function getProductName() { } return $this->defaultProductName; } + + public function getImprintUrl() : string { + if ($this->themeExist('getImprintUrl')) { + return $this->theme->getImprintUrl(); + } + return ''; + } + + public function getPrivacyUrl() : string { + if ($this->themeExist('getPrivacyUrl')) { + return $this->theme->getPrivacyUrl(); + } + return ''; + } }