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