@@ -37,95 +37,95 @@ |
||
37 | 37 | */ |
38 | 38 | class MapAdapterAddAction implements RequestHandlerInterface |
39 | 39 | { |
40 | - private ?GeoDispersionModule $module; |
|
41 | - private GeoAnalysisViewDataService $geoview_data_service; |
|
42 | - private MapAdapterDataService $mapadapter_data_service; |
|
43 | - private MapDefinitionsService $map_definition_service; |
|
40 | + private ?GeoDispersionModule $module; |
|
41 | + private GeoAnalysisViewDataService $geoview_data_service; |
|
42 | + private MapAdapterDataService $mapadapter_data_service; |
|
43 | + private MapDefinitionsService $map_definition_service; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Constructor for MapAdapterAddAction Request Handler |
|
47 | - * |
|
48 | - * @param ModuleService $module_service |
|
49 | - * @param GeoAnalysisViewDataService $geoview_data_service |
|
50 | - * @param MapAdapterDataService $mapadapter_data_service |
|
51 | - * @param MapDefinitionsService $map_definition_service |
|
52 | - */ |
|
53 | - public function __construct( |
|
54 | - ModuleService $module_service, |
|
55 | - GeoAnalysisViewDataService $geoview_data_service, |
|
56 | - MapAdapterDataService $mapadapter_data_service, |
|
57 | - MapDefinitionsService $map_definition_service |
|
58 | - ) { |
|
59 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
60 | - $this->geoview_data_service = $geoview_data_service; |
|
61 | - $this->mapadapter_data_service = $mapadapter_data_service; |
|
62 | - $this->map_definition_service = $map_definition_service; |
|
63 | - } |
|
45 | + /** |
|
46 | + * Constructor for MapAdapterAddAction Request Handler |
|
47 | + * |
|
48 | + * @param ModuleService $module_service |
|
49 | + * @param GeoAnalysisViewDataService $geoview_data_service |
|
50 | + * @param MapAdapterDataService $mapadapter_data_service |
|
51 | + * @param MapDefinitionsService $map_definition_service |
|
52 | + */ |
|
53 | + public function __construct( |
|
54 | + ModuleService $module_service, |
|
55 | + GeoAnalysisViewDataService $geoview_data_service, |
|
56 | + MapAdapterDataService $mapadapter_data_service, |
|
57 | + MapDefinitionsService $map_definition_service |
|
58 | + ) { |
|
59 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
60 | + $this->geoview_data_service = $geoview_data_service; |
|
61 | + $this->mapadapter_data_service = $mapadapter_data_service; |
|
62 | + $this->map_definition_service = $map_definition_service; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * {@inheritDoc} |
|
67 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
68 | - */ |
|
69 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
70 | - { |
|
71 | - $tree = Validator::attributes($request)->tree(); |
|
65 | + /** |
|
66 | + * {@inheritDoc} |
|
67 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
68 | + */ |
|
69 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
70 | + { |
|
71 | + $tree = Validator::attributes($request)->tree(); |
|
72 | 72 | |
73 | - if ($this->module === null) { |
|
74 | - FlashMessages::addMessage( |
|
75 | - I18N::translate('The attached module could not be found.'), |
|
76 | - 'danger' |
|
77 | - ); |
|
78 | - return redirect(route(AdminConfigPage::class, ['tree' => $tree->name()])); |
|
79 | - } |
|
73 | + if ($this->module === null) { |
|
74 | + FlashMessages::addMessage( |
|
75 | + I18N::translate('The attached module could not be found.'), |
|
76 | + 'danger' |
|
77 | + ); |
|
78 | + return redirect(route(AdminConfigPage::class, ['tree' => $tree->name()])); |
|
79 | + } |
|
80 | 80 | |
81 | - $view_id = Validator::attributes($request)->integer('view_id', -1); |
|
82 | - $view = $this->geoview_data_service->find($tree, $view_id); |
|
81 | + $view_id = Validator::attributes($request)->integer('view_id', -1); |
|
82 | + $view = $this->geoview_data_service->find($tree, $view_id); |
|
83 | 83 | |
84 | - $map = $this->map_definition_service->find(Validator::parsedBody($request)->string('map_adapter_map', '')); |
|
85 | - $mapping_property = Validator::parsedBody($request)->string('map_adapter_property_selected', ''); |
|
84 | + $map = $this->map_definition_service->find(Validator::parsedBody($request)->string('map_adapter_map', '')); |
|
85 | + $mapping_property = Validator::parsedBody($request)->string('map_adapter_property_selected', ''); |
|
86 | 86 | |
87 | - $mapper = null; |
|
88 | - try { |
|
89 | - $mapper = app(Validator::parsedBody($request)->string('map_adapter_mapper', '')); |
|
90 | - } catch (BindingResolutionException $ex) { |
|
91 | - } |
|
87 | + $mapper = null; |
|
88 | + try { |
|
89 | + $mapper = app(Validator::parsedBody($request)->string('map_adapter_mapper', '')); |
|
90 | + } catch (BindingResolutionException $ex) { |
|
91 | + } |
|
92 | 92 | |
93 | - if ($view === null || $map === null || $mapper === null || !($mapper instanceof PlaceMapperInterface)) { |
|
94 | - FlashMessages::addMessage( |
|
95 | - I18N::translate('The parameters for the map configuration are not valid.'), |
|
96 | - 'danger' |
|
97 | - ); |
|
98 | - return redirect(route(AdminConfigPage::class, ['tree' => $tree->name()])); |
|
99 | - } |
|
93 | + if ($view === null || $map === null || $mapper === null || !($mapper instanceof PlaceMapperInterface)) { |
|
94 | + FlashMessages::addMessage( |
|
95 | + I18N::translate('The parameters for the map configuration are not valid.'), |
|
96 | + 'danger' |
|
97 | + ); |
|
98 | + return redirect(route(AdminConfigPage::class, ['tree' => $tree->name()])); |
|
99 | + } |
|
100 | 100 | |
101 | - $new_adapter_id = $this->mapadapter_data_service->insertGetId( |
|
102 | - new GeoAnalysisMapAdapter( |
|
103 | - 0, |
|
104 | - $view_id, |
|
105 | - $map, |
|
106 | - $mapper, |
|
107 | - new MapViewConfig($mapping_property, $mapper->config()->withConfigUpdate($request)) |
|
108 | - ) |
|
109 | - ); |
|
110 | - if ($new_adapter_id > 0) { |
|
111 | - FlashMessages::addMessage( |
|
112 | - I18N::translate('The map configuration has been successfully added.'), |
|
113 | - 'success' |
|
114 | - ); |
|
115 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
116 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $new_adapter_id . '” has been added.'); |
|
117 | - } else { |
|
118 | - FlashMessages::addMessage( |
|
119 | - I18N::translate('An error occured while adding a new map configuration.'), |
|
120 | - 'danger' |
|
121 | - ); |
|
122 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
123 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter could not be added. See error log.'); |
|
124 | - } |
|
101 | + $new_adapter_id = $this->mapadapter_data_service->insertGetId( |
|
102 | + new GeoAnalysisMapAdapter( |
|
103 | + 0, |
|
104 | + $view_id, |
|
105 | + $map, |
|
106 | + $mapper, |
|
107 | + new MapViewConfig($mapping_property, $mapper->config()->withConfigUpdate($request)) |
|
108 | + ) |
|
109 | + ); |
|
110 | + if ($new_adapter_id > 0) { |
|
111 | + FlashMessages::addMessage( |
|
112 | + I18N::translate('The map configuration has been successfully added.'), |
|
113 | + 'success' |
|
114 | + ); |
|
115 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
116 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $new_adapter_id . '” has been added.'); |
|
117 | + } else { |
|
118 | + FlashMessages::addMessage( |
|
119 | + I18N::translate('An error occured while adding a new map configuration.'), |
|
120 | + 'danger' |
|
121 | + ); |
|
122 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
123 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter could not be added. See error log.'); |
|
124 | + } |
|
125 | 125 | |
126 | - return redirect(route(GeoAnalysisViewEditPage::class, [ |
|
127 | - 'tree' => $tree->name(), |
|
128 | - 'view_id' => $view_id |
|
129 | - ])); |
|
130 | - } |
|
126 | + return redirect(route(GeoAnalysisViewEditPage::class, [ |
|
127 | + 'tree' => $tree->name(), |
|
128 | + 'view_id' => $view_id |
|
129 | + ])); |
|
130 | + } |
|
131 | 131 | } |
@@ -32,42 +32,42 @@ |
||
32 | 32 | */ |
33 | 33 | class GeoAnalysisViewPage implements RequestHandlerInterface |
34 | 34 | { |
35 | - use ViewResponseTrait; |
|
35 | + use ViewResponseTrait; |
|
36 | 36 | |
37 | - private ?GeoDispersionModule $module; |
|
38 | - private GeoAnalysisViewDataService $geoviewdata_service; |
|
37 | + private ?GeoDispersionModule $module; |
|
38 | + private GeoAnalysisViewDataService $geoviewdata_service; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Constructor for GeoAnalysisViewPage Request Handler |
|
42 | - * |
|
43 | - * @param ModuleService $module_service |
|
44 | - */ |
|
45 | - public function __construct( |
|
46 | - ModuleService $module_service, |
|
47 | - GeoAnalysisViewDataService $geoviewdata_service |
|
48 | - ) { |
|
49 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
50 | - $this->geoviewdata_service = $geoviewdata_service; |
|
51 | - } |
|
40 | + /** |
|
41 | + * Constructor for GeoAnalysisViewPage Request Handler |
|
42 | + * |
|
43 | + * @param ModuleService $module_service |
|
44 | + */ |
|
45 | + public function __construct( |
|
46 | + ModuleService $module_service, |
|
47 | + GeoAnalysisViewDataService $geoviewdata_service |
|
48 | + ) { |
|
49 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
50 | + $this->geoviewdata_service = $geoviewdata_service; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * {@inheritDoc} |
|
55 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
56 | - */ |
|
57 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
58 | - { |
|
59 | - if ($this->module === null) { |
|
60 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
61 | - } |
|
53 | + /** |
|
54 | + * {@inheritDoc} |
|
55 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
56 | + */ |
|
57 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
58 | + { |
|
59 | + if ($this->module === null) { |
|
60 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
61 | + } |
|
62 | 62 | |
63 | - $tree = Validator::attributes($request)->tree(); |
|
64 | - $view_id = Validator::attributes($request)->integer('view_id', 0); |
|
63 | + $tree = Validator::attributes($request)->tree(); |
|
64 | + $view_id = Validator::attributes($request)->integer('view_id', 0); |
|
65 | 65 | |
66 | - return $this->viewResponse($this->module->name() . '::geoanalysisview-page', [ |
|
67 | - 'module_name' => $this->module->name(), |
|
68 | - 'title' => I18N::translate('Geographical dispersion'), |
|
69 | - 'tree' => $tree, |
|
70 | - 'view' => $this->geoviewdata_service->find($tree, $view_id) |
|
71 | - ]); |
|
72 | - } |
|
66 | + return $this->viewResponse($this->module->name() . '::geoanalysisview-page', [ |
|
67 | + 'module_name' => $this->module->name(), |
|
68 | + 'title' => I18N::translate('Geographical dispersion'), |
|
69 | + 'tree' => $tree, |
|
70 | + 'view' => $this->geoviewdata_service->find($tree, $view_id) |
|
71 | + ]); |
|
72 | + } |
|
73 | 73 | } |
@@ -33,46 +33,46 @@ |
||
33 | 33 | */ |
34 | 34 | class GeoAnalysisViewsList implements RequestHandlerInterface |
35 | 35 | { |
36 | - use ViewResponseTrait; |
|
36 | + use ViewResponseTrait; |
|
37 | 37 | |
38 | - private ?GeoDispersionModule $module; |
|
39 | - private GeoAnalysisViewDataService $geoviewdata_service; |
|
38 | + private ?GeoDispersionModule $module; |
|
39 | + private GeoAnalysisViewDataService $geoviewdata_service; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Constructor for GeoAnalysisViewsList Request Handler |
|
43 | - * |
|
44 | - * @param ModuleService $module_service |
|
45 | - */ |
|
46 | - public function __construct( |
|
47 | - ModuleService $module_service, |
|
48 | - GeoAnalysisViewDataService $geoviewdata_service |
|
49 | - ) { |
|
50 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
51 | - $this->geoviewdata_service = $geoviewdata_service; |
|
52 | - } |
|
41 | + /** |
|
42 | + * Constructor for GeoAnalysisViewsList Request Handler |
|
43 | + * |
|
44 | + * @param ModuleService $module_service |
|
45 | + */ |
|
46 | + public function __construct( |
|
47 | + ModuleService $module_service, |
|
48 | + GeoAnalysisViewDataService $geoviewdata_service |
|
49 | + ) { |
|
50 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
51 | + $this->geoviewdata_service = $geoviewdata_service; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * {@inheritDoc} |
|
56 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
57 | - */ |
|
58 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
59 | - { |
|
60 | - if ($this->module === null) { |
|
61 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
62 | - } |
|
54 | + /** |
|
55 | + * {@inheritDoc} |
|
56 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
57 | + */ |
|
58 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
59 | + { |
|
60 | + if ($this->module === null) { |
|
61 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
62 | + } |
|
63 | 63 | |
64 | - $tree = Validator::attributes($request)->tree(); |
|
64 | + $tree = Validator::attributes($request)->tree(); |
|
65 | 65 | |
66 | - $views_list = $this->geoviewdata_service |
|
67 | - ->all($tree) |
|
68 | - ->sortBy(fn(AbstractGeoAnalysisView $view) => $view->description()); |
|
66 | + $views_list = $this->geoviewdata_service |
|
67 | + ->all($tree) |
|
68 | + ->sortBy(fn(AbstractGeoAnalysisView $view) => $view->description()); |
|
69 | 69 | |
70 | - return $this->viewResponse($this->module->name() . '::geoanalysisviews-list', [ |
|
71 | - 'module' => $this->module, |
|
72 | - 'title' => I18N::translate('Geographical dispersion'), |
|
73 | - 'tree' => $tree, |
|
74 | - 'views_list' => $views_list, |
|
75 | - 'js_script_url' => $this->module->assetUrl('js/geodispersion.min.js') |
|
76 | - ]); |
|
77 | - } |
|
70 | + return $this->viewResponse($this->module->name() . '::geoanalysisviews-list', [ |
|
71 | + 'module' => $this->module, |
|
72 | + 'title' => I18N::translate('Geographical dispersion'), |
|
73 | + 'tree' => $tree, |
|
74 | + 'views_list' => $views_list, |
|
75 | + 'js_script_url' => $this->module->assetUrl('js/geodispersion.min.js') |
|
76 | + ]); |
|
77 | + } |
|
78 | 78 | } |
@@ -31,58 +31,58 @@ |
||
31 | 31 | */ |
32 | 32 | class GeoAnalysisViewTabs implements RequestHandlerInterface |
33 | 33 | { |
34 | - private ?GeoDispersionModule $module; |
|
35 | - private GeoAnalysisViewDataService $geoviewdata_service; |
|
34 | + private ?GeoDispersionModule $module; |
|
35 | + private GeoAnalysisViewDataService $geoviewdata_service; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor for GeoAnalysisMapsList Request Handler |
|
39 | - * |
|
40 | - * @param ModuleService $module_service |
|
41 | - */ |
|
42 | - public function __construct( |
|
43 | - ModuleService $module_service, |
|
44 | - GeoAnalysisViewDataService $geoviewdata_service |
|
45 | - ) { |
|
46 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
47 | - $this->geoviewdata_service = $geoviewdata_service; |
|
48 | - } |
|
37 | + /** |
|
38 | + * Constructor for GeoAnalysisMapsList Request Handler |
|
39 | + * |
|
40 | + * @param ModuleService $module_service |
|
41 | + */ |
|
42 | + public function __construct( |
|
43 | + ModuleService $module_service, |
|
44 | + GeoAnalysisViewDataService $geoviewdata_service |
|
45 | + ) { |
|
46 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
47 | + $this->geoviewdata_service = $geoviewdata_service; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * {@inheritDoc} |
|
52 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
53 | - */ |
|
54 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
55 | - { |
|
56 | - if ($this->module === null) { |
|
57 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
58 | - } |
|
50 | + /** |
|
51 | + * {@inheritDoc} |
|
52 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
53 | + */ |
|
54 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
55 | + { |
|
56 | + if ($this->module === null) { |
|
57 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
58 | + } |
|
59 | 59 | |
60 | - $tree = Validator::attributes($request)->tree(); |
|
61 | - $view_id = Validator::attributes($request)->integer('view_id', -1); |
|
60 | + $tree = Validator::attributes($request)->tree(); |
|
61 | + $view_id = Validator::attributes($request)->integer('view_id', -1); |
|
62 | 62 | |
63 | - $view = $this->geoviewdata_service->find($tree, $view_id); |
|
63 | + $view = $this->geoviewdata_service->find($tree, $view_id); |
|
64 | 64 | |
65 | - if ($view === null) { |
|
66 | - throw new HttpNotFoundException(I18N::translate('The requested dispersion analysis does not exist.')); |
|
67 | - } |
|
65 | + if ($view === null) { |
|
66 | + throw new HttpNotFoundException(I18N::translate('The requested dispersion analysis does not exist.')); |
|
67 | + } |
|
68 | 68 | |
69 | - $results = $view->analysis()->results($tree, $view->placesDepth()); |
|
69 | + $results = $view->analysis()->results($tree, $view->placesDepth()); |
|
70 | 70 | |
71 | - $params = [ |
|
72 | - 'module_name' => $this->module->name(), |
|
73 | - 'tree' => $tree, |
|
74 | - 'view' => $view, |
|
75 | - 'items_descr' => $view->analysis()->itemsDescription() |
|
76 | - ]; |
|
77 | - $response = [ |
|
78 | - 'global' => view('layouts/ajax', [ |
|
79 | - 'content' => $view->globalTabContent($this->module, $results->global(), $params) |
|
80 | - ]), |
|
81 | - 'detailed' => view('layouts/ajax', [ |
|
82 | - 'content' => $view->detailedTabContent($this->module, $results->sortedDetailed(), $params) |
|
83 | - ]) |
|
84 | - ]; |
|
71 | + $params = [ |
|
72 | + 'module_name' => $this->module->name(), |
|
73 | + 'tree' => $tree, |
|
74 | + 'view' => $view, |
|
75 | + 'items_descr' => $view->analysis()->itemsDescription() |
|
76 | + ]; |
|
77 | + $response = [ |
|
78 | + 'global' => view('layouts/ajax', [ |
|
79 | + 'content' => $view->globalTabContent($this->module, $results->global(), $params) |
|
80 | + ]), |
|
81 | + 'detailed' => view('layouts/ajax', [ |
|
82 | + 'content' => $view->detailedTabContent($this->module, $results->sortedDetailed(), $params) |
|
83 | + ]) |
|
84 | + ]; |
|
85 | 85 | |
86 | - return response($response); |
|
87 | - } |
|
86 | + return response($response); |
|
87 | + } |
|
88 | 88 | } |
@@ -32,67 +32,67 @@ |
||
32 | 32 | */ |
33 | 33 | class GeoAnalysisViewStatusAction implements RequestHandlerInterface |
34 | 34 | { |
35 | - private ?GeoDispersionModule $module; |
|
36 | - private GeoAnalysisViewDataService $geoview_data_service; |
|
35 | + private ?GeoDispersionModule $module; |
|
36 | + private GeoAnalysisViewDataService $geoview_data_service; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Constructor for GeoAnalysisViewStatusAction Request Handler |
|
40 | - * |
|
41 | - * @param ModuleService $module_service |
|
42 | - * @param GeoAnalysisViewDataService $geoview_data_service |
|
43 | - */ |
|
44 | - public function __construct(ModuleService $module_service, GeoAnalysisViewDataService $geoview_data_service) |
|
45 | - { |
|
46 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
47 | - $this->geoview_data_service = $geoview_data_service; |
|
48 | - } |
|
38 | + /** |
|
39 | + * Constructor for GeoAnalysisViewStatusAction Request Handler |
|
40 | + * |
|
41 | + * @param ModuleService $module_service |
|
42 | + * @param GeoAnalysisViewDataService $geoview_data_service |
|
43 | + */ |
|
44 | + public function __construct(ModuleService $module_service, GeoAnalysisViewDataService $geoview_data_service) |
|
45 | + { |
|
46 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
47 | + $this->geoview_data_service = $geoview_data_service; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * {@inheritDoc} |
|
52 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
53 | - */ |
|
54 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
55 | - { |
|
56 | - $tree = Validator::attributes($request)->tree(); |
|
50 | + /** |
|
51 | + * {@inheritDoc} |
|
52 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
53 | + */ |
|
54 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
55 | + { |
|
56 | + $tree = Validator::attributes($request)->tree(); |
|
57 | 57 | |
58 | - $admin_config_route = route(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
58 | + $admin_config_route = route(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
59 | 59 | |
60 | - if ($this->module === null) { |
|
61 | - FlashMessages::addMessage( |
|
62 | - I18N::translate('The attached module could not be found.'), |
|
63 | - 'danger' |
|
64 | - ); |
|
65 | - return redirect($admin_config_route); |
|
66 | - } |
|
60 | + if ($this->module === null) { |
|
61 | + FlashMessages::addMessage( |
|
62 | + I18N::translate('The attached module could not be found.'), |
|
63 | + 'danger' |
|
64 | + ); |
|
65 | + return redirect($admin_config_route); |
|
66 | + } |
|
67 | 67 | |
68 | - $view_id = Validator::attributes($request)->integer('view_id', -1); |
|
69 | - $view = $this->geoview_data_service->find($tree, $view_id, true); |
|
68 | + $view_id = Validator::attributes($request)->integer('view_id', -1); |
|
69 | + $view = $this->geoview_data_service->find($tree, $view_id, true); |
|
70 | 70 | |
71 | - if ($view === null) { |
|
72 | - FlashMessages::addMessage( |
|
73 | - I18N::translate('The view with ID “%s” does not exist.', I18N::number($view_id)), |
|
74 | - 'danger' |
|
75 | - ); |
|
76 | - return redirect($admin_config_route); |
|
77 | - } |
|
71 | + if ($view === null) { |
|
72 | + FlashMessages::addMessage( |
|
73 | + I18N::translate('The view with ID “%s” does not exist.', I18N::number($view_id)), |
|
74 | + 'danger' |
|
75 | + ); |
|
76 | + return redirect($admin_config_route); |
|
77 | + } |
|
78 | 78 | |
79 | - try { |
|
80 | - $this->geoview_data_service->updateStatus($view, Validator::attributes($request)->boolean('enable', false)); |
|
81 | - FlashMessages::addMessage( |
|
82 | - I18N::translate('The geographical dispersion analysis view has been successfully updated.'), |
|
83 | - 'success' |
|
84 | - ); |
|
85 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
86 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : View “' . $view->id() . '” has been updated.'); |
|
87 | - } catch (Throwable $ex) { |
|
88 | - FlashMessages::addMessage( |
|
89 | - I18N::translate('An error occured while updating the geographical dispersion analysis view.'), |
|
90 | - 'danger' |
|
91 | - ); |
|
92 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
93 | - Log::addErrorLog('Module ' . $this->module->title() . ' : Error when updating view “' . $view->id() . '”: ' . $ex->getMessage()); |
|
94 | - } |
|
79 | + try { |
|
80 | + $this->geoview_data_service->updateStatus($view, Validator::attributes($request)->boolean('enable', false)); |
|
81 | + FlashMessages::addMessage( |
|
82 | + I18N::translate('The geographical dispersion analysis view has been successfully updated.'), |
|
83 | + 'success' |
|
84 | + ); |
|
85 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
86 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : View “' . $view->id() . '” has been updated.'); |
|
87 | + } catch (Throwable $ex) { |
|
88 | + FlashMessages::addMessage( |
|
89 | + I18N::translate('An error occured while updating the geographical dispersion analysis view.'), |
|
90 | + 'danger' |
|
91 | + ); |
|
92 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
93 | + Log::addErrorLog('Module ' . $this->module->title() . ' : Error when updating view “' . $view->id() . '”: ' . $ex->getMessage()); |
|
94 | + } |
|
95 | 95 | |
96 | - return redirect($admin_config_route); |
|
97 | - } |
|
96 | + return redirect($admin_config_route); |
|
97 | + } |
|
98 | 98 | } |
@@ -32,64 +32,64 @@ |
||
32 | 32 | */ |
33 | 33 | class GeoAnalysisViewEditPage implements RequestHandlerInterface |
34 | 34 | { |
35 | - use ViewResponseTrait; |
|
35 | + use ViewResponseTrait; |
|
36 | 36 | |
37 | - private ?GeoDispersionModule $module; |
|
38 | - private GeoAnalysisViewDataService $geoview_data_service; |
|
39 | - private GeoAnalysisService $geoanalysis_service; |
|
40 | - private GeoAnalysisDataService $geoanalysis_data_service; |
|
37 | + private ?GeoDispersionModule $module; |
|
38 | + private GeoAnalysisViewDataService $geoview_data_service; |
|
39 | + private GeoAnalysisService $geoanalysis_service; |
|
40 | + private GeoAnalysisDataService $geoanalysis_data_service; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Constructor for GeoAnalysisViewEditPage Request Handler |
|
44 | - * |
|
45 | - * @param ModuleService $module_service |
|
46 | - * @param GeoAnalysisViewDataService $geoview_data_service |
|
47 | - * @param GeoAnalysisService $geoanalysis_service |
|
48 | - * @param GeoAnalysisDataService $geoanalysis_data_service |
|
49 | - */ |
|
50 | - public function __construct( |
|
51 | - ModuleService $module_service, |
|
52 | - GeoAnalysisViewDataService $geoview_data_service, |
|
53 | - GeoAnalysisService $geoanalysis_service, |
|
54 | - GeoAnalysisDataService $geoanalysis_data_service |
|
55 | - ) { |
|
56 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
57 | - $this->geoview_data_service = $geoview_data_service; |
|
58 | - $this->geoanalysis_service = $geoanalysis_service; |
|
59 | - $this->geoanalysis_data_service = $geoanalysis_data_service; |
|
60 | - } |
|
42 | + /** |
|
43 | + * Constructor for GeoAnalysisViewEditPage Request Handler |
|
44 | + * |
|
45 | + * @param ModuleService $module_service |
|
46 | + * @param GeoAnalysisViewDataService $geoview_data_service |
|
47 | + * @param GeoAnalysisService $geoanalysis_service |
|
48 | + * @param GeoAnalysisDataService $geoanalysis_data_service |
|
49 | + */ |
|
50 | + public function __construct( |
|
51 | + ModuleService $module_service, |
|
52 | + GeoAnalysisViewDataService $geoview_data_service, |
|
53 | + GeoAnalysisService $geoanalysis_service, |
|
54 | + GeoAnalysisDataService $geoanalysis_data_service |
|
55 | + ) { |
|
56 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
57 | + $this->geoview_data_service = $geoview_data_service; |
|
58 | + $this->geoanalysis_service = $geoanalysis_service; |
|
59 | + $this->geoanalysis_data_service = $geoanalysis_data_service; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * {@inheritDoc} |
|
64 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
65 | - */ |
|
66 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
67 | - { |
|
68 | - $this->layout = 'layouts/administration'; |
|
62 | + /** |
|
63 | + * {@inheritDoc} |
|
64 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
65 | + */ |
|
66 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
67 | + { |
|
68 | + $this->layout = 'layouts/administration'; |
|
69 | 69 | |
70 | - if ($this->module === null) { |
|
71 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
72 | - } |
|
70 | + if ($this->module === null) { |
|
71 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
72 | + } |
|
73 | 73 | |
74 | - $tree = Validator::attributes($request)->tree(); |
|
74 | + $tree = Validator::attributes($request)->tree(); |
|
75 | 75 | |
76 | - $view_id = Validator::attributes($request)->integer('view_id', -1); |
|
77 | - $view = $this->geoview_data_service->find($tree, $view_id, true); |
|
76 | + $view_id = Validator::attributes($request)->integer('view_id', -1); |
|
77 | + $view = $this->geoview_data_service->find($tree, $view_id, true); |
|
78 | 78 | |
79 | - if ($view === null) { |
|
80 | - throw new HttpNotFoundException( |
|
81 | - I18N::translate('The geographical dispersion analysis view could not be found.') |
|
82 | - ); |
|
83 | - } |
|
79 | + if ($view === null) { |
|
80 | + throw new HttpNotFoundException( |
|
81 | + I18N::translate('The geographical dispersion analysis view could not be found.') |
|
82 | + ); |
|
83 | + } |
|
84 | 84 | |
85 | - return $this->viewResponse($this->module->name() . '::admin/view-edit', [ |
|
86 | - 'module' => $this->module, |
|
87 | - 'title' => I18N::translate('Edit the geographical dispersion analysis view - %s', $view->type()), |
|
88 | - 'tree' => $tree, |
|
89 | - 'view' => $view, |
|
90 | - 'geoanalysis_list' => $this->geoanalysis_service->all(), |
|
91 | - 'place_example' => $this->geoanalysis_data_service->placeHierarchyExample($tree), |
|
92 | - 'global_settings' => $view->globalSettingsContent($this->module) |
|
93 | - ]); |
|
94 | - } |
|
85 | + return $this->viewResponse($this->module->name() . '::admin/view-edit', [ |
|
86 | + 'module' => $this->module, |
|
87 | + 'title' => I18N::translate('Edit the geographical dispersion analysis view - %s', $view->type()), |
|
88 | + 'tree' => $tree, |
|
89 | + 'view' => $view, |
|
90 | + 'geoanalysis_list' => $this->geoanalysis_service->all(), |
|
91 | + 'place_example' => $this->geoanalysis_data_service->placeHierarchyExample($tree), |
|
92 | + 'global_settings' => $view->globalSettingsContent($this->module) |
|
93 | + ]); |
|
94 | + } |
|
95 | 95 | } |
@@ -59,188 +59,188 @@ |
||
59 | 59 | * Geographical Dispersion Module. |
60 | 60 | */ |
61 | 61 | class GeoDispersionModule extends AbstractModule implements |
62 | - ModuleMyArtJaubInterface, |
|
63 | - ModuleChartInterface, |
|
64 | - ModuleConfigInterface, |
|
65 | - ModuleGlobalInterface, |
|
66 | - ModuleGeoAnalysisProviderInterface, |
|
67 | - ModulePlaceMapperProviderInterface |
|
62 | + ModuleMyArtJaubInterface, |
|
63 | + ModuleChartInterface, |
|
64 | + ModuleConfigInterface, |
|
65 | + ModuleGlobalInterface, |
|
66 | + ModuleGeoAnalysisProviderInterface, |
|
67 | + ModulePlaceMapperProviderInterface |
|
68 | 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.1-v.1'; |
|
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 | - } |
|
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.1-v.1'; |
|
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 | 246 | } |
@@ -29,111 +29,111 @@ |
||
29 | 29 | */ |
30 | 30 | class FilteredTopPlaceMapperConfig extends GenericPlaceMapperConfig |
31 | 31 | { |
32 | - private TreeService $tree_service; |
|
32 | + private TreeService $tree_service; |
|
33 | 33 | |
34 | - /** |
|
35 | - * FilteredTopPlaceMapperConfig |
|
36 | - * |
|
37 | - * @param TreeService $tree_service |
|
38 | - */ |
|
39 | - public function __construct(TreeService $tree_service) |
|
40 | - { |
|
41 | - $this->tree_service = $tree_service; |
|
42 | - } |
|
34 | + /** |
|
35 | + * FilteredTopPlaceMapperConfig |
|
36 | + * |
|
37 | + * @param TreeService $tree_service |
|
38 | + */ |
|
39 | + public function __construct(TreeService $tree_service) |
|
40 | + { |
|
41 | + $this->tree_service = $tree_service; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Get the configured Top Places to filter on |
|
46 | - * |
|
47 | - * @return Collection<Place> |
|
48 | - */ |
|
49 | - public function topPlaces(): Collection |
|
50 | - { |
|
51 | - return collect($this->get('topPlaces', [])) |
|
52 | - ->filter( |
|
53 | - /** @psalm-suppress MissingClosureParamType */ |
|
54 | - fn($item): bool => $item instanceof Place |
|
55 | - ); |
|
56 | - } |
|
44 | + /** |
|
45 | + * Get the configured Top Places to filter on |
|
46 | + * |
|
47 | + * @return Collection<Place> |
|
48 | + */ |
|
49 | + public function topPlaces(): Collection |
|
50 | + { |
|
51 | + return collect($this->get('topPlaces', [])) |
|
52 | + ->filter( |
|
53 | + /** @psalm-suppress MissingClosureParamType */ |
|
54 | + fn($item): bool => $item instanceof Place |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * {@inheritDoc} |
|
60 | - * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::jsonSerializeConfig() |
|
61 | - */ |
|
62 | - public function jsonSerializeConfig() |
|
63 | - { |
|
64 | - return [ |
|
65 | - 'topPlaces' => $this->topPlaces() |
|
66 | - ->map(fn(Place $place): array => [ $place->tree()->id(), $place->gedcomName() ]) |
|
67 | - ->toArray() |
|
68 | - ]; |
|
69 | - } |
|
58 | + /** |
|
59 | + * {@inheritDoc} |
|
60 | + * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::jsonSerializeConfig() |
|
61 | + */ |
|
62 | + public function jsonSerializeConfig() |
|
63 | + { |
|
64 | + return [ |
|
65 | + 'topPlaces' => $this->topPlaces() |
|
66 | + ->map(fn(Place $place): array => [ $place->tree()->id(), $place->gedcomName() ]) |
|
67 | + ->toArray() |
|
68 | + ]; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * {@inheritDoc} |
|
73 | - * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::jsonDeserialize() |
|
74 | - * |
|
75 | - * @param mixed $config |
|
76 | - * @return $this |
|
77 | - */ |
|
78 | - public function jsonDeserialize($config): self |
|
79 | - { |
|
80 | - if (is_string($config)) { |
|
81 | - return $this->jsonDeserialize(json_decode($config)); |
|
82 | - } |
|
83 | - if (is_array($config)) { |
|
84 | - $this->setConfig([ |
|
85 | - 'topPlaces' => collect($config['topPlaces'] ?? []) |
|
86 | - ->filter( |
|
87 | - /** @psalm-suppress MissingClosureParamType */ |
|
88 | - fn($item): bool => is_array($item) && count($item) == 2 |
|
89 | - )->map(function (array $item): ?Place { |
|
90 | - try { |
|
91 | - return new Place($item[1], $this->tree_service->find($item[0])); |
|
92 | - } catch (RuntimeException $ex) { |
|
93 | - return null; |
|
94 | - } |
|
95 | - }) |
|
96 | - ->filter() |
|
97 | - ->toArray() |
|
98 | - ]); |
|
99 | - } |
|
100 | - return $this; |
|
101 | - } |
|
71 | + /** |
|
72 | + * {@inheritDoc} |
|
73 | + * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::jsonDeserialize() |
|
74 | + * |
|
75 | + * @param mixed $config |
|
76 | + * @return $this |
|
77 | + */ |
|
78 | + public function jsonDeserialize($config): self |
|
79 | + { |
|
80 | + if (is_string($config)) { |
|
81 | + return $this->jsonDeserialize(json_decode($config)); |
|
82 | + } |
|
83 | + if (is_array($config)) { |
|
84 | + $this->setConfig([ |
|
85 | + 'topPlaces' => collect($config['topPlaces'] ?? []) |
|
86 | + ->filter( |
|
87 | + /** @psalm-suppress MissingClosureParamType */ |
|
88 | + fn($item): bool => is_array($item) && count($item) == 2 |
|
89 | + )->map(function (array $item): ?Place { |
|
90 | + try { |
|
91 | + return new Place($item[1], $this->tree_service->find($item[0])); |
|
92 | + } catch (RuntimeException $ex) { |
|
93 | + return null; |
|
94 | + } |
|
95 | + }) |
|
96 | + ->filter() |
|
97 | + ->toArray() |
|
98 | + ]); |
|
99 | + } |
|
100 | + return $this; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * {@inheritDoc} |
|
105 | - * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::configContent() |
|
106 | - */ |
|
107 | - public function configContent(ModuleInterface $module, Tree $tree): string |
|
108 | - { |
|
109 | - return view($module->name() . '::mappers/filtered-top-config', [ |
|
110 | - 'tree' => $tree, |
|
111 | - 'top_places' => $this->topPlaces() |
|
112 | - ]); |
|
113 | - } |
|
103 | + /** |
|
104 | + * {@inheritDoc} |
|
105 | + * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::configContent() |
|
106 | + */ |
|
107 | + public function configContent(ModuleInterface $module, Tree $tree): string |
|
108 | + { |
|
109 | + return view($module->name() . '::mappers/filtered-top-config', [ |
|
110 | + 'tree' => $tree, |
|
111 | + 'top_places' => $this->topPlaces() |
|
112 | + ]); |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * {@inheritDoc} |
|
117 | - * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::withConfigUpdate() |
|
118 | - * @return $this |
|
119 | - */ |
|
120 | - public function withConfigUpdate(ServerRequestInterface $request): self |
|
121 | - { |
|
122 | - $tree = Validator::attributes($request)->treeOptional(); |
|
115 | + /** |
|
116 | + * {@inheritDoc} |
|
117 | + * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::withConfigUpdate() |
|
118 | + * @return $this |
|
119 | + */ |
|
120 | + public function withConfigUpdate(ServerRequestInterface $request): self |
|
121 | + { |
|
122 | + $tree = Validator::attributes($request)->treeOptional(); |
|
123 | 123 | |
124 | - if ($tree === null) { |
|
125 | - return $this; |
|
126 | - } |
|
124 | + if ($tree === null) { |
|
125 | + return $this; |
|
126 | + } |
|
127 | 127 | |
128 | - $top_places = Validator::parsedBody($request)->array('mapper_filt_top_places'); |
|
129 | - $config = ['topPlaces' => []]; |
|
130 | - foreach ($top_places as $top_place_id) { |
|
131 | - $place = Place::find((int) $top_place_id, $tree); |
|
132 | - if (mb_strlen($place->gedcomName()) > 0) { |
|
133 | - $config['topPlaces'][] = $place; |
|
134 | - } |
|
135 | - } |
|
136 | - $this->setConfig($config); |
|
137 | - return $this; |
|
138 | - } |
|
128 | + $top_places = Validator::parsedBody($request)->array('mapper_filt_top_places'); |
|
129 | + $config = ['topPlaces' => []]; |
|
130 | + foreach ($top_places as $top_place_id) { |
|
131 | + $place = Place::find((int) $top_place_id, $tree); |
|
132 | + if (mb_strlen($place->gedcomName()) > 0) { |
|
133 | + $config['topPlaces'][] = $place; |
|
134 | + } |
|
135 | + } |
|
136 | + $this->setConfig($config); |
|
137 | + return $this; |
|
138 | + } |
|
139 | 139 | } |
@@ -21,51 +21,51 @@ |
||
21 | 21 | */ |
22 | 22 | trait TopFilteredPlaceMapperTrait |
23 | 23 | { |
24 | - /** |
|
25 | - * @var Place[] $top_places |
|
26 | - */ |
|
27 | - private array $top_places = []; |
|
24 | + /** |
|
25 | + * @var Place[] $top_places |
|
26 | + */ |
|
27 | + private array $top_places = []; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Get the list of top level places. |
|
31 | - * |
|
32 | - * @return Place[] |
|
33 | - */ |
|
34 | - public function topPlaces(): array |
|
35 | - { |
|
36 | - return $this->top_places; |
|
37 | - } |
|
29 | + /** |
|
30 | + * Get the list of top level places. |
|
31 | + * |
|
32 | + * @return Place[] |
|
33 | + */ |
|
34 | + public function topPlaces(): array |
|
35 | + { |
|
36 | + return $this->top_places; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Set the list of defined top level places. |
|
41 | - * |
|
42 | - * @param Place[] $top_places |
|
43 | - */ |
|
44 | - public function setTopPlaces(array $top_places): void |
|
45 | - { |
|
46 | - $this->top_places = collect($top_places) |
|
47 | - ->filter( |
|
48 | - /** @psalm-suppress MissingClosureParamType */ |
|
49 | - fn($top_places): bool => $top_places instanceof Place |
|
50 | - )->toArray(); |
|
51 | - } |
|
39 | + /** |
|
40 | + * Set the list of defined top level places. |
|
41 | + * |
|
42 | + * @param Place[] $top_places |
|
43 | + */ |
|
44 | + public function setTopPlaces(array $top_places): void |
|
45 | + { |
|
46 | + $this->top_places = collect($top_places) |
|
47 | + ->filter( |
|
48 | + /** @psalm-suppress MissingClosureParamType */ |
|
49 | + fn($top_places): bool => $top_places instanceof Place |
|
50 | + )->toArray(); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Check whether a Place belongs to one of the defined top places. |
|
55 | - * |
|
56 | - * @param Place $place |
|
57 | - * @return bool |
|
58 | - */ |
|
59 | - protected function belongsToTopLevels(Place $place): bool |
|
60 | - { |
|
61 | - foreach ($this->top_places as $top_place) { |
|
62 | - if ( |
|
63 | - $top_place->tree()->id() === $place->tree()->id() && |
|
64 | - str_ends_with($place->gedcomName(), $top_place->gedcomName()) |
|
65 | - ) { |
|
66 | - return true; |
|
67 | - } |
|
68 | - } |
|
69 | - return false; |
|
70 | - } |
|
53 | + /** |
|
54 | + * Check whether a Place belongs to one of the defined top places. |
|
55 | + * |
|
56 | + * @param Place $place |
|
57 | + * @return bool |
|
58 | + */ |
|
59 | + protected function belongsToTopLevels(Place $place): bool |
|
60 | + { |
|
61 | + foreach ($this->top_places as $top_place) { |
|
62 | + if ( |
|
63 | + $top_place->tree()->id() === $place->tree()->id() && |
|
64 | + str_ends_with($place->gedcomName(), $top_place->gedcomName()) |
|
65 | + ) { |
|
66 | + return true; |
|
67 | + } |
|
68 | + } |
|
69 | + return false; |
|
70 | + } |
|
71 | 71 | } |