@@ -47,174 +47,174 @@ |
||
| 47 | 47 | */ |
| 48 | 48 | class SosaModule extends AbstractModule implements ModuleMyArtJaubInterface, ModuleGlobalInterface, ModuleMenuInterface |
| 49 | 49 | { |
| 50 | - use ModuleMyArtJaubTrait { |
|
| 51 | - boot as traitBoot; |
|
| 52 | - } |
|
| 53 | - use ModuleGlobalTrait; |
|
| 54 | - use ModuleMenuTrait; |
|
| 50 | + use ModuleMyArtJaubTrait { |
|
| 51 | + boot as traitBoot; |
|
| 52 | + } |
|
| 53 | + use ModuleGlobalTrait; |
|
| 54 | + use ModuleMenuTrait; |
|
| 55 | 55 | |
| 56 | 56 | // How to update the database schema for this module |
| 57 | 57 | |
| 58 | 58 | |
| 59 | - private const SCHEMA_TARGET_VERSION = 3; |
|
| 60 | - private const SCHEMA_SETTING_NAME = 'MAJ_SOSA_SCHEMA_VERSION'; |
|
| 61 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
| 59 | + private const SCHEMA_TARGET_VERSION = 3; |
|
| 60 | + private const SCHEMA_SETTING_NAME = 'MAJ_SOSA_SCHEMA_VERSION'; |
|
| 61 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
| 62 | 62 | /** |
| 63 | - * {@inheritDoc} |
|
| 64 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
| 65 | - */ |
|
| 66 | - public function title(): string |
|
| 67 | - { |
|
| 68 | - return /* I18N: Name of the “Sosa” module */ I18N::translate('Sosa'); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * {@inheritDoc} |
|
| 73 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
| 74 | - */ |
|
| 75 | - public function description(): string |
|
| 76 | - { |
|
| 77 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 78 | - return /* I18N: Description of the “Sosa” module */ I18N::translate('Calculate and display Sosa ancestors of the root person.'); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * {@inheritDoc} |
|
| 83 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
| 84 | - */ |
|
| 85 | - public function boot(): void |
|
| 86 | - { |
|
| 87 | - $this->traitBoot(); |
|
| 88 | - app(MigrationService::class)->updateSchema( |
|
| 89 | - self::SCHEMA_MIGRATION_PREFIX, |
|
| 90 | - self::SCHEMA_SETTING_NAME, |
|
| 91 | - self::SCHEMA_TARGET_VERSION |
|
| 92 | - ); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * {@inheritDoc} |
|
| 97 | - * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
| 98 | - */ |
|
| 99 | - public function loadRoutes(Map $router): void |
|
| 100 | - { |
|
| 101 | - $router->attach('', '', static function (Map $router): void { |
|
| 102 | - |
|
| 103 | - $router->attach('', '/module-maj/sosa', static function (Map $router): void { |
|
| 104 | - |
|
| 105 | - $router->attach('', '/list', static function (Map $router): void { |
|
| 106 | - |
|
| 107 | - $router->get(AncestorsList::class, '/ancestors/{tree}{/gen}', AncestorsList::class); |
|
| 108 | - $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 109 | - $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 110 | - $router->get(MissingAncestorsList::class, '/missing/{tree}{/gen}', MissingAncestorsList::class); |
|
| 111 | - }); |
|
| 112 | - |
|
| 113 | - $router->attach('', '/statistics/{tree}', static function (Map $router): void { |
|
| 114 | - |
|
| 115 | - $router->get(SosaStatistics::class, '', SosaStatistics::class); |
|
| 116 | - $router->get(PedigreeCollapseData::class, '/pedigreecollapse', PedigreeCollapseData::class); |
|
| 117 | - }); |
|
| 118 | - |
|
| 119 | - $router->attach('', '/config/{tree}', static function (Map $router): void { |
|
| 120 | - |
|
| 121 | - $router->get(SosaConfig::class, '', SosaConfig::class); |
|
| 122 | - $router->post(SosaConfigAction::class, '', SosaConfigAction::class); |
|
| 123 | - $router->get(SosaComputeModal::class, '/compute/{xref}', SosaComputeModal::class); |
|
| 124 | - $router->post(SosaComputeAction::class, '/compute', SosaComputeAction::class); |
|
| 125 | - }); |
|
| 126 | - }); |
|
| 127 | - }); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * {@inheritDoc} |
|
| 132 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
| 133 | - */ |
|
| 134 | - public function customModuleVersion(): string |
|
| 135 | - { |
|
| 136 | - return '2.0.11-v.1'; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * {@inheritDoc} |
|
| 141 | - * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::defaultMenuOrder() |
|
| 142 | - */ |
|
| 143 | - public function defaultMenuOrder(): int |
|
| 144 | - { |
|
| 145 | - return 7; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * {@inhericDoc} |
|
| 150 | - * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::getMenu() |
|
| 151 | - */ |
|
| 152 | - public function getMenu(Tree $tree): ?Menu |
|
| 153 | - { |
|
| 154 | - $menu = new Menu(I18N::translate('Sosa Statistics')); |
|
| 155 | - $menu->setClass('menu-maj-sosa'); |
|
| 156 | - $menu->setSubmenus([ |
|
| 157 | - new Menu( |
|
| 158 | - I18N::translate('Sosa Ancestors'), |
|
| 159 | - route(AncestorsList::class, ['tree' => $tree->name()]), |
|
| 160 | - 'menu-maj-sosa-list', |
|
| 161 | - ['rel' => 'nofollow'] |
|
| 162 | - ), |
|
| 163 | - new Menu( |
|
| 164 | - I18N::translate('Missing Ancestors'), |
|
| 165 | - route(MissingAncestorsList::class, ['tree' => $tree->name()]), |
|
| 166 | - 'menu-maj-sosa-missing', |
|
| 167 | - ['rel' => 'nofollow'] |
|
| 168 | - ), |
|
| 169 | - new Menu( |
|
| 170 | - I18N::translate('Sosa Statistics'), |
|
| 171 | - route(SosaStatistics::class, ['tree' => $tree->name()]), |
|
| 172 | - 'menu-maj-sosa-stats' |
|
| 173 | - ) |
|
| 174 | - ]); |
|
| 175 | - |
|
| 176 | - if (Auth::check()) { |
|
| 177 | - $menu->addSubmenu(new Menu( |
|
| 178 | - I18N::translate('Sosa Configuration'), |
|
| 179 | - route(SosaConfig::class, ['tree' => $tree->name()]), |
|
| 180 | - 'menu-maj-sosa-config' |
|
| 181 | - )); |
|
| 182 | - |
|
| 183 | - /** @var ServerRequestInterface $request */ |
|
| 184 | - $request = app(ServerRequestInterface::class); |
|
| 185 | - $route = $request->getAttribute('route'); |
|
| 186 | - assert($route instanceof Route); |
|
| 187 | - |
|
| 188 | - $root_indi_id = $tree->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID'); |
|
| 189 | - |
|
| 190 | - if ($route->name === IndividualPage::class && mb_strlen($root_indi_id) > 0) { |
|
| 191 | - $xref = $request->getAttribute('xref'); |
|
| 192 | - assert(is_string($xref)); |
|
| 193 | - |
|
| 194 | - $menu->addSubmenu(new Menu( |
|
| 195 | - I18N::translate('Complete Sosas'), |
|
| 196 | - '#', |
|
| 197 | - 'menu-maj-sosa-compute', |
|
| 198 | - [ |
|
| 199 | - 'rel' => 'nofollow', |
|
| 200 | - 'data-href' => route(SosaComputeModal::class, ['tree' => $tree->name(), 'xref' => $xref]), |
|
| 201 | - 'data-target' => '#wt-ajax-modal', |
|
| 202 | - 'data-toggle' => 'modal', |
|
| 203 | - 'data-backdrop' => 'static' |
|
| 204 | - ] |
|
| 205 | - )); |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - return $menu; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * {@inheritDoc} |
|
| 214 | - * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
| 215 | - */ |
|
| 216 | - public function headContent(): string |
|
| 217 | - { |
|
| 218 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
| 219 | - } |
|
| 63 | + * {@inheritDoc} |
|
| 64 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
| 65 | + */ |
|
| 66 | + public function title(): string |
|
| 67 | + { |
|
| 68 | + return /* I18N: Name of the “Sosa” module */ I18N::translate('Sosa'); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * {@inheritDoc} |
|
| 73 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
| 74 | + */ |
|
| 75 | + public function description(): string |
|
| 76 | + { |
|
| 77 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 78 | + return /* I18N: Description of the “Sosa” module */ I18N::translate('Calculate and display Sosa ancestors of the root person.'); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * {@inheritDoc} |
|
| 83 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
| 84 | + */ |
|
| 85 | + public function boot(): void |
|
| 86 | + { |
|
| 87 | + $this->traitBoot(); |
|
| 88 | + app(MigrationService::class)->updateSchema( |
|
| 89 | + self::SCHEMA_MIGRATION_PREFIX, |
|
| 90 | + self::SCHEMA_SETTING_NAME, |
|
| 91 | + self::SCHEMA_TARGET_VERSION |
|
| 92 | + ); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * {@inheritDoc} |
|
| 97 | + * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
| 98 | + */ |
|
| 99 | + public function loadRoutes(Map $router): void |
|
| 100 | + { |
|
| 101 | + $router->attach('', '', static function (Map $router): void { |
|
| 102 | + |
|
| 103 | + $router->attach('', '/module-maj/sosa', static function (Map $router): void { |
|
| 104 | + |
|
| 105 | + $router->attach('', '/list', static function (Map $router): void { |
|
| 106 | + |
|
| 107 | + $router->get(AncestorsList::class, '/ancestors/{tree}{/gen}', AncestorsList::class); |
|
| 108 | + $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 109 | + $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 110 | + $router->get(MissingAncestorsList::class, '/missing/{tree}{/gen}', MissingAncestorsList::class); |
|
| 111 | + }); |
|
| 112 | + |
|
| 113 | + $router->attach('', '/statistics/{tree}', static function (Map $router): void { |
|
| 114 | + |
|
| 115 | + $router->get(SosaStatistics::class, '', SosaStatistics::class); |
|
| 116 | + $router->get(PedigreeCollapseData::class, '/pedigreecollapse', PedigreeCollapseData::class); |
|
| 117 | + }); |
|
| 118 | + |
|
| 119 | + $router->attach('', '/config/{tree}', static function (Map $router): void { |
|
| 120 | + |
|
| 121 | + $router->get(SosaConfig::class, '', SosaConfig::class); |
|
| 122 | + $router->post(SosaConfigAction::class, '', SosaConfigAction::class); |
|
| 123 | + $router->get(SosaComputeModal::class, '/compute/{xref}', SosaComputeModal::class); |
|
| 124 | + $router->post(SosaComputeAction::class, '/compute', SosaComputeAction::class); |
|
| 125 | + }); |
|
| 126 | + }); |
|
| 127 | + }); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * {@inheritDoc} |
|
| 132 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
| 133 | + */ |
|
| 134 | + public function customModuleVersion(): string |
|
| 135 | + { |
|
| 136 | + return '2.0.11-v.1'; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * {@inheritDoc} |
|
| 141 | + * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::defaultMenuOrder() |
|
| 142 | + */ |
|
| 143 | + public function defaultMenuOrder(): int |
|
| 144 | + { |
|
| 145 | + return 7; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * {@inhericDoc} |
|
| 150 | + * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::getMenu() |
|
| 151 | + */ |
|
| 152 | + public function getMenu(Tree $tree): ?Menu |
|
| 153 | + { |
|
| 154 | + $menu = new Menu(I18N::translate('Sosa Statistics')); |
|
| 155 | + $menu->setClass('menu-maj-sosa'); |
|
| 156 | + $menu->setSubmenus([ |
|
| 157 | + new Menu( |
|
| 158 | + I18N::translate('Sosa Ancestors'), |
|
| 159 | + route(AncestorsList::class, ['tree' => $tree->name()]), |
|
| 160 | + 'menu-maj-sosa-list', |
|
| 161 | + ['rel' => 'nofollow'] |
|
| 162 | + ), |
|
| 163 | + new Menu( |
|
| 164 | + I18N::translate('Missing Ancestors'), |
|
| 165 | + route(MissingAncestorsList::class, ['tree' => $tree->name()]), |
|
| 166 | + 'menu-maj-sosa-missing', |
|
| 167 | + ['rel' => 'nofollow'] |
|
| 168 | + ), |
|
| 169 | + new Menu( |
|
| 170 | + I18N::translate('Sosa Statistics'), |
|
| 171 | + route(SosaStatistics::class, ['tree' => $tree->name()]), |
|
| 172 | + 'menu-maj-sosa-stats' |
|
| 173 | + ) |
|
| 174 | + ]); |
|
| 175 | + |
|
| 176 | + if (Auth::check()) { |
|
| 177 | + $menu->addSubmenu(new Menu( |
|
| 178 | + I18N::translate('Sosa Configuration'), |
|
| 179 | + route(SosaConfig::class, ['tree' => $tree->name()]), |
|
| 180 | + 'menu-maj-sosa-config' |
|
| 181 | + )); |
|
| 182 | + |
|
| 183 | + /** @var ServerRequestInterface $request */ |
|
| 184 | + $request = app(ServerRequestInterface::class); |
|
| 185 | + $route = $request->getAttribute('route'); |
|
| 186 | + assert($route instanceof Route); |
|
| 187 | + |
|
| 188 | + $root_indi_id = $tree->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID'); |
|
| 189 | + |
|
| 190 | + if ($route->name === IndividualPage::class && mb_strlen($root_indi_id) > 0) { |
|
| 191 | + $xref = $request->getAttribute('xref'); |
|
| 192 | + assert(is_string($xref)); |
|
| 193 | + |
|
| 194 | + $menu->addSubmenu(new Menu( |
|
| 195 | + I18N::translate('Complete Sosas'), |
|
| 196 | + '#', |
|
| 197 | + 'menu-maj-sosa-compute', |
|
| 198 | + [ |
|
| 199 | + 'rel' => 'nofollow', |
|
| 200 | + 'data-href' => route(SosaComputeModal::class, ['tree' => $tree->name(), 'xref' => $xref]), |
|
| 201 | + 'data-target' => '#wt-ajax-modal', |
|
| 202 | + 'data-toggle' => 'modal', |
|
| 203 | + 'data-backdrop' => 'static' |
|
| 204 | + ] |
|
| 205 | + )); |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + return $menu; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * {@inheritDoc} |
|
| 214 | + * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
| 215 | + */ |
|
| 216 | + public function headContent(): string |
|
| 217 | + { |
|
| 218 | + return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
| 219 | + } |
|
| 220 | 220 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | private const SCHEMA_TARGET_VERSION = 3; |
| 60 | 60 | private const SCHEMA_SETTING_NAME = 'MAJ_SOSA_SCHEMA_VERSION'; |
| 61 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
| 61 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__.'\Schema'; |
|
| 62 | 62 | /** |
| 63 | 63 | * {@inheritDoc} |
| 64 | 64 | * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
@@ -98,25 +98,25 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function loadRoutes(Map $router): void |
| 100 | 100 | { |
| 101 | - $router->attach('', '', static function (Map $router): void { |
|
| 101 | + $router->attach('', '', static function(Map $router): void { |
|
| 102 | 102 | |
| 103 | - $router->attach('', '/module-maj/sosa', static function (Map $router): void { |
|
| 103 | + $router->attach('', '/module-maj/sosa', static function(Map $router): void { |
|
| 104 | 104 | |
| 105 | - $router->attach('', '/list', static function (Map $router): void { |
|
| 105 | + $router->attach('', '/list', static function(Map $router): void { |
|
| 106 | 106 | |
| 107 | 107 | $router->get(AncestorsList::class, '/ancestors/{tree}{/gen}', AncestorsList::class); |
| 108 | - $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 109 | - $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 108 | + $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 109 | + $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 110 | 110 | $router->get(MissingAncestorsList::class, '/missing/{tree}{/gen}', MissingAncestorsList::class); |
| 111 | 111 | }); |
| 112 | 112 | |
| 113 | - $router->attach('', '/statistics/{tree}', static function (Map $router): void { |
|
| 113 | + $router->attach('', '/statistics/{tree}', static function(Map $router): void { |
|
| 114 | 114 | |
| 115 | 115 | $router->get(SosaStatistics::class, '', SosaStatistics::class); |
| 116 | 116 | $router->get(PedigreeCollapseData::class, '/pedigreecollapse', PedigreeCollapseData::class); |
| 117 | 117 | }); |
| 118 | 118 | |
| 119 | - $router->attach('', '/config/{tree}', static function (Map $router): void { |
|
| 119 | + $router->attach('', '/config/{tree}', static function(Map $router): void { |
|
| 120 | 120 | |
| 121 | 121 | $router->get(SosaConfig::class, '', SosaConfig::class); |
| 122 | 122 | $router->post(SosaConfigAction::class, '', SosaConfigAction::class); |
@@ -215,6 +215,6 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | public function headContent(): string |
| 217 | 217 | { |
| 218 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
| 218 | + return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">'; |
|
| 219 | 219 | } |
| 220 | 220 | } |
@@ -32,158 +32,158 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class WelcomeBlockModule extends AbstractModule implements ModuleMyArtJaubInterface, ModuleBlockInterface |
| 34 | 34 | { |
| 35 | - use ModuleMyArtJaubTrait; |
|
| 36 | - use ModuleBlockTrait; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * {@inheritDoc} |
|
| 40 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
| 41 | - */ |
|
| 42 | - public function title(): string |
|
| 43 | - { |
|
| 44 | - return /* I18N: Name of the “WelcomeBlock” module */ I18N::translate('MyArtJaub Welcome Block'); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * {@inheritDoc} |
|
| 49 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
| 50 | - */ |
|
| 51 | - public function description(): string |
|
| 52 | - { |
|
| 53 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 54 | - return /* I18N: Description of the “WelcomeBlock” module */ I18N::translate('The MyArtJaub Welcome block welcomes the visitor to the site, allows a quick login to the site, and displays statistics on visits.'); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * {@inheritDoc} |
|
| 59 | - * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
| 60 | - */ |
|
| 61 | - public function loadRoutes(Map $router): void |
|
| 62 | - { |
|
| 63 | - $router->attach('', '', static function (Map $router): void { |
|
| 64 | - |
|
| 65 | - $router->attach('', '/module-maj/welcomeblock/{block_id}', static function (Map $router): void { |
|
| 66 | - |
|
| 67 | - $router->get(MatomoStats::class, '/matomostats', MatomoStats::class); |
|
| 68 | - }); |
|
| 69 | - }); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * {@inheritDoc} |
|
| 74 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
| 75 | - */ |
|
| 76 | - public function customModuleVersion(): string |
|
| 77 | - { |
|
| 78 | - return '2.0.11-v.1'; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * {@inheritDoc} |
|
| 83 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::getBlock() |
|
| 84 | - */ |
|
| 85 | - public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string |
|
| 86 | - { |
|
| 87 | - $fab_welcome_block_view = app(\Fisharebest\Webtrees\Module\WelcomeBlockModule::class) |
|
| 88 | - ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED); |
|
| 89 | - |
|
| 90 | - $fab_login_block_view = app(\Fisharebest\Webtrees\Module\LoginBlockModule::class) |
|
| 91 | - ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED); |
|
| 92 | - |
|
| 93 | - $content = view($this->name() . '::block-embed', [ |
|
| 94 | - 'block_id' => $block_id, |
|
| 95 | - 'fab_welcome_block_view' => $fab_welcome_block_view, |
|
| 96 | - 'fab_login_block_view' => $fab_login_block_view, |
|
| 97 | - 'matomo_enabled' => $this->isMatomoEnabled($block_id) |
|
| 98 | - ]); |
|
| 99 | - |
|
| 100 | - if ($context !== self::CONTEXT_EMBED) { |
|
| 101 | - return view('modules/block-template', [ |
|
| 102 | - 'block' => Str::kebab($this->name()), |
|
| 103 | - 'id' => $block_id, |
|
| 104 | - 'config_url' => $this->configUrl($tree, $context, $block_id), |
|
| 105 | - 'title' => $tree->title(), |
|
| 106 | - 'content' => $content, |
|
| 107 | - ]); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - return $content; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * {@inheritDoc} |
|
| 115 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::isTreeBlock() |
|
| 116 | - */ |
|
| 117 | - public function isTreeBlock(): bool |
|
| 118 | - { |
|
| 119 | - return true; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * {@inheritDoc} |
|
| 124 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::editBlockConfiguration() |
|
| 125 | - */ |
|
| 126 | - public function editBlockConfiguration(Tree $tree, int $block_id): string |
|
| 127 | - { |
|
| 128 | - return view($this->name() . '::config', $this->matomoSettings($block_id)); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * {@inheritDoc} |
|
| 133 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::saveBlockConfiguration() |
|
| 134 | - */ |
|
| 135 | - public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void |
|
| 136 | - { |
|
| 137 | - $params = (array) $request->getParsedBody(); |
|
| 138 | - |
|
| 139 | - $matomo_enabled = $params['matomo_enabled'] == 'yes'; |
|
| 140 | - $this->setBlockSetting($block_id, 'matomo_enabled', $matomo_enabled ? 'yes' : 'no'); |
|
| 141 | - if (!$matomo_enabled) { |
|
| 142 | - return; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - if (filter_var($params['matomo_url'], FILTER_VALIDATE_URL) === false) { |
|
| 146 | - FlashMessages::addMessage(I18N::translate('The Matomo URL provided is not valid.'), 'danger'); |
|
| 147 | - return; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - if (filter_var($params['matomo_siteid'], FILTER_VALIDATE_INT) === false) { |
|
| 151 | - FlashMessages::addMessage(I18N::translate('The Matomo Site ID provided is not valid.'), 'danger'); |
|
| 152 | - return; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - $this |
|
| 156 | - ->setBlockSetting($block_id, 'matomo_url', trim($params['matomo_url'])) |
|
| 157 | - ->setBlockSetting($block_id, 'matomo_token', trim($params['matomo_token'])) |
|
| 158 | - ->setBlockSetting($block_id, 'matomo_siteid', $params['matomo_siteid']); |
|
| 159 | - |
|
| 160 | - app('cache.files')->forget($this->name() . '-matomovisits-yearly-' . $block_id); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Returns whether Matomo statistics is enabled for a specific MyArtJaub WelcomeBlock block |
|
| 165 | - * |
|
| 166 | - * @param int $block_id |
|
| 167 | - * @return bool |
|
| 168 | - */ |
|
| 169 | - public function isMatomoEnabled(int $block_id): bool |
|
| 170 | - { |
|
| 171 | - return $this->getBlockSetting($block_id, 'matomo_enabled', 'no') === 'yes'; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Returns settings for retrieving Matomo statistics for a specific MyArtJaub WelcomeBlock block |
|
| 176 | - * |
|
| 177 | - * @param int $block_id |
|
| 178 | - * @return array<string, mixed> |
|
| 179 | - */ |
|
| 180 | - public function matomoSettings(int $block_id): array |
|
| 181 | - { |
|
| 182 | - return [ |
|
| 183 | - 'matomo_enabled' => $this->isMatomoEnabled($block_id), |
|
| 184 | - 'matomo_url' => $this->getBlockSetting($block_id, 'matomo_url'), |
|
| 185 | - 'matomo_token' => $this->getBlockSetting($block_id, 'matomo_token'), |
|
| 186 | - 'matomo_siteid' => (int) $this->getBlockSetting($block_id, 'matomo_siteid', '0') |
|
| 187 | - ]; |
|
| 188 | - } |
|
| 35 | + use ModuleMyArtJaubTrait; |
|
| 36 | + use ModuleBlockTrait; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * {@inheritDoc} |
|
| 40 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
| 41 | + */ |
|
| 42 | + public function title(): string |
|
| 43 | + { |
|
| 44 | + return /* I18N: Name of the “WelcomeBlock” module */ I18N::translate('MyArtJaub Welcome Block'); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * {@inheritDoc} |
|
| 49 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
| 50 | + */ |
|
| 51 | + public function description(): string |
|
| 52 | + { |
|
| 53 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 54 | + return /* I18N: Description of the “WelcomeBlock” module */ I18N::translate('The MyArtJaub Welcome block welcomes the visitor to the site, allows a quick login to the site, and displays statistics on visits.'); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * {@inheritDoc} |
|
| 59 | + * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
| 60 | + */ |
|
| 61 | + public function loadRoutes(Map $router): void |
|
| 62 | + { |
|
| 63 | + $router->attach('', '', static function (Map $router): void { |
|
| 64 | + |
|
| 65 | + $router->attach('', '/module-maj/welcomeblock/{block_id}', static function (Map $router): void { |
|
| 66 | + |
|
| 67 | + $router->get(MatomoStats::class, '/matomostats', MatomoStats::class); |
|
| 68 | + }); |
|
| 69 | + }); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * {@inheritDoc} |
|
| 74 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
| 75 | + */ |
|
| 76 | + public function customModuleVersion(): string |
|
| 77 | + { |
|
| 78 | + return '2.0.11-v.1'; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * {@inheritDoc} |
|
| 83 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::getBlock() |
|
| 84 | + */ |
|
| 85 | + public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string |
|
| 86 | + { |
|
| 87 | + $fab_welcome_block_view = app(\Fisharebest\Webtrees\Module\WelcomeBlockModule::class) |
|
| 88 | + ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED); |
|
| 89 | + |
|
| 90 | + $fab_login_block_view = app(\Fisharebest\Webtrees\Module\LoginBlockModule::class) |
|
| 91 | + ->getBlock($tree, $block_id, ModuleBlockInterface::CONTEXT_EMBED); |
|
| 92 | + |
|
| 93 | + $content = view($this->name() . '::block-embed', [ |
|
| 94 | + 'block_id' => $block_id, |
|
| 95 | + 'fab_welcome_block_view' => $fab_welcome_block_view, |
|
| 96 | + 'fab_login_block_view' => $fab_login_block_view, |
|
| 97 | + 'matomo_enabled' => $this->isMatomoEnabled($block_id) |
|
| 98 | + ]); |
|
| 99 | + |
|
| 100 | + if ($context !== self::CONTEXT_EMBED) { |
|
| 101 | + return view('modules/block-template', [ |
|
| 102 | + 'block' => Str::kebab($this->name()), |
|
| 103 | + 'id' => $block_id, |
|
| 104 | + 'config_url' => $this->configUrl($tree, $context, $block_id), |
|
| 105 | + 'title' => $tree->title(), |
|
| 106 | + 'content' => $content, |
|
| 107 | + ]); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + return $content; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * {@inheritDoc} |
|
| 115 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::isTreeBlock() |
|
| 116 | + */ |
|
| 117 | + public function isTreeBlock(): bool |
|
| 118 | + { |
|
| 119 | + return true; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * {@inheritDoc} |
|
| 124 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::editBlockConfiguration() |
|
| 125 | + */ |
|
| 126 | + public function editBlockConfiguration(Tree $tree, int $block_id): string |
|
| 127 | + { |
|
| 128 | + return view($this->name() . '::config', $this->matomoSettings($block_id)); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * {@inheritDoc} |
|
| 133 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::saveBlockConfiguration() |
|
| 134 | + */ |
|
| 135 | + public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void |
|
| 136 | + { |
|
| 137 | + $params = (array) $request->getParsedBody(); |
|
| 138 | + |
|
| 139 | + $matomo_enabled = $params['matomo_enabled'] == 'yes'; |
|
| 140 | + $this->setBlockSetting($block_id, 'matomo_enabled', $matomo_enabled ? 'yes' : 'no'); |
|
| 141 | + if (!$matomo_enabled) { |
|
| 142 | + return; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + if (filter_var($params['matomo_url'], FILTER_VALIDATE_URL) === false) { |
|
| 146 | + FlashMessages::addMessage(I18N::translate('The Matomo URL provided is not valid.'), 'danger'); |
|
| 147 | + return; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + if (filter_var($params['matomo_siteid'], FILTER_VALIDATE_INT) === false) { |
|
| 151 | + FlashMessages::addMessage(I18N::translate('The Matomo Site ID provided is not valid.'), 'danger'); |
|
| 152 | + return; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + $this |
|
| 156 | + ->setBlockSetting($block_id, 'matomo_url', trim($params['matomo_url'])) |
|
| 157 | + ->setBlockSetting($block_id, 'matomo_token', trim($params['matomo_token'])) |
|
| 158 | + ->setBlockSetting($block_id, 'matomo_siteid', $params['matomo_siteid']); |
|
| 159 | + |
|
| 160 | + app('cache.files')->forget($this->name() . '-matomovisits-yearly-' . $block_id); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Returns whether Matomo statistics is enabled for a specific MyArtJaub WelcomeBlock block |
|
| 165 | + * |
|
| 166 | + * @param int $block_id |
|
| 167 | + * @return bool |
|
| 168 | + */ |
|
| 169 | + public function isMatomoEnabled(int $block_id): bool |
|
| 170 | + { |
|
| 171 | + return $this->getBlockSetting($block_id, 'matomo_enabled', 'no') === 'yes'; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Returns settings for retrieving Matomo statistics for a specific MyArtJaub WelcomeBlock block |
|
| 176 | + * |
|
| 177 | + * @param int $block_id |
|
| 178 | + * @return array<string, mixed> |
|
| 179 | + */ |
|
| 180 | + public function matomoSettings(int $block_id): array |
|
| 181 | + { |
|
| 182 | + return [ |
|
| 183 | + 'matomo_enabled' => $this->isMatomoEnabled($block_id), |
|
| 184 | + 'matomo_url' => $this->getBlockSetting($block_id, 'matomo_url'), |
|
| 185 | + 'matomo_token' => $this->getBlockSetting($block_id, 'matomo_token'), |
|
| 186 | + 'matomo_siteid' => (int) $this->getBlockSetting($block_id, 'matomo_siteid', '0') |
|
| 187 | + ]; |
|
| 188 | + } |
|
| 189 | 189 | } |
@@ -23,73 +23,73 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | trait ModuleMyArtJaubTrait |
| 25 | 25 | { |
| 26 | - use ModuleCustomTrait; |
|
| 26 | + use ModuleCustomTrait; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
| 30 | - */ |
|
| 31 | - public function boot() : void |
|
| 32 | - { |
|
| 33 | - View::registerNamespace($this->name(), $this->resourcesFolder() . 'views/'); |
|
| 28 | + /** |
|
| 29 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
| 30 | + */ |
|
| 31 | + public function boot() : void |
|
| 32 | + { |
|
| 33 | + View::registerNamespace($this->name(), $this->resourcesFolder() . 'views/'); |
|
| 34 | 34 | |
| 35 | - $this->loadRoutes(app(RouterContainer::class)->getMap()); |
|
| 36 | - } |
|
| 35 | + $this->loadRoutes(app(RouterContainer::class)->getMap()); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::resourcesFolder() |
|
| 40 | - */ |
|
| 41 | - public function resourcesFolder(): string |
|
| 42 | - { |
|
| 43 | - return Webtrees::MODULES_DIR . trim($this->name(), '_') . '/resources/'; |
|
| 44 | - } |
|
| 38 | + /** |
|
| 39 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::resourcesFolder() |
|
| 40 | + */ |
|
| 41 | + public function resourcesFolder(): string |
|
| 42 | + { |
|
| 43 | + return Webtrees::MODULES_DIR . trim($this->name(), '_') . '/resources/'; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleAuthorName() |
|
| 48 | - */ |
|
| 49 | - public function customModuleAuthorName() : string |
|
| 50 | - { |
|
| 51 | - return 'Jonathan Jaubart'; |
|
| 52 | - } |
|
| 46 | + /** |
|
| 47 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleAuthorName() |
|
| 48 | + */ |
|
| 49 | + public function customModuleAuthorName() : string |
|
| 50 | + { |
|
| 51 | + return 'Jonathan Jaubart'; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleSupportUrl() |
|
| 56 | - */ |
|
| 57 | - public function customModuleSupportUrl() : string |
|
| 58 | - { |
|
| 59 | - return 'https://github.com/jon48/webtrees-lib'; |
|
| 60 | - } |
|
| 54 | + /** |
|
| 55 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleSupportUrl() |
|
| 56 | + */ |
|
| 57 | + public function customModuleSupportUrl() : string |
|
| 58 | + { |
|
| 59 | + return 'https://github.com/jon48/webtrees-lib'; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customTranslations() |
|
| 64 | - */ |
|
| 65 | - public function customTranslations(string $language) : array |
|
| 66 | - { |
|
| 67 | - $translation_file = $this->resourcesFolder() . 'lang/' . $language . '/messages.php'; |
|
| 62 | + /** |
|
| 63 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customTranslations() |
|
| 64 | + */ |
|
| 65 | + public function customTranslations(string $language) : array |
|
| 66 | + { |
|
| 67 | + $translation_file = $this->resourcesFolder() . 'lang/' . $language . '/messages.php'; |
|
| 68 | 68 | |
| 69 | - try { |
|
| 70 | - $translation = new Translation($translation_file); |
|
| 71 | - return $translation->asArray(); |
|
| 72 | - } catch (\Exception $e) { } |
|
| 69 | + try { |
|
| 70 | + $translation = new Translation($translation_file); |
|
| 71 | + return $translation->asArray(); |
|
| 72 | + } catch (\Exception $e) { } |
|
| 73 | 73 | |
| 74 | - return array(); |
|
| 75 | - } |
|
| 74 | + return array(); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::moduleCssUrl |
|
| 79 | - */ |
|
| 80 | - public function moduleCssUrl() : string |
|
| 81 | - { |
|
| 82 | - /** @var ModuleThemeInterface $theme */ |
|
| 83 | - $theme = app(ModuleThemeInterface::class); |
|
| 84 | - $css_file = $this->resourcesFolder() . 'css/' . $theme->name() . '.min.css'; |
|
| 77 | + /** |
|
| 78 | + * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::moduleCssUrl |
|
| 79 | + */ |
|
| 80 | + public function moduleCssUrl() : string |
|
| 81 | + { |
|
| 82 | + /** @var ModuleThemeInterface $theme */ |
|
| 83 | + $theme = app(ModuleThemeInterface::class); |
|
| 84 | + $css_file = $this->resourcesFolder() . 'css/' . $theme->name() . '.min.css'; |
|
| 85 | 85 | |
| 86 | - if(file_exists($css_file)) { |
|
| 87 | - return $this->assetUrl('css/' . $theme->name() . '.min.css'); |
|
| 88 | - } |
|
| 89 | - else { |
|
| 90 | - return $this->assetUrl('css/default.min.css'); |
|
| 91 | - } |
|
| 92 | - } |
|
| 86 | + if(file_exists($css_file)) { |
|
| 87 | + return $this->assetUrl('css/' . $theme->name() . '.min.css'); |
|
| 88 | + } |
|
| 89 | + else { |
|
| 90 | + return $this->assetUrl('css/default.min.css'); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | \ No newline at end of file |
@@ -34,100 +34,100 @@ |
||
| 34 | 34 | * Display lineages of people with the same surname. |
| 35 | 35 | */ |
| 36 | 36 | class PatronymicLineageModule extends AbstractModule implements |
| 37 | - ModuleMyArtJaubInterface, |
|
| 38 | - ModuleListInterface, |
|
| 39 | - ModuleGlobalInterface |
|
| 37 | + ModuleMyArtJaubInterface, |
|
| 38 | + ModuleListInterface, |
|
| 39 | + ModuleGlobalInterface |
|
| 40 | 40 | { |
| 41 | - use ModuleMyArtJaubTrait; |
|
| 42 | - use ModuleListTrait; |
|
| 43 | - use ModuleGlobalTrait; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * {@inheritDoc} |
|
| 47 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
| 48 | - */ |
|
| 49 | - public function title(): string |
|
| 50 | - { |
|
| 51 | - return /* I18N: Name of the “Patronymic lineage” module */ I18N::translate('Patronymic Lineages'); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * {@inheritDoc} |
|
| 56 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
| 57 | - */ |
|
| 58 | - public function description(): string |
|
| 59 | - { |
|
| 60 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 61 | - return /* I18N: Description of the “Patronymic lineage” module */ I18N::translate('Display lineages of people holding the same surname.'); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * {@inheritDoc} |
|
| 66 | - * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
| 67 | - */ |
|
| 68 | - public function loadRoutes(Map $router): void |
|
| 69 | - { |
|
| 70 | - $router->attach('', '', static function (Map $router): void { |
|
| 71 | - |
|
| 72 | - $router->attach('', '/module-maj/lineages', static function (Map $router): void { |
|
| 73 | - |
|
| 74 | - $router->attach('', '/Page', static function (Map $router): void { |
|
| 75 | - |
|
| 76 | - $router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class); |
|
| 77 | - $router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class); |
|
| 78 | - }); |
|
| 79 | - }); |
|
| 80 | - }); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * {@inheritDoc} |
|
| 85 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
| 86 | - */ |
|
| 87 | - public function customModuleVersion(): string |
|
| 88 | - { |
|
| 89 | - return '2.0.11-v.1'; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * {@inheritDoc} |
|
| 94 | - * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listUrl() |
|
| 95 | - */ |
|
| 96 | - public function listUrl(Tree $tree, array $parameters = []): string |
|
| 97 | - { |
|
| 98 | - $surname = $parameters['surname'] ?? ''; |
|
| 99 | - |
|
| 100 | - $xref = app(ServerRequestInterface::class)->getAttribute('xref', ''); |
|
| 101 | - if ($xref !== '' && ($individual = Registry::individualFactory()->make($xref, $tree)) !== null) { |
|
| 102 | - $surname = $individual->getAllNames()[$individual->getPrimaryName()]['surname']; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - if ($surname !== '') { |
|
| 106 | - return route(LineagesPage::class, [ |
|
| 107 | - 'tree' => $tree->name(), |
|
| 108 | - 'surname' => $surname |
|
| 109 | - ] + $parameters); |
|
| 110 | - } |
|
| 111 | - return route(SurnamesList::class, [ |
|
| 112 | - 'tree' => $tree->name() |
|
| 113 | - ] + $parameters); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * {@inheritDoc} |
|
| 118 | - * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listMenuClass() |
|
| 119 | - */ |
|
| 120 | - public function listMenuClass(): string |
|
| 121 | - { |
|
| 122 | - return 'menu-maj-patrolineage'; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * {@inheritDoc} |
|
| 127 | - * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
| 128 | - */ |
|
| 129 | - public function headContent(): string |
|
| 130 | - { |
|
| 131 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
| 132 | - } |
|
| 41 | + use ModuleMyArtJaubTrait; |
|
| 42 | + use ModuleListTrait; |
|
| 43 | + use ModuleGlobalTrait; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * {@inheritDoc} |
|
| 47 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
| 48 | + */ |
|
| 49 | + public function title(): string |
|
| 50 | + { |
|
| 51 | + return /* I18N: Name of the “Patronymic lineage” module */ I18N::translate('Patronymic Lineages'); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * {@inheritDoc} |
|
| 56 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
| 57 | + */ |
|
| 58 | + public function description(): string |
|
| 59 | + { |
|
| 60 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 61 | + return /* I18N: Description of the “Patronymic lineage” module */ I18N::translate('Display lineages of people holding the same surname.'); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * {@inheritDoc} |
|
| 66 | + * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
| 67 | + */ |
|
| 68 | + public function loadRoutes(Map $router): void |
|
| 69 | + { |
|
| 70 | + $router->attach('', '', static function (Map $router): void { |
|
| 71 | + |
|
| 72 | + $router->attach('', '/module-maj/lineages', static function (Map $router): void { |
|
| 73 | + |
|
| 74 | + $router->attach('', '/Page', static function (Map $router): void { |
|
| 75 | + |
|
| 76 | + $router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class); |
|
| 77 | + $router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class); |
|
| 78 | + }); |
|
| 79 | + }); |
|
| 80 | + }); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * {@inheritDoc} |
|
| 85 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
| 86 | + */ |
|
| 87 | + public function customModuleVersion(): string |
|
| 88 | + { |
|
| 89 | + return '2.0.11-v.1'; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * {@inheritDoc} |
|
| 94 | + * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listUrl() |
|
| 95 | + */ |
|
| 96 | + public function listUrl(Tree $tree, array $parameters = []): string |
|
| 97 | + { |
|
| 98 | + $surname = $parameters['surname'] ?? ''; |
|
| 99 | + |
|
| 100 | + $xref = app(ServerRequestInterface::class)->getAttribute('xref', ''); |
|
| 101 | + if ($xref !== '' && ($individual = Registry::individualFactory()->make($xref, $tree)) !== null) { |
|
| 102 | + $surname = $individual->getAllNames()[$individual->getPrimaryName()]['surname']; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + if ($surname !== '') { |
|
| 106 | + return route(LineagesPage::class, [ |
|
| 107 | + 'tree' => $tree->name(), |
|
| 108 | + 'surname' => $surname |
|
| 109 | + ] + $parameters); |
|
| 110 | + } |
|
| 111 | + return route(SurnamesList::class, [ |
|
| 112 | + 'tree' => $tree->name() |
|
| 113 | + ] + $parameters); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * {@inheritDoc} |
|
| 118 | + * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listMenuClass() |
|
| 119 | + */ |
|
| 120 | + public function listMenuClass(): string |
|
| 121 | + { |
|
| 122 | + return 'menu-maj-patrolineage'; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * {@inheritDoc} |
|
| 127 | + * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
| 128 | + */ |
|
| 129 | + public function headContent(): string |
|
| 130 | + { |
|
| 131 | + return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
| 132 | + } |
|
| 133 | 133 | } |