Skip to content

Commit 264d435

Browse files
committed
IONOS(Theming): Add support for default legal and privacy URLs
Expose imprintUrlDefault and privacyUrlDefault in admin settings. Use default values if custom URLs are not set. Update tests and UI.
1 parent 32b4d1a commit 264d435

4 files changed

Lines changed: 21 additions & 5 deletions

File tree

apps/theming/lib/Settings/AdminLegalUrls.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ public function __construct(
2525
public function getForm(): TemplateResponse {
2626
$this->initialState->provideInitialState('adminLegalUrlsParameters', [
2727
'legalNoticeUrl' => $this->config->getAppValue('theming', 'imprintUrl', ''),
28+
'legalNoticeUrlDefault' => $this->config->getAppValue('theming', 'imprintUrlDefault', ''),
2829
'privacyPolicyUrl' => $this->config->getAppValue('theming', 'privacyUrl', ''),
30+
'privacyPolicyUrlDefault' => $this->config->getAppValue('theming', 'privacyUrlDefault', ''),
2931
]);
3032

3133
Util::addScript($this->appName, 'admin-legal-urls');

apps/theming/lib/ThemingDefaults.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,19 @@ public function getSlogan(?string $lang = null) {
101101
}
102102

103103
public function getImprintUrl() {
104-
return (string)$this->config->getAppValue('theming', 'imprintUrl', '');
104+
$userValue = (string)$this->config->getAppValue('theming', 'imprintUrl', '');
105+
if ($userValue !== '') {
106+
return $userValue;
107+
}
108+
return (string)$this->config->getAppValue('theming', 'imprintUrlDefault', '');
105109
}
106110

107111
public function getPrivacyUrl() {
108-
return (string)$this->config->getAppValue('theming', 'privacyUrl', '');
112+
$userValue = (string)$this->config->getAppValue('theming', 'privacyUrl', '');
113+
if ($userValue !== '') {
114+
return $userValue;
115+
}
116+
return (string)$this->config->getAppValue('theming', 'privacyUrlDefault', '');
109117
}
110118

111119
public function getDocBaseUrl() {

apps/theming/src/AdminLegalUrls.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ import TextField from './components/admin/TextField.vue'
2929
3030
const {
3131
legalNoticeUrl,
32+
legalNoticeUrlDefault,
3233
privacyPolicyUrl,
34+
privacyPolicyUrlDefault,
3335
} = loadState('theming', 'adminLegalUrlsParameters')
3436
3537
const legalFields = [
3638
{
3739
name: 'imprintUrl',
3840
value: legalNoticeUrl,
39-
defaultValue: '',
41+
defaultValue: legalNoticeUrlDefault,
4042
type: 'url',
4143
displayName: t('theming', 'Legal notice link'),
4244
placeholder: 'https://…',
@@ -45,7 +47,7 @@ const legalFields = [
4547
{
4648
name: 'privacyUrl',
4749
value: privacyPolicyUrl,
48-
defaultValue: '',
50+
defaultValue: privacyPolicyUrlDefault,
4951
type: 'url',
5052
displayName: t('theming', 'Privacy policy link'),
5153
placeholder: 'https://…',

apps/theming/tests/Settings/AdminLegalUrlsTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,23 @@ protected function setUp(): void {
3535

3636
public function testGetForm(): void {
3737
$this->config
38-
->expects($this->exactly(2))
38+
->expects($this->exactly(4))
3939
->method('getAppValue')
4040
->willReturnMap([
4141
['theming', 'imprintUrl', '', 'https://example.com/legal'],
42+
['theming', 'imprintUrlDefault', '', 'https://default.example.com/legal'],
4243
['theming', 'privacyUrl', '', 'https://example.com/privacy'],
44+
['theming', 'privacyUrlDefault', '', 'https://default.example.com/privacy'],
4345
]);
4446

4547
$this->initialState
4648
->expects($this->once())
4749
->method('provideInitialState')
4850
->with('adminLegalUrlsParameters', [
4951
'legalNoticeUrl' => 'https://example.com/legal',
52+
'legalNoticeUrlDefault' => 'https://default.example.com/legal',
5053
'privacyPolicyUrl' => 'https://example.com/privacy',
54+
'privacyPolicyUrlDefault' => 'https://default.example.com/privacy',
5155
]);
5256

5357
$expected = new TemplateResponse('theming', 'settings-admin-legal');

0 commit comments

Comments
 (0)