xref: /webtrees/app/Module/RedirectLegacyUrlsModule.php (revision 1270d2767576ed4a83917769b0ee3613e3b010bf)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2023 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;
53use Fisharebest\Webtrees\Registry;
54
55/**
56 * Class RedirectLegacyUrlsModule - rewrite URLs from phpGedView and webtrees 1.x
57 */
58class RedirectLegacyUrlsModule extends AbstractModule
59{
60    /**
61     * Initialization.
62     *
63     * @return void
64     */
65    public function boot(): void
66    {
67        $router_container = Registry::container()->get(RouterContainer::class);
68        $router           = $router_container->getMap();
69
70        // Legacy URLs from older software.
71        $router->get(RedirectAncestryPhp::class, '/ancestry.php', RedirectAncestryPhp::class);
72        $router->get(RedirectBranchesPhp::class, '/branches.php', RedirectBranchesPhp::class);
73        $router->get(RedirectCalendarPhp::class, '/calendar.php', RedirectCalendarPhp::class);
74        $router->get(RedirectCompactPhp::class, '/compact.php', RedirectCompactPhp::class);
75        $router->get(RedirectDescendencyPhp::class, '/compact.php', RedirectDescendencyPhp::class);
76        $router->get(RedirectFamilyPhp::class, '/family.php', RedirectFamilyPhp::class);
77        $router->get(RedirectFamListPhp::class, '/famlist.php', RedirectFamListPhp::class);
78        $router->get(RedirectFamilyBookPhp::class, '/familybook.php', RedirectFamilyBookPhp::class);
79        $router->get(RedirectFanChartPhp::class, '/fanchart.php', RedirectFanChartPhp::class);
80        $router->get(RedirectGedRecordPhp::class, '/gedrecord.php', RedirectGedRecordPhp::class);
81        $router->get(RedirectHourGlassPhp::class, '/hourglass.php', RedirectHourGlassPhp::class);
82        $router->get(RedirectIndiListPhp::class, '/indilist.php', RedirectIndiListPhp::class);
83        $router->get(RedirectIndividualPhp::class, '/individual.php', RedirectIndividualPhp::class);
84        $router->get(RedirectLifeSpanPhp::class, '/lifespan.php', RedirectLifeSpanPhp::class);
85        $router->get(RedirectMediaListPhp::class, '/medialist.php', RedirectMediaListPhp::class);
86        $router->get(RedirectMediaViewerPhp::class, '/mediaviewer.php', RedirectMediaViewerPhp::class);
87        $router->get(RedirectModulePhp::class, '/module.php', RedirectModulePhp::class);
88        $router->get(RedirectNotePhp::class, '/note.php', RedirectNotePhp::class);
89        $router->get(RedirectNoteListPhp::class, '/notelist.php', RedirectNoteListPhp::class);
90        $router->get(RedirectPedigreePhp::class, '/pedigree.php', RedirectPedigreePhp::class);
91        $router->get(RedirectPlaceListPhp::class, '/placelist.php', RedirectPlaceListPhp::class);
92        $router->get(RedirectRelationshipPhp::class, '/relationship.php', RedirectRelationshipPhp::class);
93        $router->get(RedirectRepositoryPhp::class, '/repository.php', RedirectRepositoryPhp::class);
94        $router->get(RedirectRepoListPhp::class, '/repolist.php', RedirectRepoListPhp::class);
95        $router->get(RedirectReportEnginePhp::class, '/reportengine.php', RedirectReportEnginePhp::class);
96        $router->get(RedirectSourceListPhp::class, '/sourcelist.php', RedirectSourceListPhp::class);
97        $router->get(RedirectSourcePhp::class, '/source.php', RedirectSourcePhp::class);
98        $router->get(RedirectStatisticsPhp::class, '/statistics.php', RedirectStatisticsPhp::class);
99        $router->get(RedirectTimeLinePhp::class, '/timeline.php', RedirectTimeLinePhp::class);
100    }
101
102    public function description(): string
103    {
104        /* I18N: Description of the “Legacy URLs” module */
105        return I18N::translate('Redirect old URLs from webtrees version 1.');
106    }
107
108    /**
109     * How should this module be identified in the control panel, etc.?
110     *
111     * @return string
112     */
113    public function title(): string
114    {
115        /* I18N: Name of a module - historic/obsolete URLs. */
116        return I18N::translate('Legacy URLs');
117    }
118}
119