|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
|
4
|
|
|
* |
|
5
|
|
|
* @package MyArtJaub\Webtrees |
|
6
|
|
|
* @subpackage Sosa |
|
7
|
|
|
* @author Jonathan Jaubart <[email protected]> |
|
8
|
|
|
* @copyright Copyright (c) 2009-2020, Jonathan Jaubart |
|
9
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace MyArtJaub\Webtrees\Module\Sosa; |
|
15
|
|
|
|
|
16
|
|
|
use Aura\Router\Map; |
|
17
|
|
|
use Fisharebest\Webtrees\Auth; |
|
18
|
|
|
use Fisharebest\Webtrees\I18N; |
|
19
|
|
|
use Fisharebest\Webtrees\Menu; |
|
20
|
|
|
use Fisharebest\Webtrees\Tree; |
|
21
|
|
|
use Fisharebest\Webtrees\Module\ModuleGlobalInterface; |
|
22
|
|
|
use Fisharebest\Webtrees\Module\ModuleGlobalTrait; |
|
23
|
|
|
use Fisharebest\Webtrees\Module\ModuleMenuInterface; |
|
24
|
|
|
use Fisharebest\Webtrees\Module\ModuleMenuTrait; |
|
25
|
|
|
use Fisharebest\Webtrees\Services\MigrationService; |
|
26
|
|
|
use MyArtJaub\Webtrees\Module\AbstractModuleMaj; |
|
27
|
|
|
use MyArtJaub\Webtrees\Module\Sosa\Http\RequestHandlers\AncestorsList; |
|
|
|
|
|
|
28
|
|
|
use MyArtJaub\Webtrees\Module\Sosa\Http\RequestHandlers\MissingAncestorsList; |
|
|
|
|
|
|
29
|
|
|
use MyArtJaub\Webtrees\Module\Sosa\Http\RequestHandlers\SosaComputeAction; |
|
30
|
|
|
use MyArtJaub\Webtrees\Module\Sosa\Http\RequestHandlers\SosaConfig; |
|
31
|
|
|
use MyArtJaub\Webtrees\Module\Sosa\Http\RequestHandlers\SosaConfigAction; |
|
32
|
|
|
use MyArtJaub\Webtrees\Module\Sosa\Http\RequestHandlers\SosaStatistics; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* MyArtJaub Sosa Module |
|
36
|
|
|
* Identify and produce statistics about Sosa ancestors |
|
37
|
|
|
*/ |
|
38
|
|
|
class SosaModule extends AbstractModuleMaj implements ModuleMenuInterface, ModuleGlobalInterface |
|
39
|
|
|
{ |
|
40
|
|
|
use ModuleMenuTrait; |
|
41
|
|
|
use ModuleGlobalTrait; |
|
42
|
|
|
|
|
43
|
|
|
// How to update the database schema for this module |
|
44
|
|
|
private const SCHEMA_TARGET_VERSION = 3; |
|
45
|
|
|
private const SCHEMA_SETTING_NAME = 'MAJ_SOSA_SCHEMA_VERSION'; |
|
46
|
|
|
private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* {@inheritDoc} |
|
50
|
|
|
* @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
51
|
|
|
*/ |
|
52
|
|
|
public function title(): string |
|
53
|
|
|
{ |
|
54
|
|
|
return /* I18N: Name of the “Sosa” module */ I18N::translate('Sosa'); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* {@inheritDoc} |
|
59
|
|
|
* @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
60
|
|
|
*/ |
|
61
|
|
|
public function description(): string |
|
62
|
|
|
{ |
|
63
|
|
|
return /* I18N: Description of the “Sosa” module */ I18N::translate('Calculate and display Sosa ancestors of the root person.'); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* {@inheritDoc} |
|
68
|
|
|
* @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::boot() |
|
69
|
|
|
*/ |
|
70
|
|
|
public function boot(): void |
|
71
|
|
|
{ |
|
72
|
|
|
parent::boot(); |
|
73
|
|
|
app(MigrationService::class)->updateSchema( |
|
74
|
|
|
self::SCHEMA_MIGRATION_PREFIX, |
|
75
|
|
|
self::SCHEMA_SETTING_NAME, |
|
76
|
|
|
self::SCHEMA_TARGET_VERSION |
|
77
|
|
|
); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* {@inheritDoc} |
|
82
|
|
|
* @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::loadRoutes() |
|
83
|
|
|
*/ |
|
84
|
|
|
public function loadRoutes(Map $router): void |
|
85
|
|
|
{ |
|
86
|
|
|
$router->attach('', '', static function(Map $router) : void { |
|
87
|
|
|
$router->attach('', '/module-maj/sosa', static function(Map $router) : void { |
|
88
|
|
|
$router->attach('', '/list', static function (Map $router) : void { |
|
89
|
|
|
|
|
90
|
|
|
$router->get(AncestorsList::class, '/ancestors/{tree}/{/gen}', AncestorsList::class); |
|
91
|
|
|
$router->get(MissingAncestorsList::class, '/missing/{tree}/{/gen}', MissingAncestorsList::class); |
|
92
|
|
|
}); |
|
93
|
|
|
|
|
94
|
|
|
$router->get(SosaStatistics::class, '/statistics/{tree}', SosaStatistics::class); |
|
95
|
|
|
|
|
96
|
|
|
$router->attach('', '/config/{tree}', static function (Map $router) : void { |
|
97
|
|
|
|
|
98
|
|
|
$router->get(SosaConfig::class, '', SosaConfig::class); |
|
99
|
|
|
$router->post(SosaConfigAction::class, '', SosaConfigAction::class); |
|
100
|
|
|
|
|
101
|
|
|
$router->post(SosaComputeAction::class, '/compute', SosaComputeAction::class); |
|
102
|
|
|
}); |
|
103
|
|
|
}); |
|
104
|
|
|
}); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* {@inheritDoc} |
|
109
|
|
|
* @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
110
|
|
|
*/ |
|
111
|
|
|
public function customModuleVersion(): string |
|
112
|
|
|
{ |
|
113
|
|
|
return '2.0.7-v.1'; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* {@inheritDoc} |
|
118
|
|
|
* @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::defaultMenuOrder() |
|
119
|
|
|
*/ |
|
120
|
|
|
public function defaultMenuOrder(): int |
|
121
|
|
|
{ |
|
122
|
|
|
return 7; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* {@inhericDoc} |
|
127
|
|
|
* @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::getMenu() |
|
128
|
|
|
*/ |
|
129
|
|
|
public function getMenu(Tree $tree): ?Menu |
|
130
|
|
|
{ |
|
131
|
|
|
$menu = new Menu(I18N::translate('Sosa Statistics')); |
|
132
|
|
|
$menu->setClass('menu-maj-sosa'); |
|
133
|
|
|
|
|
134
|
|
|
$menu->setSubmenus([ |
|
135
|
|
|
new Menu(I18N::translate('Sosa Ancestors'), route(AncestorsList::class, ['tree' => $tree->name()]), 'menu-maj-sosa-list', ['rel' => 'nofollow']), |
|
136
|
|
|
new Menu(I18N::translate('Missing Ancestors'), route(MissingAncestorsList::class, ['tree' => $tree->name()]), 'menu-maj-sosa-missing', ['rel' => 'nofollow']), |
|
137
|
|
|
new Menu(I18N::translate('Sosa Statistics'), route(SosaStatistics::class, ['tree' => $tree->name()]), 'menu-maj-sosa-stats') |
|
138
|
|
|
]); |
|
139
|
|
|
|
|
140
|
|
|
if(Auth::check()) { |
|
141
|
|
|
$menu->addSubmenu( |
|
142
|
|
|
new Menu(I18N::translate('Sosa Configuration'), route(SosaConfig::class, ['tree' => $tree->name()]), 'menu-maj-sosa-config') |
|
143
|
|
|
); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
return $menu; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* {@inheritDoc} |
|
151
|
|
|
* @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
152
|
|
|
*/ |
|
153
|
|
|
public function headContent(): string |
|
154
|
|
|
{ |
|
155
|
|
|
return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
156
|
|
|
} |
|
157
|
|
|
} |
|
158
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths