-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLegalNoticeFooter.php
More file actions
159 lines (140 loc) · 4.02 KB
/
LegalNoticeFooter.php
File metadata and controls
159 lines (140 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/**
* Custom footer with the privacy policy for dutch locale environment.
*/
declare(strict_types=1);
namespace LegalNoticeFooterNameSpace;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Module\AbstractModule;
use Fisharebest\Webtrees\Module\ModuleCustomInterface;
use Fisharebest\Webtrees\Module\ModuleCustomTrait;
use Fisharebest\Webtrees\Module\ModuleFooterInterface;
use Fisharebest\Webtrees\Module\ModuleFooterTrait;
use Fisharebest\Webtrees\View;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class LegalNoticeFooter extends AbstractModule implements ModuleCustomInterface, ModuleFooterInterface {
use ModuleCustomTrait;
use ModuleFooterTrait;
/**
* @return string
*/
public function title(): string
{
return I18N::translate('Legal Notice');
}
/**
* {@inheritDoc}
* @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleAuthorName()
*/
public function customModuleAuthorName(): string
{
return 'Lars van Ravenzwaaij';
}
/**
* {@inheritDoc}
* @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
*/
public function customModuleVersion(): string
{
return '1.0.2';
}
/**
* {@inheritDoc}
* @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleLatestVersionUrl()
*/
public function customModuleLatestVersionUrl(): string
{
return 'https://raw.githubusercontent.com/LarsRabe/MyLegalNotice/refs/heads/main/latest-version.txt';
}
/**
* {@inheritDoc}
* @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleSupportUrl()
*/
public function customModuleSupportUrl(): string
{
return 'https://github.com/LarsRabe/LegalNoticeFooter';
}
/**
* Additional translations.
*
* @param string $language
*
* @return array<string>
*/
public function customTranslations(string $language): array
{
switch ($language) {
case 'de':
return [
'Legal Notice' => 'Impressum',
];
case 'nl':
return [
'Legal Notice' => 'Juridische Kennisgeving',
];
default:
return [];
}
}
/**
* Bootstrap the module
*/
public function boot(): void
{
// Register a namespace for our views.
View::registerNamespace($this->name(), $this->resourcesFolder() . 'views/');
}
/**
* Where does this module store its resources
*
* @return string
*/
public function resourcesFolder(): string
{
return __DIR__ . '/resources/';
}
/**
* A footer, to be added at the bottom of every page.
*
* @param ServerRequestInterface $request
*
* @return string
*/
public function getFooter(ServerRequestInterface $request): string
{
$tree = $request->getAttribute('tree');
$url = route('module', [
'module' => $this->name(),
'action' => 'Page',
'tree' => $tree ? $tree->name() : null,
]);
return view($this->name() . '::footer', ['url' => $url]);
}
/**
* Generate the page that will be shown when we click the link in the footer.
*
* @param ServerRequestInterface $request
*
* @return ResponseInterface
*/
public function getPageAction(ServerRequestInterface $request): ResponseInterface
{
$page = '';
switch (I18N::languageTag()) {
case 'de':
$page = '::page-de';
break;
case 'nl':
$page = '::page-nl';
break;
default:
$page = '::page';
break;
}
return $this->viewResponse($this->name() . $page, [
'title' => $this->title(),
'tree' => $request->getAttribute('tree'),
]);
}
};