@@ -29,44 +29,44 @@ |
||
29 | 29 | */ |
30 | 30 | class ModulesHooksPage implements RequestHandlerInterface |
31 | 31 | { |
32 | - use ViewResponseTrait; |
|
32 | + use ViewResponseTrait; |
|
33 | 33 | |
34 | - protected HookService $hook_service; |
|
34 | + protected HookService $hook_service; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Constructor for ModulesHooksPage request handler |
|
38 | - * |
|
39 | - * @param HookService $hook_service |
|
40 | - */ |
|
41 | - public function __construct(HookService $hook_service) |
|
42 | - { |
|
43 | - $this->hook_service = $hook_service; |
|
44 | - } |
|
36 | + /** |
|
37 | + * Constructor for ModulesHooksPage request handler |
|
38 | + * |
|
39 | + * @param HookService $hook_service |
|
40 | + */ |
|
41 | + public function __construct(HookService $hook_service) |
|
42 | + { |
|
43 | + $this->hook_service = $hook_service; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * {@inheritDoc} |
|
48 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
49 | - */ |
|
50 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
51 | - { |
|
52 | - $this->layout = 'layouts/administration'; |
|
46 | + /** |
|
47 | + * {@inheritDoc} |
|
48 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
49 | + */ |
|
50 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
51 | + { |
|
52 | + $this->layout = 'layouts/administration'; |
|
53 | 53 | |
54 | - $hook_name = Validator::attributes($request)->string('hook_name', ''); |
|
55 | - $hook = $this->hook_service->find($hook_name, true); |
|
56 | - if ($hook === null) { |
|
57 | - throw new HttpNotFoundException(I18N::translate('The hook with name “%s” does not exist.', $hook_name)); |
|
58 | - } |
|
54 | + $hook_name = Validator::attributes($request)->string('hook_name', ''); |
|
55 | + $hook = $this->hook_service->find($hook_name, true); |
|
56 | + if ($hook === null) { |
|
57 | + throw new HttpNotFoundException(I18N::translate('The hook with name “%s” does not exist.', $hook_name)); |
|
58 | + } |
|
59 | 59 | |
60 | - $modules = $hook->hooks() |
|
61 | - ->sortKeys() |
|
62 | - ->mapWithKeys(fn(HookInterface $hook) => [$hook->module()->name() => $hook->module()]); |
|
60 | + $modules = $hook->hooks() |
|
61 | + ->sortKeys() |
|
62 | + ->mapWithKeys(fn(HookInterface $hook) => [$hook->module()->name() => $hook->module()]); |
|
63 | 63 | |
64 | - return $this->viewResponse('admin/components', [ |
|
65 | - 'description' => $hook->description(), |
|
66 | - 'modules' => $modules, |
|
67 | - 'title' => $hook->title(), |
|
68 | - 'uses_access' => false, |
|
69 | - 'uses_sorting' => true |
|
70 | - ]); |
|
71 | - } |
|
64 | + return $this->viewResponse('admin/components', [ |
|
65 | + 'description' => $hook->description(), |
|
66 | + 'modules' => $modules, |
|
67 | + 'title' => $hook->title(), |
|
68 | + 'uses_access' => false, |
|
69 | + 'uses_sorting' => true |
|
70 | + ]); |
|
71 | + } |
|
72 | 72 | } |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function loadRoutes(Map $router): void |
64 | 64 | { |
65 | - $router->attach('', '', static function (Map $router): void { |
|
65 | + $router->attach('', '', static function(Map $router): void { |
|
66 | 66 | |
67 | - $router->attach('', '/module-maj/welcomeblock/{block_id}', static function (Map $router): void { |
|
67 | + $router->attach('', '/module-maj/welcomeblock/{block_id}', static function(Map $router): void { |
|
68 | 68 | $router->tokens(['block_id' => '\d+']); |
69 | 69 | $router->get(MatomoStats::class, '/matomostats', MatomoStats::class); |
70 | 70 | }); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $fab_login_block_view = app(\Fisharebest\Webtrees\Module\LoginBlockModule::class) |
95 | 95 | ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED); |
96 | 96 | |
97 | - $content = view($this->name() . '::block-embed', [ |
|
97 | + $content = view($this->name().'::block-embed', [ |
|
98 | 98 | 'block_id' => $block_id, |
99 | 99 | 'fab_welcome_block_view' => $fab_welcome_block_view, |
100 | 100 | 'fab_login_block_view' => $fab_login_block_view, |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function editBlockConfiguration(Tree $tree, int $block_id): string |
132 | 132 | { |
133 | - return view($this->name() . '::config', $this->matomoSettings($block_id)); |
|
133 | + return view($this->name().'::config', $this->matomoSettings($block_id)); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | $this |
163 | 163 | ->setBlockSetting($block_id, 'matomo_url', $matomo_url) |
164 | 164 | ->setBlockSetting($block_id, 'matomo_token', $matomo_token) |
165 | - ->setBlockSetting($block_id, 'matomo_siteid', (string) $matomo_siteid); |
|
165 | + ->setBlockSetting($block_id, 'matomo_siteid', (string)$matomo_siteid); |
|
166 | 166 | |
167 | - Registry::cache()->file()->forget($this->name() . '-matomovisits-yearly-' . $block_id); |
|
167 | + Registry::cache()->file()->forget($this->name().'-matomovisits-yearly-'.$block_id); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | 'matomo_enabled' => $this->isMatomoEnabled($block_id), |
191 | 191 | 'matomo_url' => $this->getBlockSetting($block_id, 'matomo_url'), |
192 | 192 | 'matomo_token' => $this->getBlockSetting($block_id, 'matomo_token'), |
193 | - 'matomo_siteid' => (int) $this->getBlockSetting($block_id, 'matomo_siteid', '0') |
|
193 | + 'matomo_siteid' => (int)$this->getBlockSetting($block_id, 'matomo_siteid', '0') |
|
194 | 194 | ]; |
195 | 195 | } |
196 | 196 | } |
@@ -34,163 +34,163 @@ |
||
34 | 34 | */ |
35 | 35 | class WelcomeBlockModule extends AbstractModule implements ModuleMyArtJaubInterface, ModuleBlockInterface |
36 | 36 | { |
37 | - use ModuleMyArtJaubTrait; |
|
38 | - use ModuleBlockTrait; |
|
39 | - |
|
40 | - /** |
|
41 | - * {@inheritDoc} |
|
42 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
43 | - */ |
|
44 | - public function title(): string |
|
45 | - { |
|
46 | - return /* I18N: Name of the “WelcomeBlock” module */ I18N::translate('MyArtJaub Welcome Block'); |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * {@inheritDoc} |
|
51 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
52 | - */ |
|
53 | - public function description(): string |
|
54 | - { |
|
55 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
56 | - 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.'); |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * {@inheritDoc} |
|
61 | - * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
62 | - */ |
|
63 | - public function loadRoutes(Map $router): void |
|
64 | - { |
|
65 | - $router->attach('', '', static function (Map $router): void { |
|
66 | - |
|
67 | - $router->attach('', '/module-maj/welcomeblock/{block_id}', static function (Map $router): void { |
|
68 | - $router->tokens(['block_id' => '\d+']); |
|
69 | - $router->get(MatomoStats::class, '/matomostats', MatomoStats::class); |
|
70 | - }); |
|
71 | - }); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * {@inheritDoc} |
|
76 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
77 | - */ |
|
78 | - public function customModuleVersion(): string |
|
79 | - { |
|
80 | - return '2.1.1-v.1'; |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * {@inheritDoc} |
|
85 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::getBlock() |
|
86 | - * |
|
87 | - * @param mixed[] $config |
|
88 | - */ |
|
89 | - public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string |
|
90 | - { |
|
91 | - $fab_welcome_block_view = app(\Fisharebest\Webtrees\Module\WelcomeBlockModule::class) |
|
92 | - ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED); |
|
93 | - |
|
94 | - $fab_login_block_view = app(\Fisharebest\Webtrees\Module\LoginBlockModule::class) |
|
95 | - ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED); |
|
96 | - |
|
97 | - $content = view($this->name() . '::block-embed', [ |
|
98 | - 'block_id' => $block_id, |
|
99 | - 'fab_welcome_block_view' => $fab_welcome_block_view, |
|
100 | - 'fab_login_block_view' => $fab_login_block_view, |
|
101 | - 'matomo_enabled' => $this->isMatomoEnabled($block_id), |
|
102 | - 'js_script_url' => $this->assetUrl('js/welcomeblock.min.js') |
|
103 | - ]); |
|
104 | - |
|
105 | - if ($context !== self::CONTEXT_EMBED) { |
|
106 | - return view('modules/block-template', [ |
|
107 | - 'block' => Str::kebab($this->name()), |
|
108 | - 'id' => $block_id, |
|
109 | - 'config_url' => $this->configUrl($tree, $context, $block_id), |
|
110 | - 'title' => e($tree->title()), |
|
111 | - 'content' => $content, |
|
112 | - ]); |
|
113 | - } |
|
114 | - |
|
115 | - return $content; |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * {@inheritDoc} |
|
120 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::isTreeBlock() |
|
121 | - */ |
|
122 | - public function isTreeBlock(): bool |
|
123 | - { |
|
124 | - return true; |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * {@inheritDoc} |
|
129 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::editBlockConfiguration() |
|
130 | - */ |
|
131 | - public function editBlockConfiguration(Tree $tree, int $block_id): string |
|
132 | - { |
|
133 | - return view($this->name() . '::config', $this->matomoSettings($block_id)); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * {@inheritDoc} |
|
138 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::saveBlockConfiguration() |
|
139 | - */ |
|
140 | - public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void |
|
141 | - { |
|
142 | - $matomo_enabled = Validator::parsedBody($request)->string('matomo_enabled', '') === 'yes'; |
|
143 | - $this->setBlockSetting($block_id, 'matomo_enabled', $matomo_enabled ? 'yes' : 'no'); |
|
144 | - if (!$matomo_enabled) { |
|
145 | - return; |
|
146 | - } |
|
147 | - |
|
148 | - $matomo_url = trim(Validator::parsedBody($request)->string('matomo_url', '')); |
|
149 | - if (filter_var($matomo_url, FILTER_VALIDATE_URL) === false) { |
|
150 | - FlashMessages::addMessage(I18N::translate('The Matomo URL provided is not valid.'), 'danger'); |
|
151 | - return; |
|
152 | - } |
|
153 | - |
|
154 | - $matomo_siteid = Validator::parsedBody($request)->integer('matomo_siteid', -1); |
|
155 | - if ($matomo_siteid === -1) { |
|
156 | - FlashMessages::addMessage(I18N::translate('The Matomo Site ID provided is not valid.'), 'danger'); |
|
157 | - return; |
|
158 | - } |
|
159 | - |
|
160 | - $matomo_token = trim(Validator::parsedBody($request)->string('matomo_token', '')); |
|
161 | - |
|
162 | - $this |
|
163 | - ->setBlockSetting($block_id, 'matomo_url', $matomo_url) |
|
164 | - ->setBlockSetting($block_id, 'matomo_token', $matomo_token) |
|
165 | - ->setBlockSetting($block_id, 'matomo_siteid', (string) $matomo_siteid); |
|
166 | - |
|
167 | - Registry::cache()->file()->forget($this->name() . '-matomovisits-yearly-' . $block_id); |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Returns whether Matomo statistics is enabled for a specific MyArtJaub WelcomeBlock block |
|
172 | - * |
|
173 | - * @param int $block_id |
|
174 | - * @return bool |
|
175 | - */ |
|
176 | - public function isMatomoEnabled(int $block_id): bool |
|
177 | - { |
|
178 | - return $this->getBlockSetting($block_id, 'matomo_enabled', 'no') === 'yes'; |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * Returns settings for retrieving Matomo statistics for a specific MyArtJaub WelcomeBlock block |
|
183 | - * |
|
184 | - * @param int $block_id |
|
185 | - * @return array<string, mixed> |
|
186 | - */ |
|
187 | - public function matomoSettings(int $block_id): array |
|
188 | - { |
|
189 | - return [ |
|
190 | - 'matomo_enabled' => $this->isMatomoEnabled($block_id), |
|
191 | - 'matomo_url' => $this->getBlockSetting($block_id, 'matomo_url'), |
|
192 | - 'matomo_token' => $this->getBlockSetting($block_id, 'matomo_token'), |
|
193 | - 'matomo_siteid' => (int) $this->getBlockSetting($block_id, 'matomo_siteid', '0') |
|
194 | - ]; |
|
195 | - } |
|
37 | + use ModuleMyArtJaubTrait; |
|
38 | + use ModuleBlockTrait; |
|
39 | + |
|
40 | + /** |
|
41 | + * {@inheritDoc} |
|
42 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
43 | + */ |
|
44 | + public function title(): string |
|
45 | + { |
|
46 | + return /* I18N: Name of the “WelcomeBlock” module */ I18N::translate('MyArtJaub Welcome Block'); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * {@inheritDoc} |
|
51 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
52 | + */ |
|
53 | + public function description(): string |
|
54 | + { |
|
55 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
56 | + 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.'); |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * {@inheritDoc} |
|
61 | + * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
62 | + */ |
|
63 | + public function loadRoutes(Map $router): void |
|
64 | + { |
|
65 | + $router->attach('', '', static function (Map $router): void { |
|
66 | + |
|
67 | + $router->attach('', '/module-maj/welcomeblock/{block_id}', static function (Map $router): void { |
|
68 | + $router->tokens(['block_id' => '\d+']); |
|
69 | + $router->get(MatomoStats::class, '/matomostats', MatomoStats::class); |
|
70 | + }); |
|
71 | + }); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * {@inheritDoc} |
|
76 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
77 | + */ |
|
78 | + public function customModuleVersion(): string |
|
79 | + { |
|
80 | + return '2.1.1-v.1'; |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * {@inheritDoc} |
|
85 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::getBlock() |
|
86 | + * |
|
87 | + * @param mixed[] $config |
|
88 | + */ |
|
89 | + public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string |
|
90 | + { |
|
91 | + $fab_welcome_block_view = app(\Fisharebest\Webtrees\Module\WelcomeBlockModule::class) |
|
92 | + ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED); |
|
93 | + |
|
94 | + $fab_login_block_view = app(\Fisharebest\Webtrees\Module\LoginBlockModule::class) |
|
95 | + ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED); |
|
96 | + |
|
97 | + $content = view($this->name() . '::block-embed', [ |
|
98 | + 'block_id' => $block_id, |
|
99 | + 'fab_welcome_block_view' => $fab_welcome_block_view, |
|
100 | + 'fab_login_block_view' => $fab_login_block_view, |
|
101 | + 'matomo_enabled' => $this->isMatomoEnabled($block_id), |
|
102 | + 'js_script_url' => $this->assetUrl('js/welcomeblock.min.js') |
|
103 | + ]); |
|
104 | + |
|
105 | + if ($context !== self::CONTEXT_EMBED) { |
|
106 | + return view('modules/block-template', [ |
|
107 | + 'block' => Str::kebab($this->name()), |
|
108 | + 'id' => $block_id, |
|
109 | + 'config_url' => $this->configUrl($tree, $context, $block_id), |
|
110 | + 'title' => e($tree->title()), |
|
111 | + 'content' => $content, |
|
112 | + ]); |
|
113 | + } |
|
114 | + |
|
115 | + return $content; |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * {@inheritDoc} |
|
120 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::isTreeBlock() |
|
121 | + */ |
|
122 | + public function isTreeBlock(): bool |
|
123 | + { |
|
124 | + return true; |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * {@inheritDoc} |
|
129 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::editBlockConfiguration() |
|
130 | + */ |
|
131 | + public function editBlockConfiguration(Tree $tree, int $block_id): string |
|
132 | + { |
|
133 | + return view($this->name() . '::config', $this->matomoSettings($block_id)); |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * {@inheritDoc} |
|
138 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::saveBlockConfiguration() |
|
139 | + */ |
|
140 | + public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void |
|
141 | + { |
|
142 | + $matomo_enabled = Validator::parsedBody($request)->string('matomo_enabled', '') === 'yes'; |
|
143 | + $this->setBlockSetting($block_id, 'matomo_enabled', $matomo_enabled ? 'yes' : 'no'); |
|
144 | + if (!$matomo_enabled) { |
|
145 | + return; |
|
146 | + } |
|
147 | + |
|
148 | + $matomo_url = trim(Validator::parsedBody($request)->string('matomo_url', '')); |
|
149 | + if (filter_var($matomo_url, FILTER_VALIDATE_URL) === false) { |
|
150 | + FlashMessages::addMessage(I18N::translate('The Matomo URL provided is not valid.'), 'danger'); |
|
151 | + return; |
|
152 | + } |
|
153 | + |
|
154 | + $matomo_siteid = Validator::parsedBody($request)->integer('matomo_siteid', -1); |
|
155 | + if ($matomo_siteid === -1) { |
|
156 | + FlashMessages::addMessage(I18N::translate('The Matomo Site ID provided is not valid.'), 'danger'); |
|
157 | + return; |
|
158 | + } |
|
159 | + |
|
160 | + $matomo_token = trim(Validator::parsedBody($request)->string('matomo_token', '')); |
|
161 | + |
|
162 | + $this |
|
163 | + ->setBlockSetting($block_id, 'matomo_url', $matomo_url) |
|
164 | + ->setBlockSetting($block_id, 'matomo_token', $matomo_token) |
|
165 | + ->setBlockSetting($block_id, 'matomo_siteid', (string) $matomo_siteid); |
|
166 | + |
|
167 | + Registry::cache()->file()->forget($this->name() . '-matomovisits-yearly-' . $block_id); |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Returns whether Matomo statistics is enabled for a specific MyArtJaub WelcomeBlock block |
|
172 | + * |
|
173 | + * @param int $block_id |
|
174 | + * @return bool |
|
175 | + */ |
|
176 | + public function isMatomoEnabled(int $block_id): bool |
|
177 | + { |
|
178 | + return $this->getBlockSetting($block_id, 'matomo_enabled', 'no') === 'yes'; |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * Returns settings for retrieving Matomo statistics for a specific MyArtJaub WelcomeBlock block |
|
183 | + * |
|
184 | + * @param int $block_id |
|
185 | + * @return array<string, mixed> |
|
186 | + */ |
|
187 | + public function matomoSettings(int $block_id): array |
|
188 | + { |
|
189 | + return [ |
|
190 | + 'matomo_enabled' => $this->isMatomoEnabled($block_id), |
|
191 | + 'matomo_url' => $this->getBlockSetting($block_id, 'matomo_url'), |
|
192 | + 'matomo_token' => $this->getBlockSetting($block_id, 'matomo_token'), |
|
193 | + 'matomo_siteid' => (int) $this->getBlockSetting($block_id, 'matomo_siteid', '0') |
|
194 | + ]; |
|
195 | + } |
|
196 | 196 | } |
@@ -36,139 +36,139 @@ |
||
36 | 36 | * Display lineages of people with the same surname. |
37 | 37 | */ |
38 | 38 | class PatronymicLineageModule extends IndividualListModule implements |
39 | - ModuleMyArtJaubInterface, |
|
40 | - ModuleListInterface, |
|
41 | - ModuleGlobalInterface |
|
39 | + ModuleMyArtJaubInterface, |
|
40 | + ModuleListInterface, |
|
41 | + ModuleGlobalInterface |
|
42 | 42 | { |
43 | - use ModuleMyArtJaubTrait; |
|
44 | - use ModuleListTrait; |
|
45 | - use ModuleGlobalTrait; |
|
46 | - |
|
47 | - /** |
|
48 | - * {@inheritDoc} |
|
49 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
50 | - */ |
|
51 | - public function title(): string |
|
52 | - { |
|
53 | - return /* I18N: Name of the “Patronymic lineage” module */ I18N::translate('Patronymic Lineages'); |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * {@inheritDoc} |
|
58 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
59 | - */ |
|
60 | - public function description(): string |
|
61 | - { |
|
62 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
63 | - return /* I18N: Description of the “Patronymic lineage” module */ I18N::translate('Display lineages of people holding the same surname.'); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * {@inheritDoc} |
|
68 | - * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
69 | - */ |
|
70 | - public function loadRoutes(Map $router): void |
|
71 | - { |
|
72 | - $router->attach('', '', static function (Map $router): void { |
|
73 | - |
|
74 | - $router->attach('', '/module-maj/lineages', static function (Map $router): void { |
|
75 | - |
|
76 | - $router->attach('', '/Page', static function (Map $router): void { |
|
77 | - |
|
78 | - $router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class); |
|
79 | - $router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class); |
|
80 | - }); |
|
81 | - }); |
|
82 | - }); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * {@inheritDoc} |
|
87 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
88 | - */ |
|
89 | - public function customModuleVersion(): string |
|
90 | - { |
|
91 | - return '2.0.11-v.1'; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * {@inheritDoc} |
|
96 | - * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listUrl() |
|
97 | - * |
|
98 | - * @param array<bool|int|string|array<mixed>|null> $parameters |
|
99 | - */ |
|
100 | - public function listUrl(Tree $tree, array $parameters = []): string |
|
101 | - { |
|
102 | - $surname = $parameters['surname'] ?? ''; |
|
103 | - |
|
104 | - $xref = app(ServerRequestInterface::class)->getAttribute('xref', ''); |
|
105 | - if ($xref !== '' && ($individual = Registry::individualFactory()->make($xref, $tree)) !== null) { |
|
106 | - $surname = $individual->getAllNames()[$individual->getPrimaryName()]['surname']; |
|
107 | - } |
|
108 | - |
|
109 | - if ($surname !== '') { |
|
110 | - return route(LineagesPage::class, [ |
|
111 | - 'tree' => $tree->name(), |
|
112 | - 'surname' => $surname |
|
113 | - ] + $parameters); |
|
114 | - } |
|
115 | - return route(SurnamesList::class, [ |
|
116 | - 'tree' => $tree->name() |
|
117 | - ] + $parameters); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * {@inheritDoc} |
|
122 | - * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listMenuClass() |
|
123 | - */ |
|
124 | - public function listMenuClass(): string |
|
125 | - { |
|
126 | - return 'menu-maj-patrolineage'; |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * {@inheritDoc} |
|
131 | - * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
132 | - */ |
|
133 | - public function headContent(): string |
|
134 | - { |
|
135 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * {@inheritDoc} |
|
140 | - * @see \Fisharebest\Webtrees\Module\IndividualListModule::individuals() |
|
141 | - * |
|
142 | - * Implemented to set the visibility to public. |
|
143 | - * This should probably be in a service, but this hack allows for reuse of mainstream code. |
|
144 | - */ |
|
145 | - public function individuals( |
|
146 | - Tree $tree, |
|
147 | - string $surn, |
|
148 | - string $salpha, |
|
149 | - string $galpha, |
|
150 | - bool $marnm, |
|
151 | - bool $fams, |
|
152 | - LocaleInterface $locale |
|
153 | - ): Collection { |
|
154 | - return parent::individuals($tree, $surn, $salpha, $galpha, $marnm, $fams, $locale); |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * {@inheritDoc} |
|
159 | - * @see \Fisharebest\Webtrees\Module\IndividualListModule::surnames() |
|
160 | - * |
|
161 | - * Implemented to set the visibility to public. |
|
162 | - * This should probably be in a service, but this hack allows for reuse of mainstream code. |
|
163 | - */ |
|
164 | - public function surnames( |
|
165 | - Tree $tree, |
|
166 | - string $surn, |
|
167 | - string $salpha, |
|
168 | - bool $marnm, |
|
169 | - bool $fams, |
|
170 | - LocaleInterface $locale |
|
171 | - ): array { |
|
172 | - return parent::surnames($tree, $surn, $salpha, $marnm, $fams, $locale); |
|
173 | - } |
|
43 | + use ModuleMyArtJaubTrait; |
|
44 | + use ModuleListTrait; |
|
45 | + use ModuleGlobalTrait; |
|
46 | + |
|
47 | + /** |
|
48 | + * {@inheritDoc} |
|
49 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
50 | + */ |
|
51 | + public function title(): string |
|
52 | + { |
|
53 | + return /* I18N: Name of the “Patronymic lineage” module */ I18N::translate('Patronymic Lineages'); |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * {@inheritDoc} |
|
58 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
59 | + */ |
|
60 | + public function description(): string |
|
61 | + { |
|
62 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
63 | + return /* I18N: Description of the “Patronymic lineage” module */ I18N::translate('Display lineages of people holding the same surname.'); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * {@inheritDoc} |
|
68 | + * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
69 | + */ |
|
70 | + public function loadRoutes(Map $router): void |
|
71 | + { |
|
72 | + $router->attach('', '', static function (Map $router): void { |
|
73 | + |
|
74 | + $router->attach('', '/module-maj/lineages', static function (Map $router): void { |
|
75 | + |
|
76 | + $router->attach('', '/Page', static function (Map $router): void { |
|
77 | + |
|
78 | + $router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class); |
|
79 | + $router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class); |
|
80 | + }); |
|
81 | + }); |
|
82 | + }); |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * {@inheritDoc} |
|
87 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
88 | + */ |
|
89 | + public function customModuleVersion(): string |
|
90 | + { |
|
91 | + return '2.0.11-v.1'; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * {@inheritDoc} |
|
96 | + * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listUrl() |
|
97 | + * |
|
98 | + * @param array<bool|int|string|array<mixed>|null> $parameters |
|
99 | + */ |
|
100 | + public function listUrl(Tree $tree, array $parameters = []): string |
|
101 | + { |
|
102 | + $surname = $parameters['surname'] ?? ''; |
|
103 | + |
|
104 | + $xref = app(ServerRequestInterface::class)->getAttribute('xref', ''); |
|
105 | + if ($xref !== '' && ($individual = Registry::individualFactory()->make($xref, $tree)) !== null) { |
|
106 | + $surname = $individual->getAllNames()[$individual->getPrimaryName()]['surname']; |
|
107 | + } |
|
108 | + |
|
109 | + if ($surname !== '') { |
|
110 | + return route(LineagesPage::class, [ |
|
111 | + 'tree' => $tree->name(), |
|
112 | + 'surname' => $surname |
|
113 | + ] + $parameters); |
|
114 | + } |
|
115 | + return route(SurnamesList::class, [ |
|
116 | + 'tree' => $tree->name() |
|
117 | + ] + $parameters); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * {@inheritDoc} |
|
122 | + * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listMenuClass() |
|
123 | + */ |
|
124 | + public function listMenuClass(): string |
|
125 | + { |
|
126 | + return 'menu-maj-patrolineage'; |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * {@inheritDoc} |
|
131 | + * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
132 | + */ |
|
133 | + public function headContent(): string |
|
134 | + { |
|
135 | + return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * {@inheritDoc} |
|
140 | + * @see \Fisharebest\Webtrees\Module\IndividualListModule::individuals() |
|
141 | + * |
|
142 | + * Implemented to set the visibility to public. |
|
143 | + * This should probably be in a service, but this hack allows for reuse of mainstream code. |
|
144 | + */ |
|
145 | + public function individuals( |
|
146 | + Tree $tree, |
|
147 | + string $surn, |
|
148 | + string $salpha, |
|
149 | + string $galpha, |
|
150 | + bool $marnm, |
|
151 | + bool $fams, |
|
152 | + LocaleInterface $locale |
|
153 | + ): Collection { |
|
154 | + return parent::individuals($tree, $surn, $salpha, $galpha, $marnm, $fams, $locale); |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * {@inheritDoc} |
|
159 | + * @see \Fisharebest\Webtrees\Module\IndividualListModule::surnames() |
|
160 | + * |
|
161 | + * Implemented to set the visibility to public. |
|
162 | + * This should probably be in a service, but this hack allows for reuse of mainstream code. |
|
163 | + */ |
|
164 | + public function surnames( |
|
165 | + Tree $tree, |
|
166 | + string $surn, |
|
167 | + string $salpha, |
|
168 | + bool $marnm, |
|
169 | + bool $fams, |
|
170 | + LocaleInterface $locale |
|
171 | + ): array { |
|
172 | + return parent::surnames($tree, $surn, $salpha, $marnm, $fams, $locale); |
|
173 | + } |
|
174 | 174 | } |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function loadRoutes(Map $router): void |
71 | 71 | { |
72 | - $router->attach('', '', static function (Map $router): void { |
|
72 | + $router->attach('', '', static function(Map $router): void { |
|
73 | 73 | |
74 | - $router->attach('', '/module-maj/lineages', static function (Map $router): void { |
|
74 | + $router->attach('', '/module-maj/lineages', static function(Map $router): void { |
|
75 | 75 | |
76 | - $router->attach('', '/Page', static function (Map $router): void { |
|
76 | + $router->attach('', '/Page', static function(Map $router): void { |
|
77 | 77 | |
78 | 78 | $router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class); |
79 | 79 | $router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function headContent(): string |
134 | 134 | { |
135 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
135 | + return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">'; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -23,68 +23,68 @@ |
||
23 | 23 | */ |
24 | 24 | class LineageRootNode extends LineageNode |
25 | 25 | { |
26 | - /** |
|
27 | - * @var Collection<string, int> $places Places for the lineage node |
|
28 | - */ |
|
29 | - private $places; |
|
26 | + /** |
|
27 | + * @var Collection<string, int> $places Places for the lineage node |
|
28 | + */ |
|
29 | + private $places; |
|
30 | 30 | |
31 | - /** |
|
32 | - * @var int $nb_children Number of node childs |
|
33 | - */ |
|
34 | - private $nb_children; |
|
31 | + /** |
|
32 | + * @var int $nb_children Number of node childs |
|
33 | + */ |
|
34 | + private $nb_children; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Constructor for LineageRootNode |
|
38 | - * |
|
39 | - * @param Individual|null $node_indi |
|
40 | - */ |
|
41 | - public function __construct(?Individual $node_indi = null) |
|
42 | - { |
|
43 | - parent::__construct($node_indi, $this); |
|
44 | - $this->places = new Collection(); |
|
45 | - $this->nb_children = 0; |
|
46 | - } |
|
36 | + /** |
|
37 | + * Constructor for LineageRootNode |
|
38 | + * |
|
39 | + * @param Individual|null $node_indi |
|
40 | + */ |
|
41 | + public function __construct(?Individual $node_indi = null) |
|
42 | + { |
|
43 | + parent::__construct($node_indi, $this); |
|
44 | + $this->places = new Collection(); |
|
45 | + $this->nb_children = 0; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Adds a place to the list of lineage's place |
|
50 | - * |
|
51 | - * @param Place $place |
|
52 | - */ |
|
53 | - public function addPlace(Place $place): void |
|
54 | - { |
|
55 | - $place_name = $place->gedcomName(); |
|
56 | - if (mb_strlen($place_name) > 0) { |
|
57 | - $this->places->put($place_name, $this->places->get($place_name, 0) + 1); |
|
58 | - } |
|
59 | - } |
|
48 | + /** |
|
49 | + * Adds a place to the list of lineage's place |
|
50 | + * |
|
51 | + * @param Place $place |
|
52 | + */ |
|
53 | + public function addPlace(Place $place): void |
|
54 | + { |
|
55 | + $place_name = $place->gedcomName(); |
|
56 | + if (mb_strlen($place_name) > 0) { |
|
57 | + $this->places->put($place_name, $this->places->get($place_name, 0) + 1); |
|
58 | + } |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Returns the number of child nodes. |
|
63 | - * This number is more to be used as indication rather than an accurate one. |
|
64 | - * |
|
65 | - * @return int |
|
66 | - */ |
|
67 | - public function numberChildNodes(): int |
|
68 | - { |
|
69 | - return $this->nb_children; |
|
70 | - } |
|
61 | + /** |
|
62 | + * Returns the number of child nodes. |
|
63 | + * This number is more to be used as indication rather than an accurate one. |
|
64 | + * |
|
65 | + * @return int |
|
66 | + */ |
|
67 | + public function numberChildNodes(): int |
|
68 | + { |
|
69 | + return $this->nb_children; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Increments the number of child nodes by one |
|
74 | - * |
|
75 | - */ |
|
76 | - public function incrementChildNodes(): void |
|
77 | - { |
|
78 | - $this->nb_children++; |
|
79 | - } |
|
72 | + /** |
|
73 | + * Increments the number of child nodes by one |
|
74 | + * |
|
75 | + */ |
|
76 | + public function incrementChildNodes(): void |
|
77 | + { |
|
78 | + $this->nb_children++; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Returns the list of place for the lineage |
|
83 | - * |
|
84 | - * @return Collection<string, int> |
|
85 | - */ |
|
86 | - public function places(): Collection |
|
87 | - { |
|
88 | - return $this->places; |
|
89 | - } |
|
81 | + /** |
|
82 | + * Returns the list of place for the lineage |
|
83 | + * |
|
84 | + * @return Collection<string, int> |
|
85 | + */ |
|
86 | + public function places(): Collection |
|
87 | + { |
|
88 | + return $this->places; |
|
89 | + } |
|
90 | 90 | } |
@@ -21,12 +21,12 @@ |
||
21 | 21 | */ |
22 | 22 | class Migration0 implements MigrationInterface |
23 | 23 | { |
24 | - /** |
|
25 | - * {@inheritDoc} |
|
26 | - * @see MigrationInterface::upgrade() |
|
27 | - */ |
|
28 | - public function upgrade(): void |
|
29 | - { |
|
30 | - // These migrations have been merged into migration 1. |
|
31 | - } |
|
24 | + /** |
|
25 | + * {@inheritDoc} |
|
26 | + * @see MigrationInterface::upgrade() |
|
27 | + */ |
|
28 | + public function upgrade(): void |
|
29 | + { |
|
30 | + // These migrations have been merged into migration 1. |
|
31 | + } |
|
32 | 32 | } |
@@ -31,58 +31,58 @@ |
||
31 | 31 | */ |
32 | 32 | class TaskEditPage implements RequestHandlerInterface |
33 | 33 | { |
34 | - use ViewResponseTrait; |
|
34 | + use ViewResponseTrait; |
|
35 | 35 | |
36 | - private ?AdminTasksModule $module; |
|
37 | - private TaskScheduleService $taskschedules_service; |
|
36 | + private ?AdminTasksModule $module; |
|
37 | + private TaskScheduleService $taskschedules_service; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Constructor for TaskEditPage Request Handler |
|
41 | - * |
|
42 | - * @param ModuleService $module_service |
|
43 | - * @param TaskScheduleService $taskschedules_service |
|
44 | - */ |
|
45 | - public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service) |
|
46 | - { |
|
47 | - $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
48 | - $this->taskschedules_service = $taskschedules_service; |
|
49 | - } |
|
39 | + /** |
|
40 | + * Constructor for TaskEditPage Request Handler |
|
41 | + * |
|
42 | + * @param ModuleService $module_service |
|
43 | + * @param TaskScheduleService $taskschedules_service |
|
44 | + */ |
|
45 | + public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service) |
|
46 | + { |
|
47 | + $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
48 | + $this->taskschedules_service = $taskschedules_service; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * {@inheritDoc} |
|
53 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
54 | - */ |
|
55 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
56 | - { |
|
57 | - $this->layout = 'layouts/administration'; |
|
51 | + /** |
|
52 | + * {@inheritDoc} |
|
53 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
54 | + */ |
|
55 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
56 | + { |
|
57 | + $this->layout = 'layouts/administration'; |
|
58 | 58 | |
59 | - if ($this->module === null) { |
|
60 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
61 | - } |
|
59 | + if ($this->module === null) { |
|
60 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
61 | + } |
|
62 | 62 | |
63 | - $task_sched_id = Validator::attributes($request)->integer('task', -1); |
|
64 | - $task_schedule = $this->taskschedules_service->find($task_sched_id); |
|
63 | + $task_sched_id = Validator::attributes($request)->integer('task', -1); |
|
64 | + $task_schedule = $this->taskschedules_service->find($task_sched_id); |
|
65 | 65 | |
66 | - if ($task_schedule === null) { |
|
67 | - throw new HttpNotFoundException(I18N::translate('The Task schedule could not be found.')); |
|
68 | - } |
|
66 | + if ($task_schedule === null) { |
|
67 | + throw new HttpNotFoundException(I18N::translate('The Task schedule could not be found.')); |
|
68 | + } |
|
69 | 69 | |
70 | - $task = $this->taskschedules_service->findTask($task_schedule->taskId()); |
|
70 | + $task = $this->taskschedules_service->findTask($task_schedule->taskId()); |
|
71 | 71 | |
72 | - if ($task === null) { |
|
73 | - throw new HttpNotFoundException(I18N::translate('The Task schedule could not be found.')); |
|
74 | - } |
|
72 | + if ($task === null) { |
|
73 | + throw new HttpNotFoundException(I18N::translate('The Task schedule could not be found.')); |
|
74 | + } |
|
75 | 75 | |
76 | - $has_task_config = $task instanceof ConfigurableTaskInterface; |
|
77 | - /** @var \MyArtJaub\Webtrees\Contracts\Tasks\TaskInterface&\MyArtJaub\Webtrees\Contracts\Tasks\ConfigurableTaskInterface $task */ |
|
76 | + $has_task_config = $task instanceof ConfigurableTaskInterface; |
|
77 | + /** @var \MyArtJaub\Webtrees\Contracts\Tasks\TaskInterface&\MyArtJaub\Webtrees\Contracts\Tasks\ConfigurableTaskInterface $task */ |
|
78 | 78 | |
79 | - return $this->viewResponse($this->module->name() . '::admin/tasks-edit', [ |
|
80 | - 'module' => $this->module, |
|
81 | - 'title' => I18N::translate('Edit the administrative task') . ' - ' . $task->name(), |
|
82 | - 'task_schedule' => $task_schedule, |
|
83 | - 'task' => $task, |
|
84 | - 'has_task_config' => $has_task_config, |
|
85 | - 'task_config_view' => $has_task_config ? $task->configView($request) : '' |
|
86 | - ]); |
|
87 | - } |
|
79 | + return $this->viewResponse($this->module->name() . '::admin/tasks-edit', [ |
|
80 | + 'module' => $this->module, |
|
81 | + 'title' => I18N::translate('Edit the administrative task') . ' - ' . $task->name(), |
|
82 | + 'task_schedule' => $task_schedule, |
|
83 | + 'task' => $task, |
|
84 | + 'has_task_config' => $has_task_config, |
|
85 | + 'task_config_view' => $has_task_config ? $task->configView($request) : '' |
|
86 | + ]); |
|
87 | + } |
|
88 | 88 | } |
@@ -76,9 +76,9 @@ |
||
76 | 76 | $has_task_config = $task instanceof ConfigurableTaskInterface; |
77 | 77 | /** @var \MyArtJaub\Webtrees\Contracts\Tasks\TaskInterface&\MyArtJaub\Webtrees\Contracts\Tasks\ConfigurableTaskInterface $task */ |
78 | 78 | |
79 | - return $this->viewResponse($this->module->name() . '::admin/tasks-edit', [ |
|
79 | + return $this->viewResponse($this->module->name().'::admin/tasks-edit', [ |
|
80 | 80 | 'module' => $this->module, |
81 | - 'title' => I18N::translate('Edit the administrative task') . ' - ' . $task->name(), |
|
81 | + 'title' => I18N::translate('Edit the administrative task').' - '.$task->name(), |
|
82 | 82 | 'task_schedule' => $task_schedule, |
83 | 83 | 'task' => $task, |
84 | 84 | 'has_task_config' => $has_task_config, |
@@ -32,117 +32,117 @@ |
||
32 | 32 | */ |
33 | 33 | class GeoAnalysisMap extends AbstractGeoAnalysisView |
34 | 34 | { |
35 | - private ?MapColorsConfig $colors_config = null; |
|
36 | - |
|
37 | - public function type(): string |
|
38 | - { |
|
39 | - return I18N::translateContext('GEODISPERSION', 'Map'); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * {@inheritDoc} |
|
44 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::icon() |
|
45 | - */ |
|
46 | - public function icon(ModuleInterface $module): string |
|
47 | - { |
|
48 | - return view($module->name() . '::icons/view-map', ['type' => $this->type()]); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * {@inheritDoc} |
|
53 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::globalSettingsContent() |
|
54 | - */ |
|
55 | - public function globalSettingsContent(ModuleInterface $module): string |
|
56 | - { |
|
57 | - return view($module->name() . '::admin/view-edit-map', [ |
|
58 | - 'module_name' => $module->name(), |
|
59 | - 'view' => $this, |
|
60 | - 'colors' => $this->colors(), |
|
61 | - 'map_adapters' => app(MapAdapterDataService::class)->allForView($this, true) |
|
62 | - ]); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * {@inheritDoc} |
|
67 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::withGlobalSettingsUpdate() |
|
68 | - * @return static |
|
69 | - */ |
|
70 | - public function withGlobalSettingsUpdate(ServerRequestInterface $request): self |
|
71 | - { |
|
72 | - $default_color = Validator::parsedBody($request)->string('view_map_color_default', ''); |
|
73 | - $stroke_color = Validator::parsedBody($request)->string('view_map_color_stroke', ''); |
|
74 | - $maxvalue_color = Validator::parsedBody($request)->string('view_map_color_maxvalue', ''); |
|
75 | - $hover_color = Validator::parsedBody($request)->string('view_map_color_hover', ''); |
|
76 | - |
|
77 | - try { |
|
78 | - return $this->withColors(new MapColorsConfig( |
|
79 | - Hex::fromString($default_color), |
|
80 | - Hex::fromString($stroke_color), |
|
81 | - Hex::fromString($maxvalue_color), |
|
82 | - Hex::fromString($hover_color) |
|
83 | - )); |
|
84 | - } catch (InvalidColorValue $ex) { |
|
85 | - } |
|
86 | - |
|
87 | - return $this; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * {@inheritDoc} |
|
92 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::globalTabContent() |
|
93 | - */ |
|
94 | - public function globalTabContent(GeoDispersionModule $module, GeoAnalysisResult $result, array $params): string |
|
95 | - { |
|
96 | - $map_adapters = app(MapAdapterDataService::class)->allForView($this); |
|
97 | - |
|
98 | - $adapter_result = null; |
|
99 | - foreach ($map_adapters as $map_adapter) { |
|
100 | - $adapter_result_tmp = $map_adapter->convert($result); |
|
101 | - $adapter_result = $adapter_result === null ? |
|
102 | - $adapter_result_tmp : |
|
103 | - $adapter_result->merge($adapter_result_tmp); |
|
104 | - } |
|
105 | - |
|
106 | - if ($adapter_result === null) { |
|
107 | - return view($module->name() . '::errors/tab-error', [ |
|
108 | - 'message' => I18N::translate('The map could not be loaded.'), |
|
109 | - ]); |
|
110 | - } |
|
111 | - |
|
112 | - return view($module->name() . '::geoanalysisview-tab-glb-map', $params + [ |
|
113 | - 'result' => $adapter_result->geoAnalysisResult(), |
|
114 | - 'features' => $adapter_result->features(), |
|
115 | - 'colors' => $this->colors(), |
|
116 | - 'leaflet_config' => app(LeafletJsService::class)->config(), |
|
117 | - 'js_script_url' => $module->assetUrl('js/geodispersion.min.js') |
|
118 | - ]); |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Get the color scheme configuration for the map view |
|
123 | - * |
|
124 | - * @return MapColorsConfig |
|
125 | - */ |
|
126 | - public function colors(): MapColorsConfig |
|
127 | - { |
|
128 | - return $this->colors_config ?? new MapColorsConfig( |
|
129 | - new Rgb(245, 245, 245), |
|
130 | - new Rgb(213, 213, 213), |
|
131 | - new Rgb(4, 147, 171), |
|
132 | - new Rgb(255, 102, 0) |
|
133 | - ); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Returns a map view with a new color scheme configuration |
|
138 | - * |
|
139 | - * @param MapColorsConfig $config |
|
140 | - * @return static |
|
141 | - */ |
|
142 | - public function withColors(?MapColorsConfig $config): self |
|
143 | - { |
|
144 | - $new = clone $this; |
|
145 | - $new->colors_config = $config; |
|
146 | - return $new; |
|
147 | - } |
|
35 | + private ?MapColorsConfig $colors_config = null; |
|
36 | + |
|
37 | + public function type(): string |
|
38 | + { |
|
39 | + return I18N::translateContext('GEODISPERSION', 'Map'); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * {@inheritDoc} |
|
44 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::icon() |
|
45 | + */ |
|
46 | + public function icon(ModuleInterface $module): string |
|
47 | + { |
|
48 | + return view($module->name() . '::icons/view-map', ['type' => $this->type()]); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * {@inheritDoc} |
|
53 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::globalSettingsContent() |
|
54 | + */ |
|
55 | + public function globalSettingsContent(ModuleInterface $module): string |
|
56 | + { |
|
57 | + return view($module->name() . '::admin/view-edit-map', [ |
|
58 | + 'module_name' => $module->name(), |
|
59 | + 'view' => $this, |
|
60 | + 'colors' => $this->colors(), |
|
61 | + 'map_adapters' => app(MapAdapterDataService::class)->allForView($this, true) |
|
62 | + ]); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * {@inheritDoc} |
|
67 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::withGlobalSettingsUpdate() |
|
68 | + * @return static |
|
69 | + */ |
|
70 | + public function withGlobalSettingsUpdate(ServerRequestInterface $request): self |
|
71 | + { |
|
72 | + $default_color = Validator::parsedBody($request)->string('view_map_color_default', ''); |
|
73 | + $stroke_color = Validator::parsedBody($request)->string('view_map_color_stroke', ''); |
|
74 | + $maxvalue_color = Validator::parsedBody($request)->string('view_map_color_maxvalue', ''); |
|
75 | + $hover_color = Validator::parsedBody($request)->string('view_map_color_hover', ''); |
|
76 | + |
|
77 | + try { |
|
78 | + return $this->withColors(new MapColorsConfig( |
|
79 | + Hex::fromString($default_color), |
|
80 | + Hex::fromString($stroke_color), |
|
81 | + Hex::fromString($maxvalue_color), |
|
82 | + Hex::fromString($hover_color) |
|
83 | + )); |
|
84 | + } catch (InvalidColorValue $ex) { |
|
85 | + } |
|
86 | + |
|
87 | + return $this; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * {@inheritDoc} |
|
92 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisView::globalTabContent() |
|
93 | + */ |
|
94 | + public function globalTabContent(GeoDispersionModule $module, GeoAnalysisResult $result, array $params): string |
|
95 | + { |
|
96 | + $map_adapters = app(MapAdapterDataService::class)->allForView($this); |
|
97 | + |
|
98 | + $adapter_result = null; |
|
99 | + foreach ($map_adapters as $map_adapter) { |
|
100 | + $adapter_result_tmp = $map_adapter->convert($result); |
|
101 | + $adapter_result = $adapter_result === null ? |
|
102 | + $adapter_result_tmp : |
|
103 | + $adapter_result->merge($adapter_result_tmp); |
|
104 | + } |
|
105 | + |
|
106 | + if ($adapter_result === null) { |
|
107 | + return view($module->name() . '::errors/tab-error', [ |
|
108 | + 'message' => I18N::translate('The map could not be loaded.'), |
|
109 | + ]); |
|
110 | + } |
|
111 | + |
|
112 | + return view($module->name() . '::geoanalysisview-tab-glb-map', $params + [ |
|
113 | + 'result' => $adapter_result->geoAnalysisResult(), |
|
114 | + 'features' => $adapter_result->features(), |
|
115 | + 'colors' => $this->colors(), |
|
116 | + 'leaflet_config' => app(LeafletJsService::class)->config(), |
|
117 | + 'js_script_url' => $module->assetUrl('js/geodispersion.min.js') |
|
118 | + ]); |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Get the color scheme configuration for the map view |
|
123 | + * |
|
124 | + * @return MapColorsConfig |
|
125 | + */ |
|
126 | + public function colors(): MapColorsConfig |
|
127 | + { |
|
128 | + return $this->colors_config ?? new MapColorsConfig( |
|
129 | + new Rgb(245, 245, 245), |
|
130 | + new Rgb(213, 213, 213), |
|
131 | + new Rgb(4, 147, 171), |
|
132 | + new Rgb(255, 102, 0) |
|
133 | + ); |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Returns a map view with a new color scheme configuration |
|
138 | + * |
|
139 | + * @param MapColorsConfig $config |
|
140 | + * @return static |
|
141 | + */ |
|
142 | + public function withColors(?MapColorsConfig $config): self |
|
143 | + { |
|
144 | + $new = clone $this; |
|
145 | + $new->colors_config = $config; |
|
146 | + return $new; |
|
147 | + } |
|
148 | 148 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function icon(ModuleInterface $module): string |
47 | 47 | { |
48 | - return view($module->name() . '::icons/view-map', ['type' => $this->type()]); |
|
48 | + return view($module->name().'::icons/view-map', ['type' => $this->type()]); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function globalSettingsContent(ModuleInterface $module): string |
56 | 56 | { |
57 | - return view($module->name() . '::admin/view-edit-map', [ |
|
57 | + return view($module->name().'::admin/view-edit-map', [ |
|
58 | 58 | 'module_name' => $module->name(), |
59 | 59 | 'view' => $this, |
60 | 60 | 'colors' => $this->colors(), |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | { |
72 | 72 | $default_color = Validator::parsedBody($request)->string('view_map_color_default', ''); |
73 | 73 | $stroke_color = Validator::parsedBody($request)->string('view_map_color_stroke', ''); |
74 | - $maxvalue_color = Validator::parsedBody($request)->string('view_map_color_maxvalue', ''); |
|
75 | - $hover_color = Validator::parsedBody($request)->string('view_map_color_hover', ''); |
|
74 | + $maxvalue_color = Validator::parsedBody($request)->string('view_map_color_maxvalue', ''); |
|
75 | + $hover_color = Validator::parsedBody($request)->string('view_map_color_hover', ''); |
|
76 | 76 | |
77 | 77 | try { |
78 | 78 | return $this->withColors(new MapColorsConfig( |
@@ -99,17 +99,16 @@ discard block |
||
99 | 99 | foreach ($map_adapters as $map_adapter) { |
100 | 100 | $adapter_result_tmp = $map_adapter->convert($result); |
101 | 101 | $adapter_result = $adapter_result === null ? |
102 | - $adapter_result_tmp : |
|
103 | - $adapter_result->merge($adapter_result_tmp); |
|
102 | + $adapter_result_tmp : $adapter_result->merge($adapter_result_tmp); |
|
104 | 103 | } |
105 | 104 | |
106 | 105 | if ($adapter_result === null) { |
107 | - return view($module->name() . '::errors/tab-error', [ |
|
106 | + return view($module->name().'::errors/tab-error', [ |
|
108 | 107 | 'message' => I18N::translate('The map could not be loaded.'), |
109 | 108 | ]); |
110 | 109 | } |
111 | 110 | |
112 | - return view($module->name() . '::geoanalysisview-tab-glb-map', $params + [ |
|
111 | + return view($module->name().'::geoanalysisview-tab-glb-map', $params + [ |
|
113 | 112 | 'result' => $adapter_result->geoAnalysisResult(), |
114 | 113 | 'features' => $adapter_result->features(), |
115 | 114 | 'colors' => $this->colors(), |
@@ -21,12 +21,12 @@ |
||
21 | 21 | */ |
22 | 22 | class Migration0 implements MigrationInterface |
23 | 23 | { |
24 | - /** |
|
25 | - * {@inheritDoc} |
|
26 | - * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
27 | - */ |
|
28 | - public function upgrade(): void |
|
29 | - { |
|
30 | - // This migration has been superseded by migration 1. |
|
31 | - } |
|
24 | + /** |
|
25 | + * {@inheritDoc} |
|
26 | + * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
27 | + */ |
|
28 | + public function upgrade(): void |
|
29 | + { |
|
30 | + // This migration has been superseded by migration 1. |
|
31 | + } |
|
32 | 32 | } |
@@ -23,41 +23,41 @@ |
||
23 | 23 | */ |
24 | 24 | class Migration1 implements MigrationInterface |
25 | 25 | { |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
29 | - */ |
|
30 | - public function upgrade(): void |
|
31 | - { |
|
32 | - $in_transaction = DB::connection()->getPdo()->inTransaction(); |
|
33 | - |
|
34 | - DB::schema()->create('maj_geodisp_views', static function (Blueprint $table): void { |
|
35 | - $table->integer('majgv_id')->autoIncrement(); |
|
36 | - $table->integer('majgv_gedcom_id')->index(); |
|
37 | - $table->string('majgv_view_class', 255); |
|
38 | - $table->enum('majgv_status', ['enabled', 'disabled'])->default('enabled'); |
|
39 | - $table->string('majgv_descr', 248); |
|
40 | - $table->string('majgv_analysis', 255); |
|
41 | - $table->tinyInteger('majgv_place_depth')->default(1); |
|
42 | - $table->tinyInteger('majgv_top_places')->default(0); |
|
43 | - $table->json('majgv_colors')->nullable(); |
|
44 | - |
|
45 | - $table->foreign('majgv_gedcom_id')->references('gedcom_id')->on('gedcom')->onDelete('cascade'); |
|
46 | - }); |
|
47 | - |
|
48 | - DB::schema()->create('maj_geodisp_mapviews', static function (Blueprint $table): void { |
|
49 | - $table->integer('majgm_id')->autoIncrement(); |
|
50 | - $table->integer('majgm_majgv_id')->index(); |
|
51 | - $table->string('majgm_map_id', 127); |
|
52 | - $table->string('majgm_mapper', 255); |
|
53 | - $table->string('majgm_feature_prop', 31); |
|
54 | - $table->json('majgm_config')->nullable(); |
|
55 | - |
|
56 | - $table->foreign('majgm_majgv_id')->references('majgv_id')->on('maj_geodisp_views')->onDelete('cascade'); |
|
57 | - }); |
|
58 | - |
|
59 | - if ($in_transaction && !DB::connection()->getPdo()->inTransaction()) { |
|
60 | - DB::connection()->beginTransaction(); |
|
61 | - } |
|
62 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
29 | + */ |
|
30 | + public function upgrade(): void |
|
31 | + { |
|
32 | + $in_transaction = DB::connection()->getPdo()->inTransaction(); |
|
33 | + |
|
34 | + DB::schema()->create('maj_geodisp_views', static function (Blueprint $table): void { |
|
35 | + $table->integer('majgv_id')->autoIncrement(); |
|
36 | + $table->integer('majgv_gedcom_id')->index(); |
|
37 | + $table->string('majgv_view_class', 255); |
|
38 | + $table->enum('majgv_status', ['enabled', 'disabled'])->default('enabled'); |
|
39 | + $table->string('majgv_descr', 248); |
|
40 | + $table->string('majgv_analysis', 255); |
|
41 | + $table->tinyInteger('majgv_place_depth')->default(1); |
|
42 | + $table->tinyInteger('majgv_top_places')->default(0); |
|
43 | + $table->json('majgv_colors')->nullable(); |
|
44 | + |
|
45 | + $table->foreign('majgv_gedcom_id')->references('gedcom_id')->on('gedcom')->onDelete('cascade'); |
|
46 | + }); |
|
47 | + |
|
48 | + DB::schema()->create('maj_geodisp_mapviews', static function (Blueprint $table): void { |
|
49 | + $table->integer('majgm_id')->autoIncrement(); |
|
50 | + $table->integer('majgm_majgv_id')->index(); |
|
51 | + $table->string('majgm_map_id', 127); |
|
52 | + $table->string('majgm_mapper', 255); |
|
53 | + $table->string('majgm_feature_prop', 31); |
|
54 | + $table->json('majgm_config')->nullable(); |
|
55 | + |
|
56 | + $table->foreign('majgm_majgv_id')->references('majgv_id')->on('maj_geodisp_views')->onDelete('cascade'); |
|
57 | + }); |
|
58 | + |
|
59 | + if ($in_transaction && !DB::connection()->getPdo()->inTransaction()) { |
|
60 | + DB::connection()->beginTransaction(); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | { |
32 | 32 | $in_transaction = DB::connection()->getPdo()->inTransaction(); |
33 | 33 | |
34 | - DB::schema()->create('maj_geodisp_views', static function (Blueprint $table): void { |
|
34 | + DB::schema()->create('maj_geodisp_views', static function(Blueprint $table): void { |
|
35 | 35 | $table->integer('majgv_id')->autoIncrement(); |
36 | 36 | $table->integer('majgv_gedcom_id')->index(); |
37 | 37 | $table->string('majgv_view_class', 255); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $table->foreign('majgv_gedcom_id')->references('gedcom_id')->on('gedcom')->onDelete('cascade'); |
46 | 46 | }); |
47 | 47 | |
48 | - DB::schema()->create('maj_geodisp_mapviews', static function (Blueprint $table): void { |
|
48 | + DB::schema()->create('maj_geodisp_mapviews', static function(Blueprint $table): void { |
|
49 | 49 | $table->integer('majgm_id')->autoIncrement(); |
50 | 50 | $table->integer('majgm_majgv_id')->index(); |
51 | 51 | $table->string('majgm_map_id', 127); |