|
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-2021, 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\Http\RequestHandlers; |
|
16
|
|
|
|
|
17
|
|
|
use Fisharebest\Webtrees\I18N; |
|
18
|
|
|
use Fisharebest\Webtrees\Registry; |
|
19
|
|
|
use Fisharebest\Webtrees\Tree; |
|
20
|
|
|
use Fisharebest\Webtrees\Exceptions\HttpNotFoundException; |
|
21
|
|
|
use Fisharebest\Webtrees\Http\ViewResponseTrait; |
|
22
|
|
|
use Fisharebest\Webtrees\Services\ModuleService; |
|
23
|
|
|
use MyArtJaub\Webtrees\Module\Certificates\CertificatesModule; |
|
24
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
25
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
26
|
|
|
use Psr\Http\Server\RequestHandlerInterface; |
|
27
|
|
|
use Fisharebest\Webtrees\Services\TreeService; |
|
28
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\GeoDispersionModule; |
|
29
|
|
|
use Fisharebest\Webtrees\Auth; |
|
30
|
|
|
use Fisharebest\Webtrees\Contracts\UserInterface; |
|
31
|
|
|
use Fisharebest\Webtrees\Exceptions\HttpAccessDeniedException; |
|
32
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Services\GeoAnalysisViewDataService; |
|
33
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Services\GeoAnalysisDataService; |
|
34
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Services\GeoAnalysisService; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Request handler for displaying configuration of a geographical analysis view. |
|
38
|
|
|
*/ |
|
39
|
|
|
class GeoAnalysisViewEditPage implements RequestHandlerInterface |
|
40
|
|
|
{ |
|
41
|
|
|
use ViewResponseTrait; |
|
42
|
|
|
|
|
43
|
|
|
private ?GeoDispersionModule $module; |
|
44
|
|
|
private GeoAnalysisViewDataService $geoview_data_service; |
|
45
|
|
|
private GeoAnalysisService $geoanalysis_service; |
|
46
|
|
|
private GeoAnalysisDataService $geoanalysis_data_service; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Constructor for GeoAnalysisViewEditPage Request Handler |
|
50
|
|
|
* |
|
51
|
|
|
* @param ModuleService $module_service |
|
52
|
|
|
* @param GeoAnalysisViewDataService $geoview_data_service |
|
53
|
|
|
* @param GeoAnalysisService $geoanalysis_service |
|
54
|
|
|
* @param GeoAnalysisDataService $geoanalysis_data_service |
|
55
|
|
|
*/ |
|
56
|
|
|
public function __construct( |
|
57
|
|
|
ModuleService $module_service, |
|
58
|
|
|
GeoAnalysisViewDataService $geoview_data_service, |
|
59
|
|
|
GeoAnalysisService $geoanalysis_service, |
|
60
|
|
|
GeoAnalysisDataService $geoanalysis_data_service |
|
61
|
|
|
) { |
|
62
|
|
|
$this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
63
|
|
|
$this->geoview_data_service = $geoview_data_service; |
|
64
|
|
|
$this->geoanalysis_service = $geoanalysis_service; |
|
65
|
|
|
$this->geoanalysis_data_service = $geoanalysis_data_service; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* {@inheritDoc} |
|
70
|
|
|
* @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
71
|
|
|
*/ |
|
72
|
|
|
public function handle(ServerRequestInterface $request): ResponseInterface |
|
73
|
|
|
{ |
|
74
|
|
|
$this->layout = 'layouts/administration'; |
|
75
|
|
|
|
|
76
|
|
|
if ($this->module === null) { |
|
77
|
|
|
throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
78
|
|
|
} |
|
79
|
|
|
$tree = $request->getAttribute('tree'); |
|
80
|
|
|
assert($tree instanceof Tree); |
|
81
|
|
|
|
|
82
|
|
|
$view_id = (int) $request->getAttribute('view_id'); |
|
83
|
|
|
$view = $this->geoview_data_service->find($tree, $view_id, true); |
|
84
|
|
|
|
|
85
|
|
|
if ($view === null) { |
|
86
|
|
|
throw new HttpNotFoundException( |
|
87
|
|
|
I18N::translate('The geographical dispersion analysis view could not be found.') |
|
88
|
|
|
); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
return $this->viewResponse($this->module->name() . '::admin/view-edit', [ |
|
92
|
|
|
'module' => $this->module, |
|
93
|
|
|
'title' => I18N::translate('Edit the geographical dispersion analysis view - %s', $view->type()), |
|
94
|
|
|
'tree' => $tree, |
|
95
|
|
|
'view' => $view, |
|
96
|
|
|
'geoanalysis_list' => $this->geoanalysis_service->all(), |
|
97
|
|
|
'place_example' => $this->geoanalysis_data_service->placeHierarchyExample($tree), |
|
98
|
|
|
'global_settings' => $view->globalSettingsContent($this->module) |
|
99
|
|
|
]); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|