|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
|
5
|
|
|
* |
|
6
|
|
|
* @package MyArtJaub\Webtrees |
|
7
|
|
|
* @subpackage MiscExtensions |
|
8
|
|
|
* @author Jonathan Jaubart <[email protected]> |
|
9
|
|
|
* @copyright Copyright (c) 2009-2022, Jonathan Jaubart |
|
10
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
declare(strict_types=1); |
|
14
|
|
|
|
|
15
|
|
|
namespace MyArtJaub\Webtrees\Module\MiscExtensions; |
|
16
|
|
|
|
|
17
|
|
|
use Aura\Router\Map; |
|
18
|
|
|
use Fisharebest\Webtrees\I18N; |
|
19
|
|
|
use Fisharebest\Webtrees\Registry; |
|
20
|
|
|
use Fisharebest\Webtrees\View; |
|
21
|
|
|
use Fisharebest\Webtrees\Module\AbstractModule; |
|
22
|
|
|
use Fisharebest\Webtrees\Module\ModuleConfigInterface; |
|
23
|
|
|
use Fisharebest\Webtrees\Module\ModuleConfigTrait; |
|
24
|
|
|
use MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface; |
|
25
|
|
|
use MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface; |
|
26
|
|
|
use MyArtJaub\Webtrees\Module\ModuleMyArtJaubTrait; |
|
27
|
|
|
use MyArtJaub\Webtrees\Module\MiscExtensions\Factories\LegacyXrefFactory; |
|
28
|
|
|
use MyArtJaub\Webtrees\Module\MiscExtensions\Hooks\TitlesCardHook; |
|
29
|
|
|
use MyArtJaub\Webtrees\Module\MiscExtensions\Http\RequestHandlers\AdminConfigAction; |
|
30
|
|
|
use MyArtJaub\Webtrees\Module\MiscExtensions\Http\RequestHandlers\AdminConfigPage; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* MyArtJaub Miscellaneous Extensions Module |
|
34
|
|
|
* Provide miscellaneous improvements to webtrees. |
|
35
|
|
|
*/ |
|
36
|
|
|
class MiscExtensionsModule extends AbstractModule implements |
|
37
|
|
|
ModuleMyArtJaubInterface, |
|
38
|
|
|
ModuleConfigInterface, |
|
39
|
|
|
ModuleHookSubscriberInterface |
|
40
|
|
|
{ |
|
41
|
|
|
use ModuleMyArtJaubTrait { |
|
42
|
|
|
boot as traitBoot; |
|
43
|
|
|
} |
|
44
|
|
|
use ModuleConfigTrait; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* {@inheritDoc} |
|
48
|
|
|
* @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
49
|
|
|
*/ |
|
50
|
|
|
public function title(): string |
|
51
|
|
|
{ |
|
52
|
|
|
return /* I18N: Name of the “MiscExtensions” module */ I18N::translate('Miscellaneous extensions'); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* {@inheritDoc} |
|
57
|
|
|
* @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
58
|
|
|
*/ |
|
59
|
|
|
public function description(): string |
|
60
|
|
|
{ |
|
61
|
|
|
//phpcs:ignore Generic.Files.LineLength.TooLong |
|
62
|
|
|
return /* I18N: Description of the “MiscExtensions” module */ I18N::translate('Miscellaneous extensions for webtrees.'); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* {@inheritDoc} |
|
67
|
|
|
* @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
68
|
|
|
*/ |
|
69
|
|
|
public function boot(): void |
|
70
|
|
|
{ |
|
71
|
|
|
$this->traitBoot(); |
|
72
|
|
|
View::registerCustomView('::modules/privacy-policy/page', $this->name() . '::privacy-policy'); |
|
73
|
|
|
|
|
74
|
|
|
if ((int) $this->getPreference('MAJ_USE_LEGACY_XREF') === 1) { |
|
75
|
|
|
Registry::xrefFactory(new LegacyXrefFactory()); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* {@inheritDoc} |
|
81
|
|
|
* @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
82
|
|
|
*/ |
|
83
|
|
|
public function loadRoutes(Map $router): void |
|
84
|
|
|
{ |
|
85
|
|
|
$router->attach('', '', static function (Map $router): void { |
|
86
|
|
|
|
|
87
|
|
|
$router->attach('', '/module-maj/misc', static function (Map $router): void { |
|
88
|
|
|
|
|
89
|
|
|
$router->attach('', '/config/admin', static function (Map $router): void { |
|
90
|
|
|
|
|
91
|
|
|
$router->get(AdminConfigPage::class, '', AdminConfigPage::class); |
|
92
|
|
|
$router->post(AdminConfigAction::class, '', AdminConfigAction::class); |
|
93
|
|
|
}); |
|
94
|
|
|
}); |
|
95
|
|
|
}); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* {@inheritDoc} |
|
100
|
|
|
* @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
101
|
|
|
*/ |
|
102
|
|
|
public function customModuleVersion(): string |
|
103
|
|
|
{ |
|
104
|
|
|
return '2.1.3-v.2'; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* {@inheritDoc} |
|
109
|
|
|
* @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
110
|
|
|
*/ |
|
111
|
|
|
public function getConfigLink(): string |
|
112
|
|
|
{ |
|
113
|
|
|
return route(AdminConfigPage::class); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* {@inheritDoc} |
|
118
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks() |
|
119
|
|
|
*/ |
|
120
|
|
|
public function listSubscribedHooks(): array |
|
121
|
|
|
{ |
|
122
|
|
|
return [ |
|
123
|
|
|
app()->makeWith(TitlesCardHook::class, [ 'module' => $this ]) |
|
124
|
|
|
]; |
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
|