@@ -19,10 +19,10 @@ |
||
19 | 19 | */ |
20 | 20 | interface ModulePlaceMapperProviderInterface |
21 | 21 | { |
22 | - /** |
|
23 | - * List place mappers provided by the module as an array. |
|
24 | - * |
|
25 | - * @return string[] List of place mappers |
|
26 | - */ |
|
27 | - public function listPlaceMappers(): array; |
|
22 | + /** |
|
23 | + * List place mappers provided by the module as an array. |
|
24 | + * |
|
25 | + * @return string[] List of place mappers |
|
26 | + */ |
|
27 | + public function listPlaceMappers(): array; |
|
28 | 28 | } |
@@ -18,26 +18,26 @@ |
||
18 | 18 | */ |
19 | 19 | interface MapViewConfigInterface |
20 | 20 | { |
21 | - /** |
|
22 | - * Get the feature property to be used for mapping the map feature with the analysis results |
|
23 | - * |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - function mapMappingProperty(): string; |
|
21 | + /** |
|
22 | + * Get the feature property to be used for mapping the map feature with the analysis results |
|
23 | + * |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + function mapMappingProperty(): string; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Get the config of the mapper associated with the map view |
|
30 | - * |
|
31 | - * @return PlaceMapperConfigInterface |
|
32 | - */ |
|
33 | - function mapperConfig(): PlaceMapperConfigInterface; |
|
28 | + /** |
|
29 | + * Get the config of the mapper associated with the map view |
|
30 | + * |
|
31 | + * @return PlaceMapperConfigInterface |
|
32 | + */ |
|
33 | + function mapperConfig(): PlaceMapperConfigInterface; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Get a MapViewConfigInterface object with the new properties |
|
37 | - * |
|
38 | - * @param string $mapping_property |
|
39 | - * @param PlaceMapperConfigInterface $mapper_config |
|
40 | - * @return self |
|
41 | - */ |
|
42 | - function with(string $mapping_property, PlaceMapperConfigInterface $mapper_config): self; |
|
35 | + /** |
|
36 | + * Get a MapViewConfigInterface object with the new properties |
|
37 | + * |
|
38 | + * @param string $mapping_property |
|
39 | + * @param PlaceMapperConfigInterface $mapper_config |
|
40 | + * @return self |
|
41 | + */ |
|
42 | + function with(string $mapping_property, PlaceMapperConfigInterface $mapper_config): self; |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -20,10 +20,10 @@ |
||
20 | 20 | interface ModuleGeoAnalysisProviderInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * List geographical analyses provided by the module as an array. |
|
25 | - * |
|
26 | - * @return string[] List of geographical analyses |
|
27 | - */ |
|
28 | - public function listGeoAnalyses(): array; |
|
23 | + /** |
|
24 | + * List geographical analyses provided by the module as an array. |
|
25 | + * |
|
26 | + * @return string[] List of geographical analyses |
|
27 | + */ |
|
28 | + public function listGeoAnalyses(): array; |
|
29 | 29 | } |
@@ -21,54 +21,54 @@ |
||
21 | 21 | */ |
22 | 22 | interface PlaceMapperInterface |
23 | 23 | { |
24 | - /** |
|
25 | - * Get the Place mapper title |
|
26 | - * |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - function title(): string; |
|
24 | + /** |
|
25 | + * Get the Place mapper title |
|
26 | + * |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + function title(): string; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Boot the Place mapper |
|
33 | - */ |
|
34 | - function boot(): void; |
|
31 | + /** |
|
32 | + * Boot the Place mapper |
|
33 | + */ |
|
34 | + function boot(): void; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Get the configuration associated to the mapper |
|
38 | - * |
|
39 | - * @return PlaceMapperConfigInterface |
|
40 | - */ |
|
41 | - function config(): PlaceMapperConfigInterface; |
|
36 | + /** |
|
37 | + * Get the configuration associated to the mapper |
|
38 | + * |
|
39 | + * @return PlaceMapperConfigInterface |
|
40 | + */ |
|
41 | + function config(): PlaceMapperConfigInterface; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Set the configured associated to the mapper |
|
45 | - * |
|
46 | - * @param PlaceMapperConfigInterface $config |
|
47 | - */ |
|
48 | - function setConfig(PlaceMapperConfigInterface $config): void; |
|
43 | + /** |
|
44 | + * Set the configured associated to the mapper |
|
45 | + * |
|
46 | + * @param PlaceMapperConfigInterface $config |
|
47 | + */ |
|
48 | + function setConfig(PlaceMapperConfigInterface $config): void; |
|
49 | 49 | |
50 | - /** |
|
51 | - * Get the data associated to the mapper, for a specific key |
|
52 | - * |
|
53 | - * @param string $key |
|
54 | - * @return null|mixed |
|
55 | - */ |
|
56 | - function data(string $key); |
|
50 | + /** |
|
51 | + * Get the data associated to the mapper, for a specific key |
|
52 | + * |
|
53 | + * @param string $key |
|
54 | + * @return null|mixed |
|
55 | + */ |
|
56 | + function data(string $key); |
|
57 | 57 | |
58 | - /** |
|
59 | - * Set the data associated to the mapper, for a specific key |
|
60 | - * |
|
61 | - * @param string $key |
|
62 | - * @param mixed $data |
|
63 | - */ |
|
64 | - function setData(string $key, $data): void; |
|
58 | + /** |
|
59 | + * Set the data associated to the mapper, for a specific key |
|
60 | + * |
|
61 | + * @param string $key |
|
62 | + * @param mixed $data |
|
63 | + */ |
|
64 | + function setData(string $key, $data): void; |
|
65 | 65 | |
66 | - /** |
|
67 | - * Return the property value of the feature identifying a place in a GeoJson map. |
|
68 | - * |
|
69 | - * @param Place $place |
|
70 | - * @param string $feature_property |
|
71 | - * @return string|NULL |
|
72 | - */ |
|
73 | - function map(Place $place, string $feature_property) : ?string; |
|
66 | + /** |
|
67 | + * Return the property value of the feature identifying a place in a GeoJson map. |
|
68 | + * |
|
69 | + * @param Place $place |
|
70 | + * @param string $feature_property |
|
71 | + * @return string|NULL |
|
72 | + */ |
|
73 | + function map(Place $place, string $feature_property) : ?string; |
|
74 | 74 | } |
75 | 75 | \ No newline at end of file |
@@ -23,45 +23,45 @@ |
||
23 | 23 | */ |
24 | 24 | interface PlaceMapperConfigInterface extends JsonSerializable |
25 | 25 | { |
26 | - /** |
|
27 | - * Deserialise the mapper configuration from a string or an array |
|
28 | - * |
|
29 | - * @param mixed $config |
|
30 | - * @return self |
|
31 | - */ |
|
32 | - function jsonDeserialize($config): self; |
|
26 | + /** |
|
27 | + * Deserialise the mapper configuration from a string or an array |
|
28 | + * |
|
29 | + * @param mixed $config |
|
30 | + * @return self |
|
31 | + */ |
|
32 | + function jsonDeserialize($config): self; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Check if the configuration contains a specific key |
|
36 | - * |
|
37 | - * @param string $key |
|
38 | - * @return bool |
|
39 | - */ |
|
40 | - function has(string $key): bool; |
|
34 | + /** |
|
35 | + * Check if the configuration contains a specific key |
|
36 | + * |
|
37 | + * @param string $key |
|
38 | + * @return bool |
|
39 | + */ |
|
40 | + function has(string $key): bool; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Return the configuration associated with a key, or a default value if none found. |
|
44 | - * |
|
45 | - * @param string $key |
|
46 | - * @param mixed|null $default |
|
47 | - * @return mixed|null |
|
48 | - */ |
|
49 | - function get(string $key, $default = null); |
|
42 | + /** |
|
43 | + * Return the configuration associated with a key, or a default value if none found. |
|
44 | + * |
|
45 | + * @param string $key |
|
46 | + * @param mixed|null $default |
|
47 | + * @return mixed|null |
|
48 | + */ |
|
49 | + function get(string $key, $default = null); |
|
50 | 50 | |
51 | - /** |
|
52 | - * Return the content of the mapper configuration section of the config page |
|
53 | - * |
|
54 | - * @param ModuleInterface $module |
|
55 | - * @param Tree $tree |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - function configContent(ModuleInterface $module, Tree $tree): string; |
|
51 | + /** |
|
52 | + * Return the content of the mapper configuration section of the config page |
|
53 | + * |
|
54 | + * @param ModuleInterface $module |
|
55 | + * @param Tree $tree |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + function configContent(ModuleInterface $module, Tree $tree): string; |
|
59 | 59 | |
60 | - /** |
|
61 | - * Return a PlaceMapperConfigInterface object updated according to its mapper configuration rules |
|
62 | - * |
|
63 | - * @param ServerRequestInterface $request |
|
64 | - * @return self |
|
65 | - */ |
|
66 | - function withConfigUpdate(ServerRequestInterface $request): self; |
|
60 | + /** |
|
61 | + * Return a PlaceMapperConfigInterface object updated according to its mapper configuration rules |
|
62 | + * |
|
63 | + * @param ServerRequestInterface $request |
|
64 | + * @return self |
|
65 | + */ |
|
66 | + function withConfigUpdate(ServerRequestInterface $request): self; |
|
67 | 67 | } |
68 | 68 | \ No newline at end of file |
@@ -33,159 +33,159 @@ |
||
33 | 33 | */ |
34 | 34 | class WelcomeBlockModule extends AbstractModule implements ModuleMyArtJaubInterface, ModuleBlockInterface |
35 | 35 | { |
36 | - use ModuleMyArtJaubTrait; |
|
37 | - use ModuleBlockTrait; |
|
38 | - |
|
39 | - /** |
|
40 | - * {@inheritDoc} |
|
41 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
42 | - */ |
|
43 | - public function title(): string |
|
44 | - { |
|
45 | - return /* I18N: Name of the “WelcomeBlock” module */ I18N::translate('MyArtJaub Welcome Block'); |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * {@inheritDoc} |
|
50 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
51 | - */ |
|
52 | - public function description(): string |
|
53 | - { |
|
54 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
55 | - return /* I18N: Description of the “WelcomeBlock” module */ I18N::translate('The MyArtJaub Welcome block welcomes the visitor to the site, allows a quick login to the site, and displays statistics on visits.'); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * {@inheritDoc} |
|
60 | - * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
61 | - */ |
|
62 | - public function loadRoutes(Map $router): void |
|
63 | - { |
|
64 | - $router->attach('', '', static function (Map $router): void { |
|
65 | - |
|
66 | - $router->attach('', '/module-maj/welcomeblock/{block_id}', static function (Map $router): void { |
|
67 | - $router->tokens(['block_id' => '\d+']); |
|
68 | - $router->get(MatomoStats::class, '/matomostats', MatomoStats::class); |
|
69 | - }); |
|
70 | - }); |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * {@inheritDoc} |
|
75 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
76 | - */ |
|
77 | - public function customModuleVersion(): string |
|
78 | - { |
|
79 | - return '2.0.11-v.2'; |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * {@inheritDoc} |
|
84 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::getBlock() |
|
85 | - */ |
|
86 | - public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string |
|
87 | - { |
|
88 | - $fab_welcome_block_view = app(\Fisharebest\Webtrees\Module\WelcomeBlockModule::class) |
|
89 | - ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED); |
|
90 | - |
|
91 | - $fab_login_block_view = app(\Fisharebest\Webtrees\Module\LoginBlockModule::class) |
|
92 | - ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED); |
|
93 | - |
|
94 | - $content = view($this->name() . '::block-embed', [ |
|
95 | - 'block_id' => $block_id, |
|
96 | - 'fab_welcome_block_view' => $fab_welcome_block_view, |
|
97 | - 'fab_login_block_view' => $fab_login_block_view, |
|
98 | - 'matomo_enabled' => $this->isMatomoEnabled($block_id), |
|
99 | - 'js_script_url' => $this->assetUrl('js/welcomeblock.min.js') |
|
100 | - ]); |
|
101 | - |
|
102 | - if ($context !== self::CONTEXT_EMBED) { |
|
103 | - return view('modules/block-template', [ |
|
104 | - 'block' => Str::kebab($this->name()), |
|
105 | - 'id' => $block_id, |
|
106 | - 'config_url' => $this->configUrl($tree, $context, $block_id), |
|
107 | - 'title' => $tree->title(), |
|
108 | - 'content' => $content, |
|
109 | - ]); |
|
110 | - } |
|
111 | - |
|
112 | - return $content; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * {@inheritDoc} |
|
117 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::isTreeBlock() |
|
118 | - */ |
|
119 | - public function isTreeBlock(): bool |
|
120 | - { |
|
121 | - return true; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * {@inheritDoc} |
|
126 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::editBlockConfiguration() |
|
127 | - */ |
|
128 | - public function editBlockConfiguration(Tree $tree, int $block_id): string |
|
129 | - { |
|
130 | - return view($this->name() . '::config', $this->matomoSettings($block_id)); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * {@inheritDoc} |
|
135 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::saveBlockConfiguration() |
|
136 | - */ |
|
137 | - public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void |
|
138 | - { |
|
139 | - $params = (array) $request->getParsedBody(); |
|
140 | - |
|
141 | - $matomo_enabled = $params['matomo_enabled'] == 'yes'; |
|
142 | - $this->setBlockSetting($block_id, 'matomo_enabled', $matomo_enabled ? 'yes' : 'no'); |
|
143 | - if (!$matomo_enabled) { |
|
144 | - return; |
|
145 | - } |
|
146 | - |
|
147 | - if (filter_var($params['matomo_url'], FILTER_VALIDATE_URL) === false) { |
|
148 | - FlashMessages::addMessage(I18N::translate('The Matomo URL provided is not valid.'), 'danger'); |
|
149 | - return; |
|
150 | - } |
|
151 | - |
|
152 | - if (filter_var($params['matomo_siteid'], FILTER_VALIDATE_INT) === false) { |
|
153 | - FlashMessages::addMessage(I18N::translate('The Matomo Site ID provided is not valid.'), 'danger'); |
|
154 | - return; |
|
155 | - } |
|
156 | - |
|
157 | - $this |
|
158 | - ->setBlockSetting($block_id, 'matomo_url', trim($params['matomo_url'])) |
|
159 | - ->setBlockSetting($block_id, 'matomo_token', trim($params['matomo_token'])) |
|
160 | - ->setBlockSetting($block_id, 'matomo_siteid', $params['matomo_siteid']); |
|
161 | - |
|
162 | - Registry::cache()->file()->forget($this->name() . '-matomovisits-yearly-' . $block_id); |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Returns whether Matomo statistics is enabled for a specific MyArtJaub WelcomeBlock block |
|
167 | - * |
|
168 | - * @param int $block_id |
|
169 | - * @return bool |
|
170 | - */ |
|
171 | - public function isMatomoEnabled(int $block_id): bool |
|
172 | - { |
|
173 | - return $this->getBlockSetting($block_id, 'matomo_enabled', 'no') === 'yes'; |
|
174 | - } |
|
175 | - |
|
176 | - /** |
|
177 | - * Returns settings for retrieving Matomo statistics for a specific MyArtJaub WelcomeBlock block |
|
178 | - * |
|
179 | - * @param int $block_id |
|
180 | - * @return array<string, mixed> |
|
181 | - */ |
|
182 | - public function matomoSettings(int $block_id): array |
|
183 | - { |
|
184 | - return [ |
|
185 | - 'matomo_enabled' => $this->isMatomoEnabled($block_id), |
|
186 | - 'matomo_url' => $this->getBlockSetting($block_id, 'matomo_url'), |
|
187 | - 'matomo_token' => $this->getBlockSetting($block_id, 'matomo_token'), |
|
188 | - 'matomo_siteid' => (int) $this->getBlockSetting($block_id, 'matomo_siteid', '0') |
|
189 | - ]; |
|
190 | - } |
|
36 | + use ModuleMyArtJaubTrait; |
|
37 | + use ModuleBlockTrait; |
|
38 | + |
|
39 | + /** |
|
40 | + * {@inheritDoc} |
|
41 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
42 | + */ |
|
43 | + public function title(): string |
|
44 | + { |
|
45 | + return /* I18N: Name of the “WelcomeBlock” module */ I18N::translate('MyArtJaub Welcome Block'); |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * {@inheritDoc} |
|
50 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
51 | + */ |
|
52 | + public function description(): string |
|
53 | + { |
|
54 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
55 | + return /* I18N: Description of the “WelcomeBlock” module */ I18N::translate('The MyArtJaub Welcome block welcomes the visitor to the site, allows a quick login to the site, and displays statistics on visits.'); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * {@inheritDoc} |
|
60 | + * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
61 | + */ |
|
62 | + public function loadRoutes(Map $router): void |
|
63 | + { |
|
64 | + $router->attach('', '', static function (Map $router): void { |
|
65 | + |
|
66 | + $router->attach('', '/module-maj/welcomeblock/{block_id}', static function (Map $router): void { |
|
67 | + $router->tokens(['block_id' => '\d+']); |
|
68 | + $router->get(MatomoStats::class, '/matomostats', MatomoStats::class); |
|
69 | + }); |
|
70 | + }); |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * {@inheritDoc} |
|
75 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
76 | + */ |
|
77 | + public function customModuleVersion(): string |
|
78 | + { |
|
79 | + return '2.0.11-v.2'; |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * {@inheritDoc} |
|
84 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::getBlock() |
|
85 | + */ |
|
86 | + public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string |
|
87 | + { |
|
88 | + $fab_welcome_block_view = app(\Fisharebest\Webtrees\Module\WelcomeBlockModule::class) |
|
89 | + ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED); |
|
90 | + |
|
91 | + $fab_login_block_view = app(\Fisharebest\Webtrees\Module\LoginBlockModule::class) |
|
92 | + ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED); |
|
93 | + |
|
94 | + $content = view($this->name() . '::block-embed', [ |
|
95 | + 'block_id' => $block_id, |
|
96 | + 'fab_welcome_block_view' => $fab_welcome_block_view, |
|
97 | + 'fab_login_block_view' => $fab_login_block_view, |
|
98 | + 'matomo_enabled' => $this->isMatomoEnabled($block_id), |
|
99 | + 'js_script_url' => $this->assetUrl('js/welcomeblock.min.js') |
|
100 | + ]); |
|
101 | + |
|
102 | + if ($context !== self::CONTEXT_EMBED) { |
|
103 | + return view('modules/block-template', [ |
|
104 | + 'block' => Str::kebab($this->name()), |
|
105 | + 'id' => $block_id, |
|
106 | + 'config_url' => $this->configUrl($tree, $context, $block_id), |
|
107 | + 'title' => $tree->title(), |
|
108 | + 'content' => $content, |
|
109 | + ]); |
|
110 | + } |
|
111 | + |
|
112 | + return $content; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * {@inheritDoc} |
|
117 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::isTreeBlock() |
|
118 | + */ |
|
119 | + public function isTreeBlock(): bool |
|
120 | + { |
|
121 | + return true; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * {@inheritDoc} |
|
126 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::editBlockConfiguration() |
|
127 | + */ |
|
128 | + public function editBlockConfiguration(Tree $tree, int $block_id): string |
|
129 | + { |
|
130 | + return view($this->name() . '::config', $this->matomoSettings($block_id)); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * {@inheritDoc} |
|
135 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::saveBlockConfiguration() |
|
136 | + */ |
|
137 | + public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void |
|
138 | + { |
|
139 | + $params = (array) $request->getParsedBody(); |
|
140 | + |
|
141 | + $matomo_enabled = $params['matomo_enabled'] == 'yes'; |
|
142 | + $this->setBlockSetting($block_id, 'matomo_enabled', $matomo_enabled ? 'yes' : 'no'); |
|
143 | + if (!$matomo_enabled) { |
|
144 | + return; |
|
145 | + } |
|
146 | + |
|
147 | + if (filter_var($params['matomo_url'], FILTER_VALIDATE_URL) === false) { |
|
148 | + FlashMessages::addMessage(I18N::translate('The Matomo URL provided is not valid.'), 'danger'); |
|
149 | + return; |
|
150 | + } |
|
151 | + |
|
152 | + if (filter_var($params['matomo_siteid'], FILTER_VALIDATE_INT) === false) { |
|
153 | + FlashMessages::addMessage(I18N::translate('The Matomo Site ID provided is not valid.'), 'danger'); |
|
154 | + return; |
|
155 | + } |
|
156 | + |
|
157 | + $this |
|
158 | + ->setBlockSetting($block_id, 'matomo_url', trim($params['matomo_url'])) |
|
159 | + ->setBlockSetting($block_id, 'matomo_token', trim($params['matomo_token'])) |
|
160 | + ->setBlockSetting($block_id, 'matomo_siteid', $params['matomo_siteid']); |
|
161 | + |
|
162 | + Registry::cache()->file()->forget($this->name() . '-matomovisits-yearly-' . $block_id); |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Returns whether Matomo statistics is enabled for a specific MyArtJaub WelcomeBlock block |
|
167 | + * |
|
168 | + * @param int $block_id |
|
169 | + * @return bool |
|
170 | + */ |
|
171 | + public function isMatomoEnabled(int $block_id): bool |
|
172 | + { |
|
173 | + return $this->getBlockSetting($block_id, 'matomo_enabled', 'no') === 'yes'; |
|
174 | + } |
|
175 | + |
|
176 | + /** |
|
177 | + * Returns settings for retrieving Matomo statistics for a specific MyArtJaub WelcomeBlock block |
|
178 | + * |
|
179 | + * @param int $block_id |
|
180 | + * @return array<string, mixed> |
|
181 | + */ |
|
182 | + public function matomoSettings(int $block_id): array |
|
183 | + { |
|
184 | + return [ |
|
185 | + 'matomo_enabled' => $this->isMatomoEnabled($block_id), |
|
186 | + 'matomo_url' => $this->getBlockSetting($block_id, 'matomo_url'), |
|
187 | + 'matomo_token' => $this->getBlockSetting($block_id, 'matomo_token'), |
|
188 | + 'matomo_siteid' => (int) $this->getBlockSetting($block_id, 'matomo_siteid', '0') |
|
189 | + ]; |
|
190 | + } |
|
191 | 191 | } |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function loadRoutes(Map $router): void |
63 | 63 | { |
64 | - $router->attach('', '', static function (Map $router): void { |
|
64 | + $router->attach('', '', static function(Map $router): void { |
|
65 | 65 | |
66 | - $router->attach('', '/module-maj/welcomeblock/{block_id}', static function (Map $router): void { |
|
66 | + $router->attach('', '/module-maj/welcomeblock/{block_id}', static function(Map $router): void { |
|
67 | 67 | $router->tokens(['block_id' => '\d+']); |
68 | 68 | $router->get(MatomoStats::class, '/matomostats', MatomoStats::class); |
69 | 69 | }); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $fab_login_block_view = app(\Fisharebest\Webtrees\Module\LoginBlockModule::class) |
92 | 92 | ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED); |
93 | 93 | |
94 | - $content = view($this->name() . '::block-embed', [ |
|
94 | + $content = view($this->name().'::block-embed', [ |
|
95 | 95 | 'block_id' => $block_id, |
96 | 96 | 'fab_welcome_block_view' => $fab_welcome_block_view, |
97 | 97 | 'fab_login_block_view' => $fab_login_block_view, |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function editBlockConfiguration(Tree $tree, int $block_id): string |
129 | 129 | { |
130 | - return view($this->name() . '::config', $this->matomoSettings($block_id)); |
|
130 | + return view($this->name().'::config', $this->matomoSettings($block_id)); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void |
138 | 138 | { |
139 | - $params = (array) $request->getParsedBody(); |
|
139 | + $params = (array)$request->getParsedBody(); |
|
140 | 140 | |
141 | 141 | $matomo_enabled = $params['matomo_enabled'] == 'yes'; |
142 | 142 | $this->setBlockSetting($block_id, 'matomo_enabled', $matomo_enabled ? 'yes' : 'no'); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | ->setBlockSetting($block_id, 'matomo_token', trim($params['matomo_token'])) |
160 | 160 | ->setBlockSetting($block_id, 'matomo_siteid', $params['matomo_siteid']); |
161 | 161 | |
162 | - Registry::cache()->file()->forget($this->name() . '-matomovisits-yearly-' . $block_id); |
|
162 | + Registry::cache()->file()->forget($this->name().'-matomovisits-yearly-'.$block_id); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | 'matomo_enabled' => $this->isMatomoEnabled($block_id), |
186 | 186 | 'matomo_url' => $this->getBlockSetting($block_id, 'matomo_url'), |
187 | 187 | 'matomo_token' => $this->getBlockSetting($block_id, 'matomo_token'), |
188 | - 'matomo_siteid' => (int) $this->getBlockSetting($block_id, 'matomo_siteid', '0') |
|
188 | + 'matomo_siteid' => (int)$this->getBlockSetting($block_id, 'matomo_siteid', '0') |
|
189 | 189 | ]; |
190 | 190 | } |
191 | 191 | } |
@@ -54,256 +54,256 @@ |
||
54 | 54 | * Identify and produce statistics about Sosa ancestors |
55 | 55 | */ |
56 | 56 | class SosaModule extends AbstractModule implements |
57 | - ModuleMyArtJaubInterface, |
|
58 | - ModuleGlobalInterface, |
|
59 | - ModuleMenuInterface, |
|
60 | - ModuleSidebarInterface, |
|
61 | - ModuleGeoAnalysisProviderInterface |
|
57 | + ModuleMyArtJaubInterface, |
|
58 | + ModuleGlobalInterface, |
|
59 | + ModuleMenuInterface, |
|
60 | + ModuleSidebarInterface, |
|
61 | + ModuleGeoAnalysisProviderInterface |
|
62 | 62 | { |
63 | - use ModuleMyArtJaubTrait { |
|
64 | - boot as traitBoot; |
|
65 | - } |
|
66 | - use ModuleGlobalTrait; |
|
67 | - use ModuleMenuTrait; |
|
68 | - use ModuleSidebarTrait; |
|
69 | - |
|
70 | - // How to update the database schema for this module |
|
71 | - private const SCHEMA_TARGET_VERSION = 3; |
|
72 | - private const SCHEMA_SETTING_NAME = 'MAJ_SOSA_SCHEMA_VERSION'; |
|
73 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
63 | + use ModuleMyArtJaubTrait { |
|
64 | + boot as traitBoot; |
|
65 | + } |
|
66 | + use ModuleGlobalTrait; |
|
67 | + use ModuleMenuTrait; |
|
68 | + use ModuleSidebarTrait; |
|
69 | + |
|
70 | + // How to update the database schema for this module |
|
71 | + private const SCHEMA_TARGET_VERSION = 3; |
|
72 | + private const SCHEMA_SETTING_NAME = 'MAJ_SOSA_SCHEMA_VERSION'; |
|
73 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
74 | 74 | /** |
75 | - * {@inheritDoc} |
|
76 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
77 | - */ |
|
78 | - public function title(): string |
|
79 | - { |
|
80 | - return /* I18N: Name of the “Sosa” module */ I18N::translate('Sosa'); |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * {@inheritDoc} |
|
85 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
86 | - */ |
|
87 | - public function description(): string |
|
88 | - { |
|
89 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
90 | - return /* I18N: Description of the “Sosa” module */ I18N::translate('Calculate and display Sosa ancestors of the root person.'); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * {@inheritDoc} |
|
95 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
96 | - */ |
|
97 | - public function boot(): void |
|
98 | - { |
|
99 | - $this->traitBoot(); |
|
100 | - app(MigrationService::class)->updateSchema( |
|
101 | - self::SCHEMA_MIGRATION_PREFIX, |
|
102 | - self::SCHEMA_SETTING_NAME, |
|
103 | - self::SCHEMA_TARGET_VERSION |
|
104 | - ); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * {@inheritDoc} |
|
109 | - * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
110 | - */ |
|
111 | - public function loadRoutes(Map $router): void |
|
112 | - { |
|
113 | - $router->attach('', '', static function (Map $router): void { |
|
114 | - |
|
115 | - $router->attach('', '/module-maj/sosa', static function (Map $router): void { |
|
116 | - |
|
117 | - $router->attach('', '/list', static function (Map $router): void { |
|
118 | - $router->tokens(['gen' => '\d+']); |
|
119 | - $router->get(AncestorsList::class, '/ancestors/{tree}{/gen}', AncestorsList::class); |
|
120 | - $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
121 | - $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
122 | - $router->get(MissingAncestorsList::class, '/missing/{tree}{/gen}', MissingAncestorsList::class); |
|
123 | - }); |
|
124 | - |
|
125 | - $router->attach('', '/statistics/{tree}', static function (Map $router): void { |
|
126 | - |
|
127 | - $router->get(SosaStatistics::class, '', SosaStatistics::class); |
|
128 | - $router->get(PedigreeCollapseData::class, '/pedigreecollapse', PedigreeCollapseData::class); |
|
129 | - }); |
|
130 | - |
|
131 | - $router->attach('', '/config/{tree}', static function (Map $router): void { |
|
132 | - |
|
133 | - $router->get(SosaConfig::class, '', SosaConfig::class); |
|
134 | - $router->post(SosaConfigAction::class, '', SosaConfigAction::class); |
|
135 | - $router->get(SosaComputeModal::class, '/compute/{xref}', SosaComputeModal::class); |
|
136 | - $router->post(SosaComputeAction::class, '/compute', SosaComputeAction::class); |
|
137 | - }); |
|
138 | - }); |
|
139 | - }); |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * {@inheritDoc} |
|
144 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
145 | - */ |
|
146 | - public function customModuleVersion(): string |
|
147 | - { |
|
148 | - return '2.1.0-v.1'; |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * {@inheritDoc} |
|
153 | - * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::defaultMenuOrder() |
|
154 | - */ |
|
155 | - public function defaultMenuOrder(): int |
|
156 | - { |
|
157 | - return 7; |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * {@inhericDoc} |
|
162 | - * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::getMenu() |
|
163 | - */ |
|
164 | - public function getMenu(Tree $tree): ?Menu |
|
165 | - { |
|
166 | - $menu = new Menu(I18N::translate('Sosa Statistics')); |
|
167 | - $menu->setClass('menu-maj-sosa'); |
|
168 | - $menu->setSubmenus([ |
|
169 | - new Menu( |
|
170 | - I18N::translate('Sosa Ancestors'), |
|
171 | - route(AncestorsList::class, ['tree' => $tree->name()]), |
|
172 | - 'menu-maj-sosa-list', |
|
173 | - ['rel' => 'nofollow'] |
|
174 | - ), |
|
175 | - new Menu( |
|
176 | - I18N::translate('Missing Ancestors'), |
|
177 | - route(MissingAncestorsList::class, ['tree' => $tree->name()]), |
|
178 | - 'menu-maj-sosa-missing', |
|
179 | - ['rel' => 'nofollow'] |
|
180 | - ), |
|
181 | - new Menu( |
|
182 | - I18N::translate('Sosa Statistics'), |
|
183 | - route(SosaStatistics::class, ['tree' => $tree->name()]), |
|
184 | - 'menu-maj-sosa-stats' |
|
185 | - ) |
|
186 | - ]); |
|
187 | - |
|
188 | - if (Auth::check()) { |
|
189 | - $menu->addSubmenu(new Menu( |
|
190 | - I18N::translate('Sosa Configuration'), |
|
191 | - route(SosaConfig::class, ['tree' => $tree->name()]), |
|
192 | - 'menu-maj-sosa-config' |
|
193 | - )); |
|
194 | - |
|
195 | - /** @var ServerRequestInterface $request */ |
|
196 | - $request = app(ServerRequestInterface::class); |
|
197 | - $route = $request->getAttribute('route'); |
|
198 | - assert($route instanceof Route); |
|
199 | - |
|
200 | - $root_indi_id = $tree->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID'); |
|
201 | - |
|
202 | - if ($route->name === IndividualPage::class && mb_strlen($root_indi_id) > 0) { |
|
203 | - $xref = $request->getAttribute('xref'); |
|
204 | - assert(is_string($xref)); |
|
205 | - |
|
206 | - $menu->addSubmenu(new Menu( |
|
207 | - I18N::translate('Complete Sosas'), |
|
208 | - '#', |
|
209 | - 'menu-maj-sosa-compute', |
|
210 | - [ |
|
211 | - 'rel' => 'nofollow', |
|
212 | - 'data-href' => route(SosaComputeModal::class, ['tree' => $tree->name(), 'xref' => $xref]), |
|
213 | - 'data-target' => '#wt-ajax-modal', |
|
214 | - 'data-toggle' => 'modal', |
|
215 | - 'data-backdrop' => 'static' |
|
216 | - ] |
|
217 | - )); |
|
218 | - } |
|
219 | - } |
|
220 | - |
|
221 | - return $menu; |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * {@inheritDoc} |
|
226 | - * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
227 | - */ |
|
228 | - public function headContent(): string |
|
229 | - { |
|
230 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * {@inheritDoc} |
|
235 | - * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::bodyContent() |
|
236 | - */ |
|
237 | - public function bodyContent(): string |
|
238 | - { |
|
239 | - return '<script src="' . $this->assetUrl('js/sosa.min.js') . '"></script>'; |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * {@inheritDoc} |
|
244 | - * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::sidebarTitle() |
|
245 | - */ |
|
246 | - public function sidebarTitle(): string |
|
247 | - { |
|
248 | - $request = app(ServerRequestInterface::class); |
|
249 | - $xref = $request->getAttribute('xref'); |
|
250 | - $tree = $request->getAttribute('tree'); |
|
251 | - $user = Auth::check() ? Auth::user() : new DefaultUser(); |
|
252 | - |
|
253 | - $individual = Registry::individualFactory()->make($xref, $tree); |
|
254 | - |
|
255 | - return view($this->name() . '::sidebar/title', [ |
|
256 | - 'module_name' => $this->name(), |
|
257 | - 'sosa_numbers' => app(SosaRecordsService::class)->sosaNumbers($tree, $user, $individual) |
|
258 | - ]); |
|
259 | - } |
|
260 | - |
|
261 | - /** |
|
262 | - * {@inheritDoc} |
|
263 | - * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::getSidebarContent() |
|
264 | - */ |
|
265 | - public function getSidebarContent(Individual $individual): string |
|
266 | - { |
|
267 | - $sosa_root_xref = $individual->tree()->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID'); |
|
268 | - $sosa_root = Registry::individualFactory()->make($sosa_root_xref, $individual->tree()); |
|
269 | - $user = Auth::check() ? Auth::user() : new DefaultUser(); |
|
270 | - |
|
271 | - return view($this->name() . '::sidebar/content', [ |
|
272 | - 'sosa_ancestor' => $individual, |
|
273 | - 'sosa_root' => $sosa_root, |
|
274 | - 'sosa_numbers' => app(SosaRecordsService::class)->sosaNumbers($individual->tree(), $user, $individual) |
|
275 | - ]); |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * {@inheritDoc} |
|
280 | - * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::hasSidebarContent() |
|
281 | - */ |
|
282 | - public function hasSidebarContent(Individual $individual): bool |
|
283 | - { |
|
284 | - $user = Auth::check() ? Auth::user() : new DefaultUser(); |
|
285 | - |
|
286 | - return app(SosaRecordsService::class) |
|
287 | - ->sosaNumbers($individual->tree(), $user, $individual)->count() > 0; |
|
288 | - } |
|
289 | - |
|
290 | - /** |
|
291 | - * {@inheritDoc} |
|
292 | - * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::defaultSidebarOrder() |
|
293 | - */ |
|
294 | - public function defaultSidebarOrder(): int |
|
295 | - { |
|
296 | - return 1; |
|
297 | - } |
|
298 | - |
|
299 | - /** |
|
300 | - * {@inheritDoc} |
|
301 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModuleGeoAnalysisProviderInterface::listGeoAnalyses() |
|
302 | - */ |
|
303 | - public function listGeoAnalyses(): array |
|
304 | - { |
|
305 | - return [ |
|
306 | - SosaByGenerationGeoAnalysis::class |
|
307 | - ]; |
|
308 | - } |
|
75 | + * {@inheritDoc} |
|
76 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
77 | + */ |
|
78 | + public function title(): string |
|
79 | + { |
|
80 | + return /* I18N: Name of the “Sosa” module */ I18N::translate('Sosa'); |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * {@inheritDoc} |
|
85 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
86 | + */ |
|
87 | + public function description(): string |
|
88 | + { |
|
89 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
90 | + return /* I18N: Description of the “Sosa” module */ I18N::translate('Calculate and display Sosa ancestors of the root person.'); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * {@inheritDoc} |
|
95 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
96 | + */ |
|
97 | + public function boot(): void |
|
98 | + { |
|
99 | + $this->traitBoot(); |
|
100 | + app(MigrationService::class)->updateSchema( |
|
101 | + self::SCHEMA_MIGRATION_PREFIX, |
|
102 | + self::SCHEMA_SETTING_NAME, |
|
103 | + self::SCHEMA_TARGET_VERSION |
|
104 | + ); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * {@inheritDoc} |
|
109 | + * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
110 | + */ |
|
111 | + public function loadRoutes(Map $router): void |
|
112 | + { |
|
113 | + $router->attach('', '', static function (Map $router): void { |
|
114 | + |
|
115 | + $router->attach('', '/module-maj/sosa', static function (Map $router): void { |
|
116 | + |
|
117 | + $router->attach('', '/list', static function (Map $router): void { |
|
118 | + $router->tokens(['gen' => '\d+']); |
|
119 | + $router->get(AncestorsList::class, '/ancestors/{tree}{/gen}', AncestorsList::class); |
|
120 | + $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
121 | + $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
122 | + $router->get(MissingAncestorsList::class, '/missing/{tree}{/gen}', MissingAncestorsList::class); |
|
123 | + }); |
|
124 | + |
|
125 | + $router->attach('', '/statistics/{tree}', static function (Map $router): void { |
|
126 | + |
|
127 | + $router->get(SosaStatistics::class, '', SosaStatistics::class); |
|
128 | + $router->get(PedigreeCollapseData::class, '/pedigreecollapse', PedigreeCollapseData::class); |
|
129 | + }); |
|
130 | + |
|
131 | + $router->attach('', '/config/{tree}', static function (Map $router): void { |
|
132 | + |
|
133 | + $router->get(SosaConfig::class, '', SosaConfig::class); |
|
134 | + $router->post(SosaConfigAction::class, '', SosaConfigAction::class); |
|
135 | + $router->get(SosaComputeModal::class, '/compute/{xref}', SosaComputeModal::class); |
|
136 | + $router->post(SosaComputeAction::class, '/compute', SosaComputeAction::class); |
|
137 | + }); |
|
138 | + }); |
|
139 | + }); |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * {@inheritDoc} |
|
144 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
145 | + */ |
|
146 | + public function customModuleVersion(): string |
|
147 | + { |
|
148 | + return '2.1.0-v.1'; |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * {@inheritDoc} |
|
153 | + * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::defaultMenuOrder() |
|
154 | + */ |
|
155 | + public function defaultMenuOrder(): int |
|
156 | + { |
|
157 | + return 7; |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * {@inhericDoc} |
|
162 | + * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::getMenu() |
|
163 | + */ |
|
164 | + public function getMenu(Tree $tree): ?Menu |
|
165 | + { |
|
166 | + $menu = new Menu(I18N::translate('Sosa Statistics')); |
|
167 | + $menu->setClass('menu-maj-sosa'); |
|
168 | + $menu->setSubmenus([ |
|
169 | + new Menu( |
|
170 | + I18N::translate('Sosa Ancestors'), |
|
171 | + route(AncestorsList::class, ['tree' => $tree->name()]), |
|
172 | + 'menu-maj-sosa-list', |
|
173 | + ['rel' => 'nofollow'] |
|
174 | + ), |
|
175 | + new Menu( |
|
176 | + I18N::translate('Missing Ancestors'), |
|
177 | + route(MissingAncestorsList::class, ['tree' => $tree->name()]), |
|
178 | + 'menu-maj-sosa-missing', |
|
179 | + ['rel' => 'nofollow'] |
|
180 | + ), |
|
181 | + new Menu( |
|
182 | + I18N::translate('Sosa Statistics'), |
|
183 | + route(SosaStatistics::class, ['tree' => $tree->name()]), |
|
184 | + 'menu-maj-sosa-stats' |
|
185 | + ) |
|
186 | + ]); |
|
187 | + |
|
188 | + if (Auth::check()) { |
|
189 | + $menu->addSubmenu(new Menu( |
|
190 | + I18N::translate('Sosa Configuration'), |
|
191 | + route(SosaConfig::class, ['tree' => $tree->name()]), |
|
192 | + 'menu-maj-sosa-config' |
|
193 | + )); |
|
194 | + |
|
195 | + /** @var ServerRequestInterface $request */ |
|
196 | + $request = app(ServerRequestInterface::class); |
|
197 | + $route = $request->getAttribute('route'); |
|
198 | + assert($route instanceof Route); |
|
199 | + |
|
200 | + $root_indi_id = $tree->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID'); |
|
201 | + |
|
202 | + if ($route->name === IndividualPage::class && mb_strlen($root_indi_id) > 0) { |
|
203 | + $xref = $request->getAttribute('xref'); |
|
204 | + assert(is_string($xref)); |
|
205 | + |
|
206 | + $menu->addSubmenu(new Menu( |
|
207 | + I18N::translate('Complete Sosas'), |
|
208 | + '#', |
|
209 | + 'menu-maj-sosa-compute', |
|
210 | + [ |
|
211 | + 'rel' => 'nofollow', |
|
212 | + 'data-href' => route(SosaComputeModal::class, ['tree' => $tree->name(), 'xref' => $xref]), |
|
213 | + 'data-target' => '#wt-ajax-modal', |
|
214 | + 'data-toggle' => 'modal', |
|
215 | + 'data-backdrop' => 'static' |
|
216 | + ] |
|
217 | + )); |
|
218 | + } |
|
219 | + } |
|
220 | + |
|
221 | + return $menu; |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * {@inheritDoc} |
|
226 | + * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
227 | + */ |
|
228 | + public function headContent(): string |
|
229 | + { |
|
230 | + return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * {@inheritDoc} |
|
235 | + * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::bodyContent() |
|
236 | + */ |
|
237 | + public function bodyContent(): string |
|
238 | + { |
|
239 | + return '<script src="' . $this->assetUrl('js/sosa.min.js') . '"></script>'; |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * {@inheritDoc} |
|
244 | + * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::sidebarTitle() |
|
245 | + */ |
|
246 | + public function sidebarTitle(): string |
|
247 | + { |
|
248 | + $request = app(ServerRequestInterface::class); |
|
249 | + $xref = $request->getAttribute('xref'); |
|
250 | + $tree = $request->getAttribute('tree'); |
|
251 | + $user = Auth::check() ? Auth::user() : new DefaultUser(); |
|
252 | + |
|
253 | + $individual = Registry::individualFactory()->make($xref, $tree); |
|
254 | + |
|
255 | + return view($this->name() . '::sidebar/title', [ |
|
256 | + 'module_name' => $this->name(), |
|
257 | + 'sosa_numbers' => app(SosaRecordsService::class)->sosaNumbers($tree, $user, $individual) |
|
258 | + ]); |
|
259 | + } |
|
260 | + |
|
261 | + /** |
|
262 | + * {@inheritDoc} |
|
263 | + * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::getSidebarContent() |
|
264 | + */ |
|
265 | + public function getSidebarContent(Individual $individual): string |
|
266 | + { |
|
267 | + $sosa_root_xref = $individual->tree()->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID'); |
|
268 | + $sosa_root = Registry::individualFactory()->make($sosa_root_xref, $individual->tree()); |
|
269 | + $user = Auth::check() ? Auth::user() : new DefaultUser(); |
|
270 | + |
|
271 | + return view($this->name() . '::sidebar/content', [ |
|
272 | + 'sosa_ancestor' => $individual, |
|
273 | + 'sosa_root' => $sosa_root, |
|
274 | + 'sosa_numbers' => app(SosaRecordsService::class)->sosaNumbers($individual->tree(), $user, $individual) |
|
275 | + ]); |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * {@inheritDoc} |
|
280 | + * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::hasSidebarContent() |
|
281 | + */ |
|
282 | + public function hasSidebarContent(Individual $individual): bool |
|
283 | + { |
|
284 | + $user = Auth::check() ? Auth::user() : new DefaultUser(); |
|
285 | + |
|
286 | + return app(SosaRecordsService::class) |
|
287 | + ->sosaNumbers($individual->tree(), $user, $individual)->count() > 0; |
|
288 | + } |
|
289 | + |
|
290 | + /** |
|
291 | + * {@inheritDoc} |
|
292 | + * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::defaultSidebarOrder() |
|
293 | + */ |
|
294 | + public function defaultSidebarOrder(): int |
|
295 | + { |
|
296 | + return 1; |
|
297 | + } |
|
298 | + |
|
299 | + /** |
|
300 | + * {@inheritDoc} |
|
301 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModuleGeoAnalysisProviderInterface::listGeoAnalyses() |
|
302 | + */ |
|
303 | + public function listGeoAnalyses(): array |
|
304 | + { |
|
305 | + return [ |
|
306 | + SosaByGenerationGeoAnalysis::class |
|
307 | + ]; |
|
308 | + } |
|
309 | 309 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | // How to update the database schema for this module |
71 | 71 | private const SCHEMA_TARGET_VERSION = 3; |
72 | 72 | private const SCHEMA_SETTING_NAME = 'MAJ_SOSA_SCHEMA_VERSION'; |
73 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
73 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__.'\Schema'; |
|
74 | 74 | /** |
75 | 75 | * {@inheritDoc} |
76 | 76 | * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
@@ -110,25 +110,25 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function loadRoutes(Map $router): void |
112 | 112 | { |
113 | - $router->attach('', '', static function (Map $router): void { |
|
113 | + $router->attach('', '', static function(Map $router): void { |
|
114 | 114 | |
115 | - $router->attach('', '/module-maj/sosa', static function (Map $router): void { |
|
115 | + $router->attach('', '/module-maj/sosa', static function(Map $router): void { |
|
116 | 116 | |
117 | - $router->attach('', '/list', static function (Map $router): void { |
|
117 | + $router->attach('', '/list', static function(Map $router): void { |
|
118 | 118 | $router->tokens(['gen' => '\d+']); |
119 | 119 | $router->get(AncestorsList::class, '/ancestors/{tree}{/gen}', AncestorsList::class); |
120 | - $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
121 | - $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
120 | + $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
121 | + $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
122 | 122 | $router->get(MissingAncestorsList::class, '/missing/{tree}{/gen}', MissingAncestorsList::class); |
123 | 123 | }); |
124 | 124 | |
125 | - $router->attach('', '/statistics/{tree}', static function (Map $router): void { |
|
125 | + $router->attach('', '/statistics/{tree}', static function(Map $router): void { |
|
126 | 126 | |
127 | 127 | $router->get(SosaStatistics::class, '', SosaStatistics::class); |
128 | 128 | $router->get(PedigreeCollapseData::class, '/pedigreecollapse', PedigreeCollapseData::class); |
129 | 129 | }); |
130 | 130 | |
131 | - $router->attach('', '/config/{tree}', static function (Map $router): void { |
|
131 | + $router->attach('', '/config/{tree}', static function(Map $router): void { |
|
132 | 132 | |
133 | 133 | $router->get(SosaConfig::class, '', SosaConfig::class); |
134 | 134 | $router->post(SosaConfigAction::class, '', SosaConfigAction::class); |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function headContent(): string |
229 | 229 | { |
230 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
230 | + return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">'; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function bodyContent(): string |
238 | 238 | { |
239 | - return '<script src="' . $this->assetUrl('js/sosa.min.js') . '"></script>'; |
|
239 | + return '<script src="'.$this->assetUrl('js/sosa.min.js').'"></script>'; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | |
253 | 253 | $individual = Registry::individualFactory()->make($xref, $tree); |
254 | 254 | |
255 | - return view($this->name() . '::sidebar/title', [ |
|
255 | + return view($this->name().'::sidebar/title', [ |
|
256 | 256 | 'module_name' => $this->name(), |
257 | 257 | 'sosa_numbers' => app(SosaRecordsService::class)->sosaNumbers($tree, $user, $individual) |
258 | 258 | ]); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $sosa_root = Registry::individualFactory()->make($sosa_root_xref, $individual->tree()); |
269 | 269 | $user = Auth::check() ? Auth::user() : new DefaultUser(); |
270 | 270 | |
271 | - return view($this->name() . '::sidebar/content', [ |
|
271 | + return view($this->name().'::sidebar/content', [ |
|
272 | 272 | 'sosa_ancestor' => $individual, |
273 | 273 | 'sosa_root' => $sosa_root, |
274 | 274 | 'sosa_numbers' => app(SosaRecordsService::class)->sosaNumbers($individual->tree(), $user, $individual) |
@@ -31,101 +31,101 @@ |
||
31 | 31 | */ |
32 | 32 | class SosaByGenerationGeoAnalysis implements GeoAnalysisInterface |
33 | 33 | { |
34 | - private SosaRecordsService $records_service; |
|
35 | - |
|
36 | - /** |
|
37 | - * Constructor for SosaByGenerationGeoAnalysis |
|
38 | - * |
|
39 | - * @param SosaRecordsService $records_service |
|
40 | - */ |
|
41 | - public function __construct(SosaRecordsService $records_service) |
|
42 | - { |
|
43 | - $this->records_service = $records_service; |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * {@inheritDoc} |
|
48 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::title() |
|
49 | - */ |
|
50 | - public function title(): string |
|
51 | - { |
|
52 | - return I18N::translate('Sosa ancestors places by generation'); |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * {@inheritDoc} |
|
57 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::itemsDescription() |
|
58 | - */ |
|
59 | - public function itemsDescription(): callable |
|
60 | - { |
|
61 | - return fn(int $count): string => I18N::plural('ancestor', 'ancestors', $count); |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * {@inheritDoc} |
|
66 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::results() |
|
67 | - */ |
|
68 | - public function results(Tree $tree, int $depth): GeoAnalysisResults |
|
69 | - { |
|
70 | - $results = new GeoAnalysisResults(); |
|
71 | - |
|
72 | - $unique_ancestors = $this->records_service |
|
73 | - ->listAncestors($tree, Auth::user()) |
|
74 | - ->uniqueStrict(fn(stdClass $item): string => $item->majs_i_id); |
|
75 | - |
|
76 | - foreach ($unique_ancestors as $item) { |
|
77 | - $ancestor = Registry::individualFactory()->make($item->majs_i_id, $tree); |
|
78 | - if ($ancestor === null || !$ancestor->canShow()) { |
|
79 | - continue; |
|
80 | - } |
|
81 | - $generation = $this->records_service->generation((int) $item->majs_sosa); |
|
82 | - $significantplace = new GeoAnalysisPlace($tree, null, $depth); |
|
83 | - foreach ($this->significantPlaces($ancestor) as $place) { |
|
84 | - $significantplace = new GeoAnalysisPlace($tree, $place, $depth, true); |
|
85 | - if ($significantplace->isKnown()) { |
|
86 | - break; |
|
87 | - } |
|
88 | - } |
|
89 | - $results->addPlace($significantplace); |
|
90 | - $results->addPlaceInCategory( |
|
91 | - I18N::translate('Generation %s', I18N::number($generation)), |
|
92 | - $generation, |
|
93 | - $significantplace |
|
94 | - ); |
|
95 | - } |
|
96 | - |
|
97 | - return $results; |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Returns significant places in order of priority for an individual |
|
102 | - * |
|
103 | - * @param Individual $individual |
|
104 | - * @return Generator<\Fisharebest\Webtrees\Place> |
|
105 | - */ |
|
106 | - protected function significantPlaces(Individual $individual): Generator |
|
107 | - { |
|
108 | - yield $individual->getBirthPlace(); |
|
109 | - |
|
110 | - /** @var \Fisharebest\Webtrees\Fact $fact */ |
|
111 | - foreach ($individual->facts(['RESI']) as $fact) { |
|
112 | - yield $fact->place(); |
|
113 | - } |
|
114 | - |
|
115 | - yield $individual->getDeathPlace(); |
|
116 | - |
|
117 | - /** @var \Fisharebest\Webtrees\Family $family */ |
|
118 | - foreach ($individual->childFamilies() as $family) { |
|
119 | - foreach ($family->facts(['RESI']) as $fact) { |
|
120 | - yield $fact->place(); |
|
121 | - } |
|
122 | - } |
|
123 | - |
|
124 | - /** @var \Fisharebest\Webtrees\Family $family */ |
|
125 | - foreach ($individual->spouseFamilies() as $family) { |
|
126 | - foreach ($family->facts(['RESI']) as $fact) { |
|
127 | - yield $fact->place(); |
|
128 | - } |
|
129 | - } |
|
130 | - } |
|
34 | + private SosaRecordsService $records_service; |
|
35 | + |
|
36 | + /** |
|
37 | + * Constructor for SosaByGenerationGeoAnalysis |
|
38 | + * |
|
39 | + * @param SosaRecordsService $records_service |
|
40 | + */ |
|
41 | + public function __construct(SosaRecordsService $records_service) |
|
42 | + { |
|
43 | + $this->records_service = $records_service; |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * {@inheritDoc} |
|
48 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::title() |
|
49 | + */ |
|
50 | + public function title(): string |
|
51 | + { |
|
52 | + return I18N::translate('Sosa ancestors places by generation'); |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * {@inheritDoc} |
|
57 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::itemsDescription() |
|
58 | + */ |
|
59 | + public function itemsDescription(): callable |
|
60 | + { |
|
61 | + return fn(int $count): string => I18N::plural('ancestor', 'ancestors', $count); |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * {@inheritDoc} |
|
66 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::results() |
|
67 | + */ |
|
68 | + public function results(Tree $tree, int $depth): GeoAnalysisResults |
|
69 | + { |
|
70 | + $results = new GeoAnalysisResults(); |
|
71 | + |
|
72 | + $unique_ancestors = $this->records_service |
|
73 | + ->listAncestors($tree, Auth::user()) |
|
74 | + ->uniqueStrict(fn(stdClass $item): string => $item->majs_i_id); |
|
75 | + |
|
76 | + foreach ($unique_ancestors as $item) { |
|
77 | + $ancestor = Registry::individualFactory()->make($item->majs_i_id, $tree); |
|
78 | + if ($ancestor === null || !$ancestor->canShow()) { |
|
79 | + continue; |
|
80 | + } |
|
81 | + $generation = $this->records_service->generation((int) $item->majs_sosa); |
|
82 | + $significantplace = new GeoAnalysisPlace($tree, null, $depth); |
|
83 | + foreach ($this->significantPlaces($ancestor) as $place) { |
|
84 | + $significantplace = new GeoAnalysisPlace($tree, $place, $depth, true); |
|
85 | + if ($significantplace->isKnown()) { |
|
86 | + break; |
|
87 | + } |
|
88 | + } |
|
89 | + $results->addPlace($significantplace); |
|
90 | + $results->addPlaceInCategory( |
|
91 | + I18N::translate('Generation %s', I18N::number($generation)), |
|
92 | + $generation, |
|
93 | + $significantplace |
|
94 | + ); |
|
95 | + } |
|
96 | + |
|
97 | + return $results; |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Returns significant places in order of priority for an individual |
|
102 | + * |
|
103 | + * @param Individual $individual |
|
104 | + * @return Generator<\Fisharebest\Webtrees\Place> |
|
105 | + */ |
|
106 | + protected function significantPlaces(Individual $individual): Generator |
|
107 | + { |
|
108 | + yield $individual->getBirthPlace(); |
|
109 | + |
|
110 | + /** @var \Fisharebest\Webtrees\Fact $fact */ |
|
111 | + foreach ($individual->facts(['RESI']) as $fact) { |
|
112 | + yield $fact->place(); |
|
113 | + } |
|
114 | + |
|
115 | + yield $individual->getDeathPlace(); |
|
116 | + |
|
117 | + /** @var \Fisharebest\Webtrees\Family $family */ |
|
118 | + foreach ($individual->childFamilies() as $family) { |
|
119 | + foreach ($family->facts(['RESI']) as $fact) { |
|
120 | + yield $fact->place(); |
|
121 | + } |
|
122 | + } |
|
123 | + |
|
124 | + /** @var \Fisharebest\Webtrees\Family $family */ |
|
125 | + foreach ($individual->spouseFamilies() as $family) { |
|
126 | + foreach ($family->facts(['RESI']) as $fact) { |
|
127 | + yield $fact->place(); |
|
128 | + } |
|
129 | + } |
|
130 | + } |
|
131 | 131 | } |
@@ -58,185 +58,185 @@ |
||
58 | 58 | * Geographical Dispersion Module. |
59 | 59 | */ |
60 | 60 | class GeoDispersionModule extends AbstractModule implements |
61 | - ModuleMyArtJaubInterface, |
|
62 | - ModuleChartInterface, |
|
63 | - ModuleConfigInterface, |
|
64 | - ModuleGlobalInterface, |
|
65 | - ModuleGeoAnalysisProviderInterface, |
|
66 | - ModulePlaceMapperProviderInterface |
|
61 | + ModuleMyArtJaubInterface, |
|
62 | + ModuleChartInterface, |
|
63 | + ModuleConfigInterface, |
|
64 | + ModuleGlobalInterface, |
|
65 | + ModuleGeoAnalysisProviderInterface, |
|
66 | + ModulePlaceMapperProviderInterface |
|
67 | 67 | { |
68 | - use ModuleMyArtJaubTrait { |
|
69 | - boot as traitBoot; |
|
70 | - } |
|
71 | - use ModuleChartTrait; |
|
72 | - use ModuleConfigTrait; |
|
73 | - use ModuleGlobalTrait; |
|
74 | - |
|
75 | - // How to update the database schema for this module |
|
76 | - private const SCHEMA_TARGET_VERSION = 2; |
|
77 | - private const SCHEMA_SETTING_NAME = 'MAJ_GEODISP_SCHEMA_VERSION'; |
|
78 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
79 | - |
|
80 | - /** |
|
81 | - * {@inheritDoc} |
|
82 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
83 | - */ |
|
84 | - public function title(): string |
|
85 | - { |
|
86 | - return /* I18N: Name of the “GeoDispersion” module */ I18N::translate('Geographical Dispersion'); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * {@inheritDoc} |
|
91 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
92 | - */ |
|
93 | - public function description(): string |
|
94 | - { |
|
95 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
96 | - return /* I18N: Description of the “GeoDispersion” module */ I18N::translate('Perform and display geographical dispersion analysis'); |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * {@inheritDoc} |
|
101 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
102 | - */ |
|
103 | - public function boot(): void |
|
104 | - { |
|
105 | - $this->traitBoot(); |
|
106 | - app(MigrationService::class)->updateSchema( |
|
107 | - self::SCHEMA_MIGRATION_PREFIX, |
|
108 | - self::SCHEMA_SETTING_NAME, |
|
109 | - self::SCHEMA_TARGET_VERSION |
|
110 | - ); |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * {@inheritDoc} |
|
115 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
116 | - */ |
|
117 | - public function customModuleVersion(): string |
|
118 | - { |
|
119 | - return '2.1.0-v.1'; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * {@inheritDoc} |
|
124 | - * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
125 | - */ |
|
126 | - public function loadRoutes(Map $router): void |
|
127 | - { |
|
128 | - $router->attach('', '', static function (Map $router): void { |
|
129 | - |
|
130 | - $router->attach('', '/module-maj/geodispersion', static function (Map $router): void { |
|
131 | - $router->attach('', '/admin', static function (Map $router): void { |
|
132 | - $router->get(AdminConfigPage::class, '/config{/tree}', AdminConfigPage::class); |
|
133 | - |
|
134 | - $router->attach('', '/analysis-views/{tree}', static function (Map $router): void { |
|
135 | - $router->tokens(['view_id' => '\d+', 'enable' => '[01]']); |
|
136 | - $router->extras([ |
|
137 | - 'middleware' => [ |
|
138 | - AuthManager::class, |
|
139 | - ], |
|
140 | - ]); |
|
141 | - $router->get(GeoAnalysisViewListData::class, '', GeoAnalysisViewListData::class); |
|
142 | - |
|
143 | - $router->get(GeoAnalysisViewAddPage::class, '/add', GeoAnalysisViewAddPage::class); |
|
144 | - $router->post(GeoAnalysisViewAddAction::class, '/add', GeoAnalysisViewAddAction::class); |
|
145 | - $router->get(GeoAnalysisViewEditPage::class, '/{view_id}', GeoAnalysisViewEditPage::class); |
|
146 | - $router->post(GeoAnalysisViewEditAction::class, '/{view_id}', GeoAnalysisViewEditAction::class); |
|
147 | - //phpcs:disable Generic.Files.LineLength.TooLong |
|
148 | - $router->get(GeoAnalysisViewStatusAction::class, '/{view_id}/status/{enable}', GeoAnalysisViewStatusAction::class); |
|
149 | - $router->get(GeoAnalysisViewDeleteAction::class, '/{view_id}/delete', GeoAnalysisViewDeleteAction::class); |
|
150 | - //phpcs:enable |
|
151 | - }); |
|
152 | - |
|
153 | - $router->attach('', '/map-adapters/{tree}', static function (Map $router): void { |
|
154 | - $router->tokens(['adapter_id' => '\d+', 'view_id' => '\d+']); |
|
155 | - $router->extras([ |
|
156 | - 'middleware' => [ |
|
157 | - AuthManager::class, |
|
158 | - ], |
|
159 | - ]); |
|
160 | - |
|
161 | - $router->get(MapAdapterAddPage::class, '/add/{view_id}', MapAdapterAddPage::class); |
|
162 | - $router->post(MapAdapterAddAction::class, '/add/{view_id}', MapAdapterAddAction::class); |
|
163 | - $router->get(MapAdapterEditPage::class, '/{adapter_id}', MapAdapterEditPage::class); |
|
164 | - $router->post(MapAdapterEditAction::class, '/{adapter_id}', MapAdapterEditAction::class); |
|
165 | - //phpcs:disable Generic.Files.LineLength.TooLong |
|
166 | - $router->get(MapAdapterDeleteAction::class, '/{adapter_id}/delete', MapAdapterDeleteAction::class); |
|
167 | - $router->get(MapAdapterMapperConfig::class, '/mapper/config{/adapter_id}', MapAdapterMapperConfig::class); |
|
168 | - //phpcs:enable |
|
169 | - }); |
|
170 | - |
|
171 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
172 | - $router->get(MapFeaturePropertyData::class, '/map/feature-properties{/map_id}', MapFeaturePropertyData::class); |
|
173 | - }); |
|
174 | - |
|
175 | - $router->get(GeoAnalysisViewsList::class, '/list/{tree}', GeoAnalysisViewsList::class); |
|
176 | - |
|
177 | - $router->attach('', '/analysisview/{tree}/{view_id}', static function (Map $router): void { |
|
178 | - $router->tokens(['view_id' => '\d+']); |
|
179 | - $router->get(GeoAnalysisViewPage::class, '', GeoAnalysisViewPage::class); |
|
180 | - $router->get(GeoAnalysisViewTabs::class, '/tabs', GeoAnalysisViewTabs::class); |
|
181 | - }); |
|
182 | - }); |
|
183 | - }); |
|
184 | - } |
|
185 | - |
|
186 | - public function getConfigLink(): string |
|
187 | - { |
|
188 | - return route(AdminConfigPage::class); |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * {@inheritDoc} |
|
193 | - * @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartUrl() |
|
194 | - */ |
|
195 | - public function chartUrl(Individual $individual, array $parameters = []): string |
|
196 | - { |
|
197 | - return route(GeoAnalysisViewsList::class, ['tree' => $individual->tree()->name()] + $parameters); |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * {@inheritDoc} |
|
202 | - * @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartMenuClass() |
|
203 | - */ |
|
204 | - public function chartMenuClass(): string |
|
205 | - { |
|
206 | - return 'menu-maj-geodispersion'; |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * {@inheritDoc} |
|
211 | - * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
212 | - */ |
|
213 | - public function headContent(): string |
|
214 | - { |
|
215 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
216 | - } |
|
217 | - |
|
218 | - /** |
|
219 | - * {@inheritDoc} |
|
220 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModulePlaceMapperProviderInterface::listPlaceMappers() |
|
221 | - */ |
|
222 | - public function listPlaceMappers(): array |
|
223 | - { |
|
224 | - return [ |
|
225 | - CoordinatesPlaceMapper::class, |
|
226 | - SimplePlaceMapper::class, |
|
227 | - SimpleTopFilteredPlaceMapper::class |
|
228 | - ]; |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * {@inheritDoc} |
|
233 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModuleGeoAnalysisProviderInterface::listGeoAnalyses() |
|
234 | - */ |
|
235 | - public function listGeoAnalyses(): array |
|
236 | - { |
|
237 | - return [ |
|
238 | - AllEventsByCenturyGeoAnalysis::class, |
|
239 | - AllEventsByTypeGeoAnalysis::class |
|
240 | - ]; |
|
241 | - } |
|
68 | + use ModuleMyArtJaubTrait { |
|
69 | + boot as traitBoot; |
|
70 | + } |
|
71 | + use ModuleChartTrait; |
|
72 | + use ModuleConfigTrait; |
|
73 | + use ModuleGlobalTrait; |
|
74 | + |
|
75 | + // How to update the database schema for this module |
|
76 | + private const SCHEMA_TARGET_VERSION = 2; |
|
77 | + private const SCHEMA_SETTING_NAME = 'MAJ_GEODISP_SCHEMA_VERSION'; |
|
78 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
79 | + |
|
80 | + /** |
|
81 | + * {@inheritDoc} |
|
82 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
83 | + */ |
|
84 | + public function title(): string |
|
85 | + { |
|
86 | + return /* I18N: Name of the “GeoDispersion” module */ I18N::translate('Geographical Dispersion'); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * {@inheritDoc} |
|
91 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
92 | + */ |
|
93 | + public function description(): string |
|
94 | + { |
|
95 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
96 | + return /* I18N: Description of the “GeoDispersion” module */ I18N::translate('Perform and display geographical dispersion analysis'); |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * {@inheritDoc} |
|
101 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
102 | + */ |
|
103 | + public function boot(): void |
|
104 | + { |
|
105 | + $this->traitBoot(); |
|
106 | + app(MigrationService::class)->updateSchema( |
|
107 | + self::SCHEMA_MIGRATION_PREFIX, |
|
108 | + self::SCHEMA_SETTING_NAME, |
|
109 | + self::SCHEMA_TARGET_VERSION |
|
110 | + ); |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * {@inheritDoc} |
|
115 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
116 | + */ |
|
117 | + public function customModuleVersion(): string |
|
118 | + { |
|
119 | + return '2.1.0-v.1'; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * {@inheritDoc} |
|
124 | + * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
125 | + */ |
|
126 | + public function loadRoutes(Map $router): void |
|
127 | + { |
|
128 | + $router->attach('', '', static function (Map $router): void { |
|
129 | + |
|
130 | + $router->attach('', '/module-maj/geodispersion', static function (Map $router): void { |
|
131 | + $router->attach('', '/admin', static function (Map $router): void { |
|
132 | + $router->get(AdminConfigPage::class, '/config{/tree}', AdminConfigPage::class); |
|
133 | + |
|
134 | + $router->attach('', '/analysis-views/{tree}', static function (Map $router): void { |
|
135 | + $router->tokens(['view_id' => '\d+', 'enable' => '[01]']); |
|
136 | + $router->extras([ |
|
137 | + 'middleware' => [ |
|
138 | + AuthManager::class, |
|
139 | + ], |
|
140 | + ]); |
|
141 | + $router->get(GeoAnalysisViewListData::class, '', GeoAnalysisViewListData::class); |
|
142 | + |
|
143 | + $router->get(GeoAnalysisViewAddPage::class, '/add', GeoAnalysisViewAddPage::class); |
|
144 | + $router->post(GeoAnalysisViewAddAction::class, '/add', GeoAnalysisViewAddAction::class); |
|
145 | + $router->get(GeoAnalysisViewEditPage::class, '/{view_id}', GeoAnalysisViewEditPage::class); |
|
146 | + $router->post(GeoAnalysisViewEditAction::class, '/{view_id}', GeoAnalysisViewEditAction::class); |
|
147 | + //phpcs:disable Generic.Files.LineLength.TooLong |
|
148 | + $router->get(GeoAnalysisViewStatusAction::class, '/{view_id}/status/{enable}', GeoAnalysisViewStatusAction::class); |
|
149 | + $router->get(GeoAnalysisViewDeleteAction::class, '/{view_id}/delete', GeoAnalysisViewDeleteAction::class); |
|
150 | + //phpcs:enable |
|
151 | + }); |
|
152 | + |
|
153 | + $router->attach('', '/map-adapters/{tree}', static function (Map $router): void { |
|
154 | + $router->tokens(['adapter_id' => '\d+', 'view_id' => '\d+']); |
|
155 | + $router->extras([ |
|
156 | + 'middleware' => [ |
|
157 | + AuthManager::class, |
|
158 | + ], |
|
159 | + ]); |
|
160 | + |
|
161 | + $router->get(MapAdapterAddPage::class, '/add/{view_id}', MapAdapterAddPage::class); |
|
162 | + $router->post(MapAdapterAddAction::class, '/add/{view_id}', MapAdapterAddAction::class); |
|
163 | + $router->get(MapAdapterEditPage::class, '/{adapter_id}', MapAdapterEditPage::class); |
|
164 | + $router->post(MapAdapterEditAction::class, '/{adapter_id}', MapAdapterEditAction::class); |
|
165 | + //phpcs:disable Generic.Files.LineLength.TooLong |
|
166 | + $router->get(MapAdapterDeleteAction::class, '/{adapter_id}/delete', MapAdapterDeleteAction::class); |
|
167 | + $router->get(MapAdapterMapperConfig::class, '/mapper/config{/adapter_id}', MapAdapterMapperConfig::class); |
|
168 | + //phpcs:enable |
|
169 | + }); |
|
170 | + |
|
171 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
172 | + $router->get(MapFeaturePropertyData::class, '/map/feature-properties{/map_id}', MapFeaturePropertyData::class); |
|
173 | + }); |
|
174 | + |
|
175 | + $router->get(GeoAnalysisViewsList::class, '/list/{tree}', GeoAnalysisViewsList::class); |
|
176 | + |
|
177 | + $router->attach('', '/analysisview/{tree}/{view_id}', static function (Map $router): void { |
|
178 | + $router->tokens(['view_id' => '\d+']); |
|
179 | + $router->get(GeoAnalysisViewPage::class, '', GeoAnalysisViewPage::class); |
|
180 | + $router->get(GeoAnalysisViewTabs::class, '/tabs', GeoAnalysisViewTabs::class); |
|
181 | + }); |
|
182 | + }); |
|
183 | + }); |
|
184 | + } |
|
185 | + |
|
186 | + public function getConfigLink(): string |
|
187 | + { |
|
188 | + return route(AdminConfigPage::class); |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * {@inheritDoc} |
|
193 | + * @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartUrl() |
|
194 | + */ |
|
195 | + public function chartUrl(Individual $individual, array $parameters = []): string |
|
196 | + { |
|
197 | + return route(GeoAnalysisViewsList::class, ['tree' => $individual->tree()->name()] + $parameters); |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * {@inheritDoc} |
|
202 | + * @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartMenuClass() |
|
203 | + */ |
|
204 | + public function chartMenuClass(): string |
|
205 | + { |
|
206 | + return 'menu-maj-geodispersion'; |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * {@inheritDoc} |
|
211 | + * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
212 | + */ |
|
213 | + public function headContent(): string |
|
214 | + { |
|
215 | + return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
216 | + } |
|
217 | + |
|
218 | + /** |
|
219 | + * {@inheritDoc} |
|
220 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModulePlaceMapperProviderInterface::listPlaceMappers() |
|
221 | + */ |
|
222 | + public function listPlaceMappers(): array |
|
223 | + { |
|
224 | + return [ |
|
225 | + CoordinatesPlaceMapper::class, |
|
226 | + SimplePlaceMapper::class, |
|
227 | + SimpleTopFilteredPlaceMapper::class |
|
228 | + ]; |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * {@inheritDoc} |
|
233 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModuleGeoAnalysisProviderInterface::listGeoAnalyses() |
|
234 | + */ |
|
235 | + public function listGeoAnalyses(): array |
|
236 | + { |
|
237 | + return [ |
|
238 | + AllEventsByCenturyGeoAnalysis::class, |
|
239 | + AllEventsByTypeGeoAnalysis::class |
|
240 | + ]; |
|
241 | + } |
|
242 | 242 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | // How to update the database schema for this module |
76 | 76 | private const SCHEMA_TARGET_VERSION = 2; |
77 | 77 | private const SCHEMA_SETTING_NAME = 'MAJ_GEODISP_SCHEMA_VERSION'; |
78 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
78 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__.'\Schema'; |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * {@inheritDoc} |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function loadRoutes(Map $router): void |
127 | 127 | { |
128 | - $router->attach('', '', static function (Map $router): void { |
|
128 | + $router->attach('', '', static function(Map $router): void { |
|
129 | 129 | |
130 | - $router->attach('', '/module-maj/geodispersion', static function (Map $router): void { |
|
131 | - $router->attach('', '/admin', static function (Map $router): void { |
|
130 | + $router->attach('', '/module-maj/geodispersion', static function(Map $router): void { |
|
131 | + $router->attach('', '/admin', static function(Map $router): void { |
|
132 | 132 | $router->get(AdminConfigPage::class, '/config{/tree}', AdminConfigPage::class); |
133 | 133 | |
134 | - $router->attach('', '/analysis-views/{tree}', static function (Map $router): void { |
|
134 | + $router->attach('', '/analysis-views/{tree}', static function(Map $router): void { |
|
135 | 135 | $router->tokens(['view_id' => '\d+', 'enable' => '[01]']); |
136 | 136 | $router->extras([ |
137 | 137 | 'middleware' => [ |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | //phpcs:enable |
151 | 151 | }); |
152 | 152 | |
153 | - $router->attach('', '/map-adapters/{tree}', static function (Map $router): void { |
|
153 | + $router->attach('', '/map-adapters/{tree}', static function(Map $router): void { |
|
154 | 154 | $router->tokens(['adapter_id' => '\d+', 'view_id' => '\d+']); |
155 | 155 | $router->extras([ |
156 | 156 | 'middleware' => [ |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | $router->get(GeoAnalysisViewsList::class, '/list/{tree}', GeoAnalysisViewsList::class); |
176 | 176 | |
177 | - $router->attach('', '/analysisview/{tree}/{view_id}', static function (Map $router): void { |
|
177 | + $router->attach('', '/analysisview/{tree}/{view_id}', static function(Map $router): void { |
|
178 | 178 | $router->tokens(['view_id' => '\d+']); |
179 | 179 | $router->get(GeoAnalysisViewPage::class, '', GeoAnalysisViewPage::class); |
180 | 180 | $router->get(GeoAnalysisViewTabs::class, '/tabs', GeoAnalysisViewTabs::class); |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function headContent(): string |
214 | 214 | { |
215 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
215 | + return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">'; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |