@@ -30,69 +30,69 @@ |
||
30 | 30 | */ |
31 | 31 | class MapAdapterDeleteAction implements RequestHandlerInterface |
32 | 32 | { |
33 | - private ?GeoDispersionModule $module; |
|
34 | - private MapAdapterDataService $mapadapter_data_service; |
|
33 | + private ?GeoDispersionModule $module; |
|
34 | + private MapAdapterDataService $mapadapter_data_service; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Constructor for MapAdapterDeleteAction Request Handler |
|
38 | - * |
|
39 | - * @param ModuleService $module_service |
|
40 | - * @param MapAdapterDataService $mapadapter_data_service |
|
41 | - */ |
|
42 | - public function __construct(ModuleService $module_service, MapAdapterDataService $mapadapter_data_service) |
|
43 | - { |
|
44 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
45 | - $this->mapadapter_data_service = $mapadapter_data_service; |
|
46 | - } |
|
36 | + /** |
|
37 | + * Constructor for MapAdapterDeleteAction Request Handler |
|
38 | + * |
|
39 | + * @param ModuleService $module_service |
|
40 | + * @param MapAdapterDataService $mapadapter_data_service |
|
41 | + */ |
|
42 | + public function __construct(ModuleService $module_service, MapAdapterDataService $mapadapter_data_service) |
|
43 | + { |
|
44 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
45 | + $this->mapadapter_data_service = $mapadapter_data_service; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * {@inheritDoc} |
|
50 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
51 | - */ |
|
52 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
53 | - { |
|
54 | - $tree = $request->getAttribute('tree'); |
|
55 | - assert($tree instanceof Tree); |
|
48 | + /** |
|
49 | + * {@inheritDoc} |
|
50 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
51 | + */ |
|
52 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
53 | + { |
|
54 | + $tree = $request->getAttribute('tree'); |
|
55 | + assert($tree instanceof Tree); |
|
56 | 56 | |
57 | - $admin_config_route = route(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
57 | + $admin_config_route = route(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
58 | 58 | |
59 | - if ($this->module === null) { |
|
60 | - FlashMessages::addMessage( |
|
61 | - I18N::translate('The attached module could not be found.'), |
|
62 | - 'danger' |
|
63 | - ); |
|
64 | - return redirect($admin_config_route); |
|
65 | - } |
|
66 | - $adapter_id = (int) $request->getAttribute('adapter_id'); |
|
67 | - $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
59 | + if ($this->module === null) { |
|
60 | + FlashMessages::addMessage( |
|
61 | + I18N::translate('The attached module could not be found.'), |
|
62 | + 'danger' |
|
63 | + ); |
|
64 | + return redirect($admin_config_route); |
|
65 | + } |
|
66 | + $adapter_id = (int) $request->getAttribute('adapter_id'); |
|
67 | + $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
68 | 68 | |
69 | - if ($map_adapter === null) { |
|
70 | - FlashMessages::addMessage( |
|
71 | - I18N::translate('The map configuration with ID “%d” does not exist.', I18N::number($adapter_id)), |
|
72 | - 'danger' |
|
73 | - ); |
|
74 | - return redirect($admin_config_route); |
|
75 | - } |
|
69 | + if ($map_adapter === null) { |
|
70 | + FlashMessages::addMessage( |
|
71 | + I18N::translate('The map configuration with ID “%d” does not exist.', I18N::number($adapter_id)), |
|
72 | + 'danger' |
|
73 | + ); |
|
74 | + return redirect($admin_config_route); |
|
75 | + } |
|
76 | 76 | |
77 | - if ($this->mapadapter_data_service->delete($map_adapter) > 0) { |
|
78 | - FlashMessages::addMessage( |
|
79 | - I18N::translate('The map configuration has been successfully deleted.'), |
|
80 | - 'success' |
|
81 | - ); |
|
82 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
83 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” has been deleted.'); |
|
84 | - } else { |
|
85 | - FlashMessages::addMessage( |
|
86 | - I18N::translate('An error occured while deleting the map configuration.'), |
|
87 | - 'danger' |
|
88 | - ); |
|
89 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
90 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” could not be deleted. See error log.'); |
|
91 | - } |
|
77 | + if ($this->mapadapter_data_service->delete($map_adapter) > 0) { |
|
78 | + FlashMessages::addMessage( |
|
79 | + I18N::translate('The map configuration has been successfully deleted.'), |
|
80 | + 'success' |
|
81 | + ); |
|
82 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
83 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” has been deleted.'); |
|
84 | + } else { |
|
85 | + FlashMessages::addMessage( |
|
86 | + I18N::translate('An error occured while deleting the map configuration.'), |
|
87 | + 'danger' |
|
88 | + ); |
|
89 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
90 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” could not be deleted. See error log.'); |
|
91 | + } |
|
92 | 92 | |
93 | - return redirect(route(GeoAnalysisViewEditPage::class, [ |
|
94 | - 'tree' => $tree->name(), |
|
95 | - 'view_id' => $map_adapter->geoAnalysisViewId() |
|
96 | - ])); |
|
97 | - } |
|
93 | + return redirect(route(GeoAnalysisViewEditPage::class, [ |
|
94 | + 'tree' => $tree->name(), |
|
95 | + 'view_id' => $map_adapter->geoAnalysisViewId() |
|
96 | + ])); |
|
97 | + } |
|
98 | 98 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | ); |
64 | 64 | return redirect($admin_config_route); |
65 | 65 | } |
66 | - $adapter_id = (int) $request->getAttribute('adapter_id'); |
|
66 | + $adapter_id = (int)$request->getAttribute('adapter_id'); |
|
67 | 67 | $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
68 | 68 | |
69 | 69 | if ($map_adapter === null) { |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | 'success' |
81 | 81 | ); |
82 | 82 | //phpcs:ignore Generic.Files.LineLength.TooLong |
83 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” has been deleted.'); |
|
83 | + Log::addConfigurationLog('Module '.$this->module->title().' : Map Adapter “'.$map_adapter->id().'” has been deleted.'); |
|
84 | 84 | } else { |
85 | 85 | FlashMessages::addMessage( |
86 | 86 | I18N::translate('An error occured while deleting the map configuration.'), |
87 | 87 | 'danger' |
88 | 88 | ); |
89 | 89 | //phpcs:ignore Generic.Files.LineLength.TooLong |
90 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” could not be deleted. See error log.'); |
|
90 | + Log::addConfigurationLog('Module '.$this->module->title().' : Map Adapter “'.$map_adapter->id().'” could not be deleted. See error log.'); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | return redirect(route(GeoAnalysisViewEditPage::class, [ |
@@ -32,68 +32,68 @@ |
||
32 | 32 | */ |
33 | 33 | class MapAdapterAddPage implements RequestHandlerInterface |
34 | 34 | { |
35 | - use ViewResponseTrait; |
|
35 | + use ViewResponseTrait; |
|
36 | 36 | |
37 | - private ?GeoDispersionModule $module; |
|
38 | - private GeoAnalysisViewDataService $geoview_data_service; |
|
39 | - private MapDefinitionsService $map_definition_service; |
|
40 | - private PlaceMapperService $place_mapper_service; |
|
37 | + private ?GeoDispersionModule $module; |
|
38 | + private GeoAnalysisViewDataService $geoview_data_service; |
|
39 | + private MapDefinitionsService $map_definition_service; |
|
40 | + private PlaceMapperService $place_mapper_service; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Constructor for MapAdapterAddPage Request Handler |
|
44 | - * |
|
45 | - * @param ModuleService $module_service |
|
46 | - * @param GeoAnalysisViewDataService $geoview_data_service |
|
47 | - * @param MapDefinitionsService $map_definition_service |
|
48 | - * @param PlaceMapperService $place_mapper_service |
|
49 | - */ |
|
50 | - public function __construct( |
|
51 | - ModuleService $module_service, |
|
52 | - GeoAnalysisViewDataService $geoview_data_service, |
|
53 | - MapDefinitionsService $map_definition_service, |
|
54 | - PlaceMapperService $place_mapper_service |
|
55 | - ) { |
|
56 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
57 | - $this->geoview_data_service = $geoview_data_service; |
|
58 | - $this->map_definition_service = $map_definition_service; |
|
59 | - $this->place_mapper_service = $place_mapper_service; |
|
60 | - } |
|
42 | + /** |
|
43 | + * Constructor for MapAdapterAddPage Request Handler |
|
44 | + * |
|
45 | + * @param ModuleService $module_service |
|
46 | + * @param GeoAnalysisViewDataService $geoview_data_service |
|
47 | + * @param MapDefinitionsService $map_definition_service |
|
48 | + * @param PlaceMapperService $place_mapper_service |
|
49 | + */ |
|
50 | + public function __construct( |
|
51 | + ModuleService $module_service, |
|
52 | + GeoAnalysisViewDataService $geoview_data_service, |
|
53 | + MapDefinitionsService $map_definition_service, |
|
54 | + PlaceMapperService $place_mapper_service |
|
55 | + ) { |
|
56 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
57 | + $this->geoview_data_service = $geoview_data_service; |
|
58 | + $this->map_definition_service = $map_definition_service; |
|
59 | + $this->place_mapper_service = $place_mapper_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 | - } |
|
73 | - $tree = $request->getAttribute('tree'); |
|
74 | - assert($tree instanceof Tree); |
|
70 | + if ($this->module === null) { |
|
71 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
72 | + } |
|
73 | + $tree = $request->getAttribute('tree'); |
|
74 | + assert($tree instanceof Tree); |
|
75 | 75 | |
76 | - $view_id = (int) $request->getAttribute('view_id'); |
|
77 | - $view = $this->geoview_data_service->find($tree, $view_id, true); |
|
76 | + $view_id = (int) $request->getAttribute('view_id'); |
|
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/map-adapter-edit', [ |
|
86 | - 'module' => $this->module, |
|
87 | - 'title' => I18N::translate('Add a map configuration'), |
|
88 | - 'tree' => $tree, |
|
89 | - 'view_id' => $view_id, |
|
90 | - 'map_adapter' => null, |
|
91 | - 'maps_list' => $this->map_definition_service->all(), |
|
92 | - 'mappers_list' => $this->place_mapper_service->all(), |
|
93 | - 'route_edit' => route(MapAdapterAddAction::class, [ |
|
94 | - 'tree' => $tree->name(), |
|
95 | - 'view_id' => $view_id |
|
96 | - ]) |
|
97 | - ]); |
|
98 | - } |
|
85 | + return $this->viewResponse($this->module->name() . '::admin/map-adapter-edit', [ |
|
86 | + 'module' => $this->module, |
|
87 | + 'title' => I18N::translate('Add a map configuration'), |
|
88 | + 'tree' => $tree, |
|
89 | + 'view_id' => $view_id, |
|
90 | + 'map_adapter' => null, |
|
91 | + 'maps_list' => $this->map_definition_service->all(), |
|
92 | + 'mappers_list' => $this->place_mapper_service->all(), |
|
93 | + 'route_edit' => route(MapAdapterAddAction::class, [ |
|
94 | + 'tree' => $tree->name(), |
|
95 | + 'view_id' => $view_id |
|
96 | + ]) |
|
97 | + ]); |
|
98 | + } |
|
99 | 99 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $tree = $request->getAttribute('tree'); |
74 | 74 | assert($tree instanceof Tree); |
75 | 75 | |
76 | - $view_id = (int) $request->getAttribute('view_id'); |
|
76 | + $view_id = (int)$request->getAttribute('view_id'); |
|
77 | 77 | $view = $this->geoview_data_service->find($tree, $view_id, true); |
78 | 78 | |
79 | 79 | if ($view === null) { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | ); |
83 | 83 | } |
84 | 84 | |
85 | - return $this->viewResponse($this->module->name() . '::admin/map-adapter-edit', [ |
|
85 | + return $this->viewResponse($this->module->name().'::admin/map-adapter-edit', [ |
|
86 | 86 | 'module' => $this->module, |
87 | 87 | 'title' => I18N::translate('Add a map configuration'), |
88 | 88 | 'tree' => $tree, |
@@ -32,79 +32,79 @@ |
||
32 | 32 | */ |
33 | 33 | class GeoAnalysisViewListData implements RequestHandlerInterface |
34 | 34 | { |
35 | - private ?GeoDispersionModule $module; |
|
36 | - private GeoAnalysisViewDataService $geoview_data_service; |
|
37 | - private DatatablesService $datatables_service; |
|
35 | + private ?GeoDispersionModule $module; |
|
36 | + private GeoAnalysisViewDataService $geoview_data_service; |
|
37 | + private DatatablesService $datatables_service; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Constructor for GeoAnalysisViewListData Request Handler |
|
41 | - * |
|
42 | - * @param ModuleService $module_service |
|
43 | - * @param GeoAnalysisViewDataService $geoview_data_service |
|
44 | - * @param DatatablesService $datatables_service |
|
45 | - */ |
|
46 | - public function __construct( |
|
47 | - ModuleService $module_service, |
|
48 | - GeoAnalysisViewDataService $geoview_data_service, |
|
49 | - DatatablesService $datatables_service |
|
50 | - ) { |
|
51 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
52 | - $this->geoview_data_service = $geoview_data_service; |
|
53 | - $this->datatables_service = $datatables_service; |
|
54 | - } |
|
39 | + /** |
|
40 | + * Constructor for GeoAnalysisViewListData Request Handler |
|
41 | + * |
|
42 | + * @param ModuleService $module_service |
|
43 | + * @param GeoAnalysisViewDataService $geoview_data_service |
|
44 | + * @param DatatablesService $datatables_service |
|
45 | + */ |
|
46 | + public function __construct( |
|
47 | + ModuleService $module_service, |
|
48 | + GeoAnalysisViewDataService $geoview_data_service, |
|
49 | + DatatablesService $datatables_service |
|
50 | + ) { |
|
51 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
52 | + $this->geoview_data_service = $geoview_data_service; |
|
53 | + $this->datatables_service = $datatables_service; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * {@inheritDoc} |
|
58 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
59 | - */ |
|
60 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
61 | - { |
|
62 | - if ($this->module === null) { |
|
63 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
64 | - } |
|
56 | + /** |
|
57 | + * {@inheritDoc} |
|
58 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
59 | + */ |
|
60 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
61 | + { |
|
62 | + if ($this->module === null) { |
|
63 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
64 | + } |
|
65 | 65 | |
66 | - $tree = $request->getAttribute('tree'); |
|
67 | - assert($tree instanceof Tree); |
|
66 | + $tree = $request->getAttribute('tree'); |
|
67 | + assert($tree instanceof Tree); |
|
68 | 68 | |
69 | - $module = $this->module; |
|
70 | - $module_name = $this->module->name(); |
|
71 | - return response(['data' => $this->geoview_data_service->all($tree, true) |
|
72 | - ->map(fn(AbstractGeoAnalysisView $view) => [ |
|
73 | - 'edit' => view($module_name . '::admin/view-table-options', [ |
|
74 | - 'view_id' => $view->id(), |
|
75 | - 'view_enabled' => $view->isEnabled(), |
|
76 | - 'view_edit_route' => route(GeoAnalysisViewEditPage::class, [ |
|
77 | - 'tree' => $tree->name(), |
|
78 | - 'view_id' => $view->id() |
|
79 | - ]), |
|
80 | - 'view_delete_route' => route(GeoAnalysisViewDeleteAction::class, [ |
|
81 | - 'tree' => $tree->name(), |
|
82 | - 'view_id' => $view->id() |
|
83 | - ]), |
|
84 | - 'view_status_route' => route(GeoAnalysisViewStatusAction::class, [ |
|
85 | - 'tree' => $tree->name(), |
|
86 | - 'view_id' => $view->id(), |
|
87 | - 'enable' => $view->isEnabled() ? 0 : 1 |
|
88 | - ]), |
|
89 | - ]), |
|
90 | - 'enabled' => [ |
|
91 | - 'display' => view($module_name . '::components/yes-no-icons', ['yes' => $view->isEnabled()]), |
|
92 | - 'raw' => $view->isEnabled() ? 0 : 1 |
|
93 | - ], |
|
94 | - 'type' => $view->icon($module), |
|
95 | - 'description' => [ |
|
96 | - 'display' => '<span dir="auto">' . e($view->description()) . '</span>', |
|
97 | - 'raw' => e($view->description()) |
|
98 | - ], |
|
99 | - 'analysis' => [ |
|
100 | - 'display' => '<span dir="auto">' . e($view->analysis()->title()) . '</span>', |
|
101 | - 'raw' => e($view->analysis()->title()) |
|
102 | - ], |
|
103 | - 'place_depth' => [ |
|
104 | - 'display' => I18N::number($view->placesDepth()), |
|
105 | - 'raw' => $view->placesDepth() |
|
106 | - ] |
|
107 | - ]) |
|
108 | - ]); |
|
109 | - } |
|
69 | + $module = $this->module; |
|
70 | + $module_name = $this->module->name(); |
|
71 | + return response(['data' => $this->geoview_data_service->all($tree, true) |
|
72 | + ->map(fn(AbstractGeoAnalysisView $view) => [ |
|
73 | + 'edit' => view($module_name . '::admin/view-table-options', [ |
|
74 | + 'view_id' => $view->id(), |
|
75 | + 'view_enabled' => $view->isEnabled(), |
|
76 | + 'view_edit_route' => route(GeoAnalysisViewEditPage::class, [ |
|
77 | + 'tree' => $tree->name(), |
|
78 | + 'view_id' => $view->id() |
|
79 | + ]), |
|
80 | + 'view_delete_route' => route(GeoAnalysisViewDeleteAction::class, [ |
|
81 | + 'tree' => $tree->name(), |
|
82 | + 'view_id' => $view->id() |
|
83 | + ]), |
|
84 | + 'view_status_route' => route(GeoAnalysisViewStatusAction::class, [ |
|
85 | + 'tree' => $tree->name(), |
|
86 | + 'view_id' => $view->id(), |
|
87 | + 'enable' => $view->isEnabled() ? 0 : 1 |
|
88 | + ]), |
|
89 | + ]), |
|
90 | + 'enabled' => [ |
|
91 | + 'display' => view($module_name . '::components/yes-no-icons', ['yes' => $view->isEnabled()]), |
|
92 | + 'raw' => $view->isEnabled() ? 0 : 1 |
|
93 | + ], |
|
94 | + 'type' => $view->icon($module), |
|
95 | + 'description' => [ |
|
96 | + 'display' => '<span dir="auto">' . e($view->description()) . '</span>', |
|
97 | + 'raw' => e($view->description()) |
|
98 | + ], |
|
99 | + 'analysis' => [ |
|
100 | + 'display' => '<span dir="auto">' . e($view->analysis()->title()) . '</span>', |
|
101 | + 'raw' => e($view->analysis()->title()) |
|
102 | + ], |
|
103 | + 'place_depth' => [ |
|
104 | + 'display' => I18N::number($view->placesDepth()), |
|
105 | + 'raw' => $view->placesDepth() |
|
106 | + ] |
|
107 | + ]) |
|
108 | + ]); |
|
109 | + } |
|
110 | 110 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $module_name = $this->module->name(); |
71 | 71 | return response(['data' => $this->geoview_data_service->all($tree, true) |
72 | 72 | ->map(fn(AbstractGeoAnalysisView $view) => [ |
73 | - 'edit' => view($module_name . '::admin/view-table-options', [ |
|
73 | + 'edit' => view($module_name.'::admin/view-table-options', [ |
|
74 | 74 | 'view_id' => $view->id(), |
75 | 75 | 'view_enabled' => $view->isEnabled(), |
76 | 76 | 'view_edit_route' => route(GeoAnalysisViewEditPage::class, [ |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | ]), |
89 | 89 | ]), |
90 | 90 | 'enabled' => [ |
91 | - 'display' => view($module_name . '::components/yes-no-icons', ['yes' => $view->isEnabled()]), |
|
91 | + 'display' => view($module_name.'::components/yes-no-icons', ['yes' => $view->isEnabled()]), |
|
92 | 92 | 'raw' => $view->isEnabled() ? 0 : 1 |
93 | 93 | ], |
94 | 94 | 'type' => $view->icon($module), |
95 | 95 | 'description' => [ |
96 | - 'display' => '<span dir="auto">' . e($view->description()) . '</span>', |
|
96 | + 'display' => '<span dir="auto">'.e($view->description()).'</span>', |
|
97 | 97 | 'raw' => e($view->description()) |
98 | 98 | ], |
99 | 99 | 'analysis' => [ |
100 | - 'display' => '<span dir="auto">' . e($view->analysis()->title()) . '</span>', |
|
100 | + 'display' => '<span dir="auto">'.e($view->analysis()->title()).'</span>', |
|
101 | 101 | 'raw' => e($view->analysis()->title()) |
102 | 102 | ], |
103 | 103 | 'place_depth' => [ |
@@ -29,48 +29,48 @@ |
||
29 | 29 | */ |
30 | 30 | class MapFeaturePropertyData implements RequestHandlerInterface |
31 | 31 | { |
32 | - private MapDefinitionsService $map_definition_service; |
|
32 | + private MapDefinitionsService $map_definition_service; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Constructor for MapFeaturePropertyData Request Handler |
|
36 | - * |
|
37 | - * @param MapDefinitionsService $map_definition_service |
|
38 | - */ |
|
39 | - public function __construct( |
|
40 | - MapDefinitionsService $map_definition_service |
|
41 | - ) { |
|
42 | - $this->map_definition_service = $map_definition_service; |
|
43 | - } |
|
34 | + /** |
|
35 | + * Constructor for MapFeaturePropertyData Request Handler |
|
36 | + * |
|
37 | + * @param MapDefinitionsService $map_definition_service |
|
38 | + */ |
|
39 | + public function __construct( |
|
40 | + MapDefinitionsService $map_definition_service |
|
41 | + ) { |
|
42 | + $this->map_definition_service = $map_definition_service; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * {@inheritDoc} |
|
47 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
48 | - */ |
|
49 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
50 | - { |
|
51 | - $map_id = $request->getQueryParams()['map_id'] ?? $request->getAttribute('map_id') ?? ''; |
|
45 | + /** |
|
46 | + * {@inheritDoc} |
|
47 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
48 | + */ |
|
49 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
50 | + { |
|
51 | + $map_id = $request->getQueryParams()['map_id'] ?? $request->getAttribute('map_id') ?? ''; |
|
52 | 52 | |
53 | - return response(Registry::cache()->file()->remember( |
|
54 | - 'map-properties-' . $map_id, |
|
55 | - function () use ($map_id): array { |
|
56 | - $map = $this->map_definition_service->find($map_id); |
|
57 | - if ($map === null) { |
|
58 | - throw new HttpNotFoundException(I18N::translate('The map could not be found.')); |
|
59 | - } |
|
53 | + return response(Registry::cache()->file()->remember( |
|
54 | + 'map-properties-' . $map_id, |
|
55 | + function () use ($map_id): array { |
|
56 | + $map = $this->map_definition_service->find($map_id); |
|
57 | + if ($map === null) { |
|
58 | + throw new HttpNotFoundException(I18N::translate('The map could not be found.')); |
|
59 | + } |
|
60 | 60 | |
61 | - $features = []; |
|
62 | - collect($map->features()) |
|
63 | - ->map(fn(Feature $feature): ?stdClass => $feature->getProperties()) |
|
64 | - ->filter() |
|
65 | - ->map(fn(stdClass $properties): array => array_keys(get_object_vars($properties))) |
|
66 | - ->each(function (array $properties) use (&$features): void { |
|
67 | - $features = count($features) === 0 ? $properties : array_intersect($features, $properties); |
|
68 | - }); |
|
61 | + $features = []; |
|
62 | + collect($map->features()) |
|
63 | + ->map(fn(Feature $feature): ?stdClass => $feature->getProperties()) |
|
64 | + ->filter() |
|
65 | + ->map(fn(stdClass $properties): array => array_keys(get_object_vars($properties))) |
|
66 | + ->each(function (array $properties) use (&$features): void { |
|
67 | + $features = count($features) === 0 ? $properties : array_intersect($features, $properties); |
|
68 | + }); |
|
69 | 69 | |
70 | - usort($features, I18N::comparator()); |
|
71 | - return $features; |
|
72 | - }, |
|
73 | - 86400000 |
|
74 | - )); |
|
75 | - } |
|
70 | + usort($features, I18N::comparator()); |
|
71 | + return $features; |
|
72 | + }, |
|
73 | + 86400000 |
|
74 | + )); |
|
75 | + } |
|
76 | 76 | } |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | $map_id = $request->getQueryParams()['map_id'] ?? $request->getAttribute('map_id') ?? ''; |
52 | 52 | |
53 | 53 | return response(Registry::cache()->file()->remember( |
54 | - 'map-properties-' . $map_id, |
|
55 | - function () use ($map_id): array { |
|
54 | + 'map-properties-'.$map_id, |
|
55 | + function() use ($map_id): array { |
|
56 | 56 | $map = $this->map_definition_service->find($map_id); |
57 | 57 | if ($map === null) { |
58 | 58 | throw new HttpNotFoundException(I18N::translate('The map could not be found.')); |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | collect($map->features()) |
63 | 63 | ->map(fn(Feature $feature): ?stdClass => $feature->getProperties()) |
64 | 64 | ->filter() |
65 | - ->map(fn(stdClass $properties): array => array_keys(get_object_vars($properties))) |
|
66 | - ->each(function (array $properties) use (&$features): void { |
|
65 | + ->map(fn(stdClass $properties) : array => array_keys(get_object_vars($properties))) |
|
66 | + ->each(function(array $properties) use (&$features) : void { |
|
67 | 67 | $features = count($features) === 0 ? $properties : array_intersect($features, $properties); |
68 | 68 | }); |
69 | 69 |
@@ -34,88 +34,88 @@ |
||
34 | 34 | */ |
35 | 35 | class MapAdapterEditAction implements RequestHandlerInterface |
36 | 36 | { |
37 | - private ?GeoDispersionModule $module; |
|
38 | - private MapAdapterDataService $mapadapter_data_service; |
|
39 | - private MapDefinitionsService $map_definition_service; |
|
37 | + private ?GeoDispersionModule $module; |
|
38 | + private MapAdapterDataService $mapadapter_data_service; |
|
39 | + private MapDefinitionsService $map_definition_service; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Constructor for MapAdapterEditAction Request Handler |
|
43 | - * |
|
44 | - * @param ModuleService $module_service |
|
45 | - * @param MapAdapterDataService $mapadapter_data_service |
|
46 | - * @param MapDefinitionsService $map_definition_service |
|
47 | - */ |
|
48 | - public function __construct( |
|
49 | - ModuleService $module_service, |
|
50 | - MapAdapterDataService $mapadapter_data_service, |
|
51 | - MapDefinitionsService $map_definition_service |
|
52 | - ) { |
|
53 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
54 | - $this->mapadapter_data_service = $mapadapter_data_service; |
|
55 | - $this->map_definition_service = $map_definition_service; |
|
56 | - } |
|
41 | + /** |
|
42 | + * Constructor for MapAdapterEditAction Request Handler |
|
43 | + * |
|
44 | + * @param ModuleService $module_service |
|
45 | + * @param MapAdapterDataService $mapadapter_data_service |
|
46 | + * @param MapDefinitionsService $map_definition_service |
|
47 | + */ |
|
48 | + public function __construct( |
|
49 | + ModuleService $module_service, |
|
50 | + MapAdapterDataService $mapadapter_data_service, |
|
51 | + MapDefinitionsService $map_definition_service |
|
52 | + ) { |
|
53 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
54 | + $this->mapadapter_data_service = $mapadapter_data_service; |
|
55 | + $this->map_definition_service = $map_definition_service; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * {@inheritDoc} |
|
60 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
61 | - */ |
|
62 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
63 | - { |
|
64 | - $tree = $request->getAttribute('tree'); |
|
65 | - assert($tree instanceof Tree); |
|
58 | + /** |
|
59 | + * {@inheritDoc} |
|
60 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
61 | + */ |
|
62 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
63 | + { |
|
64 | + $tree = $request->getAttribute('tree'); |
|
65 | + assert($tree instanceof Tree); |
|
66 | 66 | |
67 | - if ($this->module === null) { |
|
68 | - FlashMessages::addMessage( |
|
69 | - I18N::translate('The attached module could not be found.'), |
|
70 | - 'danger' |
|
71 | - ); |
|
72 | - return redirect(route(AdminConfigPage::class, ['tree' => $tree])); |
|
73 | - } |
|
67 | + if ($this->module === null) { |
|
68 | + FlashMessages::addMessage( |
|
69 | + I18N::translate('The attached module could not be found.'), |
|
70 | + 'danger' |
|
71 | + ); |
|
72 | + return redirect(route(AdminConfigPage::class, ['tree' => $tree])); |
|
73 | + } |
|
74 | 74 | |
75 | - $adapter_id = (int) $request->getAttribute('adapter_id'); |
|
76 | - $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
75 | + $adapter_id = (int) $request->getAttribute('adapter_id'); |
|
76 | + $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
77 | 77 | |
78 | - $params = (array) $request->getParsedBody(); |
|
78 | + $params = (array) $request->getParsedBody(); |
|
79 | 79 | |
80 | - $map = $this->map_definition_service->find($params['map_adapter_map'] ?? ''); |
|
81 | - $mapping_property = $params['map_adapter_property_selected'] ?? ''; |
|
80 | + $map = $this->map_definition_service->find($params['map_adapter_map'] ?? ''); |
|
81 | + $mapping_property = $params['map_adapter_property_selected'] ?? ''; |
|
82 | 82 | |
83 | - $mapper = null; |
|
84 | - try { |
|
85 | - $mapper = app($params['map_adapter_mapper'] ?? ''); |
|
86 | - } catch (BindingResolutionException $ex) { |
|
87 | - } |
|
83 | + $mapper = null; |
|
84 | + try { |
|
85 | + $mapper = app($params['map_adapter_mapper'] ?? ''); |
|
86 | + } catch (BindingResolutionException $ex) { |
|
87 | + } |
|
88 | 88 | |
89 | - if ($map_adapter === null || $map === null || $mapper === null || !($mapper instanceof PlaceMapperInterface)) { |
|
90 | - FlashMessages::addMessage( |
|
91 | - I18N::translate('The parameters for the map configuration are not valid.'), |
|
92 | - 'danger' |
|
93 | - ); |
|
94 | - return redirect(route(AdminConfigPage::class, ['tree' => $tree])); |
|
95 | - } |
|
89 | + if ($map_adapter === null || $map === null || $mapper === null || !($mapper instanceof PlaceMapperInterface)) { |
|
90 | + FlashMessages::addMessage( |
|
91 | + I18N::translate('The parameters for the map configuration are not valid.'), |
|
92 | + 'danger' |
|
93 | + ); |
|
94 | + return redirect(route(AdminConfigPage::class, ['tree' => $tree])); |
|
95 | + } |
|
96 | 96 | |
97 | - $mapper->setConfig($mapper->config()->withConfigUpdate($request)); |
|
98 | - $new_map_adapter = $map_adapter->with($map, $mapper, $mapping_property); |
|
99 | - try { |
|
100 | - $this->mapadapter_data_service->update($new_map_adapter); |
|
101 | - FlashMessages::addMessage( |
|
102 | - I18N::translate('The map configuration has been successfully updated.'), |
|
103 | - 'success' |
|
104 | - ); |
|
105 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
106 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” has been updated.'); |
|
107 | - } catch (Throwable $ex) { |
|
108 | - FlashMessages::addMessage( |
|
109 | - I18N::translate('An error occured while updating the map configuration.'), |
|
110 | - 'danger' |
|
111 | - ); |
|
112 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
113 | - Log::addErrorLog('Module ' . $this->module->title() . ' : Error when updating Map Adapter “' . $map_adapter->id() . '”: ' . $ex->getMessage()); |
|
114 | - } |
|
97 | + $mapper->setConfig($mapper->config()->withConfigUpdate($request)); |
|
98 | + $new_map_adapter = $map_adapter->with($map, $mapper, $mapping_property); |
|
99 | + try { |
|
100 | + $this->mapadapter_data_service->update($new_map_adapter); |
|
101 | + FlashMessages::addMessage( |
|
102 | + I18N::translate('The map configuration has been successfully updated.'), |
|
103 | + 'success' |
|
104 | + ); |
|
105 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
106 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” has been updated.'); |
|
107 | + } catch (Throwable $ex) { |
|
108 | + FlashMessages::addMessage( |
|
109 | + I18N::translate('An error occured while updating the map configuration.'), |
|
110 | + 'danger' |
|
111 | + ); |
|
112 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
113 | + Log::addErrorLog('Module ' . $this->module->title() . ' : Error when updating Map Adapter “' . $map_adapter->id() . '”: ' . $ex->getMessage()); |
|
114 | + } |
|
115 | 115 | |
116 | - return redirect(route(GeoAnalysisViewEditPage::class, [ |
|
117 | - 'tree' => $tree->name(), |
|
118 | - 'view_id' => $map_adapter->geoAnalysisViewId() |
|
119 | - ])); |
|
120 | - } |
|
116 | + return redirect(route(GeoAnalysisViewEditPage::class, [ |
|
117 | + 'tree' => $tree->name(), |
|
118 | + 'view_id' => $map_adapter->geoAnalysisViewId() |
|
119 | + ])); |
|
120 | + } |
|
121 | 121 | } |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | return redirect(route(AdminConfigPage::class, ['tree' => $tree])); |
73 | 73 | } |
74 | 74 | |
75 | - $adapter_id = (int) $request->getAttribute('adapter_id'); |
|
75 | + $adapter_id = (int)$request->getAttribute('adapter_id'); |
|
76 | 76 | $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
77 | 77 | |
78 | - $params = (array) $request->getParsedBody(); |
|
78 | + $params = (array)$request->getParsedBody(); |
|
79 | 79 | |
80 | 80 | $map = $this->map_definition_service->find($params['map_adapter_map'] ?? ''); |
81 | - $mapping_property = $params['map_adapter_property_selected'] ?? ''; |
|
81 | + $mapping_property = $params['map_adapter_property_selected'] ?? ''; |
|
82 | 82 | |
83 | 83 | $mapper = null; |
84 | 84 | try { |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | 'success' |
104 | 104 | ); |
105 | 105 | //phpcs:ignore Generic.Files.LineLength.TooLong |
106 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” has been updated.'); |
|
106 | + Log::addConfigurationLog('Module '.$this->module->title().' : Map Adapter “'.$map_adapter->id().'” has been updated.'); |
|
107 | 107 | } catch (Throwable $ex) { |
108 | 108 | FlashMessages::addMessage( |
109 | 109 | I18N::translate('An error occured while updating the map configuration.'), |
110 | 110 | 'danger' |
111 | 111 | ); |
112 | 112 | //phpcs:ignore Generic.Files.LineLength.TooLong |
113 | - Log::addErrorLog('Module ' . $this->module->title() . ' : Error when updating Map Adapter “' . $map_adapter->id() . '”: ' . $ex->getMessage()); |
|
113 | + Log::addErrorLog('Module '.$this->module->title().' : Error when updating Map Adapter “'.$map_adapter->id().'”: '.$ex->getMessage()); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return redirect(route(GeoAnalysisViewEditPage::class, [ |
@@ -26,224 +26,224 @@ |
||
26 | 26 | */ |
27 | 27 | abstract class AbstractGeoAnalysisView |
28 | 28 | { |
29 | - private int $id; |
|
30 | - private Tree $tree; |
|
31 | - private bool $enabled; |
|
32 | - private string $description; |
|
33 | - private GeoAnalysisInterface $geoanalysis; |
|
34 | - private int $depth; |
|
35 | - private int $detailed_top_places; |
|
36 | - private bool $use_flags; |
|
37 | - |
|
38 | - /** |
|
39 | - * Constructor for AbstractGeoAnalysisView |
|
40 | - * |
|
41 | - * @param int $id |
|
42 | - * @param Tree $tree |
|
43 | - * @param bool $enabled |
|
44 | - * @param string $description |
|
45 | - * @param GeoAnalysisInterface $geoanalysis |
|
46 | - * @param int $depth |
|
47 | - * @param int $detailed_top_places |
|
48 | - * @param bool $use_flags |
|
49 | - */ |
|
50 | - final public function __construct( |
|
51 | - int $id, |
|
52 | - Tree $tree, |
|
53 | - bool $enabled, |
|
54 | - string $description, |
|
55 | - GeoAnalysisInterface $geoanalysis, |
|
56 | - int $depth, |
|
57 | - int $detailed_top_places = 0, |
|
58 | - bool $use_flags = false |
|
59 | - ) { |
|
60 | - $this->id = $id; |
|
61 | - $this->tree = $tree; |
|
62 | - $this->enabled = $enabled; |
|
63 | - $this->description = $description; |
|
64 | - $this->geoanalysis = $geoanalysis; |
|
65 | - $this->depth = $depth; |
|
66 | - $this->detailed_top_places = $detailed_top_places; |
|
67 | - $this->use_flags = $use_flags; |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Create a copy of the view with a new ID. |
|
72 | - * |
|
73 | - * @param int $id |
|
74 | - * @return static |
|
75 | - */ |
|
76 | - public function withId(int $id): self |
|
77 | - { |
|
78 | - $new = clone $this; |
|
79 | - $new->id = $id; |
|
80 | - return $new; |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * Create a copy of the view with new properties. |
|
85 | - * |
|
86 | - * @param bool $enabled |
|
87 | - * @param string $description |
|
88 | - * @param GeoAnalysisInterface $geoanalysis |
|
89 | - * @param int $depth |
|
90 | - * @param int $detailed_top_places |
|
91 | - * @param bool $use_flags |
|
92 | - * @return static |
|
93 | - */ |
|
94 | - public function with( |
|
95 | - bool $enabled, |
|
96 | - string $description, |
|
97 | - GeoAnalysisInterface $geoanalysis, |
|
98 | - int $depth, |
|
99 | - int $detailed_top_places = 0, |
|
100 | - bool $use_flags = false |
|
101 | - ): self { |
|
102 | - $new = clone $this; |
|
103 | - $new->enabled = $enabled; |
|
104 | - $new->description = $description; |
|
105 | - $new->geoanalysis = $geoanalysis; |
|
106 | - $new->depth = $depth; |
|
107 | - $new->detailed_top_places = $detailed_top_places; |
|
108 | - $new->use_flags = $use_flags; |
|
109 | - return $new; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Get the view ID |
|
114 | - * |
|
115 | - * @return int |
|
116 | - */ |
|
117 | - public function id(): int |
|
118 | - { |
|
119 | - return $this->id; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Get the view type for display |
|
124 | - * |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - abstract public function type(): string; |
|
128 | - |
|
129 | - /** |
|
130 | - * Get the icon for the view type |
|
131 | - * |
|
132 | - * @param ModuleInterface $module |
|
133 | - * @return string |
|
134 | - */ |
|
135 | - abstract public function icon(ModuleInterface $module): string; |
|
136 | - |
|
137 | - /** |
|
138 | - * Return the content of the global settings section of the config page |
|
139 | - * |
|
140 | - * @param ModuleInterface $module |
|
141 | - * @return string |
|
142 | - */ |
|
143 | - abstract public function globalSettingsContent(ModuleInterface $module): string; |
|
144 | - |
|
145 | - /** |
|
146 | - * Return a view with global settings updated according to the view rules |
|
147 | - * |
|
148 | - * @param ServerRequestInterface $request |
|
149 | - * @return static |
|
150 | - */ |
|
151 | - abstract public function withGlobalSettingsUpdate(ServerRequestInterface $request): self; |
|
152 | - |
|
153 | - /** |
|
154 | - * Returns the content of the view global tab |
|
155 | - * |
|
156 | - * @param ModuleInterface $module |
|
157 | - * @param GeoAnalysisResult $result |
|
158 | - * @param array $params |
|
159 | - * @return string |
|
160 | - */ |
|
161 | - abstract public function globalTabContent( |
|
162 | - ModuleInterface $module, |
|
163 | - GeoAnalysisResult $result, |
|
164 | - array $params |
|
165 | - ): string; |
|
166 | - |
|
167 | - /** |
|
168 | - * Returns the content of the view detailed tab |
|
169 | - * |
|
170 | - * @param ModuleInterface $module |
|
171 | - * @param Collection $results |
|
172 | - * @param array $params |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - public function detailedTabContent(ModuleInterface $module, Collection $results, array $params): string |
|
176 | - { |
|
177 | - return view($module->name() . '::geoanalysisview-tab-detailed', $params + [ 'results' => $results ]); |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * Get the tree to which the view belongs |
|
182 | - * |
|
183 | - * @return Tree |
|
184 | - */ |
|
185 | - public function tree(): Tree |
|
186 | - { |
|
187 | - return $this->tree; |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Get the description of the view |
|
192 | - * |
|
193 | - * @return string |
|
194 | - */ |
|
195 | - public function description(): string |
|
196 | - { |
|
197 | - return $this->description; |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * Get whether the view is enabled |
|
202 | - * |
|
203 | - * @return bool |
|
204 | - */ |
|
205 | - public function isEnabled(): bool |
|
206 | - { |
|
207 | - return $this->enabled; |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * Get the geographical dispersion analysis for the view |
|
212 | - * |
|
213 | - * @return GeoAnalysisInterface |
|
214 | - */ |
|
215 | - public function analysis(): GeoAnalysisInterface |
|
216 | - { |
|
217 | - return $this->geoanalysis; |
|
218 | - } |
|
219 | - |
|
220 | - /** |
|
221 | - * Get the place hierarchy depth for the view |
|
222 | - * |
|
223 | - * @return int |
|
224 | - */ |
|
225 | - public function placesDepth(): int |
|
226 | - { |
|
227 | - return $this->depth; |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Get the number of places to display in the detailed tab |
|
232 | - * |
|
233 | - * @return int |
|
234 | - */ |
|
235 | - public function numberTopPlaces(): int |
|
236 | - { |
|
237 | - return $this->detailed_top_places; |
|
238 | - } |
|
239 | - |
|
240 | - /** |
|
241 | - * Get whether flags should be used in the detailed tab |
|
242 | - * |
|
243 | - * @return bool |
|
244 | - */ |
|
245 | - public function useFlags(): bool |
|
246 | - { |
|
247 | - return $this->use_flags; |
|
248 | - } |
|
29 | + private int $id; |
|
30 | + private Tree $tree; |
|
31 | + private bool $enabled; |
|
32 | + private string $description; |
|
33 | + private GeoAnalysisInterface $geoanalysis; |
|
34 | + private int $depth; |
|
35 | + private int $detailed_top_places; |
|
36 | + private bool $use_flags; |
|
37 | + |
|
38 | + /** |
|
39 | + * Constructor for AbstractGeoAnalysisView |
|
40 | + * |
|
41 | + * @param int $id |
|
42 | + * @param Tree $tree |
|
43 | + * @param bool $enabled |
|
44 | + * @param string $description |
|
45 | + * @param GeoAnalysisInterface $geoanalysis |
|
46 | + * @param int $depth |
|
47 | + * @param int $detailed_top_places |
|
48 | + * @param bool $use_flags |
|
49 | + */ |
|
50 | + final public function __construct( |
|
51 | + int $id, |
|
52 | + Tree $tree, |
|
53 | + bool $enabled, |
|
54 | + string $description, |
|
55 | + GeoAnalysisInterface $geoanalysis, |
|
56 | + int $depth, |
|
57 | + int $detailed_top_places = 0, |
|
58 | + bool $use_flags = false |
|
59 | + ) { |
|
60 | + $this->id = $id; |
|
61 | + $this->tree = $tree; |
|
62 | + $this->enabled = $enabled; |
|
63 | + $this->description = $description; |
|
64 | + $this->geoanalysis = $geoanalysis; |
|
65 | + $this->depth = $depth; |
|
66 | + $this->detailed_top_places = $detailed_top_places; |
|
67 | + $this->use_flags = $use_flags; |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Create a copy of the view with a new ID. |
|
72 | + * |
|
73 | + * @param int $id |
|
74 | + * @return static |
|
75 | + */ |
|
76 | + public function withId(int $id): self |
|
77 | + { |
|
78 | + $new = clone $this; |
|
79 | + $new->id = $id; |
|
80 | + return $new; |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * Create a copy of the view with new properties. |
|
85 | + * |
|
86 | + * @param bool $enabled |
|
87 | + * @param string $description |
|
88 | + * @param GeoAnalysisInterface $geoanalysis |
|
89 | + * @param int $depth |
|
90 | + * @param int $detailed_top_places |
|
91 | + * @param bool $use_flags |
|
92 | + * @return static |
|
93 | + */ |
|
94 | + public function with( |
|
95 | + bool $enabled, |
|
96 | + string $description, |
|
97 | + GeoAnalysisInterface $geoanalysis, |
|
98 | + int $depth, |
|
99 | + int $detailed_top_places = 0, |
|
100 | + bool $use_flags = false |
|
101 | + ): self { |
|
102 | + $new = clone $this; |
|
103 | + $new->enabled = $enabled; |
|
104 | + $new->description = $description; |
|
105 | + $new->geoanalysis = $geoanalysis; |
|
106 | + $new->depth = $depth; |
|
107 | + $new->detailed_top_places = $detailed_top_places; |
|
108 | + $new->use_flags = $use_flags; |
|
109 | + return $new; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Get the view ID |
|
114 | + * |
|
115 | + * @return int |
|
116 | + */ |
|
117 | + public function id(): int |
|
118 | + { |
|
119 | + return $this->id; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Get the view type for display |
|
124 | + * |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + abstract public function type(): string; |
|
128 | + |
|
129 | + /** |
|
130 | + * Get the icon for the view type |
|
131 | + * |
|
132 | + * @param ModuleInterface $module |
|
133 | + * @return string |
|
134 | + */ |
|
135 | + abstract public function icon(ModuleInterface $module): string; |
|
136 | + |
|
137 | + /** |
|
138 | + * Return the content of the global settings section of the config page |
|
139 | + * |
|
140 | + * @param ModuleInterface $module |
|
141 | + * @return string |
|
142 | + */ |
|
143 | + abstract public function globalSettingsContent(ModuleInterface $module): string; |
|
144 | + |
|
145 | + /** |
|
146 | + * Return a view with global settings updated according to the view rules |
|
147 | + * |
|
148 | + * @param ServerRequestInterface $request |
|
149 | + * @return static |
|
150 | + */ |
|
151 | + abstract public function withGlobalSettingsUpdate(ServerRequestInterface $request): self; |
|
152 | + |
|
153 | + /** |
|
154 | + * Returns the content of the view global tab |
|
155 | + * |
|
156 | + * @param ModuleInterface $module |
|
157 | + * @param GeoAnalysisResult $result |
|
158 | + * @param array $params |
|
159 | + * @return string |
|
160 | + */ |
|
161 | + abstract public function globalTabContent( |
|
162 | + ModuleInterface $module, |
|
163 | + GeoAnalysisResult $result, |
|
164 | + array $params |
|
165 | + ): string; |
|
166 | + |
|
167 | + /** |
|
168 | + * Returns the content of the view detailed tab |
|
169 | + * |
|
170 | + * @param ModuleInterface $module |
|
171 | + * @param Collection $results |
|
172 | + * @param array $params |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + public function detailedTabContent(ModuleInterface $module, Collection $results, array $params): string |
|
176 | + { |
|
177 | + return view($module->name() . '::geoanalysisview-tab-detailed', $params + [ 'results' => $results ]); |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * Get the tree to which the view belongs |
|
182 | + * |
|
183 | + * @return Tree |
|
184 | + */ |
|
185 | + public function tree(): Tree |
|
186 | + { |
|
187 | + return $this->tree; |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * Get the description of the view |
|
192 | + * |
|
193 | + * @return string |
|
194 | + */ |
|
195 | + public function description(): string |
|
196 | + { |
|
197 | + return $this->description; |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * Get whether the view is enabled |
|
202 | + * |
|
203 | + * @return bool |
|
204 | + */ |
|
205 | + public function isEnabled(): bool |
|
206 | + { |
|
207 | + return $this->enabled; |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * Get the geographical dispersion analysis for the view |
|
212 | + * |
|
213 | + * @return GeoAnalysisInterface |
|
214 | + */ |
|
215 | + public function analysis(): GeoAnalysisInterface |
|
216 | + { |
|
217 | + return $this->geoanalysis; |
|
218 | + } |
|
219 | + |
|
220 | + /** |
|
221 | + * Get the place hierarchy depth for the view |
|
222 | + * |
|
223 | + * @return int |
|
224 | + */ |
|
225 | + public function placesDepth(): int |
|
226 | + { |
|
227 | + return $this->depth; |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Get the number of places to display in the detailed tab |
|
232 | + * |
|
233 | + * @return int |
|
234 | + */ |
|
235 | + public function numberTopPlaces(): int |
|
236 | + { |
|
237 | + return $this->detailed_top_places; |
|
238 | + } |
|
239 | + |
|
240 | + /** |
|
241 | + * Get whether flags should be used in the detailed tab |
|
242 | + * |
|
243 | + * @return bool |
|
244 | + */ |
|
245 | + public function useFlags(): bool |
|
246 | + { |
|
247 | + return $this->use_flags; |
|
248 | + } |
|
249 | 249 | } |
@@ -21,51 +21,51 @@ |
||
21 | 21 | |
22 | 22 | class GeoAnalysisTable extends AbstractGeoAnalysisView |
23 | 23 | { |
24 | - /** |
|
25 | - * {@inheritDoc} |
|
26 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::type() |
|
27 | - */ |
|
28 | - public function type(): string |
|
29 | - { |
|
30 | - return I18N::translateContext('GEODISPERSION', 'Table'); |
|
31 | - } |
|
24 | + /** |
|
25 | + * {@inheritDoc} |
|
26 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::type() |
|
27 | + */ |
|
28 | + public function type(): string |
|
29 | + { |
|
30 | + return I18N::translateContext('GEODISPERSION', 'Table'); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * {@inheritDoc} |
|
35 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::icon() |
|
36 | - */ |
|
37 | - public function icon(ModuleInterface $module): string |
|
38 | - { |
|
39 | - return view($module->name() . '::icons/view-table', ['type' => $this->type()]); |
|
40 | - } |
|
33 | + /** |
|
34 | + * {@inheritDoc} |
|
35 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::icon() |
|
36 | + */ |
|
37 | + public function icon(ModuleInterface $module): string |
|
38 | + { |
|
39 | + return view($module->name() . '::icons/view-table', ['type' => $this->type()]); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * {@inheritDoc} |
|
44 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::globalSettingsContent() |
|
45 | - */ |
|
46 | - public function globalSettingsContent(ModuleInterface $module): string |
|
47 | - { |
|
48 | - return ''; |
|
49 | - } |
|
42 | + /** |
|
43 | + * {@inheritDoc} |
|
44 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::globalSettingsContent() |
|
45 | + */ |
|
46 | + public function globalSettingsContent(ModuleInterface $module): string |
|
47 | + { |
|
48 | + return ''; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * {@inheritDoc} |
|
53 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::withGlobalSettingsUpdate() |
|
54 | - * @return $this |
|
55 | - */ |
|
56 | - public function withGlobalSettingsUpdate(ServerRequestInterface $request): self |
|
57 | - { |
|
58 | - return $this; |
|
59 | - } |
|
51 | + /** |
|
52 | + * {@inheritDoc} |
|
53 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::withGlobalSettingsUpdate() |
|
54 | + * @return $this |
|
55 | + */ |
|
56 | + public function withGlobalSettingsUpdate(ServerRequestInterface $request): self |
|
57 | + { |
|
58 | + return $this; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * {@inheritDoc} |
|
63 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::globalTabContent() |
|
64 | - */ |
|
65 | - public function globalTabContent(ModuleInterface $module, GeoAnalysisResult $result, array $params): string |
|
66 | - { |
|
67 | - return view($module->name() . '::geoanalysisview-tab-glb-table', $params + [ |
|
68 | - 'result' => $result |
|
69 | - ]); |
|
70 | - } |
|
61 | + /** |
|
62 | + * {@inheritDoc} |
|
63 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::globalTabContent() |
|
64 | + */ |
|
65 | + public function globalTabContent(ModuleInterface $module, GeoAnalysisResult $result, array $params): string |
|
66 | + { |
|
67 | + return view($module->name() . '::geoanalysisview-tab-glb-table', $params + [ |
|
68 | + 'result' => $result |
|
69 | + ]); |
|
70 | + } |
|
71 | 71 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function icon(ModuleInterface $module): string |
38 | 38 | { |
39 | - return view($module->name() . '::icons/view-table', ['type' => $this->type()]); |
|
39 | + return view($module->name().'::icons/view-table', ['type' => $this->type()]); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function globalTabContent(ModuleInterface $module, GeoAnalysisResult $result, array $params): string |
65 | 65 | { |
66 | - return view($module->name() . '::geoanalysisview-tab-glb-table', $params + [ |
|
66 | + return view($module->name().'::geoanalysisview-tab-glb-table', $params + [ |
|
67 | 67 | 'result' => $result |
68 | 68 | ]); |
69 | 69 | } |
@@ -29,128 +29,128 @@ |
||
29 | 29 | */ |
30 | 30 | class GeoAnalysisMap extends AbstractGeoAnalysisView |
31 | 31 | { |
32 | - private ?MapColorsConfig $colors_config = null; |
|
33 | - |
|
34 | - public function type(): string |
|
35 | - { |
|
36 | - return I18N::translateContext('GEODISPERSION', 'Map'); |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * {@inheritDoc} |
|
41 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::icon() |
|
42 | - */ |
|
43 | - public function icon(ModuleInterface $module): string |
|
44 | - { |
|
45 | - return view($module->name() . '::icons/view-map', ['type' => $this->type()]); |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * {@inheritDoc} |
|
50 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::globalSettingsContent() |
|
51 | - */ |
|
52 | - public function globalSettingsContent(ModuleInterface $module): string |
|
53 | - { |
|
54 | - return view($module->name() . '::admin/view-edit-map', [ |
|
55 | - 'module_name' => $module->name(), |
|
56 | - 'view' => $this, |
|
57 | - 'colors' => $this->colors(), |
|
58 | - 'map_adapters' => app(MapAdapterDataService::class)->allForView($this, true) |
|
59 | - ]); |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * {@inheritDoc} |
|
64 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::withGlobalSettingsUpdate() |
|
65 | - * @return static |
|
66 | - */ |
|
67 | - public function withGlobalSettingsUpdate(ServerRequestInterface $request): self |
|
68 | - { |
|
69 | - $params = (array) $request->getParsedBody(); |
|
70 | - |
|
71 | - $default_color = $params['view_map_color_default'] ?? ''; |
|
72 | - $stroke_color = $params['view_map_color_stroke'] ?? ''; |
|
73 | - $maxvalue_color = $params['view_map_color_maxvalue'] ?? ''; |
|
74 | - $hover_color = $params['view_map_color_hover'] ?? ''; |
|
75 | - |
|
76 | - try { |
|
77 | - return $this->withColors(new MapColorsConfig( |
|
78 | - Hex::fromString($default_color), |
|
79 | - Hex::fromString($stroke_color), |
|
80 | - Hex::fromString($maxvalue_color), |
|
81 | - Hex::fromString($hover_color) |
|
82 | - )); |
|
83 | - } catch (InvalidColorValue $ex) { |
|
84 | - } |
|
85 | - |
|
86 | - return $this; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * {@inheritDoc} |
|
91 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::globalTabContent() |
|
92 | - */ |
|
93 | - public function globalTabContent(ModuleInterface $module, GeoAnalysisResult $result, array $params): string |
|
94 | - { |
|
95 | - $map_adapters = app(MapAdapterDataService::class)->allForView($this); |
|
96 | - |
|
97 | - $adapter_result = null; |
|
98 | - foreach ($map_adapters as $map_adapter) { |
|
99 | - $adapter_result_tmp = $map_adapter->convert($result); |
|
100 | - $adapter_result = $adapter_result === null ? |
|
101 | - $adapter_result_tmp : |
|
102 | - $adapter_result->merge($adapter_result_tmp); |
|
103 | - } |
|
104 | - |
|
105 | - if ($adapter_result === null) { |
|
106 | - return view($module->name() . '::errors/tab-error', [ |
|
107 | - 'message' => I18N::translate('The map could not be loaded.'), |
|
108 | - ]); |
|
109 | - } |
|
110 | - |
|
111 | - //phpcs:disable Generic.Files.LineLength.TooLong |
|
112 | - $basemap_provider = [ |
|
113 | - 'url' => 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
|
114 | - 'options' => [ |
|
115 | - 'attribution' => '<a href="https://www.openstreetmap.org/copyright">© OpenStreetMap</a> contributors', |
|
116 | - 'max_zoom' => 19 |
|
117 | - ] |
|
118 | - ]; |
|
119 | - //phpcs:enable |
|
120 | - |
|
121 | - return view($module->name() . '::geoanalysisview-tab-glb-map', $params + [ |
|
122 | - 'result' => $adapter_result->geoAnalysisResult(), |
|
123 | - 'features' => $adapter_result->features(), |
|
124 | - 'colors' => $this->colors(), |
|
125 | - 'basemap_provider' => $basemap_provider |
|
126 | - ]); |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * Get the color scheme configuration for the map view |
|
131 | - * |
|
132 | - * @return MapColorsConfig |
|
133 | - */ |
|
134 | - public function colors(): MapColorsConfig |
|
135 | - { |
|
136 | - return $this->colors_config ?? new MapColorsConfig( |
|
137 | - new Rgb(245, 245, 245), |
|
138 | - new Rgb(213, 213, 213), |
|
139 | - new Rgb(4, 147, 171), |
|
140 | - new Rgb(255, 102, 0) |
|
141 | - ); |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * Returns a map view with a new color scheme configuration |
|
146 | - * |
|
147 | - * @param MapColorsConfig $config |
|
148 | - * @return static |
|
149 | - */ |
|
150 | - public function withColors(?MapColorsConfig $config): self |
|
151 | - { |
|
152 | - $new = clone $this; |
|
153 | - $new->colors_config = $config; |
|
154 | - return $new; |
|
155 | - } |
|
32 | + private ?MapColorsConfig $colors_config = null; |
|
33 | + |
|
34 | + public function type(): string |
|
35 | + { |
|
36 | + return I18N::translateContext('GEODISPERSION', 'Map'); |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * {@inheritDoc} |
|
41 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::icon() |
|
42 | + */ |
|
43 | + public function icon(ModuleInterface $module): string |
|
44 | + { |
|
45 | + return view($module->name() . '::icons/view-map', ['type' => $this->type()]); |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * {@inheritDoc} |
|
50 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::globalSettingsContent() |
|
51 | + */ |
|
52 | + public function globalSettingsContent(ModuleInterface $module): string |
|
53 | + { |
|
54 | + return view($module->name() . '::admin/view-edit-map', [ |
|
55 | + 'module_name' => $module->name(), |
|
56 | + 'view' => $this, |
|
57 | + 'colors' => $this->colors(), |
|
58 | + 'map_adapters' => app(MapAdapterDataService::class)->allForView($this, true) |
|
59 | + ]); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * {@inheritDoc} |
|
64 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::withGlobalSettingsUpdate() |
|
65 | + * @return static |
|
66 | + */ |
|
67 | + public function withGlobalSettingsUpdate(ServerRequestInterface $request): self |
|
68 | + { |
|
69 | + $params = (array) $request->getParsedBody(); |
|
70 | + |
|
71 | + $default_color = $params['view_map_color_default'] ?? ''; |
|
72 | + $stroke_color = $params['view_map_color_stroke'] ?? ''; |
|
73 | + $maxvalue_color = $params['view_map_color_maxvalue'] ?? ''; |
|
74 | + $hover_color = $params['view_map_color_hover'] ?? ''; |
|
75 | + |
|
76 | + try { |
|
77 | + return $this->withColors(new MapColorsConfig( |
|
78 | + Hex::fromString($default_color), |
|
79 | + Hex::fromString($stroke_color), |
|
80 | + Hex::fromString($maxvalue_color), |
|
81 | + Hex::fromString($hover_color) |
|
82 | + )); |
|
83 | + } catch (InvalidColorValue $ex) { |
|
84 | + } |
|
85 | + |
|
86 | + return $this; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * {@inheritDoc} |
|
91 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::globalTabContent() |
|
92 | + */ |
|
93 | + public function globalTabContent(ModuleInterface $module, GeoAnalysisResult $result, array $params): string |
|
94 | + { |
|
95 | + $map_adapters = app(MapAdapterDataService::class)->allForView($this); |
|
96 | + |
|
97 | + $adapter_result = null; |
|
98 | + foreach ($map_adapters as $map_adapter) { |
|
99 | + $adapter_result_tmp = $map_adapter->convert($result); |
|
100 | + $adapter_result = $adapter_result === null ? |
|
101 | + $adapter_result_tmp : |
|
102 | + $adapter_result->merge($adapter_result_tmp); |
|
103 | + } |
|
104 | + |
|
105 | + if ($adapter_result === null) { |
|
106 | + return view($module->name() . '::errors/tab-error', [ |
|
107 | + 'message' => I18N::translate('The map could not be loaded.'), |
|
108 | + ]); |
|
109 | + } |
|
110 | + |
|
111 | + //phpcs:disable Generic.Files.LineLength.TooLong |
|
112 | + $basemap_provider = [ |
|
113 | + 'url' => 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
|
114 | + 'options' => [ |
|
115 | + 'attribution' => '<a href="https://www.openstreetmap.org/copyright">© OpenStreetMap</a> contributors', |
|
116 | + 'max_zoom' => 19 |
|
117 | + ] |
|
118 | + ]; |
|
119 | + //phpcs:enable |
|
120 | + |
|
121 | + return view($module->name() . '::geoanalysisview-tab-glb-map', $params + [ |
|
122 | + 'result' => $adapter_result->geoAnalysisResult(), |
|
123 | + 'features' => $adapter_result->features(), |
|
124 | + 'colors' => $this->colors(), |
|
125 | + 'basemap_provider' => $basemap_provider |
|
126 | + ]); |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * Get the color scheme configuration for the map view |
|
131 | + * |
|
132 | + * @return MapColorsConfig |
|
133 | + */ |
|
134 | + public function colors(): MapColorsConfig |
|
135 | + { |
|
136 | + return $this->colors_config ?? new MapColorsConfig( |
|
137 | + new Rgb(245, 245, 245), |
|
138 | + new Rgb(213, 213, 213), |
|
139 | + new Rgb(4, 147, 171), |
|
140 | + new Rgb(255, 102, 0) |
|
141 | + ); |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * Returns a map view with a new color scheme configuration |
|
146 | + * |
|
147 | + * @param MapColorsConfig $config |
|
148 | + * @return static |
|
149 | + */ |
|
150 | + public function withColors(?MapColorsConfig $config): self |
|
151 | + { |
|
152 | + $new = clone $this; |
|
153 | + $new->colors_config = $config; |
|
154 | + return $new; |
|
155 | + } |
|
156 | 156 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function icon(ModuleInterface $module): string |
44 | 44 | { |
45 | - return view($module->name() . '::icons/view-map', ['type' => $this->type()]); |
|
45 | + return view($module->name().'::icons/view-map', ['type' => $this->type()]); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function globalSettingsContent(ModuleInterface $module): string |
53 | 53 | { |
54 | - return view($module->name() . '::admin/view-edit-map', [ |
|
54 | + return view($module->name().'::admin/view-edit-map', [ |
|
55 | 55 | 'module_name' => $module->name(), |
56 | 56 | 'view' => $this, |
57 | 57 | 'colors' => $this->colors(), |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function withGlobalSettingsUpdate(ServerRequestInterface $request): self |
67 | 67 | { |
68 | - $params = (array) $request->getParsedBody(); |
|
68 | + $params = (array)$request->getParsedBody(); |
|
69 | 69 | |
70 | 70 | $default_color = $params['view_map_color_default'] ?? ''; |
71 | 71 | $stroke_color = $params['view_map_color_stroke'] ?? ''; |
72 | - $maxvalue_color = $params['view_map_color_maxvalue'] ?? ''; |
|
73 | - $hover_color = $params['view_map_color_hover'] ?? ''; |
|
72 | + $maxvalue_color = $params['view_map_color_maxvalue'] ?? ''; |
|
73 | + $hover_color = $params['view_map_color_hover'] ?? ''; |
|
74 | 74 | |
75 | 75 | try { |
76 | 76 | return $this->withColors(new MapColorsConfig( |
@@ -97,12 +97,11 @@ discard block |
||
97 | 97 | foreach ($map_adapters as $map_adapter) { |
98 | 98 | $adapter_result_tmp = $map_adapter->convert($result); |
99 | 99 | $adapter_result = $adapter_result === null ? |
100 | - $adapter_result_tmp : |
|
101 | - $adapter_result->merge($adapter_result_tmp); |
|
100 | + $adapter_result_tmp : $adapter_result->merge($adapter_result_tmp); |
|
102 | 101 | } |
103 | 102 | |
104 | 103 | if ($adapter_result === null) { |
105 | - return view($module->name() . '::errors/tab-error', [ |
|
104 | + return view($module->name().'::errors/tab-error', [ |
|
106 | 105 | 'message' => I18N::translate('The map could not be loaded.'), |
107 | 106 | ]); |
108 | 107 | } |
@@ -117,7 +116,7 @@ discard block |
||
117 | 116 | ]; |
118 | 117 | //phpcs:enable |
119 | 118 | |
120 | - return view($module->name() . '::geoanalysisview-tab-glb-map', $params + [ |
|
119 | + return view($module->name().'::geoanalysisview-tab-glb-map', $params + [ |
|
121 | 120 | 'result' => $adapter_result->geoAnalysisResult(), |
122 | 121 | 'features' => $adapter_result->features(), |
123 | 122 | 'colors' => $this->colors(), |
@@ -39,213 +39,213 @@ |
||
39 | 39 | */ |
40 | 40 | class Migration2 implements MigrationInterface |
41 | 41 | { |
42 | - /** |
|
43 | - * Mapping from old map definitions to new ones |
|
44 | - * @var array<string,mixed> MAPS_XML_MAPPING |
|
45 | - */ |
|
46 | - private const MAPS_XML_MAPPING = [ |
|
47 | - 'aubracmargeridebycommunes.xml' => 'fr-area-aubrac-lot-margeride-planeze-communes', |
|
48 | - 'calvadosbycommunes.xml' => 'fr-dpt-14-communes', |
|
49 | - 'cantalbycommunes.xml' => 'fr-dpt-15-communes', |
|
50 | - 'cotesdarmorbycommunes.xml' => 'fr-dpt-22-communes', |
|
51 | - 'essonnebycommunes.xml' => 'fr-dpt-91-communes', |
|
52 | - 'eurebycommunes.xml' => 'fr-dpt-27-communes', |
|
53 | - 'eureetloirbycommunes.xml' => 'fr-dpt-28-communes', |
|
54 | - 'francebydepartements.xml' => 'fr-metropole-departements', |
|
55 | - 'francebyregions1970.xml' => 'fr-metropole-regions-1970', |
|
56 | - 'francebyregions2016.xml' => 'fr-metropole-regions-2016', |
|
57 | - 'hauteloirebycommunes.xml' => 'fr-dpt-43-communes', |
|
58 | - 'illeetvilainebycommunes.xml' => 'fr-dpt-35-communes', |
|
59 | - 'loiretbycommunes.xml' => 'fr-dpt-45-communes', |
|
60 | - 'lozerebycodepostaux.xml' => 'fr-dpt-48-codespostaux', |
|
61 | - 'lozerebycommunes.xml' => 'fr-dpt-48-communes', |
|
62 | - 'mayennebycommunes.xml' => 'fr-dpt-53-communes', |
|
63 | - 'oisebycommunes.xml' => 'fr-dpt-60-communes', |
|
64 | - 'ornebycommunes.xml' => 'fr-dpt-61-communes', |
|
65 | - 'puydedomebycommunes.xml' => 'fr-dpt-63-communes', |
|
66 | - 'sarthebycommunes.xml' => 'fr-dpt-72-communes', |
|
67 | - 'seinemaritimebycommunes.xml' => 'fr-dpt-76-communes', |
|
68 | - 'seinesommeoisebycommunes.xml' => ['fr-dpt-60-communes', 'fr-dpt-76-communes', 'fr-dpt-80-communes'], |
|
69 | - 'valdoisebycommunes.xml' => 'fr-dpt-95-communes', |
|
70 | - 'yvelinesbycommunes.xml' => 'fr-dpt-78-communes' |
|
71 | - ]; |
|
72 | - |
|
73 | - /** |
|
74 | - * {@inheritDoc} |
|
75 | - * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
76 | - */ |
|
77 | - public function upgrade(): void |
|
78 | - { |
|
79 | - if (!DB::schema()->hasTable('maj_geodispersion')) { |
|
80 | - return; |
|
81 | - } |
|
82 | - |
|
83 | - /** @var TreeService $tree_service */ |
|
84 | - $tree_service = app(TreeService::class); |
|
85 | - /** @var GeoAnalysisViewDataService $geoview_data_service */ |
|
86 | - $geoview_data_service = app(GeoAnalysisViewDataService::class); |
|
87 | - |
|
88 | - $existing_views = DB::table('maj_geodispersion') |
|
89 | - ->select() |
|
90 | - ->get(); |
|
91 | - |
|
92 | - foreach ($existing_views as $old_view) { |
|
93 | - try { |
|
94 | - $tree = $tree_service->find((int) $old_view->majgd_file); |
|
95 | - } catch (RuntimeException $ex) { |
|
96 | - continue; |
|
97 | - } |
|
98 | - |
|
99 | - if ($old_view->majgd_map === null) { |
|
100 | - $this->migrateGeoAnalysisTable($old_view, $tree, $geoview_data_service); |
|
101 | - } else { |
|
102 | - DB::connection()->beginTransaction(); |
|
103 | - if ($this->migrateGeoAnalysisMap($old_view, $tree, $geoview_data_service)) { |
|
104 | - DB::connection()->commit(); |
|
105 | - } else { |
|
106 | - DB::connection()->rollBack(); |
|
107 | - } |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - DB::schema()->drop('maj_geodispersion'); |
|
112 | - |
|
113 | - FlashMessages::addMessage(I18N::translate( |
|
114 | - 'The geographical dispersion analyses have been migrated for webtrees 2. Please review their settings.' |
|
115 | - )); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Create a Table geographical analysis view from a migrated item. |
|
120 | - * |
|
121 | - * @param stdClass $old_view |
|
122 | - * @param Tree $tree |
|
123 | - * @param GeoAnalysisViewDataService $geoview_data_service |
|
124 | - * @return bool |
|
125 | - */ |
|
126 | - private function migrateGeoAnalysisTable( |
|
127 | - stdClass $old_view, |
|
128 | - Tree $tree, |
|
129 | - GeoAnalysisViewDataService $geoview_data_service |
|
130 | - ): bool { |
|
131 | - $new_view = new GeoAnalysisTable( |
|
132 | - 0, |
|
133 | - $tree, |
|
134 | - $old_view->majgd_status === 'enabled', |
|
135 | - $old_view->majgd_descr, |
|
136 | - app(SosaByGenerationGeoAnalysis::class), |
|
137 | - (int) $old_view->majgd_sublevel, |
|
138 | - (int) $old_view->majgd_detailsgen |
|
139 | - ); |
|
140 | - |
|
141 | - return $geoview_data_service->insertGetId($new_view) > 0; |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * Create a Map geographical analysis view from a migrated item. |
|
146 | - * |
|
147 | - * @param stdClass $old_view |
|
148 | - * @param Tree $tree |
|
149 | - * @param GeoAnalysisViewDataService $geoview_data_service |
|
150 | - * @return bool |
|
151 | - */ |
|
152 | - private function migrateGeoAnalysisMap( |
|
153 | - stdClass $old_view, |
|
154 | - Tree $tree, |
|
155 | - GeoAnalysisViewDataService $geoview_data_service |
|
156 | - ): bool { |
|
157 | - /** @var MapDefinitionsService $map_definition_service */ |
|
158 | - $map_definition_service = app(MapDefinitionsService::class); |
|
159 | - /** @var MapAdapterDataService $mapadapter_data_service */ |
|
160 | - $mapadapter_data_service = app(MapAdapterDataService::class); |
|
161 | - |
|
162 | - $new_view = new GeoAnalysisMap( |
|
163 | - 0, |
|
164 | - $tree, |
|
165 | - $old_view->majgd_status === 'enabled', |
|
166 | - $old_view->majgd_descr, |
|
167 | - app(SosaByGenerationGeoAnalysis::class), |
|
168 | - (int) $old_view->majgd_sublevel, |
|
169 | - (int) $old_view->majgd_detailsgen |
|
170 | - ); |
|
171 | - |
|
172 | - $view_id = $geoview_data_service->insertGetId($new_view); |
|
173 | - if ($view_id === 0) { |
|
174 | - return false; |
|
175 | - } |
|
176 | - $new_view = $new_view->withId($view_id); |
|
177 | - |
|
178 | - $colors = $new_view->colors(); |
|
179 | - foreach ($this->mapIdsFromOld($old_view->majgd_map) as $new_map_id) { |
|
180 | - $map = $map_definition_service->find($new_map_id); |
|
181 | - if ($map === null) { |
|
182 | - return false; |
|
183 | - } |
|
184 | - $colors = $this->colorsFromMap($new_map_id); |
|
185 | - |
|
186 | - /** @var SimplePlaceMapper $mapper */ |
|
187 | - $mapper = app(SimplePlaceMapper::class); |
|
188 | - $mapview_config = new MapViewConfig($this->mappingPropertyForMap($new_map_id), $mapper->config()); |
|
189 | - $map_adapter = new GeoAnalysisMapAdapter(0, $view_id, $map, $mapper, $mapview_config); |
|
190 | - |
|
191 | - $mapadapter_data_service->insertGetId($map_adapter); |
|
192 | - } |
|
193 | - |
|
194 | - return $geoview_data_service->update($new_view->withColors($colors)) > 0; |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * Get all new map definitions IDs representing an old map definition |
|
199 | - * |
|
200 | - * @param string $map_xml |
|
201 | - * @return array |
|
202 | - */ |
|
203 | - private function mapIdsFromOld(string $map_xml): array |
|
204 | - { |
|
205 | - $mapping = self::MAPS_XML_MAPPING[$map_xml] ?? []; |
|
206 | - return is_array($mapping) ? $mapping : [ $mapping ]; |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * Get the mapping property to be used for the migrated map adapter |
|
211 | - * |
|
212 | - * @param string $map_id |
|
213 | - * @return string |
|
214 | - */ |
|
215 | - private function mappingPropertyForMap(string $map_id): string |
|
216 | - { |
|
217 | - switch ($map_id) { |
|
218 | - case 'fr-metropole-regions-1970': |
|
219 | - case 'fr-metropole-regions-2016': |
|
220 | - return 'region_insee_libelle'; |
|
221 | - case 'fr-metropole-departements': |
|
222 | - return 'dpt_insee_libelle'; |
|
223 | - case 'fr-dpt-48-codespostaux': |
|
224 | - return 'code_postal'; |
|
225 | - default: |
|
226 | - return 'commune_insee_libelle'; |
|
227 | - } |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Get the color configuration to be used for the migrated map view |
|
232 | - * |
|
233 | - * @param string $map_id |
|
234 | - * @return MapColorsConfig |
|
235 | - */ |
|
236 | - private function colorsFromMap(string $map_id): MapColorsConfig |
|
237 | - { |
|
238 | - $default = Hex::fromString('#f5f5f5'); |
|
239 | - $stroke = Hex::fromString('#d5d5d5'); |
|
240 | - $hover = Hex::fromString('#ff6600'); |
|
241 | - |
|
242 | - switch ($map_id) { |
|
243 | - case 'fr-metropole-departements': |
|
244 | - return new MapColorsConfig($default, $stroke, Hex::fromString('#0493ab'), $hover); |
|
245 | - case 'fr-dpt-48-codespostaux': |
|
246 | - return new MapColorsConfig($default, $stroke, Hex::fromString('#44aa00'), $hover); |
|
247 | - default: |
|
248 | - return new MapColorsConfig($default, $stroke, Hex::fromString('#e2a61d'), $hover); |
|
249 | - } |
|
250 | - } |
|
42 | + /** |
|
43 | + * Mapping from old map definitions to new ones |
|
44 | + * @var array<string,mixed> MAPS_XML_MAPPING |
|
45 | + */ |
|
46 | + private const MAPS_XML_MAPPING = [ |
|
47 | + 'aubracmargeridebycommunes.xml' => 'fr-area-aubrac-lot-margeride-planeze-communes', |
|
48 | + 'calvadosbycommunes.xml' => 'fr-dpt-14-communes', |
|
49 | + 'cantalbycommunes.xml' => 'fr-dpt-15-communes', |
|
50 | + 'cotesdarmorbycommunes.xml' => 'fr-dpt-22-communes', |
|
51 | + 'essonnebycommunes.xml' => 'fr-dpt-91-communes', |
|
52 | + 'eurebycommunes.xml' => 'fr-dpt-27-communes', |
|
53 | + 'eureetloirbycommunes.xml' => 'fr-dpt-28-communes', |
|
54 | + 'francebydepartements.xml' => 'fr-metropole-departements', |
|
55 | + 'francebyregions1970.xml' => 'fr-metropole-regions-1970', |
|
56 | + 'francebyregions2016.xml' => 'fr-metropole-regions-2016', |
|
57 | + 'hauteloirebycommunes.xml' => 'fr-dpt-43-communes', |
|
58 | + 'illeetvilainebycommunes.xml' => 'fr-dpt-35-communes', |
|
59 | + 'loiretbycommunes.xml' => 'fr-dpt-45-communes', |
|
60 | + 'lozerebycodepostaux.xml' => 'fr-dpt-48-codespostaux', |
|
61 | + 'lozerebycommunes.xml' => 'fr-dpt-48-communes', |
|
62 | + 'mayennebycommunes.xml' => 'fr-dpt-53-communes', |
|
63 | + 'oisebycommunes.xml' => 'fr-dpt-60-communes', |
|
64 | + 'ornebycommunes.xml' => 'fr-dpt-61-communes', |
|
65 | + 'puydedomebycommunes.xml' => 'fr-dpt-63-communes', |
|
66 | + 'sarthebycommunes.xml' => 'fr-dpt-72-communes', |
|
67 | + 'seinemaritimebycommunes.xml' => 'fr-dpt-76-communes', |
|
68 | + 'seinesommeoisebycommunes.xml' => ['fr-dpt-60-communes', 'fr-dpt-76-communes', 'fr-dpt-80-communes'], |
|
69 | + 'valdoisebycommunes.xml' => 'fr-dpt-95-communes', |
|
70 | + 'yvelinesbycommunes.xml' => 'fr-dpt-78-communes' |
|
71 | + ]; |
|
72 | + |
|
73 | + /** |
|
74 | + * {@inheritDoc} |
|
75 | + * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
76 | + */ |
|
77 | + public function upgrade(): void |
|
78 | + { |
|
79 | + if (!DB::schema()->hasTable('maj_geodispersion')) { |
|
80 | + return; |
|
81 | + } |
|
82 | + |
|
83 | + /** @var TreeService $tree_service */ |
|
84 | + $tree_service = app(TreeService::class); |
|
85 | + /** @var GeoAnalysisViewDataService $geoview_data_service */ |
|
86 | + $geoview_data_service = app(GeoAnalysisViewDataService::class); |
|
87 | + |
|
88 | + $existing_views = DB::table('maj_geodispersion') |
|
89 | + ->select() |
|
90 | + ->get(); |
|
91 | + |
|
92 | + foreach ($existing_views as $old_view) { |
|
93 | + try { |
|
94 | + $tree = $tree_service->find((int) $old_view->majgd_file); |
|
95 | + } catch (RuntimeException $ex) { |
|
96 | + continue; |
|
97 | + } |
|
98 | + |
|
99 | + if ($old_view->majgd_map === null) { |
|
100 | + $this->migrateGeoAnalysisTable($old_view, $tree, $geoview_data_service); |
|
101 | + } else { |
|
102 | + DB::connection()->beginTransaction(); |
|
103 | + if ($this->migrateGeoAnalysisMap($old_view, $tree, $geoview_data_service)) { |
|
104 | + DB::connection()->commit(); |
|
105 | + } else { |
|
106 | + DB::connection()->rollBack(); |
|
107 | + } |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + DB::schema()->drop('maj_geodispersion'); |
|
112 | + |
|
113 | + FlashMessages::addMessage(I18N::translate( |
|
114 | + 'The geographical dispersion analyses have been migrated for webtrees 2. Please review their settings.' |
|
115 | + )); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Create a Table geographical analysis view from a migrated item. |
|
120 | + * |
|
121 | + * @param stdClass $old_view |
|
122 | + * @param Tree $tree |
|
123 | + * @param GeoAnalysisViewDataService $geoview_data_service |
|
124 | + * @return bool |
|
125 | + */ |
|
126 | + private function migrateGeoAnalysisTable( |
|
127 | + stdClass $old_view, |
|
128 | + Tree $tree, |
|
129 | + GeoAnalysisViewDataService $geoview_data_service |
|
130 | + ): bool { |
|
131 | + $new_view = new GeoAnalysisTable( |
|
132 | + 0, |
|
133 | + $tree, |
|
134 | + $old_view->majgd_status === 'enabled', |
|
135 | + $old_view->majgd_descr, |
|
136 | + app(SosaByGenerationGeoAnalysis::class), |
|
137 | + (int) $old_view->majgd_sublevel, |
|
138 | + (int) $old_view->majgd_detailsgen |
|
139 | + ); |
|
140 | + |
|
141 | + return $geoview_data_service->insertGetId($new_view) > 0; |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * Create a Map geographical analysis view from a migrated item. |
|
146 | + * |
|
147 | + * @param stdClass $old_view |
|
148 | + * @param Tree $tree |
|
149 | + * @param GeoAnalysisViewDataService $geoview_data_service |
|
150 | + * @return bool |
|
151 | + */ |
|
152 | + private function migrateGeoAnalysisMap( |
|
153 | + stdClass $old_view, |
|
154 | + Tree $tree, |
|
155 | + GeoAnalysisViewDataService $geoview_data_service |
|
156 | + ): bool { |
|
157 | + /** @var MapDefinitionsService $map_definition_service */ |
|
158 | + $map_definition_service = app(MapDefinitionsService::class); |
|
159 | + /** @var MapAdapterDataService $mapadapter_data_service */ |
|
160 | + $mapadapter_data_service = app(MapAdapterDataService::class); |
|
161 | + |
|
162 | + $new_view = new GeoAnalysisMap( |
|
163 | + 0, |
|
164 | + $tree, |
|
165 | + $old_view->majgd_status === 'enabled', |
|
166 | + $old_view->majgd_descr, |
|
167 | + app(SosaByGenerationGeoAnalysis::class), |
|
168 | + (int) $old_view->majgd_sublevel, |
|
169 | + (int) $old_view->majgd_detailsgen |
|
170 | + ); |
|
171 | + |
|
172 | + $view_id = $geoview_data_service->insertGetId($new_view); |
|
173 | + if ($view_id === 0) { |
|
174 | + return false; |
|
175 | + } |
|
176 | + $new_view = $new_view->withId($view_id); |
|
177 | + |
|
178 | + $colors = $new_view->colors(); |
|
179 | + foreach ($this->mapIdsFromOld($old_view->majgd_map) as $new_map_id) { |
|
180 | + $map = $map_definition_service->find($new_map_id); |
|
181 | + if ($map === null) { |
|
182 | + return false; |
|
183 | + } |
|
184 | + $colors = $this->colorsFromMap($new_map_id); |
|
185 | + |
|
186 | + /** @var SimplePlaceMapper $mapper */ |
|
187 | + $mapper = app(SimplePlaceMapper::class); |
|
188 | + $mapview_config = new MapViewConfig($this->mappingPropertyForMap($new_map_id), $mapper->config()); |
|
189 | + $map_adapter = new GeoAnalysisMapAdapter(0, $view_id, $map, $mapper, $mapview_config); |
|
190 | + |
|
191 | + $mapadapter_data_service->insertGetId($map_adapter); |
|
192 | + } |
|
193 | + |
|
194 | + return $geoview_data_service->update($new_view->withColors($colors)) > 0; |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * Get all new map definitions IDs representing an old map definition |
|
199 | + * |
|
200 | + * @param string $map_xml |
|
201 | + * @return array |
|
202 | + */ |
|
203 | + private function mapIdsFromOld(string $map_xml): array |
|
204 | + { |
|
205 | + $mapping = self::MAPS_XML_MAPPING[$map_xml] ?? []; |
|
206 | + return is_array($mapping) ? $mapping : [ $mapping ]; |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * Get the mapping property to be used for the migrated map adapter |
|
211 | + * |
|
212 | + * @param string $map_id |
|
213 | + * @return string |
|
214 | + */ |
|
215 | + private function mappingPropertyForMap(string $map_id): string |
|
216 | + { |
|
217 | + switch ($map_id) { |
|
218 | + case 'fr-metropole-regions-1970': |
|
219 | + case 'fr-metropole-regions-2016': |
|
220 | + return 'region_insee_libelle'; |
|
221 | + case 'fr-metropole-departements': |
|
222 | + return 'dpt_insee_libelle'; |
|
223 | + case 'fr-dpt-48-codespostaux': |
|
224 | + return 'code_postal'; |
|
225 | + default: |
|
226 | + return 'commune_insee_libelle'; |
|
227 | + } |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Get the color configuration to be used for the migrated map view |
|
232 | + * |
|
233 | + * @param string $map_id |
|
234 | + * @return MapColorsConfig |
|
235 | + */ |
|
236 | + private function colorsFromMap(string $map_id): MapColorsConfig |
|
237 | + { |
|
238 | + $default = Hex::fromString('#f5f5f5'); |
|
239 | + $stroke = Hex::fromString('#d5d5d5'); |
|
240 | + $hover = Hex::fromString('#ff6600'); |
|
241 | + |
|
242 | + switch ($map_id) { |
|
243 | + case 'fr-metropole-departements': |
|
244 | + return new MapColorsConfig($default, $stroke, Hex::fromString('#0493ab'), $hover); |
|
245 | + case 'fr-dpt-48-codespostaux': |
|
246 | + return new MapColorsConfig($default, $stroke, Hex::fromString('#44aa00'), $hover); |
|
247 | + default: |
|
248 | + return new MapColorsConfig($default, $stroke, Hex::fromString('#e2a61d'), $hover); |
|
249 | + } |
|
250 | + } |
|
251 | 251 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | foreach ($existing_views as $old_view) { |
93 | 93 | try { |
94 | - $tree = $tree_service->find((int) $old_view->majgd_file); |
|
94 | + $tree = $tree_service->find((int)$old_view->majgd_file); |
|
95 | 95 | } catch (RuntimeException $ex) { |
96 | 96 | continue; |
97 | 97 | } |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | $old_view->majgd_status === 'enabled', |
135 | 135 | $old_view->majgd_descr, |
136 | 136 | app(SosaByGenerationGeoAnalysis::class), |
137 | - (int) $old_view->majgd_sublevel, |
|
138 | - (int) $old_view->majgd_detailsgen |
|
137 | + (int)$old_view->majgd_sublevel, |
|
138 | + (int)$old_view->majgd_detailsgen |
|
139 | 139 | ); |
140 | 140 | |
141 | 141 | return $geoview_data_service->insertGetId($new_view) > 0; |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | $old_view->majgd_status === 'enabled', |
166 | 166 | $old_view->majgd_descr, |
167 | 167 | app(SosaByGenerationGeoAnalysis::class), |
168 | - (int) $old_view->majgd_sublevel, |
|
169 | - (int) $old_view->majgd_detailsgen |
|
168 | + (int)$old_view->majgd_sublevel, |
|
169 | + (int)$old_view->majgd_detailsgen |
|
170 | 170 | ); |
171 | 171 | |
172 | 172 | $view_id = $geoview_data_service->insertGetId($new_view); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | private function mapIdsFromOld(string $map_xml): array |
204 | 204 | { |
205 | 205 | $mapping = self::MAPS_XML_MAPPING[$map_xml] ?? []; |
206 | - return is_array($mapping) ? $mapping : [ $mapping ]; |
|
206 | + return is_array($mapping) ? $mapping : [$mapping]; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |