1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
5
|
|
|
* |
6
|
|
|
* @package MyArtJaub\Webtrees |
7
|
|
|
* @subpackage GeoDispersion |
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\GeoDispersion; |
16
|
|
|
|
17
|
|
|
use Aura\Router\Map; |
18
|
|
|
use Fisharebest\Webtrees\I18N; |
19
|
|
|
use Fisharebest\Webtrees\Individual; |
20
|
|
|
use Fisharebest\Webtrees\Http\Middleware\AuthManager; |
21
|
|
|
use Fisharebest\Webtrees\Module\AbstractModule; |
22
|
|
|
use Fisharebest\Webtrees\Module\ModuleChartInterface; |
23
|
|
|
use Fisharebest\Webtrees\Module\ModuleChartTrait; |
24
|
|
|
use Fisharebest\Webtrees\Module\ModuleConfigInterface; |
25
|
|
|
use Fisharebest\Webtrees\Module\ModuleConfigTrait; |
26
|
|
|
use Fisharebest\Webtrees\Module\ModuleGlobalInterface; |
27
|
|
|
use Fisharebest\Webtrees\Module\ModuleGlobalTrait; |
28
|
|
|
use Fisharebest\Webtrees\Services\MigrationService; |
29
|
|
|
use MyArtJaub\Webtrees\Contracts\GeoDispersion\ModuleGeoAnalysisProviderInterface; |
30
|
|
|
use MyArtJaub\Webtrees\Contracts\GeoDispersion\ModulePlaceMapperProviderInterface; |
31
|
|
|
use MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface; |
32
|
|
|
use MyArtJaub\Webtrees\Module\ModuleMyArtJaubTrait; |
33
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\GeoAnalyses\AllEventsByCenturyGeoAnalysis; |
34
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\GeoAnalyses\AllEventsByTypeGeoAnalysis; |
35
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\AdminConfigPage; |
36
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\GeoAnalysisViewAddAction; |
37
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\GeoAnalysisViewAddPage; |
38
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\GeoAnalysisViewDeleteAction; |
39
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\GeoAnalysisViewEditAction; |
40
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\GeoAnalysisViewEditPage; |
41
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\GeoAnalysisViewListData; |
42
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\GeoAnalysisViewPage; |
43
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\GeoAnalysisViewStatusAction; |
44
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\GeoAnalysisViewTabs; |
45
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\GeoAnalysisViewsList; |
46
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\MapAdapterAddAction; |
47
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\MapAdapterAddPage; |
48
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\MapAdapterDeleteAction; |
49
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\MapAdapterDeleteInvalidAction; |
50
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\MapAdapterEditAction; |
51
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\MapAdapterEditPage; |
52
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\MapAdapterMapperConfig; |
53
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Http\RequestHandlers\MapFeaturePropertyData; |
54
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\PlaceMappers\CoordinatesPlaceMapper; |
55
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\PlaceMappers\SimplePlaceMapper; |
56
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\PlaceMappers\SimpleTopFilteredPlaceMapper; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Geographical Dispersion Module. |
60
|
|
|
*/ |
61
|
|
|
class GeoDispersionModule extends AbstractModule implements |
62
|
|
|
ModuleMyArtJaubInterface, |
63
|
|
|
ModuleChartInterface, |
64
|
|
|
ModuleConfigInterface, |
65
|
|
|
ModuleGlobalInterface, |
66
|
|
|
ModuleGeoAnalysisProviderInterface, |
67
|
|
|
ModulePlaceMapperProviderInterface |
68
|
|
|
{ |
69
|
|
|
use ModuleMyArtJaubTrait { |
70
|
|
|
boot as traitBoot; |
71
|
|
|
} |
72
|
|
|
use ModuleChartTrait; |
73
|
|
|
use ModuleConfigTrait; |
74
|
|
|
use ModuleGlobalTrait; |
75
|
|
|
|
76
|
|
|
// How to update the database schema for this module |
77
|
|
|
private const SCHEMA_TARGET_VERSION = 3; |
78
|
|
|
private const SCHEMA_SETTING_NAME = 'MAJ_GEODISP_SCHEMA_VERSION'; |
79
|
|
|
private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* {@inheritDoc} |
83
|
|
|
* @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
84
|
|
|
*/ |
85
|
|
|
public function title(): string |
86
|
|
|
{ |
87
|
|
|
return /* I18N: Name of the “GeoDispersion” module */ I18N::translate('Geographical dispersion'); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* {@inheritDoc} |
92
|
|
|
* @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
93
|
|
|
*/ |
94
|
|
|
public function description(): string |
95
|
|
|
{ |
96
|
|
|
//phpcs:ignore Generic.Files.LineLength.TooLong |
97
|
|
|
return /* I18N: Description of the “GeoDispersion” module */ I18N::translate('Perform and display geographical dispersion analyses.'); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* {@inheritDoc} |
102
|
|
|
* @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
103
|
|
|
*/ |
104
|
|
|
public function boot(): void |
105
|
|
|
{ |
106
|
|
|
$this->traitBoot(); |
107
|
|
|
app(MigrationService::class)->updateSchema( |
108
|
|
|
self::SCHEMA_MIGRATION_PREFIX, |
109
|
|
|
self::SCHEMA_SETTING_NAME, |
110
|
|
|
self::SCHEMA_TARGET_VERSION |
111
|
|
|
); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* {@inheritDoc} |
116
|
|
|
* @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
117
|
|
|
*/ |
118
|
|
|
public function customModuleVersion(): string |
119
|
|
|
{ |
120
|
|
|
return '2.1.3-v.2'; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* {@inheritDoc} |
125
|
|
|
* @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
126
|
|
|
*/ |
127
|
|
|
public function loadRoutes(Map $router): void |
128
|
|
|
{ |
129
|
|
|
$router->attach('', '', static function (Map $router): void { |
130
|
|
|
|
131
|
|
|
$router->attach('', '/module-maj/geodispersion', static function (Map $router): void { |
132
|
|
|
$router->attach('', '/admin', static function (Map $router): void { |
133
|
|
|
$router->get(AdminConfigPage::class, '/config{/tree}', AdminConfigPage::class); |
134
|
|
|
|
135
|
|
|
$router->attach('', '/analysis-views/{tree}', static function (Map $router): void { |
136
|
|
|
$router->tokens(['view_id' => '\d+', 'enable' => '[01]']); |
137
|
|
|
$router->extras([ |
138
|
|
|
'middleware' => [ |
139
|
|
|
AuthManager::class, |
140
|
|
|
], |
141
|
|
|
]); |
142
|
|
|
$router->get(GeoAnalysisViewListData::class, '', GeoAnalysisViewListData::class); |
143
|
|
|
|
144
|
|
|
$router->get(GeoAnalysisViewAddPage::class, '/add', GeoAnalysisViewAddPage::class); |
145
|
|
|
$router->post(GeoAnalysisViewAddAction::class, '/add', GeoAnalysisViewAddAction::class); |
146
|
|
|
$router->get(GeoAnalysisViewEditPage::class, '/{view_id}', GeoAnalysisViewEditPage::class); |
147
|
|
|
$router->post(GeoAnalysisViewEditAction::class, '/{view_id}', GeoAnalysisViewEditAction::class); |
148
|
|
|
//phpcs:disable Generic.Files.LineLength.TooLong |
149
|
|
|
$router->get(GeoAnalysisViewStatusAction::class, '/{view_id}/status/{enable}', GeoAnalysisViewStatusAction::class); |
150
|
|
|
$router->get(GeoAnalysisViewDeleteAction::class, '/{view_id}/delete', GeoAnalysisViewDeleteAction::class); |
151
|
|
|
//phpcs:enable |
152
|
|
|
}); |
153
|
|
|
|
154
|
|
|
$router->attach('', '/map-adapters/{tree}', static function (Map $router): void { |
155
|
|
|
$router->tokens(['adapter_id' => '\d+', 'view_id' => '\d+']); |
156
|
|
|
$router->extras([ |
157
|
|
|
'middleware' => [ |
158
|
|
|
AuthManager::class, |
159
|
|
|
], |
160
|
|
|
]); |
161
|
|
|
|
162
|
|
|
$router->get(MapAdapterAddPage::class, '/add/{view_id}', MapAdapterAddPage::class); |
163
|
|
|
$router->post(MapAdapterAddAction::class, '/add/{view_id}', MapAdapterAddAction::class); |
164
|
|
|
$router->get(MapAdapterEditPage::class, '/{adapter_id}', MapAdapterEditPage::class); |
165
|
|
|
$router->post(MapAdapterEditAction::class, '/{adapter_id}', MapAdapterEditAction::class); |
166
|
|
|
//phpcs:disable Generic.Files.LineLength.TooLong |
167
|
|
|
$router->get(MapAdapterDeleteAction::class, '/{adapter_id}/delete', MapAdapterDeleteAction::class); |
168
|
|
|
$router->get(MapAdapterDeleteInvalidAction::class, '/delete-invalid/{view_id}', MapAdapterDeleteInvalidAction::class); |
169
|
|
|
$router->get(MapAdapterMapperConfig::class, '/mapper/config{/adapter_id}', MapAdapterMapperConfig::class); |
170
|
|
|
//phpcs:enable |
171
|
|
|
}); |
172
|
|
|
|
173
|
|
|
//phpcs:ignore Generic.Files.LineLength.TooLong |
174
|
|
|
$router->get(MapFeaturePropertyData::class, '/map/feature-properties{/map_id}', MapFeaturePropertyData::class); |
175
|
|
|
}); |
176
|
|
|
|
177
|
|
|
$router->get(GeoAnalysisViewsList::class, '/list/{tree}', GeoAnalysisViewsList::class); |
178
|
|
|
|
179
|
|
|
$router->attach('', '/analysisview/{tree}/{view_id}', static function (Map $router): void { |
180
|
|
|
$router->tokens(['view_id' => '\d+']); |
181
|
|
|
$router->get(GeoAnalysisViewPage::class, '', GeoAnalysisViewPage::class); |
182
|
|
|
$router->get(GeoAnalysisViewTabs::class, '/tabs', GeoAnalysisViewTabs::class); |
183
|
|
|
}); |
184
|
|
|
}); |
185
|
|
|
}); |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
public function getConfigLink(): string |
189
|
|
|
{ |
190
|
|
|
return route(AdminConfigPage::class); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* {@inheritDoc} |
195
|
|
|
* @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartUrl() |
196
|
|
|
* |
197
|
|
|
* @param array<bool|int|string|array<mixed>|null> $parameters |
198
|
|
|
*/ |
199
|
|
|
public function chartUrl(Individual $individual, array $parameters = []): string |
200
|
|
|
{ |
201
|
|
|
return route(GeoAnalysisViewsList::class, ['tree' => $individual->tree()->name()] + $parameters); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* {@inheritDoc} |
206
|
|
|
* @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartMenuClass() |
207
|
|
|
*/ |
208
|
|
|
public function chartMenuClass(): string |
209
|
|
|
{ |
210
|
|
|
return 'menu-maj-geodispersion'; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* {@inheritDoc} |
215
|
|
|
* @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
216
|
|
|
*/ |
217
|
|
|
public function headContent(): string |
218
|
|
|
{ |
219
|
|
|
return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* {@inheritDoc} |
224
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModulePlaceMapperProviderInterface::listPlaceMappers() |
225
|
|
|
*/ |
226
|
|
|
public function listPlaceMappers(): array |
227
|
|
|
{ |
228
|
|
|
return [ |
229
|
|
|
CoordinatesPlaceMapper::class, |
230
|
|
|
SimplePlaceMapper::class, |
231
|
|
|
SimpleTopFilteredPlaceMapper::class |
232
|
|
|
]; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* {@inheritDoc} |
237
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModuleGeoAnalysisProviderInterface::listGeoAnalyses() |
238
|
|
|
*/ |
239
|
|
|
public function listGeoAnalyses(): array |
240
|
|
|
{ |
241
|
|
|
return [ |
242
|
|
|
AllEventsByCenturyGeoAnalysis::class, |
243
|
|
|
AllEventsByTypeGeoAnalysis::class |
244
|
|
|
]; |
245
|
|
|
} |
246
|
|
|
} |
247
|
|
|
|