@@ -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 | } |
@@ -24,106 +24,106 @@ |
||
24 | 24 | */ |
25 | 25 | class LineageNode |
26 | 26 | { |
27 | - /** |
|
28 | - * @var Collection<string, stdClass> $linked_fams Spouse families linked to the node |
|
29 | - */ |
|
30 | - private Collection $linked_fams; |
|
27 | + /** |
|
28 | + * @var Collection<string, stdClass> $linked_fams Spouse families linked to the node |
|
29 | + */ |
|
30 | + private Collection $linked_fams; |
|
31 | 31 | |
32 | - private ?Individual $node_indi; |
|
33 | - private LineageRootNode $root_node; |
|
34 | - private ?string $alt_surname; |
|
32 | + private ?Individual $node_indi; |
|
33 | + private LineageRootNode $root_node; |
|
34 | + private ?string $alt_surname; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Constructor for Lineage node |
|
38 | - * |
|
39 | - * @param Individual $node_indi Main individual |
|
40 | - * @param LineageRootNode $root_node Node of the lineage root |
|
41 | - * @param null|string $alt_surname Follow-up surname |
|
42 | - */ |
|
43 | - public function __construct(?Individual $node_indi = null, LineageRootNode $root_node, $alt_surname = null) |
|
44 | - { |
|
45 | - $this->node_indi = $node_indi; |
|
46 | - $this->root_node = $root_node; |
|
47 | - $this->alt_surname = $alt_surname; |
|
48 | - $this->linked_fams = new Collection(); |
|
49 | - } |
|
36 | + /** |
|
37 | + * Constructor for Lineage node |
|
38 | + * |
|
39 | + * @param Individual $node_indi Main individual |
|
40 | + * @param LineageRootNode $root_node Node of the lineage root |
|
41 | + * @param null|string $alt_surname Follow-up surname |
|
42 | + */ |
|
43 | + public function __construct(?Individual $node_indi = null, LineageRootNode $root_node, $alt_surname = null) |
|
44 | + { |
|
45 | + $this->node_indi = $node_indi; |
|
46 | + $this->root_node = $root_node; |
|
47 | + $this->alt_surname = $alt_surname; |
|
48 | + $this->linked_fams = new Collection(); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Add a spouse family to the node |
|
53 | - * |
|
54 | - * @param Family $fams |
|
55 | - * @return stdClass |
|
56 | - */ |
|
57 | - public function addFamily(Family $fams): object |
|
58 | - { |
|
59 | - if (!$this->linked_fams->has($fams->xref())) { |
|
60 | - $this->linked_fams->put($fams->xref(), (object) [ |
|
61 | - 'family' => $fams, |
|
62 | - 'children' => new Collection() |
|
63 | - ]); |
|
64 | - } |
|
65 | - return $this->linked_fams->get($fams->xref()); |
|
66 | - } |
|
51 | + /** |
|
52 | + * Add a spouse family to the node |
|
53 | + * |
|
54 | + * @param Family $fams |
|
55 | + * @return stdClass |
|
56 | + */ |
|
57 | + public function addFamily(Family $fams): object |
|
58 | + { |
|
59 | + if (!$this->linked_fams->has($fams->xref())) { |
|
60 | + $this->linked_fams->put($fams->xref(), (object) [ |
|
61 | + 'family' => $fams, |
|
62 | + 'children' => new Collection() |
|
63 | + ]); |
|
64 | + } |
|
65 | + return $this->linked_fams->get($fams->xref()); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Add a child LineageNode to the node |
|
70 | - * |
|
71 | - * @param Family $fams |
|
72 | - * @param LineageNode $child |
|
73 | - */ |
|
74 | - public function addChild(Family $fams, LineageNode $child = null): void |
|
75 | - { |
|
76 | - $this->addFamily($fams)->children->push($child); |
|
77 | - $this->root_node->incrementChildNodes(); |
|
78 | - } |
|
68 | + /** |
|
69 | + * Add a child LineageNode to the node |
|
70 | + * |
|
71 | + * @param Family $fams |
|
72 | + * @param LineageNode $child |
|
73 | + */ |
|
74 | + public function addChild(Family $fams, LineageNode $child = null): void |
|
75 | + { |
|
76 | + $this->addFamily($fams)->children->push($child); |
|
77 | + $this->root_node->incrementChildNodes(); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Returns the node individual |
|
82 | - * |
|
83 | - * @return Individual|NULL |
|
84 | - */ |
|
85 | - public function individual(): ?Individual |
|
86 | - { |
|
87 | - return $this->node_indi; |
|
88 | - } |
|
80 | + /** |
|
81 | + * Returns the node individual |
|
82 | + * |
|
83 | + * @return Individual|NULL |
|
84 | + */ |
|
85 | + public function individual(): ?Individual |
|
86 | + { |
|
87 | + return $this->node_indi; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Returns the lineage root node individual |
|
92 | - * |
|
93 | - * @return LineageRootNode |
|
94 | - */ |
|
95 | - public function rootNode(): LineageRootNode |
|
96 | - { |
|
97 | - return $this->root_node; |
|
98 | - } |
|
90 | + /** |
|
91 | + * Returns the lineage root node individual |
|
92 | + * |
|
93 | + * @return LineageRootNode |
|
94 | + */ |
|
95 | + public function rootNode(): LineageRootNode |
|
96 | + { |
|
97 | + return $this->root_node; |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * Returns the spouse families linked to the node |
|
102 | - * |
|
103 | - * @return Collection<string, \stdClass> |
|
104 | - */ |
|
105 | - public function families(): Collection |
|
106 | - { |
|
107 | - return $this->linked_fams; |
|
108 | - } |
|
100 | + /** |
|
101 | + * Returns the spouse families linked to the node |
|
102 | + * |
|
103 | + * @return Collection<string, \stdClass> |
|
104 | + */ |
|
105 | + public function families(): Collection |
|
106 | + { |
|
107 | + return $this->linked_fams; |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * Returns the follow-up surname |
|
112 | - * |
|
113 | - * @return string |
|
114 | - */ |
|
115 | - public function followUpSurname(): string |
|
116 | - { |
|
117 | - return $this->alt_surname ?? ''; |
|
118 | - } |
|
110 | + /** |
|
111 | + * Returns the follow-up surname |
|
112 | + * |
|
113 | + * @return string |
|
114 | + */ |
|
115 | + public function followUpSurname(): string |
|
116 | + { |
|
117 | + return $this->alt_surname ?? ''; |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Indicates whether the node has a follow up surname |
|
122 | - * |
|
123 | - * @return boolean |
|
124 | - */ |
|
125 | - public function hasFollowUpSurname(): bool |
|
126 | - { |
|
127 | - return mb_strlen($this->followUpSurname()) > 0 ; |
|
128 | - } |
|
120 | + /** |
|
121 | + * Indicates whether the node has a follow up surname |
|
122 | + * |
|
123 | + * @return boolean |
|
124 | + */ |
|
125 | + public function hasFollowUpSurname(): bool |
|
126 | + { |
|
127 | + return mb_strlen($this->followUpSurname()) > 0 ; |
|
128 | + } |
|
129 | 129 | } |
@@ -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 | } |
@@ -25,31 +25,31 @@ |
||
25 | 25 | */ |
26 | 26 | class Migration1 implements MigrationInterface |
27 | 27 | { |
28 | - /** |
|
29 | - * {@inheritDoc} |
|
30 | - * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
31 | - */ |
|
32 | - public function upgrade(): void |
|
33 | - { |
|
34 | - $in_transaction = DB::connection()->getPdo()->inTransaction(); |
|
35 | - |
|
36 | - // Clean up previous admin tasks table if it exists |
|
37 | - DB::schema()->dropIfExists('maj_admintasks'); |
|
38 | - |
|
39 | - DB::schema()->create('maj_admintasks', static function (Blueprint $table): void { |
|
40 | - |
|
41 | - $table->increments('majat_id'); |
|
42 | - $table->string('majat_task_id', 32)->unique(); |
|
43 | - $table->enum('majat_status', ['enabled', 'disabled'])->default('disabled'); |
|
44 | - $table->dateTime('majat_last_run')->default(Carbon::createFromTimestampUTC(0)); |
|
45 | - $table->boolean('majat_last_result')->default(true); |
|
46 | - $table->integer('majat_frequency')->default(10080); |
|
47 | - $table->smallInteger('majat_nb_occur')->default(0); |
|
48 | - $table->boolean('majat_running')->default(false); |
|
49 | - }); |
|
50 | - |
|
51 | - if ($in_transaction && !DB::connection()->getPdo()->inTransaction()) { |
|
52 | - DB::connection()->beginTransaction(); |
|
53 | - } |
|
54 | - } |
|
28 | + /** |
|
29 | + * {@inheritDoc} |
|
30 | + * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
31 | + */ |
|
32 | + public function upgrade(): void |
|
33 | + { |
|
34 | + $in_transaction = DB::connection()->getPdo()->inTransaction(); |
|
35 | + |
|
36 | + // Clean up previous admin tasks table if it exists |
|
37 | + DB::schema()->dropIfExists('maj_admintasks'); |
|
38 | + |
|
39 | + DB::schema()->create('maj_admintasks', static function (Blueprint $table): void { |
|
40 | + |
|
41 | + $table->increments('majat_id'); |
|
42 | + $table->string('majat_task_id', 32)->unique(); |
|
43 | + $table->enum('majat_status', ['enabled', 'disabled'])->default('disabled'); |
|
44 | + $table->dateTime('majat_last_run')->default(Carbon::createFromTimestampUTC(0)); |
|
45 | + $table->boolean('majat_last_result')->default(true); |
|
46 | + $table->integer('majat_frequency')->default(10080); |
|
47 | + $table->smallInteger('majat_nb_occur')->default(0); |
|
48 | + $table->boolean('majat_running')->default(false); |
|
49 | + }); |
|
50 | + |
|
51 | + if ($in_transaction && !DB::connection()->getPdo()->inTransaction()) { |
|
52 | + DB::connection()->beginTransaction(); |
|
53 | + } |
|
54 | + } |
|
55 | 55 | } |
@@ -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 | } |
@@ -27,101 +27,101 @@ |
||
27 | 27 | */ |
28 | 28 | class HealthCheckService |
29 | 29 | { |
30 | - /** |
|
31 | - * Returns a query collating all gedcom records, for use in other queries |
|
32 | - * |
|
33 | - * @param Tree $tree |
|
34 | - * @return Builder |
|
35 | - */ |
|
36 | - private function allGedcomRecords(Tree $tree): Builder |
|
37 | - { |
|
38 | - return DB::table('individuals') |
|
39 | - ->select(DB::raw("'indi' AS ged_type"), 'i_id AS ged_id')->where('i_file', '=', $tree->id()) |
|
40 | - ->unionAll(DB::table('families') |
|
41 | - ->select(DB::raw("'fam' AS ged_type"), 'f_id AS ged_id')->where('f_file', '=', $tree->id())) |
|
42 | - ->unionAll(DB::table('sources') |
|
43 | - ->select(DB::raw("'sour' AS ged_type"), 's_id AS ged_id')->where('s_file', '=', $tree->id())) |
|
44 | - ->unionAll(DB::table('media') |
|
45 | - ->select(DB::raw("'media' AS ged_type"), 'm_id AS ged_id')->where('m_file', '=', $tree->id())) |
|
46 | - ->unionAll(DB::table('other') |
|
47 | - ->select(DB::raw('LOWER(o_type) AS ged_type'), 'o_id AS ged_id')->where('o_file', '=', $tree->id())); |
|
48 | - } |
|
30 | + /** |
|
31 | + * Returns a query collating all gedcom records, for use in other queries |
|
32 | + * |
|
33 | + * @param Tree $tree |
|
34 | + * @return Builder |
|
35 | + */ |
|
36 | + private function allGedcomRecords(Tree $tree): Builder |
|
37 | + { |
|
38 | + return DB::table('individuals') |
|
39 | + ->select(DB::raw("'indi' AS ged_type"), 'i_id AS ged_id')->where('i_file', '=', $tree->id()) |
|
40 | + ->unionAll(DB::table('families') |
|
41 | + ->select(DB::raw("'fam' AS ged_type"), 'f_id AS ged_id')->where('f_file', '=', $tree->id())) |
|
42 | + ->unionAll(DB::table('sources') |
|
43 | + ->select(DB::raw("'sour' AS ged_type"), 's_id AS ged_id')->where('s_file', '=', $tree->id())) |
|
44 | + ->unionAll(DB::table('media') |
|
45 | + ->select(DB::raw("'media' AS ged_type"), 'm_id AS ged_id')->where('m_file', '=', $tree->id())) |
|
46 | + ->unionAll(DB::table('other') |
|
47 | + ->select(DB::raw('LOWER(o_type) AS ged_type'), 'o_id AS ged_id')->where('o_file', '=', $tree->id())); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Returns the count of gedcom records by type in a Tree, as a keyed Collection. |
|
52 | - * |
|
53 | - * Collection output: |
|
54 | - * - Key : gedcom record type |
|
55 | - * - Value: count of records |
|
56 | - * |
|
57 | - * @param Tree $tree |
|
58 | - * @return Collection<string, int> |
|
59 | - */ |
|
60 | - public function countByRecordType(Tree $tree): Collection |
|
61 | - { |
|
62 | - return DB::query() |
|
63 | - ->fromSub($this->allGedcomRecords($tree), 'gedrecords') |
|
64 | - ->select('ged_type', new Expression('COUNT(ged_id) AS total')) |
|
65 | - ->groupBy('ged_type') |
|
66 | - ->pluck('total', 'ged_type'); |
|
67 | - } |
|
50 | + /** |
|
51 | + * Returns the count of gedcom records by type in a Tree, as a keyed Collection. |
|
52 | + * |
|
53 | + * Collection output: |
|
54 | + * - Key : gedcom record type |
|
55 | + * - Value: count of records |
|
56 | + * |
|
57 | + * @param Tree $tree |
|
58 | + * @return Collection<string, int> |
|
59 | + */ |
|
60 | + public function countByRecordType(Tree $tree): Collection |
|
61 | + { |
|
62 | + return DB::query() |
|
63 | + ->fromSub($this->allGedcomRecords($tree), 'gedrecords') |
|
64 | + ->select('ged_type', new Expression('COUNT(ged_id) AS total')) |
|
65 | + ->groupBy('ged_type') |
|
66 | + ->pluck('total', 'ged_type'); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Returns the count of gedcom records changes by type in a Tree across a number of days, as a keyed Collection. |
|
71 | - * |
|
72 | - * Collection output: |
|
73 | - * - Key : gedcom record type |
|
74 | - * - Value: count of changes |
|
75 | - * |
|
76 | - * @param Tree $tree |
|
77 | - * @return Collection<string, int> |
|
78 | - */ |
|
79 | - public function changesByRecordType(Tree $tree, int $nb_days): Collection |
|
80 | - { |
|
81 | - return DB::table('change') |
|
82 | - ->joinSub($this->allGedcomRecords($tree), 'gedrecords', function (JoinClause $join) use ($tree): void { |
|
69 | + /** |
|
70 | + * Returns the count of gedcom records changes by type in a Tree across a number of days, as a keyed Collection. |
|
71 | + * |
|
72 | + * Collection output: |
|
73 | + * - Key : gedcom record type |
|
74 | + * - Value: count of changes |
|
75 | + * |
|
76 | + * @param Tree $tree |
|
77 | + * @return Collection<string, int> |
|
78 | + */ |
|
79 | + public function changesByRecordType(Tree $tree, int $nb_days): Collection |
|
80 | + { |
|
81 | + return DB::table('change') |
|
82 | + ->joinSub($this->allGedcomRecords($tree), 'gedrecords', function (JoinClause $join) use ($tree): void { |
|
83 | 83 | |
84 | - $join->on('change.xref', '=', 'gedrecords.ged_id') |
|
85 | - ->where('change.gedcom_id', '=', $tree->id()); |
|
86 | - }) |
|
87 | - ->select('ged_type AS type', new Expression('COUNT(change_id) AS count')) |
|
88 | - ->where('change.status', '', 'accepted') |
|
89 | - ->where('change.change_time', '>=', Carbon::now()->subDays($nb_days)) |
|
90 | - ->groupBy('ged_type') |
|
91 | - ->pluck('total', 'ged_type'); |
|
92 | - } |
|
84 | + $join->on('change.xref', '=', 'gedrecords.ged_id') |
|
85 | + ->where('change.gedcom_id', '=', $tree->id()); |
|
86 | + }) |
|
87 | + ->select('ged_type AS type', new Expression('COUNT(change_id) AS count')) |
|
88 | + ->where('change.status', '', 'accepted') |
|
89 | + ->where('change.change_time', '>=', Carbon::now()->subDays($nb_days)) |
|
90 | + ->groupBy('ged_type') |
|
91 | + ->pluck('total', 'ged_type'); |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Return the error logs associated with a tree across a number of days, grouped by error message, as a Collection. |
|
96 | - * |
|
97 | - * Collection output: |
|
98 | - * - Value: stdClass object |
|
99 | - * - log message: Error log message |
|
100 | - * - type: 'site' if no associated Tree, the Tree ID otherwise |
|
101 | - * - nblogs: The number of occurrence of the same error message |
|
102 | - * - lastoccurred: Date/time of the last occurrence of the error message |
|
103 | - * |
|
104 | - * @param Tree $tree |
|
105 | - * @param int $nb_days |
|
106 | - * @return Collection<\stdClass> |
|
107 | - */ |
|
108 | - public function errorLogs(Tree $tree, int $nb_days): Collection |
|
109 | - { |
|
110 | - return DB::table('log') |
|
111 | - ->select( |
|
112 | - 'log_message', |
|
113 | - new Expression("IFNULL(gedcom_id, 'site') as type"), |
|
114 | - new Expression('COUNT(log_id) AS nblogs'), |
|
115 | - new Expression('MAX(log_time) AS lastoccurred') |
|
116 | - ) |
|
117 | - ->where('log_type', '=', 'error') |
|
118 | - ->where(function (Builder $query) use ($tree): void { |
|
119 | - $query->where('gedcom_id', '=', $tree->id()) |
|
120 | - ->orWhereNull('gedcom_id'); |
|
121 | - }) |
|
122 | - ->where('log_time', '>=', Carbon::now()->subDays($nb_days)) |
|
123 | - ->groupBy('log_message', 'gedcom_id') |
|
124 | - ->orderByDesc('lastoccurred') |
|
125 | - ->get(); |
|
126 | - } |
|
94 | + /** |
|
95 | + * Return the error logs associated with a tree across a number of days, grouped by error message, as a Collection. |
|
96 | + * |
|
97 | + * Collection output: |
|
98 | + * - Value: stdClass object |
|
99 | + * - log message: Error log message |
|
100 | + * - type: 'site' if no associated Tree, the Tree ID otherwise |
|
101 | + * - nblogs: The number of occurrence of the same error message |
|
102 | + * - lastoccurred: Date/time of the last occurrence of the error message |
|
103 | + * |
|
104 | + * @param Tree $tree |
|
105 | + * @param int $nb_days |
|
106 | + * @return Collection<\stdClass> |
|
107 | + */ |
|
108 | + public function errorLogs(Tree $tree, int $nb_days): Collection |
|
109 | + { |
|
110 | + return DB::table('log') |
|
111 | + ->select( |
|
112 | + 'log_message', |
|
113 | + new Expression("IFNULL(gedcom_id, 'site') as type"), |
|
114 | + new Expression('COUNT(log_id) AS nblogs'), |
|
115 | + new Expression('MAX(log_time) AS lastoccurred') |
|
116 | + ) |
|
117 | + ->where('log_type', '=', 'error') |
|
118 | + ->where(function (Builder $query) use ($tree): void { |
|
119 | + $query->where('gedcom_id', '=', $tree->id()) |
|
120 | + ->orWhereNull('gedcom_id'); |
|
121 | + }) |
|
122 | + ->where('log_time', '>=', Carbon::now()->subDays($nb_days)) |
|
123 | + ->groupBy('log_message', 'gedcom_id') |
|
124 | + ->orderByDesc('lastoccurred') |
|
125 | + ->get(); |
|
126 | + } |
|
127 | 127 | } |
@@ -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 | } |
@@ -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 | } |