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