@@ -44,167 +44,167 @@ |
||
44 | 44 | */ |
45 | 45 | class SosaModule extends AbstractModuleMaj implements ModuleGlobalInterface, ModuleMenuInterface |
46 | 46 | { |
47 | - use ModuleGlobalTrait; |
|
48 | - use ModuleMenuTrait; |
|
47 | + use ModuleGlobalTrait; |
|
48 | + use ModuleMenuTrait; |
|
49 | 49 | |
50 | 50 | // How to update the database schema for this module |
51 | 51 | |
52 | 52 | |
53 | - private const SCHEMA_TARGET_VERSION = 3; |
|
54 | - private const SCHEMA_SETTING_NAME = 'MAJ_SOSA_SCHEMA_VERSION'; |
|
55 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
53 | + private const SCHEMA_TARGET_VERSION = 3; |
|
54 | + private const SCHEMA_SETTING_NAME = 'MAJ_SOSA_SCHEMA_VERSION'; |
|
55 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
56 | 56 | /** |
57 | - * {@inheritDoc} |
|
58 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
59 | - */ |
|
60 | - public function title(): string |
|
61 | - { |
|
62 | - return /* I18N: Name of the “Sosa” module */ I18N::translate('Sosa'); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * {@inheritDoc} |
|
67 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
68 | - */ |
|
69 | - public function description(): string |
|
70 | - { |
|
71 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
72 | - return /* I18N: Description of the “Sosa” module */ I18N::translate('Calculate and display Sosa ancestors of the root person.'); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * {@inheritDoc} |
|
77 | - * @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::boot() |
|
78 | - */ |
|
79 | - public function boot(): void |
|
80 | - { |
|
81 | - parent::boot(); |
|
82 | - app(MigrationService::class)->updateSchema( |
|
83 | - self::SCHEMA_MIGRATION_PREFIX, |
|
84 | - self::SCHEMA_SETTING_NAME, |
|
85 | - self::SCHEMA_TARGET_VERSION |
|
86 | - ); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * {@inheritDoc} |
|
91 | - * @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::loadRoutes() |
|
92 | - */ |
|
93 | - public function loadRoutes(Map $router): void |
|
94 | - { |
|
95 | - $router->attach('', '', static function (Map $router): void { |
|
96 | - |
|
97 | - $router->attach('', '/module-maj/sosa', static function (Map $router): void { |
|
98 | - |
|
99 | - $router->attach('', '/list', static function (Map $router): void { |
|
100 | - |
|
101 | - |
|
102 | - $router->get(AncestorsList::class, '/ancestors/{tree}{/gen}', AncestorsList::class); |
|
103 | - $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
104 | - $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
105 | - $router->get(MissingAncestorsList::class, '/missing/{tree}{/gen}', MissingAncestorsList::class); |
|
106 | - }); |
|
107 | - $router->get(SosaStatistics::class, '/statistics/{tree}', SosaStatistics::class); |
|
108 | - $router->attach('', '/config/{tree}', static function (Map $router): void { |
|
109 | - |
|
110 | - |
|
111 | - $router->get(SosaConfig::class, '', SosaConfig::class); |
|
112 | - $router->post(SosaConfigAction::class, '', SosaConfigAction::class); |
|
113 | - $router->get(SosaComputeModal::class, '/compute/{xref}', SosaComputeModal::class); |
|
114 | - $router->post(SosaComputeAction::class, '/compute', SosaComputeAction::class); |
|
115 | - }); |
|
116 | - }); |
|
117 | - }); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * {@inheritDoc} |
|
122 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
123 | - */ |
|
124 | - public function customModuleVersion(): string |
|
125 | - { |
|
126 | - return '2.0.7-v.1'; |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * {@inheritDoc} |
|
131 | - * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::defaultMenuOrder() |
|
132 | - */ |
|
133 | - public function defaultMenuOrder(): int |
|
134 | - { |
|
135 | - return 7; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * {@inhericDoc} |
|
140 | - * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::getMenu() |
|
141 | - */ |
|
142 | - public function getMenu(Tree $tree): ?Menu |
|
143 | - { |
|
144 | - $menu = new Menu(I18N::translate('Sosa Statistics')); |
|
145 | - $menu->setClass('menu-maj-sosa'); |
|
146 | - $menu->setSubmenus([ |
|
147 | - new Menu( |
|
148 | - I18N::translate('Sosa Ancestors'), |
|
149 | - route(AncestorsList::class, ['tree' => $tree->name()]), |
|
150 | - 'menu-maj-sosa-list', |
|
151 | - ['rel' => 'nofollow'] |
|
152 | - ), |
|
153 | - new Menu( |
|
154 | - I18N::translate('Missing Ancestors'), |
|
155 | - route(MissingAncestorsList::class, ['tree' => $tree->name()]), |
|
156 | - 'menu-maj-sosa-missing', |
|
157 | - ['rel' => 'nofollow'] |
|
158 | - ), |
|
159 | - new Menu( |
|
160 | - I18N::translate('Sosa Statistics'), |
|
161 | - route(SosaStatistics::class, ['tree' => $tree->name()]), |
|
162 | - 'menu-maj-sosa-stats' |
|
163 | - ) |
|
164 | - ]); |
|
165 | - |
|
166 | - if (Auth::check()) { |
|
167 | - $menu->addSubmenu(new Menu( |
|
168 | - I18N::translate('Sosa Configuration'), |
|
169 | - route(SosaConfig::class, ['tree' => $tree->name()]), |
|
170 | - 'menu-maj-sosa-config' |
|
171 | - )); |
|
172 | - |
|
173 | - /** @var ServerRequestInterface $request */ |
|
174 | - $request = app(ServerRequestInterface::class); |
|
175 | - $route = $request->getAttribute('route'); |
|
176 | - assert($route instanceof Route); |
|
177 | - |
|
178 | - $root_indi_id = $tree->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID'); |
|
179 | - |
|
180 | - if ($route->name === IndividualPage::class && mb_strlen($root_indi_id) > 0) { |
|
181 | - $xref = $request->getAttribute('xref'); |
|
182 | - assert(is_string($xref)); |
|
183 | - |
|
184 | - $menu->addSubmenu(new Menu( |
|
185 | - I18N::translate('Complete Sosas'), |
|
186 | - '#', |
|
187 | - 'menu-maj-sosa-compute', |
|
188 | - [ |
|
189 | - 'rel' => 'nofollow', |
|
190 | - 'data-href' => route(SosaComputeModal::class, ['tree' => $tree->name(), 'xref' => $xref]), |
|
191 | - 'data-target' => '#wt-ajax-modal', |
|
192 | - 'data-toggle' => 'modal', |
|
193 | - 'data-backdrop' => 'static' |
|
194 | - ] |
|
195 | - )); |
|
196 | - } |
|
197 | - } |
|
198 | - |
|
199 | - return $menu; |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * {@inheritDoc} |
|
204 | - * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
205 | - */ |
|
206 | - public function headContent(): string |
|
207 | - { |
|
208 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
209 | - } |
|
57 | + * {@inheritDoc} |
|
58 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
59 | + */ |
|
60 | + public function title(): string |
|
61 | + { |
|
62 | + return /* I18N: Name of the “Sosa” module */ I18N::translate('Sosa'); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * {@inheritDoc} |
|
67 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
68 | + */ |
|
69 | + public function description(): string |
|
70 | + { |
|
71 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
72 | + return /* I18N: Description of the “Sosa” module */ I18N::translate('Calculate and display Sosa ancestors of the root person.'); |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * {@inheritDoc} |
|
77 | + * @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::boot() |
|
78 | + */ |
|
79 | + public function boot(): void |
|
80 | + { |
|
81 | + parent::boot(); |
|
82 | + app(MigrationService::class)->updateSchema( |
|
83 | + self::SCHEMA_MIGRATION_PREFIX, |
|
84 | + self::SCHEMA_SETTING_NAME, |
|
85 | + self::SCHEMA_TARGET_VERSION |
|
86 | + ); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * {@inheritDoc} |
|
91 | + * @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::loadRoutes() |
|
92 | + */ |
|
93 | + public function loadRoutes(Map $router): void |
|
94 | + { |
|
95 | + $router->attach('', '', static function (Map $router): void { |
|
96 | + |
|
97 | + $router->attach('', '/module-maj/sosa', static function (Map $router): void { |
|
98 | + |
|
99 | + $router->attach('', '/list', static function (Map $router): void { |
|
100 | + |
|
101 | + |
|
102 | + $router->get(AncestorsList::class, '/ancestors/{tree}{/gen}', AncestorsList::class); |
|
103 | + $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
104 | + $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
105 | + $router->get(MissingAncestorsList::class, '/missing/{tree}{/gen}', MissingAncestorsList::class); |
|
106 | + }); |
|
107 | + $router->get(SosaStatistics::class, '/statistics/{tree}', SosaStatistics::class); |
|
108 | + $router->attach('', '/config/{tree}', static function (Map $router): void { |
|
109 | + |
|
110 | + |
|
111 | + $router->get(SosaConfig::class, '', SosaConfig::class); |
|
112 | + $router->post(SosaConfigAction::class, '', SosaConfigAction::class); |
|
113 | + $router->get(SosaComputeModal::class, '/compute/{xref}', SosaComputeModal::class); |
|
114 | + $router->post(SosaComputeAction::class, '/compute', SosaComputeAction::class); |
|
115 | + }); |
|
116 | + }); |
|
117 | + }); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * {@inheritDoc} |
|
122 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
123 | + */ |
|
124 | + public function customModuleVersion(): string |
|
125 | + { |
|
126 | + return '2.0.7-v.1'; |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * {@inheritDoc} |
|
131 | + * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::defaultMenuOrder() |
|
132 | + */ |
|
133 | + public function defaultMenuOrder(): int |
|
134 | + { |
|
135 | + return 7; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * {@inhericDoc} |
|
140 | + * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::getMenu() |
|
141 | + */ |
|
142 | + public function getMenu(Tree $tree): ?Menu |
|
143 | + { |
|
144 | + $menu = new Menu(I18N::translate('Sosa Statistics')); |
|
145 | + $menu->setClass('menu-maj-sosa'); |
|
146 | + $menu->setSubmenus([ |
|
147 | + new Menu( |
|
148 | + I18N::translate('Sosa Ancestors'), |
|
149 | + route(AncestorsList::class, ['tree' => $tree->name()]), |
|
150 | + 'menu-maj-sosa-list', |
|
151 | + ['rel' => 'nofollow'] |
|
152 | + ), |
|
153 | + new Menu( |
|
154 | + I18N::translate('Missing Ancestors'), |
|
155 | + route(MissingAncestorsList::class, ['tree' => $tree->name()]), |
|
156 | + 'menu-maj-sosa-missing', |
|
157 | + ['rel' => 'nofollow'] |
|
158 | + ), |
|
159 | + new Menu( |
|
160 | + I18N::translate('Sosa Statistics'), |
|
161 | + route(SosaStatistics::class, ['tree' => $tree->name()]), |
|
162 | + 'menu-maj-sosa-stats' |
|
163 | + ) |
|
164 | + ]); |
|
165 | + |
|
166 | + if (Auth::check()) { |
|
167 | + $menu->addSubmenu(new Menu( |
|
168 | + I18N::translate('Sosa Configuration'), |
|
169 | + route(SosaConfig::class, ['tree' => $tree->name()]), |
|
170 | + 'menu-maj-sosa-config' |
|
171 | + )); |
|
172 | + |
|
173 | + /** @var ServerRequestInterface $request */ |
|
174 | + $request = app(ServerRequestInterface::class); |
|
175 | + $route = $request->getAttribute('route'); |
|
176 | + assert($route instanceof Route); |
|
177 | + |
|
178 | + $root_indi_id = $tree->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID'); |
|
179 | + |
|
180 | + if ($route->name === IndividualPage::class && mb_strlen($root_indi_id) > 0) { |
|
181 | + $xref = $request->getAttribute('xref'); |
|
182 | + assert(is_string($xref)); |
|
183 | + |
|
184 | + $menu->addSubmenu(new Menu( |
|
185 | + I18N::translate('Complete Sosas'), |
|
186 | + '#', |
|
187 | + 'menu-maj-sosa-compute', |
|
188 | + [ |
|
189 | + 'rel' => 'nofollow', |
|
190 | + 'data-href' => route(SosaComputeModal::class, ['tree' => $tree->name(), 'xref' => $xref]), |
|
191 | + 'data-target' => '#wt-ajax-modal', |
|
192 | + 'data-toggle' => 'modal', |
|
193 | + 'data-backdrop' => 'static' |
|
194 | + ] |
|
195 | + )); |
|
196 | + } |
|
197 | + } |
|
198 | + |
|
199 | + return $menu; |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * {@inheritDoc} |
|
204 | + * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
205 | + */ |
|
206 | + public function headContent(): string |
|
207 | + { |
|
208 | + return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
209 | + } |
|
210 | 210 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | private const SCHEMA_TARGET_VERSION = 3; |
54 | 54 | private const SCHEMA_SETTING_NAME = 'MAJ_SOSA_SCHEMA_VERSION'; |
55 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
55 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__.'\Schema'; |
|
56 | 56 | /** |
57 | 57 | * {@inheritDoc} |
58 | 58 | * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
@@ -92,20 +92,20 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function loadRoutes(Map $router): void |
94 | 94 | { |
95 | - $router->attach('', '', static function (Map $router): void { |
|
95 | + $router->attach('', '', static function(Map $router): void { |
|
96 | 96 | |
97 | - $router->attach('', '/module-maj/sosa', static function (Map $router): void { |
|
97 | + $router->attach('', '/module-maj/sosa', static function(Map $router): void { |
|
98 | 98 | |
99 | - $router->attach('', '/list', static function (Map $router): void { |
|
99 | + $router->attach('', '/list', static function(Map $router): void { |
|
100 | 100 | |
101 | 101 | |
102 | 102 | $router->get(AncestorsList::class, '/ancestors/{tree}{/gen}', AncestorsList::class); |
103 | - $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
104 | - $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
103 | + $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
104 | + $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
105 | 105 | $router->get(MissingAncestorsList::class, '/missing/{tree}{/gen}', MissingAncestorsList::class); |
106 | 106 | }); |
107 | 107 | $router->get(SosaStatistics::class, '/statistics/{tree}', SosaStatistics::class); |
108 | - $router->attach('', '/config/{tree}', static function (Map $router): void { |
|
108 | + $router->attach('', '/config/{tree}', static function(Map $router): void { |
|
109 | 109 | |
110 | 110 | |
111 | 111 | $router->get(SosaConfig::class, '', SosaConfig::class); |
@@ -205,6 +205,6 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function headContent(): string |
207 | 207 | { |
208 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
208 | + return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">'; |
|
209 | 209 | } |
210 | 210 | } |
@@ -30,50 +30,50 @@ |
||
30 | 30 | */ |
31 | 31 | class SosaConfigAction implements RequestHandlerInterface |
32 | 32 | { |
33 | - /** |
|
34 | - * @var UserService $user_service |
|
35 | - */ |
|
36 | - private $user_service; |
|
33 | + /** |
|
34 | + * @var UserService $user_service |
|
35 | + */ |
|
36 | + private $user_service; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Constructor for SosaConfigAction Request Handler |
|
40 | - * |
|
41 | - * @param UserService $user_service |
|
42 | - */ |
|
43 | - public function __construct(UserService $user_service) |
|
44 | - { |
|
45 | - $this->user_service = $user_service; |
|
46 | - } |
|
38 | + /** |
|
39 | + * Constructor for SosaConfigAction Request Handler |
|
40 | + * |
|
41 | + * @param UserService $user_service |
|
42 | + */ |
|
43 | + public function __construct(UserService $user_service) |
|
44 | + { |
|
45 | + $this->user_service = $user_service; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * {@inheritDoc} |
|
50 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
51 | - */ |
|
52 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
53 | - { |
|
54 | - $tree = $request->getAttribute('tree'); |
|
55 | - assert($tree instanceof Tree); |
|
48 | + /** |
|
49 | + * {@inheritDoc} |
|
50 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
51 | + */ |
|
52 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
53 | + { |
|
54 | + $tree = $request->getAttribute('tree'); |
|
55 | + assert($tree instanceof Tree); |
|
56 | 56 | |
57 | - $params = $request->getParsedBody(); |
|
58 | - assert(is_array($params)); |
|
57 | + $params = $request->getParsedBody(); |
|
58 | + assert(is_array($params)); |
|
59 | 59 | |
60 | - $user_id = (int) $params['sosa-userid']; |
|
61 | - $root_id = $params['sosa-rootid'] ?? ''; |
|
60 | + $user_id = (int) $params['sosa-userid']; |
|
61 | + $root_id = $params['sosa-rootid'] ?? ''; |
|
62 | 62 | |
63 | - if (Auth::id() == $user_id || ($user_id == -1 && Auth::isManager($tree))) { |
|
64 | - $user = $user_id == -1 ? new DefaultUser() : $this->user_service->find($user_id); |
|
65 | - if ($user !== null && ($root_indi = Registry::individualFactory()->make($root_id, $tree)) !== null) { |
|
66 | - $tree->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $root_indi->xref()); |
|
67 | - FlashMessages::addMessage(I18N::translate('The root individual has been updated.')); |
|
68 | - return redirect(route(SosaConfig::class, [ |
|
69 | - 'tree' => $tree->name(), |
|
70 | - 'compute' => 'yes', |
|
71 | - 'user_id' => $user_id |
|
72 | - ])); |
|
73 | - } |
|
74 | - } |
|
63 | + if (Auth::id() == $user_id || ($user_id == -1 && Auth::isManager($tree))) { |
|
64 | + $user = $user_id == -1 ? new DefaultUser() : $this->user_service->find($user_id); |
|
65 | + if ($user !== null && ($root_indi = Registry::individualFactory()->make($root_id, $tree)) !== null) { |
|
66 | + $tree->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $root_indi->xref()); |
|
67 | + FlashMessages::addMessage(I18N::translate('The root individual has been updated.')); |
|
68 | + return redirect(route(SosaConfig::class, [ |
|
69 | + 'tree' => $tree->name(), |
|
70 | + 'compute' => 'yes', |
|
71 | + 'user_id' => $user_id |
|
72 | + ])); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | - FlashMessages::addMessage(I18N::translate('The root individual could not be updated.'), 'danger'); |
|
77 | - return redirect(route(SosaConfig::class, ['tree' => $tree->name()])); |
|
78 | - } |
|
76 | + FlashMessages::addMessage(I18N::translate('The root individual could not be updated.'), 'danger'); |
|
77 | + return redirect(route(SosaConfig::class, ['tree' => $tree->name()])); |
|
78 | + } |
|
79 | 79 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | $params = $request->getParsedBody(); |
58 | 58 | assert(is_array($params)); |
59 | 59 | |
60 | - $user_id = (int) $params['sosa-userid']; |
|
60 | + $user_id = (int)$params['sosa-userid']; |
|
61 | 61 | $root_id = $params['sosa-rootid'] ?? ''; |
62 | 62 | |
63 | 63 | if (Auth::id() == $user_id || ($user_id == -1 && Auth::isManager($tree))) { |
@@ -35,73 +35,73 @@ |
||
35 | 35 | */ |
36 | 36 | class AncestorsListFamily implements RequestHandlerInterface |
37 | 37 | { |
38 | - use ViewResponseTrait; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var SosaModule $module |
|
42 | - */ |
|
43 | - private $module; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var SosaRecordsService $sosa_record_service |
|
47 | - */ |
|
48 | - private $sosa_record_service; |
|
49 | - |
|
50 | - /** |
|
51 | - * Constructor for AncestorsListFamily Request Handler |
|
52 | - * |
|
53 | - * @param ModuleService $module_service |
|
54 | - * @param SosaRecordsService $sosa_record_service |
|
55 | - */ |
|
56 | - public function __construct( |
|
57 | - ModuleService $module_service, |
|
58 | - SosaRecordsService $sosa_record_service |
|
59 | - ) { |
|
60 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
61 | - $this->sosa_record_service = $sosa_record_service; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * {@inheritDoc} |
|
66 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
67 | - */ |
|
68 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
69 | - { |
|
70 | - $this->layout = 'layouts/ajax'; |
|
71 | - |
|
72 | - if ($this->module === null) { |
|
73 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
74 | - } |
|
75 | - |
|
76 | - $tree = $request->getAttribute('tree'); |
|
77 | - assert($tree instanceof Tree); |
|
78 | - |
|
79 | - $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
80 | - |
|
81 | - $current_gen = (int) ($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
82 | - |
|
83 | - if ($current_gen <= 0) { |
|
84 | - return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY); |
|
85 | - } |
|
86 | - |
|
87 | - $list_families = $this->sosa_record_service->listAncestorFamiliesAtGeneration($tree, $user, $current_gen); |
|
88 | - $nb_families_all = $list_families->count(); |
|
89 | - |
|
90 | - /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Family> $list_families */ |
|
91 | - $list_families = $list_families->mapWithKeys(function (stdClass $value) use ($tree): ?array { |
|
92 | - $fam = Registry::familyFactory()->make($value->f_id, $tree); |
|
93 | - return ($fam !== null && $fam->canShow()) ? [(int) $value->majs_sosa => $fam] : null; |
|
94 | - })->filter(); |
|
95 | - |
|
96 | - $nb_families_shown = $list_families->count(); |
|
97 | - |
|
98 | - return $this->viewResponse($this->module->name() . '::list-ancestors-fam-tab', [ |
|
99 | - 'module_name' => $this->module->name(), |
|
100 | - 'title' => I18N::translate('Sosa Ancestors'), |
|
101 | - 'tree' => $tree, |
|
102 | - 'list_families' => $list_families, |
|
103 | - 'nb_families_all' => $nb_families_all, |
|
104 | - 'nb_families_shown' => $nb_families_shown |
|
105 | - ]); |
|
106 | - } |
|
38 | + use ViewResponseTrait; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var SosaModule $module |
|
42 | + */ |
|
43 | + private $module; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var SosaRecordsService $sosa_record_service |
|
47 | + */ |
|
48 | + private $sosa_record_service; |
|
49 | + |
|
50 | + /** |
|
51 | + * Constructor for AncestorsListFamily Request Handler |
|
52 | + * |
|
53 | + * @param ModuleService $module_service |
|
54 | + * @param SosaRecordsService $sosa_record_service |
|
55 | + */ |
|
56 | + public function __construct( |
|
57 | + ModuleService $module_service, |
|
58 | + SosaRecordsService $sosa_record_service |
|
59 | + ) { |
|
60 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
61 | + $this->sosa_record_service = $sosa_record_service; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * {@inheritDoc} |
|
66 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
67 | + */ |
|
68 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
69 | + { |
|
70 | + $this->layout = 'layouts/ajax'; |
|
71 | + |
|
72 | + if ($this->module === null) { |
|
73 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
74 | + } |
|
75 | + |
|
76 | + $tree = $request->getAttribute('tree'); |
|
77 | + assert($tree instanceof Tree); |
|
78 | + |
|
79 | + $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
80 | + |
|
81 | + $current_gen = (int) ($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
82 | + |
|
83 | + if ($current_gen <= 0) { |
|
84 | + return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY); |
|
85 | + } |
|
86 | + |
|
87 | + $list_families = $this->sosa_record_service->listAncestorFamiliesAtGeneration($tree, $user, $current_gen); |
|
88 | + $nb_families_all = $list_families->count(); |
|
89 | + |
|
90 | + /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Family> $list_families */ |
|
91 | + $list_families = $list_families->mapWithKeys(function (stdClass $value) use ($tree): ?array { |
|
92 | + $fam = Registry::familyFactory()->make($value->f_id, $tree); |
|
93 | + return ($fam !== null && $fam->canShow()) ? [(int) $value->majs_sosa => $fam] : null; |
|
94 | + })->filter(); |
|
95 | + |
|
96 | + $nb_families_shown = $list_families->count(); |
|
97 | + |
|
98 | + return $this->viewResponse($this->module->name() . '::list-ancestors-fam-tab', [ |
|
99 | + 'module_name' => $this->module->name(), |
|
100 | + 'title' => I18N::translate('Sosa Ancestors'), |
|
101 | + 'tree' => $tree, |
|
102 | + 'list_families' => $list_families, |
|
103 | + 'nb_families_all' => $nb_families_all, |
|
104 | + 'nb_families_shown' => $nb_families_shown |
|
105 | + ]); |
|
106 | + } |
|
107 | 107 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
80 | 80 | |
81 | - $current_gen = (int) ($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
81 | + $current_gen = (int)($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
82 | 82 | |
83 | 83 | if ($current_gen <= 0) { |
84 | 84 | return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY); |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | $nb_families_all = $list_families->count(); |
89 | 89 | |
90 | 90 | /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Family> $list_families */ |
91 | - $list_families = $list_families->mapWithKeys(function (stdClass $value) use ($tree): ?array { |
|
91 | + $list_families = $list_families->mapWithKeys(function(stdClass $value) use ($tree): ?array { |
|
92 | 92 | $fam = Registry::familyFactory()->make($value->f_id, $tree); |
93 | - return ($fam !== null && $fam->canShow()) ? [(int) $value->majs_sosa => $fam] : null; |
|
93 | + return ($fam !== null && $fam->canShow()) ? [(int)$value->majs_sosa => $fam] : null; |
|
94 | 94 | })->filter(); |
95 | 95 | |
96 | 96 | $nb_families_shown = $list_families->count(); |
97 | 97 | |
98 | - return $this->viewResponse($this->module->name() . '::list-ancestors-fam-tab', [ |
|
98 | + return $this->viewResponse($this->module->name().'::list-ancestors-fam-tab', [ |
|
99 | 99 | 'module_name' => $this->module->name(), |
100 | 100 | 'title' => I18N::translate('Sosa Ancestors'), |
101 | 101 | 'tree' => $tree, |
@@ -36,88 +36,88 @@ |
||
36 | 36 | */ |
37 | 37 | class MissingAncestorsList implements RequestHandlerInterface |
38 | 38 | { |
39 | - use ViewResponseTrait; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var SosaModule $module |
|
43 | - */ |
|
44 | - private $module; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var SosaRecordsService $sosa_record_service |
|
48 | - */ |
|
49 | - private $sosa_record_service; |
|
50 | - |
|
51 | - /** |
|
52 | - * Constructor for MissingAncestorsList Request Handler |
|
53 | - * |
|
54 | - * @param ModuleService $module_service |
|
55 | - * @param SosaRecordsService $sosa_record_service |
|
56 | - */ |
|
57 | - public function __construct( |
|
58 | - ModuleService $module_service, |
|
59 | - SosaRecordsService $sosa_record_service |
|
60 | - ) { |
|
61 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
62 | - $this->sosa_record_service = $sosa_record_service; |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * {@inheritDoc} |
|
67 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
68 | - */ |
|
69 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
70 | - { |
|
71 | - if ($this->module === null) { |
|
72 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
73 | - } |
|
74 | - |
|
75 | - $tree = $request->getAttribute('tree'); |
|
76 | - assert($tree instanceof Tree); |
|
77 | - |
|
78 | - $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
79 | - |
|
80 | - /** @var SosaStatisticsService $sosa_stats_service */ |
|
81 | - $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
82 | - |
|
83 | - $current_gen = (int) ($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
84 | - |
|
85 | - $list_missing = $this->sosa_record_service->listMissingAncestorsAtGeneration($tree, $user, $current_gen); |
|
86 | - $nb_missing_diff = $list_missing->sum(function (stdClass $value): int { |
|
87 | - return ($value->majs_fat_id === null ? 1 : 0) + ($value->majs_mot_id === null ? 1 : 0); |
|
88 | - }); |
|
89 | - |
|
90 | - $list_missing = $list_missing->map(function (stdClass $value) use ($tree): ?MissingAncestor { |
|
91 | - $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
|
92 | - if ($indi !== null && $indi->canShowName()) { |
|
93 | - return new MissingAncestor( |
|
94 | - $indi, |
|
95 | - (int) $value->majs_sosa, |
|
96 | - $value->majs_fat_id === null, |
|
97 | - $value->majs_mot_id === null |
|
98 | - ); |
|
99 | - } |
|
100 | - return null; |
|
101 | - })->filter(); |
|
102 | - |
|
103 | - $nb_missing_shown = $list_missing->sum(function (MissingAncestor $value): int { |
|
104 | - return ($value->isFatherMissing() ? 1 : 0) + ($value->isMotherMissing() ? 1 : 0); |
|
105 | - }); |
|
106 | - |
|
107 | - return $this->viewResponse($this->module->name() . '::list-missing-page', [ |
|
108 | - 'module_name' => $this->module->name(), |
|
109 | - 'title' => I18N::translate('Missing Ancestors'), |
|
110 | - 'tree' => $tree, |
|
111 | - 'root_indi' => $sosa_stats_service->rootIndividual(), |
|
112 | - 'max_gen' => $sosa_stats_service->maxGeneration(), |
|
113 | - 'current_gen' => $current_gen, |
|
114 | - 'list_missing' => $list_missing, |
|
115 | - 'nb_missing_diff' => $nb_missing_diff, |
|
116 | - 'nb_missing_shown' => $nb_missing_shown, |
|
117 | - 'gen_completeness' => |
|
118 | - $sosa_stats_service->totalAncestorsAtGeneration($current_gen) / pow(2, $current_gen - 1), |
|
119 | - 'gen_potential' => |
|
120 | - $sosa_stats_service->totalAncestorsAtGeneration($current_gen - 1) / pow(2, $current_gen - 2) |
|
121 | - ]); |
|
122 | - } |
|
39 | + use ViewResponseTrait; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var SosaModule $module |
|
43 | + */ |
|
44 | + private $module; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var SosaRecordsService $sosa_record_service |
|
48 | + */ |
|
49 | + private $sosa_record_service; |
|
50 | + |
|
51 | + /** |
|
52 | + * Constructor for MissingAncestorsList Request Handler |
|
53 | + * |
|
54 | + * @param ModuleService $module_service |
|
55 | + * @param SosaRecordsService $sosa_record_service |
|
56 | + */ |
|
57 | + public function __construct( |
|
58 | + ModuleService $module_service, |
|
59 | + SosaRecordsService $sosa_record_service |
|
60 | + ) { |
|
61 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
62 | + $this->sosa_record_service = $sosa_record_service; |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * {@inheritDoc} |
|
67 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
68 | + */ |
|
69 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
70 | + { |
|
71 | + if ($this->module === null) { |
|
72 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
73 | + } |
|
74 | + |
|
75 | + $tree = $request->getAttribute('tree'); |
|
76 | + assert($tree instanceof Tree); |
|
77 | + |
|
78 | + $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
79 | + |
|
80 | + /** @var SosaStatisticsService $sosa_stats_service */ |
|
81 | + $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
82 | + |
|
83 | + $current_gen = (int) ($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
84 | + |
|
85 | + $list_missing = $this->sosa_record_service->listMissingAncestorsAtGeneration($tree, $user, $current_gen); |
|
86 | + $nb_missing_diff = $list_missing->sum(function (stdClass $value): int { |
|
87 | + return ($value->majs_fat_id === null ? 1 : 0) + ($value->majs_mot_id === null ? 1 : 0); |
|
88 | + }); |
|
89 | + |
|
90 | + $list_missing = $list_missing->map(function (stdClass $value) use ($tree): ?MissingAncestor { |
|
91 | + $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
|
92 | + if ($indi !== null && $indi->canShowName()) { |
|
93 | + return new MissingAncestor( |
|
94 | + $indi, |
|
95 | + (int) $value->majs_sosa, |
|
96 | + $value->majs_fat_id === null, |
|
97 | + $value->majs_mot_id === null |
|
98 | + ); |
|
99 | + } |
|
100 | + return null; |
|
101 | + })->filter(); |
|
102 | + |
|
103 | + $nb_missing_shown = $list_missing->sum(function (MissingAncestor $value): int { |
|
104 | + return ($value->isFatherMissing() ? 1 : 0) + ($value->isMotherMissing() ? 1 : 0); |
|
105 | + }); |
|
106 | + |
|
107 | + return $this->viewResponse($this->module->name() . '::list-missing-page', [ |
|
108 | + 'module_name' => $this->module->name(), |
|
109 | + 'title' => I18N::translate('Missing Ancestors'), |
|
110 | + 'tree' => $tree, |
|
111 | + 'root_indi' => $sosa_stats_service->rootIndividual(), |
|
112 | + 'max_gen' => $sosa_stats_service->maxGeneration(), |
|
113 | + 'current_gen' => $current_gen, |
|
114 | + 'list_missing' => $list_missing, |
|
115 | + 'nb_missing_diff' => $nb_missing_diff, |
|
116 | + 'nb_missing_shown' => $nb_missing_shown, |
|
117 | + 'gen_completeness' => |
|
118 | + $sosa_stats_service->totalAncestorsAtGeneration($current_gen) / pow(2, $current_gen - 1), |
|
119 | + 'gen_potential' => |
|
120 | + $sosa_stats_service->totalAncestorsAtGeneration($current_gen - 1) / pow(2, $current_gen - 2) |
|
121 | + ]); |
|
122 | + } |
|
123 | 123 | } |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | /** @var SosaStatisticsService $sosa_stats_service */ |
81 | 81 | $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
82 | 82 | |
83 | - $current_gen = (int) ($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
83 | + $current_gen = (int)($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
84 | 84 | |
85 | 85 | $list_missing = $this->sosa_record_service->listMissingAncestorsAtGeneration($tree, $user, $current_gen); |
86 | - $nb_missing_diff = $list_missing->sum(function (stdClass $value): int { |
|
86 | + $nb_missing_diff = $list_missing->sum(function(stdClass $value): int { |
|
87 | 87 | return ($value->majs_fat_id === null ? 1 : 0) + ($value->majs_mot_id === null ? 1 : 0); |
88 | 88 | }); |
89 | 89 | |
90 | - $list_missing = $list_missing->map(function (stdClass $value) use ($tree): ?MissingAncestor { |
|
90 | + $list_missing = $list_missing->map(function(stdClass $value) use ($tree): ?MissingAncestor { |
|
91 | 91 | $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
92 | 92 | if ($indi !== null && $indi->canShowName()) { |
93 | 93 | return new MissingAncestor( |
94 | 94 | $indi, |
95 | - (int) $value->majs_sosa, |
|
95 | + (int)$value->majs_sosa, |
|
96 | 96 | $value->majs_fat_id === null, |
97 | 97 | $value->majs_mot_id === null |
98 | 98 | ); |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | return null; |
101 | 101 | })->filter(); |
102 | 102 | |
103 | - $nb_missing_shown = $list_missing->sum(function (MissingAncestor $value): int { |
|
103 | + $nb_missing_shown = $list_missing->sum(function(MissingAncestor $value): int { |
|
104 | 104 | return ($value->isFatherMissing() ? 1 : 0) + ($value->isMotherMissing() ? 1 : 0); |
105 | 105 | }); |
106 | 106 | |
107 | - return $this->viewResponse($this->module->name() . '::list-missing-page', [ |
|
107 | + return $this->viewResponse($this->module->name().'::list-missing-page', [ |
|
108 | 108 | 'module_name' => $this->module->name(), |
109 | 109 | 'title' => I18N::translate('Missing Ancestors'), |
110 | 110 | 'tree' => $tree, |
@@ -35,74 +35,74 @@ |
||
35 | 35 | */ |
36 | 36 | class AncestorsListIndividual implements RequestHandlerInterface |
37 | 37 | { |
38 | - use ViewResponseTrait; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var SosaModule $module |
|
42 | - */ |
|
43 | - private $module; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var SosaRecordsService $sosa_record_service |
|
47 | - */ |
|
48 | - private $sosa_record_service; |
|
49 | - |
|
50 | - /** |
|
51 | - * Constructor for AncestorsListIndividual Request Handler |
|
52 | - * |
|
53 | - * @param ModuleService $module_service |
|
54 | - * @param SosaRecordsService $sosa_record_service |
|
55 | - */ |
|
56 | - public function __construct( |
|
57 | - ModuleService $module_service, |
|
58 | - SosaRecordsService $sosa_record_service |
|
59 | - ) { |
|
60 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
61 | - $this->sosa_record_service = $sosa_record_service; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * {@inheritDoc} |
|
66 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
67 | - */ |
|
68 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
69 | - { |
|
70 | - $this->layout = 'layouts/ajax'; |
|
71 | - |
|
72 | - if ($this->module === null) { |
|
73 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
74 | - } |
|
75 | - |
|
76 | - $tree = $request->getAttribute('tree'); |
|
77 | - assert($tree instanceof Tree); |
|
78 | - |
|
79 | - $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
80 | - |
|
81 | - $current_gen = (int) ($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
82 | - |
|
83 | - if ($current_gen <= 0) { |
|
84 | - return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY); |
|
85 | - } |
|
86 | - |
|
87 | - $list_ancestors = $this->sosa_record_service->listAncestorsAtGeneration($tree, $user, $current_gen); |
|
88 | - $nb_ancestors_all = $list_ancestors->count(); |
|
89 | - |
|
90 | - /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Individual> $list_ancestors */ |
|
91 | - $list_ancestors = $list_ancestors->mapWithKeys(function (stdClass $value) use ($tree): ?array { |
|
92 | - $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
|
93 | - return ($indi !== null && $indi->canShowName()) ? [(int) $value->majs_sosa => $indi] : null; |
|
94 | - })->filter(); |
|
95 | - |
|
96 | - $nb_ancestors_shown = $list_ancestors->count(); |
|
97 | - |
|
98 | - return $this->viewResponse($this->module->name() . '::list-ancestors-indi-tab', [ |
|
99 | - 'module_name' => $this->module->name(), |
|
100 | - 'title' => I18N::translate('Sosa Ancestors'), |
|
101 | - 'tree' => $tree, |
|
102 | - 'list_ancestors' => $list_ancestors, |
|
103 | - 'nb_ancestors_all' => $nb_ancestors_all, |
|
104 | - 'nb_ancestors_theor' => pow(2, $current_gen - 1), |
|
105 | - 'nb_ancestors_shown' => $nb_ancestors_shown |
|
106 | - ]); |
|
107 | - } |
|
38 | + use ViewResponseTrait; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var SosaModule $module |
|
42 | + */ |
|
43 | + private $module; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var SosaRecordsService $sosa_record_service |
|
47 | + */ |
|
48 | + private $sosa_record_service; |
|
49 | + |
|
50 | + /** |
|
51 | + * Constructor for AncestorsListIndividual Request Handler |
|
52 | + * |
|
53 | + * @param ModuleService $module_service |
|
54 | + * @param SosaRecordsService $sosa_record_service |
|
55 | + */ |
|
56 | + public function __construct( |
|
57 | + ModuleService $module_service, |
|
58 | + SosaRecordsService $sosa_record_service |
|
59 | + ) { |
|
60 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
61 | + $this->sosa_record_service = $sosa_record_service; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * {@inheritDoc} |
|
66 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
67 | + */ |
|
68 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
69 | + { |
|
70 | + $this->layout = 'layouts/ajax'; |
|
71 | + |
|
72 | + if ($this->module === null) { |
|
73 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
74 | + } |
|
75 | + |
|
76 | + $tree = $request->getAttribute('tree'); |
|
77 | + assert($tree instanceof Tree); |
|
78 | + |
|
79 | + $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
80 | + |
|
81 | + $current_gen = (int) ($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
82 | + |
|
83 | + if ($current_gen <= 0) { |
|
84 | + return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY); |
|
85 | + } |
|
86 | + |
|
87 | + $list_ancestors = $this->sosa_record_service->listAncestorsAtGeneration($tree, $user, $current_gen); |
|
88 | + $nb_ancestors_all = $list_ancestors->count(); |
|
89 | + |
|
90 | + /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Individual> $list_ancestors */ |
|
91 | + $list_ancestors = $list_ancestors->mapWithKeys(function (stdClass $value) use ($tree): ?array { |
|
92 | + $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
|
93 | + return ($indi !== null && $indi->canShowName()) ? [(int) $value->majs_sosa => $indi] : null; |
|
94 | + })->filter(); |
|
95 | + |
|
96 | + $nb_ancestors_shown = $list_ancestors->count(); |
|
97 | + |
|
98 | + return $this->viewResponse($this->module->name() . '::list-ancestors-indi-tab', [ |
|
99 | + 'module_name' => $this->module->name(), |
|
100 | + 'title' => I18N::translate('Sosa Ancestors'), |
|
101 | + 'tree' => $tree, |
|
102 | + 'list_ancestors' => $list_ancestors, |
|
103 | + 'nb_ancestors_all' => $nb_ancestors_all, |
|
104 | + 'nb_ancestors_theor' => pow(2, $current_gen - 1), |
|
105 | + 'nb_ancestors_shown' => $nb_ancestors_shown |
|
106 | + ]); |
|
107 | + } |
|
108 | 108 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
80 | 80 | |
81 | - $current_gen = (int) ($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
81 | + $current_gen = (int)($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
82 | 82 | |
83 | 83 | if ($current_gen <= 0) { |
84 | 84 | return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY); |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | $nb_ancestors_all = $list_ancestors->count(); |
89 | 89 | |
90 | 90 | /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Individual> $list_ancestors */ |
91 | - $list_ancestors = $list_ancestors->mapWithKeys(function (stdClass $value) use ($tree): ?array { |
|
91 | + $list_ancestors = $list_ancestors->mapWithKeys(function(stdClass $value) use ($tree): ?array { |
|
92 | 92 | $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
93 | - return ($indi !== null && $indi->canShowName()) ? [(int) $value->majs_sosa => $indi] : null; |
|
93 | + return ($indi !== null && $indi->canShowName()) ? [(int)$value->majs_sosa => $indi] : null; |
|
94 | 94 | })->filter(); |
95 | 95 | |
96 | 96 | $nb_ancestors_shown = $list_ancestors->count(); |
97 | 97 | |
98 | - return $this->viewResponse($this->module->name() . '::list-ancestors-indi-tab', [ |
|
98 | + return $this->viewResponse($this->module->name().'::list-ancestors-indi-tab', [ |
|
99 | 99 | 'module_name' => $this->module->name(), |
100 | 100 | 'title' => I18N::translate('Sosa Ancestors'), |
101 | 101 | 'tree' => $tree, |
@@ -29,40 +29,40 @@ |
||
29 | 29 | */ |
30 | 30 | class SosaComputeModal implements RequestHandlerInterface |
31 | 31 | { |
32 | - /** |
|
33 | - * @var SosaModule $module |
|
34 | - */ |
|
35 | - private $module; |
|
32 | + /** |
|
33 | + * @var SosaModule $module |
|
34 | + */ |
|
35 | + private $module; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor for SosaComputeModal Request Handler |
|
39 | - * |
|
40 | - * @param ModuleService $module_service |
|
41 | - */ |
|
42 | - public function __construct(ModuleService $module_service) |
|
43 | - { |
|
44 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
45 | - } |
|
37 | + /** |
|
38 | + * Constructor for SosaComputeModal Request Handler |
|
39 | + * |
|
40 | + * @param ModuleService $module_service |
|
41 | + */ |
|
42 | + public function __construct(ModuleService $module_service) |
|
43 | + { |
|
44 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * {@inheritDoc} |
|
49 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
50 | - */ |
|
51 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
52 | - { |
|
53 | - if ($this->module === null) { |
|
54 | - return response( |
|
55 | - I18N::translate('The attached module could not be found.'), |
|
56 | - StatusCodeInterface::STATUS_NOT_FOUND |
|
57 | - ); |
|
58 | - } |
|
47 | + /** |
|
48 | + * {@inheritDoc} |
|
49 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
50 | + */ |
|
51 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
52 | + { |
|
53 | + if ($this->module === null) { |
|
54 | + return response( |
|
55 | + I18N::translate('The attached module could not be found.'), |
|
56 | + StatusCodeInterface::STATUS_NOT_FOUND |
|
57 | + ); |
|
58 | + } |
|
59 | 59 | |
60 | - $tree = $request->getAttribute('tree'); |
|
61 | - assert($tree instanceof Tree); |
|
60 | + $tree = $request->getAttribute('tree'); |
|
61 | + assert($tree instanceof Tree); |
|
62 | 62 | |
63 | - return response(view($this->module->name() . '::modals/sosa-compute', [ |
|
64 | - 'tree' => $tree, |
|
65 | - 'xref' => $request->getAttribute('xref') |
|
66 | - ])); |
|
67 | - } |
|
63 | + return response(view($this->module->name() . '::modals/sosa-compute', [ |
|
64 | + 'tree' => $tree, |
|
65 | + 'xref' => $request->getAttribute('xref') |
|
66 | + ])); |
|
67 | + } |
|
68 | 68 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | $tree = $request->getAttribute('tree'); |
61 | 61 | assert($tree instanceof Tree); |
62 | 62 | |
63 | - return response(view($this->module->name() . '::modals/sosa-compute', [ |
|
63 | + return response(view($this->module->name().'::modals/sosa-compute', [ |
|
64 | 64 | 'tree' => $tree, |
65 | 65 | 'xref' => $request->getAttribute('xref') |
66 | 66 | ])); |
@@ -31,61 +31,61 @@ |
||
31 | 31 | */ |
32 | 32 | class SosaComputeAction implements RequestHandlerInterface |
33 | 33 | { |
34 | - /** |
|
35 | - * @var UserService $user_service |
|
36 | - */ |
|
37 | - private $user_service; |
|
34 | + /** |
|
35 | + * @var UserService $user_service |
|
36 | + */ |
|
37 | + private $user_service; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Constructor for SosaConfigAction Request Handler |
|
41 | - * |
|
42 | - * @param UserService $user_service |
|
43 | - */ |
|
44 | - public function __construct(UserService $user_service) |
|
45 | - { |
|
46 | - $this->user_service = $user_service; |
|
47 | - } |
|
39 | + /** |
|
40 | + * Constructor for SosaConfigAction Request Handler |
|
41 | + * |
|
42 | + * @param UserService $user_service |
|
43 | + */ |
|
44 | + public function __construct(UserService $user_service) |
|
45 | + { |
|
46 | + $this->user_service = $user_service; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * {@inheritDoc} |
|
51 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
52 | - */ |
|
53 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
54 | - { |
|
55 | - $tree = $request->getAttribute('tree'); |
|
56 | - assert($tree instanceof Tree); |
|
49 | + /** |
|
50 | + * {@inheritDoc} |
|
51 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
52 | + */ |
|
53 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
54 | + { |
|
55 | + $tree = $request->getAttribute('tree'); |
|
56 | + assert($tree instanceof Tree); |
|
57 | 57 | |
58 | - $params = $request->getParsedBody(); |
|
59 | - assert(is_array($params)); |
|
58 | + $params = $request->getParsedBody(); |
|
59 | + assert(is_array($params)); |
|
60 | 60 | |
61 | - $user_id = (int) ($params['user_id'] ?? Auth::id() ?? 0); |
|
62 | - $partial_from = $params['partial_from'] ?? null; |
|
61 | + $user_id = (int) ($params['user_id'] ?? Auth::id() ?? 0); |
|
62 | + $partial_from = $params['partial_from'] ?? null; |
|
63 | 63 | |
64 | - if (($user_id == -1 && Auth::isManager($tree)) || Auth::id() == $user_id) { |
|
65 | - $user = $user_id == -1 ? new DefaultUser() : $this->user_service->find($user_id); |
|
64 | + if (($user_id == -1 && Auth::isManager($tree)) || Auth::id() == $user_id) { |
|
65 | + $user = $user_id == -1 ? new DefaultUser() : $this->user_service->find($user_id); |
|
66 | 66 | |
67 | - /** @var SosaCalculatorService $sosa_calc_service */ |
|
68 | - $sosa_calc_service = app()->makeWith(SosaCalculatorService::class, [ 'tree' => $tree, 'user' => $user]); |
|
67 | + /** @var SosaCalculatorService $sosa_calc_service */ |
|
68 | + $sosa_calc_service = app()->makeWith(SosaCalculatorService::class, [ 'tree' => $tree, 'user' => $user]); |
|
69 | 69 | |
70 | - if ( |
|
71 | - $partial_from !== null && |
|
72 | - ($sosa_from = Registry::individualFactory()->make($partial_from, $tree)) !== null |
|
73 | - ) { |
|
74 | - $res = $sosa_calc_service->computeFromIndividual($sosa_from); |
|
75 | - } else { |
|
76 | - $res = $sosa_calc_service->computeAll(); |
|
77 | - } |
|
70 | + if ( |
|
71 | + $partial_from !== null && |
|
72 | + ($sosa_from = Registry::individualFactory()->make($partial_from, $tree)) !== null |
|
73 | + ) { |
|
74 | + $res = $sosa_calc_service->computeFromIndividual($sosa_from); |
|
75 | + } else { |
|
76 | + $res = $sosa_calc_service->computeAll(); |
|
77 | + } |
|
78 | 78 | |
79 | - return $res ? |
|
80 | - response('', 200) : |
|
81 | - response( |
|
82 | - I18N::translate('An error occurred while computing Sosa ancestors.'), |
|
83 | - StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR |
|
84 | - ); |
|
85 | - } |
|
86 | - return response( |
|
87 | - I18N::translate('You do not have permission to modify the user.'), |
|
88 | - StatusCodeInterface::STATUS_FORBIDDEN |
|
89 | - ); |
|
90 | - } |
|
79 | + return $res ? |
|
80 | + response('', 200) : |
|
81 | + response( |
|
82 | + I18N::translate('An error occurred while computing Sosa ancestors.'), |
|
83 | + StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR |
|
84 | + ); |
|
85 | + } |
|
86 | + return response( |
|
87 | + I18N::translate('You do not have permission to modify the user.'), |
|
88 | + StatusCodeInterface::STATUS_FORBIDDEN |
|
89 | + ); |
|
90 | + } |
|
91 | 91 | } |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | $params = $request->getParsedBody(); |
59 | 59 | assert(is_array($params)); |
60 | 60 | |
61 | - $user_id = (int) ($params['user_id'] ?? Auth::id() ?? 0); |
|
61 | + $user_id = (int)($params['user_id'] ?? Auth::id() ?? 0); |
|
62 | 62 | $partial_from = $params['partial_from'] ?? null; |
63 | 63 | |
64 | 64 | if (($user_id == -1 && Auth::isManager($tree)) || Auth::id() == $user_id) { |
65 | 65 | $user = $user_id == -1 ? new DefaultUser() : $this->user_service->find($user_id); |
66 | 66 | |
67 | 67 | /** @var SosaCalculatorService $sosa_calc_service */ |
68 | - $sosa_calc_service = app()->makeWith(SosaCalculatorService::class, [ 'tree' => $tree, 'user' => $user]); |
|
68 | + $sosa_calc_service = app()->makeWith(SosaCalculatorService::class, ['tree' => $tree, 'user' => $user]); |
|
69 | 69 | |
70 | 70 | if ( |
71 | 71 | $partial_from !== null && |
@@ -77,8 +77,7 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | return $res ? |
80 | - response('', 200) : |
|
81 | - response( |
|
80 | + response('', 200) : response( |
|
82 | 81 | I18N::translate('An error occurred while computing Sosa ancestors.'), |
83 | 82 | StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR |
84 | 83 | ); |
@@ -31,59 +31,59 @@ |
||
31 | 31 | */ |
32 | 32 | class SosaConfig implements RequestHandlerInterface |
33 | 33 | { |
34 | - use ViewResponseTrait; |
|
34 | + use ViewResponseTrait; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var SosaModule $module |
|
38 | - */ |
|
39 | - private $module; |
|
36 | + /** |
|
37 | + * @var SosaModule $module |
|
38 | + */ |
|
39 | + private $module; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Constructor for SosaConfig Request Handler |
|
43 | - * |
|
44 | - * @param ModuleService $module_service |
|
45 | - */ |
|
46 | - public function __construct(ModuleService $module_service) |
|
47 | - { |
|
48 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
49 | - } |
|
41 | + /** |
|
42 | + * Constructor for SosaConfig Request Handler |
|
43 | + * |
|
44 | + * @param ModuleService $module_service |
|
45 | + */ |
|
46 | + public function __construct(ModuleService $module_service) |
|
47 | + { |
|
48 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * {@inheritDoc} |
|
53 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
54 | - */ |
|
55 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
56 | - { |
|
57 | - if ($this->module === null) { |
|
58 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
59 | - } |
|
51 | + /** |
|
52 | + * {@inheritDoc} |
|
53 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
54 | + */ |
|
55 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
56 | + { |
|
57 | + if ($this->module === null) { |
|
58 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
59 | + } |
|
60 | 60 | |
61 | - $tree = $request->getAttribute('tree'); |
|
62 | - assert($tree instanceof Tree); |
|
61 | + $tree = $request->getAttribute('tree'); |
|
62 | + assert($tree instanceof Tree); |
|
63 | 63 | |
64 | - $users_root = array(); |
|
65 | - if (Auth::check()) { |
|
66 | - /** @var \Fisharebest\Webtrees\User $user */ |
|
67 | - $user = Auth::user(); |
|
68 | - $users_root[] = ['user' => $user, 'root_id' => $tree->getUserPreference($user, 'MAJ_SOSA_ROOT_ID')]; |
|
64 | + $users_root = array(); |
|
65 | + if (Auth::check()) { |
|
66 | + /** @var \Fisharebest\Webtrees\User $user */ |
|
67 | + $user = Auth::user(); |
|
68 | + $users_root[] = ['user' => $user, 'root_id' => $tree->getUserPreference($user, 'MAJ_SOSA_ROOT_ID')]; |
|
69 | 69 | |
70 | - if (Auth::isManager($tree)) { |
|
71 | - $default_user = new DefaultUser(); |
|
72 | - $users_root[] = [ |
|
73 | - 'user' => $default_user, |
|
74 | - 'root_id' => $tree->getUserPreference($default_user, 'MAJ_SOSA_ROOT_ID') |
|
75 | - ]; |
|
76 | - } |
|
77 | - } |
|
70 | + if (Auth::isManager($tree)) { |
|
71 | + $default_user = new DefaultUser(); |
|
72 | + $users_root[] = [ |
|
73 | + 'user' => $default_user, |
|
74 | + 'root_id' => $tree->getUserPreference($default_user, 'MAJ_SOSA_ROOT_ID') |
|
75 | + ]; |
|
76 | + } |
|
77 | + } |
|
78 | 78 | |
79 | - return $this->viewResponse($this->module->name() . '::config-page', [ |
|
80 | - 'module_name' => $this->module->name(), |
|
81 | - 'title' => I18N::translate('Sosa Configuration'), |
|
82 | - 'tree' => $tree, |
|
83 | - 'user_id' => $request->getAttribute('user'), |
|
84 | - 'selected_user_id' => (int) ($request->getQueryParams()['user_id'] ?? 0), |
|
85 | - 'immediate_compute' => ($request->getQueryParams()['compute'] ?? '') == 'yes', |
|
86 | - 'users_root' => $users_root |
|
87 | - ]); |
|
88 | - } |
|
79 | + return $this->viewResponse($this->module->name() . '::config-page', [ |
|
80 | + 'module_name' => $this->module->name(), |
|
81 | + 'title' => I18N::translate('Sosa Configuration'), |
|
82 | + 'tree' => $tree, |
|
83 | + 'user_id' => $request->getAttribute('user'), |
|
84 | + 'selected_user_id' => (int) ($request->getQueryParams()['user_id'] ?? 0), |
|
85 | + 'immediate_compute' => ($request->getQueryParams()['compute'] ?? '') == 'yes', |
|
86 | + 'users_root' => $users_root |
|
87 | + ]); |
|
88 | + } |
|
89 | 89 | } |
@@ -76,12 +76,12 @@ |
||
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | - return $this->viewResponse($this->module->name() . '::config-page', [ |
|
79 | + return $this->viewResponse($this->module->name().'::config-page', [ |
|
80 | 80 | 'module_name' => $this->module->name(), |
81 | 81 | 'title' => I18N::translate('Sosa Configuration'), |
82 | 82 | 'tree' => $tree, |
83 | 83 | 'user_id' => $request->getAttribute('user'), |
84 | - 'selected_user_id' => (int) ($request->getQueryParams()['user_id'] ?? 0), |
|
84 | + 'selected_user_id' => (int)($request->getQueryParams()['user_id'] ?? 0), |
|
85 | 85 | 'immediate_compute' => ($request->getQueryParams()['compute'] ?? '') == 'yes', |
86 | 86 | 'users_root' => $users_root |
87 | 87 | ]); |
@@ -33,59 +33,59 @@ |
||
33 | 33 | */ |
34 | 34 | class AncestorsList implements RequestHandlerInterface |
35 | 35 | { |
36 | - use ViewResponseTrait; |
|
36 | + use ViewResponseTrait; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var SosaModule $module |
|
40 | - */ |
|
41 | - private $module; |
|
38 | + /** |
|
39 | + * @var SosaModule $module |
|
40 | + */ |
|
41 | + private $module; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @var SosaRecordsService $sosa_record_service |
|
45 | - */ |
|
46 | - private $sosa_record_service; |
|
43 | + /** |
|
44 | + * @var SosaRecordsService $sosa_record_service |
|
45 | + */ |
|
46 | + private $sosa_record_service; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Constructor for AncestorsList Request Handler |
|
50 | - * |
|
51 | - * @param ModuleService $module_service |
|
52 | - * @param SosaRecordsService $sosa_record_service |
|
53 | - */ |
|
54 | - public function __construct( |
|
55 | - ModuleService $module_service, |
|
56 | - SosaRecordsService $sosa_record_service |
|
57 | - ) { |
|
58 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
59 | - $this->sosa_record_service = $sosa_record_service; |
|
60 | - } |
|
48 | + /** |
|
49 | + * Constructor for AncestorsList Request Handler |
|
50 | + * |
|
51 | + * @param ModuleService $module_service |
|
52 | + * @param SosaRecordsService $sosa_record_service |
|
53 | + */ |
|
54 | + public function __construct( |
|
55 | + ModuleService $module_service, |
|
56 | + SosaRecordsService $sosa_record_service |
|
57 | + ) { |
|
58 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
59 | + $this->sosa_record_service = $sosa_record_service; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * {@inheritDoc} |
|
64 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
65 | - */ |
|
66 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
67 | - { |
|
68 | - if ($this->module === null) { |
|
69 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
70 | - } |
|
62 | + /** |
|
63 | + * {@inheritDoc} |
|
64 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
65 | + */ |
|
66 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
67 | + { |
|
68 | + if ($this->module === null) { |
|
69 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
70 | + } |
|
71 | 71 | |
72 | - $tree = $request->getAttribute('tree'); |
|
73 | - assert($tree instanceof Tree); |
|
72 | + $tree = $request->getAttribute('tree'); |
|
73 | + assert($tree instanceof Tree); |
|
74 | 74 | |
75 | - $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
75 | + $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
76 | 76 | |
77 | - /** @var SosaStatisticsService $sosa_stats_service */ |
|
78 | - $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
77 | + /** @var SosaStatisticsService $sosa_stats_service */ |
|
78 | + $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
79 | 79 | |
80 | - $current_gen = (int) ($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
80 | + $current_gen = (int) ($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
81 | 81 | |
82 | - return $this->viewResponse($this->module->name() . '::list-ancestors-page', [ |
|
83 | - 'module_name' => $this->module->name(), |
|
84 | - 'title' => I18N::translate('Sosa Ancestors'), |
|
85 | - 'tree' => $tree, |
|
86 | - 'root_indi' => $sosa_stats_service->rootIndividual(), |
|
87 | - 'max_gen' => $sosa_stats_service->maxGeneration(), |
|
88 | - 'current_gen' => $current_gen |
|
89 | - ]); |
|
90 | - } |
|
82 | + return $this->viewResponse($this->module->name() . '::list-ancestors-page', [ |
|
83 | + 'module_name' => $this->module->name(), |
|
84 | + 'title' => I18N::translate('Sosa Ancestors'), |
|
85 | + 'tree' => $tree, |
|
86 | + 'root_indi' => $sosa_stats_service->rootIndividual(), |
|
87 | + 'max_gen' => $sosa_stats_service->maxGeneration(), |
|
88 | + 'current_gen' => $current_gen |
|
89 | + ]); |
|
90 | + } |
|
91 | 91 | } |
@@ -77,9 +77,9 @@ |
||
77 | 77 | /** @var SosaStatisticsService $sosa_stats_service */ |
78 | 78 | $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
79 | 79 | |
80 | - $current_gen = (int) ($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
80 | + $current_gen = (int)($request->getAttribute('gen') ?? $request->getQueryParams()['gen'] ?? 0); |
|
81 | 81 | |
82 | - return $this->viewResponse($this->module->name() . '::list-ancestors-page', [ |
|
82 | + return $this->viewResponse($this->module->name().'::list-ancestors-page', [ |
|
83 | 83 | 'module_name' => $this->module->name(), |
84 | 84 | 'title' => I18N::translate('Sosa Ancestors'), |
85 | 85 | 'tree' => $tree, |