1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2022 webtrees development team 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18declare(strict_types=1); 19 20namespace Fisharebest\Webtrees\Module; 21 22use Aura\Router\RouterContainer; 23use Fisharebest\Webtrees\Http\RequestHandlers\RedirectAncestryPhp; 24use Fisharebest\Webtrees\Http\RequestHandlers\RedirectBranchesPhp; 25use Fisharebest\Webtrees\Http\RequestHandlers\RedirectCalendarPhp; 26use Fisharebest\Webtrees\Http\RequestHandlers\RedirectCompactPhp; 27use Fisharebest\Webtrees\Http\RequestHandlers\RedirectDescendencyPhp; 28use Fisharebest\Webtrees\Http\RequestHandlers\RedirectFamilyBookPhp; 29use Fisharebest\Webtrees\Http\RequestHandlers\RedirectFamilyPhp; 30use Fisharebest\Webtrees\Http\RequestHandlers\RedirectFamListPhp; 31use Fisharebest\Webtrees\Http\RequestHandlers\RedirectFanChartPhp; 32use Fisharebest\Webtrees\Http\RequestHandlers\RedirectGedRecordPhp; 33use Fisharebest\Webtrees\Http\RequestHandlers\RedirectHourGlassPhp; 34use Fisharebest\Webtrees\Http\RequestHandlers\RedirectIndiListPhp; 35use Fisharebest\Webtrees\Http\RequestHandlers\RedirectIndividualPhp; 36use Fisharebest\Webtrees\Http\RequestHandlers\RedirectLifeSpanPhp; 37use Fisharebest\Webtrees\Http\RequestHandlers\RedirectMediaListPhp; 38use Fisharebest\Webtrees\Http\RequestHandlers\RedirectMediaViewerPhp; 39use Fisharebest\Webtrees\Http\RequestHandlers\RedirectModulePhp; 40use Fisharebest\Webtrees\Http\RequestHandlers\RedirectNoteListPhp; 41use Fisharebest\Webtrees\Http\RequestHandlers\RedirectNotePhp; 42use Fisharebest\Webtrees\Http\RequestHandlers\RedirectPedigreePhp; 43use Fisharebest\Webtrees\Http\RequestHandlers\RedirectPlaceListPhp; 44use Fisharebest\Webtrees\Http\RequestHandlers\RedirectRelationshipPhp; 45use Fisharebest\Webtrees\Http\RequestHandlers\RedirectRepoListPhp; 46use Fisharebest\Webtrees\Http\RequestHandlers\RedirectReportEnginePhp; 47use Fisharebest\Webtrees\Http\RequestHandlers\RedirectRepositoryPhp; 48use Fisharebest\Webtrees\Http\RequestHandlers\RedirectSourceListPhp; 49use Fisharebest\Webtrees\Http\RequestHandlers\RedirectSourcePhp; 50use Fisharebest\Webtrees\Http\RequestHandlers\RedirectStatisticsPhp; 51use Fisharebest\Webtrees\Http\RequestHandlers\RedirectTimeLinePhp; 52use Fisharebest\Webtrees\I18N; 53 54use function app; 55use function assert; 56 57/** 58 * Class RedirectLegacyUrlsModule - rewrite URLs from phpGedView and webtrees 1.x 59 */ 60class RedirectLegacyUrlsModule extends AbstractModule 61{ 62 /** 63 * Initialization. 64 * 65 * @return void 66 */ 67 public function boot(): void 68 { 69 $router_container = app(RouterContainer::class); 70 assert($router_container instanceof RouterContainer); 71 72 $router = $router_container->getMap(); 73 74 // Legacy URLs from older software. 75 $router->get(RedirectAncestryPhp::class, '/ancestry.php', RedirectAncestryPhp::class); 76 $router->get(RedirectBranchesPhp::class, '/branches.php', RedirectBranchesPhp::class); 77 $router->get(RedirectCalendarPhp::class, '/calendar.php', RedirectCalendarPhp::class); 78 $router->get(RedirectCompactPhp::class, '/compact.php', RedirectCompactPhp::class); 79 $router->get(RedirectDescendencyPhp::class, '/compact.php', RedirectDescendencyPhp::class); 80 $router->get(RedirectFamilyPhp::class, '/family.php', RedirectFamilyPhp::class); 81 $router->get(RedirectFamListPhp::class, '/famlist.php', RedirectFamListPhp::class); 82 $router->get(RedirectFamilyBookPhp::class, '/familybook.php', RedirectFamilyBookPhp::class); 83 $router->get(RedirectFanChartPhp::class, '/fanchart.php', RedirectFanChartPhp::class); 84 $router->get(RedirectGedRecordPhp::class, '/gedrecord.php', RedirectGedRecordPhp::class); 85 $router->get(RedirectHourGlassPhp::class, '/hourglass.php', RedirectHourGlassPhp::class); 86 $router->get(RedirectIndiListPhp::class, '/indilist.php', RedirectIndiListPhp::class); 87 $router->get(RedirectIndividualPhp::class, '/individual.php', RedirectIndividualPhp::class); 88 $router->get(RedirectLifeSpanPhp::class, '/lifespan.php', RedirectLifeSpanPhp::class); 89 $router->get(RedirectMediaListPhp::class, '/medialist.php', RedirectMediaListPhp::class); 90 $router->get(RedirectMediaViewerPhp::class, '/mediaviewer.php', RedirectMediaViewerPhp::class); 91 $router->get(RedirectModulePhp::class, '/module.php', RedirectModulePhp::class); 92 $router->get(RedirectNotePhp::class, '/note.php', RedirectNotePhp::class); 93 $router->get(RedirectNoteListPhp::class, '/notelist.php', RedirectNoteListPhp::class); 94 $router->get(RedirectPedigreePhp::class, '/pedigree.php', RedirectPedigreePhp::class); 95 $router->get(RedirectPlaceListPhp::class, '/placelist.php', RedirectPlaceListPhp::class); 96 $router->get(RedirectRelationshipPhp::class, '/relationship.php', RedirectRelationshipPhp::class); 97 $router->get(RedirectRepositoryPhp::class, '/repository.php', RedirectRepositoryPhp::class); 98 $router->get(RedirectRepoListPhp::class, '/repolist.php', RedirectRepoListPhp::class); 99 $router->get(RedirectReportEnginePhp::class, '/reportengine.php', RedirectReportEnginePhp::class); 100 $router->get(RedirectSourceListPhp::class, '/sourcelist.php', RedirectSourceListPhp::class); 101 $router->get(RedirectSourcePhp::class, '/source.php', RedirectSourcePhp::class); 102 $router->get(RedirectStatisticsPhp::class, '/statistics.php', RedirectStatisticsPhp::class); 103 $router->get(RedirectTimeLinePhp::class, '/timeline.php', RedirectTimeLinePhp::class); 104 } 105 106 /** 107 * A sentence describing what this module does. 108 * 109 * @return string 110 */ 111 public function description(): string 112 { 113 /* I18N: Description of the “Legacy URLs” module */ 114 return I18N::translate('Redirect old URLs from webtrees version 1.'); 115 } 116 117 public function title(): string 118 { 119 /* I18N: Name of a module - historic/obsolete URLs. */ 120 return I18N::translate('Legacy URLs'); 121 } 122} 123