xref: /webtrees/app/Http/Routes/WebRoutes.php (revision 901ade1953ff80475c76de02812ca766c7a64210)
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\Http\Routes;
21
22use Aura\Router\Map;
23use Fig\Http\Message\RequestMethodInterface;
24use Fisharebest\Webtrees\Http\Middleware\AuthAdministrator;
25use Fisharebest\Webtrees\Http\Middleware\AuthEditor;
26use Fisharebest\Webtrees\Http\Middleware\AuthLoggedIn;
27use Fisharebest\Webtrees\Http\Middleware\AuthManager;
28use Fisharebest\Webtrees\Http\Middleware\AuthMember;
29use Fisharebest\Webtrees\Http\Middleware\AuthModerator;
30use Fisharebest\Webtrees\Http\Middleware\AuthVisitor;
31use Fisharebest\Webtrees\Http\Middleware\CheckCsrf;
32use Fisharebest\Webtrees\Http\RequestHandlers\AccountDelete;
33use Fisharebest\Webtrees\Http\RequestHandlers\AccountEdit;
34use Fisharebest\Webtrees\Http\RequestHandlers\AccountUpdate;
35use Fisharebest\Webtrees\Http\RequestHandlers\AddNewFact;
36use Fisharebest\Webtrees\Http\RequestHandlers\BroadcastAction;
37use Fisharebest\Webtrees\Http\RequestHandlers\BroadcastPage;
38use Fisharebest\Webtrees\Http\RequestHandlers\CleanDataFolder;
39use Fisharebest\Webtrees\Http\RequestHandlers\ContactAction;
40use Fisharebest\Webtrees\Http\RequestHandlers\ContactPage;
41use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
42use Fisharebest\Webtrees\Http\RequestHandlers\CopyFact;
43use Fisharebest\Webtrees\Http\RequestHandlers\CreateMediaObjectAction;
44use Fisharebest\Webtrees\Http\RequestHandlers\CreateMediaObjectModal;
45use Fisharebest\Webtrees\Http\RequestHandlers\CreateNoteAction;
46use Fisharebest\Webtrees\Http\RequestHandlers\CreateNoteModal;
47use Fisharebest\Webtrees\Http\RequestHandlers\CreateRepositoryAction;
48use Fisharebest\Webtrees\Http\RequestHandlers\CreateRepositoryModal;
49use Fisharebest\Webtrees\Http\RequestHandlers\CreateSourceAction;
50use Fisharebest\Webtrees\Http\RequestHandlers\CreateSourceModal;
51use Fisharebest\Webtrees\Http\RequestHandlers\CreateSubmitterAction;
52use Fisharebest\Webtrees\Http\RequestHandlers\CreateSubmitterModal;
53use Fisharebest\Webtrees\Http\RequestHandlers\CreateTreeAction;
54use Fisharebest\Webtrees\Http\RequestHandlers\CreateTreePage;
55use Fisharebest\Webtrees\Http\RequestHandlers\DeleteFact;
56use Fisharebest\Webtrees\Http\RequestHandlers\DeletePath;
57use Fisharebest\Webtrees\Http\RequestHandlers\DeleteRecord;
58use Fisharebest\Webtrees\Http\RequestHandlers\DeleteTreeAction;
59use Fisharebest\Webtrees\Http\RequestHandlers\DeleteUser;
60use Fisharebest\Webtrees\Http\RequestHandlers\EditFact;
61use Fisharebest\Webtrees\Http\RequestHandlers\EditRawFactAction;
62use Fisharebest\Webtrees\Http\RequestHandlers\EditRawFactPage;
63use Fisharebest\Webtrees\Http\RequestHandlers\EditRawRecordAction;
64use Fisharebest\Webtrees\Http\RequestHandlers\EditRawRecordPage;
65use Fisharebest\Webtrees\Http\RequestHandlers\EmailPreferencesAction;
66use Fisharebest\Webtrees\Http\RequestHandlers\EmailPreferencesPage;
67use Fisharebest\Webtrees\Http\RequestHandlers\ExportGedcomClient;
68use Fisharebest\Webtrees\Http\RequestHandlers\ExportGedcomPage;
69use Fisharebest\Webtrees\Http\RequestHandlers\ExportGedcomServer;
70use Fisharebest\Webtrees\Http\RequestHandlers\FamilyPage;
71use Fisharebest\Webtrees\Http\RequestHandlers\GedcomRecordPage;
72use Fisharebest\Webtrees\Http\RequestHandlers\HelpText;
73use Fisharebest\Webtrees\Http\RequestHandlers\HomePage;
74use Fisharebest\Webtrees\Http\RequestHandlers\IndividualPage;
75use Fisharebest\Webtrees\Http\RequestHandlers\LoginAction;
76use Fisharebest\Webtrees\Http\RequestHandlers\LoginPage;
77use Fisharebest\Webtrees\Http\RequestHandlers\Logout;
78use Fisharebest\Webtrees\Http\RequestHandlers\Masquerade;
79use Fisharebest\Webtrees\Http\RequestHandlers\MediaPage;
80use Fisharebest\Webtrees\Http\RequestHandlers\MergeFactsAction;
81use Fisharebest\Webtrees\Http\RequestHandlers\MergeFactsPage;
82use Fisharebest\Webtrees\Http\RequestHandlers\MergeRecordsAction;
83use Fisharebest\Webtrees\Http\RequestHandlers\MergeRecordsPage;
84use Fisharebest\Webtrees\Http\RequestHandlers\MessageAction;
85use Fisharebest\Webtrees\Http\RequestHandlers\MessagePage;
86use Fisharebest\Webtrees\Http\RequestHandlers\MessageSelect;
87use Fisharebest\Webtrees\Http\RequestHandlers\ModuleAction;
88use Fisharebest\Webtrees\Http\RequestHandlers\NotePage;
89use Fisharebest\Webtrees\Http\RequestHandlers\PasswordRequestAction;
90use Fisharebest\Webtrees\Http\RequestHandlers\PasswordRequestPage;
91use Fisharebest\Webtrees\Http\RequestHandlers\PasswordResetAction;
92use Fisharebest\Webtrees\Http\RequestHandlers\PasswordResetPage;
93use Fisharebest\Webtrees\Http\RequestHandlers\PasteFact;
94use Fisharebest\Webtrees\Http\RequestHandlers\PendingChanges;
95use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesAcceptChange;
96use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesAcceptRecord;
97use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesAcceptTree;
98use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesLogAction;
99use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesLogData;
100use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesLogDelete;
101use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesLogDownload;
102use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesLogPage;
103use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesRejectChange;
104use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesRejectRecord;
105use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesRejectTree;
106use Fisharebest\Webtrees\Http\RequestHandlers\PhpInformation;
107use Fisharebest\Webtrees\Http\RequestHandlers\Ping;
108use Fisharebest\Webtrees\Http\RequestHandlers\RedirectFamilyPhp;
109use Fisharebest\Webtrees\Http\RequestHandlers\RedirectGedRecordPhp;
110use Fisharebest\Webtrees\Http\RequestHandlers\RedirectIndividualPhp;
111use Fisharebest\Webtrees\Http\RequestHandlers\RedirectMediaViewerPhp;
112use Fisharebest\Webtrees\Http\RequestHandlers\RedirectNotePhp;
113use Fisharebest\Webtrees\Http\RequestHandlers\RedirectRepoPhp;
114use Fisharebest\Webtrees\Http\RequestHandlers\RedirectSourcePhp;
115use Fisharebest\Webtrees\Http\RequestHandlers\RegisterAction;
116use Fisharebest\Webtrees\Http\RequestHandlers\RegisterPage;
117use Fisharebest\Webtrees\Http\RequestHandlers\ReorderChildrenAction;
118use Fisharebest\Webtrees\Http\RequestHandlers\ReorderChildrenPage;
119use Fisharebest\Webtrees\Http\RequestHandlers\ReorderFamiliesAction;
120use Fisharebest\Webtrees\Http\RequestHandlers\ReorderFamiliesPage;
121use Fisharebest\Webtrees\Http\RequestHandlers\ReorderMediaAction;
122use Fisharebest\Webtrees\Http\RequestHandlers\ReorderMediaPage;
123use Fisharebest\Webtrees\Http\RequestHandlers\ReorderNamesAction;
124use Fisharebest\Webtrees\Http\RequestHandlers\ReorderNamesPage;
125use Fisharebest\Webtrees\Http\RequestHandlers\ReportGenerate;
126use Fisharebest\Webtrees\Http\RequestHandlers\ReportListAction;
127use Fisharebest\Webtrees\Http\RequestHandlers\ReportListPage;
128use Fisharebest\Webtrees\Http\RequestHandlers\ReportSetupAction;
129use Fisharebest\Webtrees\Http\RequestHandlers\ReportSetupPage;
130use Fisharebest\Webtrees\Http\RequestHandlers\RepositoryPage;
131use Fisharebest\Webtrees\Http\RequestHandlers\RobotsTxt;
132use Fisharebest\Webtrees\Http\RequestHandlers\SearchAdvancedAction;
133use Fisharebest\Webtrees\Http\RequestHandlers\SearchAdvancedPage;
134use Fisharebest\Webtrees\Http\RequestHandlers\SearchGeneralAction;
135use Fisharebest\Webtrees\Http\RequestHandlers\SearchGeneralPage;
136use Fisharebest\Webtrees\Http\RequestHandlers\SearchPhoneticAction;
137use Fisharebest\Webtrees\Http\RequestHandlers\SearchPhoneticPage;
138use Fisharebest\Webtrees\Http\RequestHandlers\SearchQuickAction;
139use Fisharebest\Webtrees\Http\RequestHandlers\SearchReplaceAction;
140use Fisharebest\Webtrees\Http\RequestHandlers\SearchReplacePage;
141use Fisharebest\Webtrees\Http\RequestHandlers\Select2Family;
142use Fisharebest\Webtrees\Http\RequestHandlers\Select2Individual;
143use Fisharebest\Webtrees\Http\RequestHandlers\Select2MediaObject;
144use Fisharebest\Webtrees\Http\RequestHandlers\Select2Note;
145use Fisharebest\Webtrees\Http\RequestHandlers\Select2Repository;
146use Fisharebest\Webtrees\Http\RequestHandlers\Select2Source;
147use Fisharebest\Webtrees\Http\RequestHandlers\Select2Submitter;
148use Fisharebest\Webtrees\Http\RequestHandlers\SelectDefaultTree;
149use Fisharebest\Webtrees\Http\RequestHandlers\SelectLanguage;
150use Fisharebest\Webtrees\Http\RequestHandlers\SelectNewFact;
151use Fisharebest\Webtrees\Http\RequestHandlers\SelectTheme;
152use Fisharebest\Webtrees\Http\RequestHandlers\SiteLogsAction;
153use Fisharebest\Webtrees\Http\RequestHandlers\SiteLogsData;
154use Fisharebest\Webtrees\Http\RequestHandlers\SiteLogsDelete;
155use Fisharebest\Webtrees\Http\RequestHandlers\SiteLogsDownload;
156use Fisharebest\Webtrees\Http\RequestHandlers\SiteLogsPage;
157use Fisharebest\Webtrees\Http\RequestHandlers\SourcePage;
158use Fisharebest\Webtrees\Http\RequestHandlers\SubmitterPage;
159use Fisharebest\Webtrees\Http\RequestHandlers\UnconnectedAction;
160use Fisharebest\Webtrees\Http\RequestHandlers\UnconnectedPage;
161use Fisharebest\Webtrees\Http\RequestHandlers\UpdatePlacesAction;
162use Fisharebest\Webtrees\Http\RequestHandlers\UpdatePlacesPage;
163use Fisharebest\Webtrees\Http\RequestHandlers\UsersCleanupAction;
164use Fisharebest\Webtrees\Http\RequestHandlers\UsersCleanupPage;
165use Fisharebest\Webtrees\Http\RequestHandlers\VerifyEmail;
166
167/**
168 * Routing table for web requests
169 */
170class WebRoutes
171{
172    public function load(Map $router): void
173    {
174        $router->attach('', '', static function (Map $router) {
175            $router->extras([
176                'middleware' => [
177                    CheckCsrf::class,
178                ],
179            ]);
180
181            // Admin routes.
182            $router->attach('', '/admin', static function (Map $router) {
183                $router->extras([
184                    'middleware' => [
185                        AuthAdministrator::class,
186                    ],
187                ]);
188
189                $router->get(ControlPanel::class, '', ControlPanel::class);
190                $router->get(BroadcastPage::class, '/broadcast', BroadcastPage::class);
191                $router->post(BroadcastAction::class, '/broadcast', BroadcastAction::class);
192                $router->get(CleanDataFolder::class, '/clean', CleanDataFolder::class);
193                $router->post(DeletePath::class, '/delete-path', DeletePath::class);
194                $router->get(EmailPreferencesPage::class, '/email', EmailPreferencesPage::class);
195                $router->post(EmailPreferencesAction::class, '/email', EmailPreferencesAction::class);
196                $router->get(PhpInformation::class, '/information', PhpInformation::class);
197                $router->get(SiteLogsPage::class, '/logs', SiteLogsPage::class);
198                $router->post(SiteLogsAction::class, '/logs', SiteLogsAction::class);
199                $router->get(SiteLogsData::class, '/logs-data', SiteLogsData::class);
200                $router->post(SiteLogsDelete::class, '/logs-delete', SiteLogsDelete::class);
201                $router->get(SiteLogsDownload::class, '/logs-download', SiteLogsDownload::class);
202                $router->post(Masquerade::class, '/masquerade/{user_id}', Masquerade::class);
203                $router->get('admin-media', '/media', 'Admin\MediaController::index');
204                $router->post('admin-media-select', '/media', 'Admin\MediaController::select');
205                $router->get('admin-media-data', '/media-data', 'Admin\MediaController::data');
206                $router->get('admin-media-upload', '/media-upload', 'Admin\MediaController::upload');
207                $router->post('admin-media-upload-action', '/media-upload', 'Admin\MediaController::uploadAction');
208                $router->get(CreateTreePage::class, '/trees/create', CreateTreePage::class);
209                $router->post(CreateTreeAction::class, '/trees/create', CreateTreeAction::class);
210                $router->post(SelectDefaultTree::class, '/trees/default/{tree}', SelectDefaultTree::class);
211                $router->post(DeleteTreeAction::class, '/trees/delete/{tree}', DeleteTreeAction::class);
212                $router->get('admin-fix-level-0-media', '/fix-level-0-media', 'Admin\FixLevel0MediaController::fixLevel0Media');
213                $router->post('admin-fix-level-0-media-action', '/fix-level-0-media', 'Admin\FixLevel0MediaController::fixLevel0MediaAction');
214                $router->get('admin-fix-level-0-media-data', '/fix-level-0-media-data', 'Admin\FixLevel0MediaController::fixLevel0MediaData');
215                $router->get('admin-webtrees1-thumbs', '/webtrees1-thumbs', 'Admin\ImportThumbnailsController::webtrees1Thumbnails');
216                $router->post('admin-webtrees1-thumbs-action', '/webtrees1-thumbs', 'Admin\ImportThumbnailsController::webtrees1ThumbnailsAction');
217                $router->get('admin-webtrees1-thumbs-data', '/webtrees1-thumbs-data', 'Admin\ImportThumbnailsController::webtrees1ThumbnailsData');
218                $router->get('modules', '/modules', 'Admin\ModuleController::list');
219                $router->post('modules-update', '/modules', 'Admin\ModuleController::update');
220                $router->get('analytics', '/analytics', 'Admin\ModuleController::listAnalytics');
221                $router->post('analytics-update', '/analytics', 'Admin\ModuleController::updateAnalytics');
222                $router->get('blocks', '/blocks', 'Admin\ModuleController::listBlocks');
223                $router->post('blocks-update', '/blocks', 'Admin\ModuleController::updateBlocks');
224                $router->get('charts', '/charts', 'Admin\ModuleController::listCharts');
225                $router->post('charts-update', '/charts', 'Admin\ModuleController::updateCharts');
226                $router->get('lists', '/lists', 'Admin\ModuleController::listLists');
227                $router->post('lists-update', '/lists', 'Admin\ModuleController::updateLists');
228                $router->get('footers', '/footers', 'Admin\ModuleController::listFooters');
229                $router->post('footers-update', '/footers', 'Admin\ModuleController::updateFooters');
230                $router->get('history', '/history', 'Admin\ModuleController::listHistory');
231                $router->post('history-update', '/history', 'Admin\ModuleController::updateHistory');
232                $router->get('menus', '/menus', 'Admin\ModuleController::listMenus');
233                $router->post('menus-update', '/menus', 'Admin\ModuleController::updateMenus');
234                $router->get('languages', '/languages', 'Admin\ModuleController::listLanguages');
235                $router->post('languages-update', '/languages', 'Admin\ModuleController::updateLanguages');
236                $router->get('reports', '/reports', 'Admin\ModuleController::listReports');
237                $router->post('reports-update', '/reports', 'Admin\ModuleController::updateReports');
238                $router->get('sidebars', '/sidebars', 'Admin\ModuleController::listSidebars');
239                $router->post('sidebars-update', '/sidebars', 'Admin\ModuleController::updateSidebars');
240                $router->get('themes', '/themes', 'Admin\ModuleController::listThemes');
241                $router->post('themes-update', '/themes', 'Admin\ModuleController::updateThemes');
242                $router->get('tabs', '/tabs', 'Admin\ModuleController::listTabs');
243                $router->post('tabs-update', '/tabs', 'Admin\ModuleController::updateTabs');
244                $router->get(UsersCleanupPage::class, '/users-cleanup', UsersCleanupPage::class);
245                $router->post(UsersCleanupAction::class, '/users-cleanup', UsersCleanupAction::class);
246                $router->post('delete-module-settings', '/delete-module-settings', 'Admin\ModuleController::deleteModuleSettings');
247                $router->get('map-data', '/map-data', 'Admin\LocationController::mapData');
248                $router->get('map-data-edit', '/map-data-edit', 'Admin\LocationController::mapDataEdit');
249                $router->post('map-data-update', '/map-data-edit', 'Admin\LocationController::mapDataSave');
250                $router->post('map-data-delete', '/map-data-delete', 'Admin\LocationController::mapDataDelete');
251                $router->get('locations-export', '/locations-export', 'Admin\LocationController::exportLocations');
252                $router->get('locations-import', '/locations-import', 'Admin\LocationController::importLocations');
253                $router->post('locations-import-action', '/locations-import', 'Admin\LocationController::importLocationsAction');
254                $router->post('locations-import-from-tree', '/locations-import-from-tree', 'Admin\LocationController::importLocationsFromTree');
255                $router->get('map-provider', '/map-provider', 'Admin\MapProviderController::mapProviderEdit');
256                $router->post('map-provider-action', '/map-provider', 'Admin\MapProviderController::mapProviderSave');
257                $router->get('upgrade', '/upgrade', 'Admin\UpgradeController::wizard');
258                $router->post('upgrade-confirm', '/upgrade-confirm', 'Admin\UpgradeController::confirm');
259                $router->post('upgrade-action', '/upgrade', 'Admin\UpgradeController::step');
260                $router->get('admin-users', '/admin-users', 'Admin\UsersController::index');
261                $router->get('admin-users-data', '/admin-users-data', 'Admin\UsersController::data');
262                $router->get('admin-users-create', '/admin-users-create', 'Admin\UsersController::create');
263                $router->post('admin-users-create-action', '/admin-users-create', 'Admin\UsersController::save');
264                $router->get('admin-users-edit', '/admin-users-edit', 'Admin\UsersController::edit');
265                $router->post('admin-users-update', '/admin-users-edit', 'Admin\UsersController::update');
266                $router->get('admin-site-preferences', '/admin-site-preferences', 'AdminSiteController::preferencesForm');
267                $router->post('admin-site-preferences-update', '/admin-site-preferences', 'AdminSiteController::preferencesSave');
268                $router->get('admin-site-registration', '/admin-site-registration', 'AdminSiteController::registrationForm');
269                $router->post('admin-site-registration-update', '/admin-site-registration', 'AdminSiteController::registrationSave');
270                $router->get('tree-page-default-edit', '/trees/default-blocks', 'HomePageController::treePageDefaultEdit');
271                $router->post('tree-page-default-update', '/trees/default-blocks', 'HomePageController::treePageDefaultUpdate');
272                $router->get('admin-trees-merge', '/trees/merge', 'AdminTreesController::merge');
273                $router->post('admin-trees-merge-action', '/trees/merge', 'AdminTreesController::mergeAction');
274                $router->post('admin-trees-sync', '/trees/sync', 'AdminTreesController::synchronize');
275                $router->get('unused-media-thumbnail', '/unused-media-thumbnail', 'MediaFileController::unusedMediaThumbnail');
276                $router->post('delete-user', '/users/delete/{user_id}', DeleteUser::class);
277                $router->get('user-page-default-edit', '/user-page-default-edit', 'HomePageController::userPageDefaultEdit');
278                $router->post('user-page-default-update', '/user-page-default-update', 'HomePageController::userPageDefaultUpdate');
279            });
280
281            // Manager routes (without a tree).
282            $router->attach('', '/admin', static function (Map $router) {
283                $router->extras([
284                    'middleware' => [
285                        AuthManager::class,
286                    ],
287                ]);
288
289                $router->get('manage-trees', '/trees/manage{/tree}', 'AdminTreesController::index');
290            });
291
292            // Manager routes.
293            $router->attach('', '/tree/{tree}', static function (Map $router) {
294                $router->extras([
295                    'middleware' => [
296                        AuthManager::class,
297                    ],
298                ]);
299
300                $router->get(PendingChangesLogPage::class, '/changes-log', PendingChangesLogPage::class);
301                $router->post(PendingChangesLogAction::class, '/changes-log', PendingChangesLogAction::class);
302                $router->get(PendingChangesLogData::class, '/changes-data', PendingChangesLogData::class);
303                $router->post(PendingChangesLogDelete::class, '/changes-delete', PendingChangesLogDelete::class);
304                $router->get(PendingChangesLogDownload::class, '/changes-download', PendingChangesLogDownload::class);
305                $router->get('admin-trees-check', '/check', 'AdminTreesController::check');
306                $router->get('admin-trees-duplicates', '/duplicates', 'AdminTreesController::duplicates');
307                $router->get(ExportGedcomPage::class, '/export', ExportGedcomPage::class);
308                $router->post(ExportGedcomClient::class, '/export-client', ExportGedcomClient::class);
309                $router->post(ExportGedcomServer::class, '/export-server', ExportGedcomServer::class);
310                $router->get('admin-trees-import', '/import', 'AdminTreesController::importForm');
311                $router->post('admin-trees-import-action', '/import', 'AdminTreesController::importAction');
312                $router->get(MergeRecordsPage::class, '/merge-step1', MergeRecordsPage::class);
313                $router->post(MergeRecordsAction::class, '/merge-step1', MergeRecordsAction::class);
314                $router->get(MergeFactsPage::class, '/merge-step2', MergeFactsPage::class);
315                $router->post(MergeFactsAction::class, '/merge-step2', MergeFactsAction::class);
316                $router->get(UpdatePlacesPage::class, '/places', UpdatePlacesPage::class);
317                $router->post(UpdatePlacesAction::class, '/places', UpdatePlacesAction::class);
318                $router->get('admin-trees-preferences', '/preferences', 'AdminTreesController::preferences');
319                $router->post('admin-trees-preferences-update', '/preferences', 'AdminTreesController::preferencesUpdate');
320                $router->get('admin-trees-renumber', '/renumber', 'AdminTreesController::renumber');
321                $router->post('admin-trees-renumber-action', '/renumber', 'AdminTreesController::renumberAction');
322                $router->get('tree-page-edit', '/tree-page-edit', 'HomePageController::treePageEdit');
323                $router->post('import', '/load', 'GedcomFileController::import');
324                $router->post('tree-page-update', '/tree-page-update', 'HomePageController::treePageUpdate');
325                $router->get('tree-page-block-edit', '/tree-page-block-edit', 'HomePageController::treePageBlockEdit');
326                $router->post('tree-page-block-update', '/tree-page-block-edit', 'HomePageController::treePageBlockUpdate');
327                $router->get('tree-preferences', '/preferences', 'AdminController::treePreferencesEdit');
328                $router->post('tree-preferences-update', '/preferences', 'AdminController::treePreferencesUpdate');
329                $router->get('tree-privacy', '/privacy', 'AdminController::treePrivacyEdit');
330                $router->post('tree-privacy-update', '/privacy', 'AdminController::treePrivacyUpdate');
331                $router->get(UnconnectedPage::class, '/unconnected', UnconnectedPage::class);
332                $router->post(UnconnectedAction::class, '/unconnected', UnconnectedAction::class);
333            });
334
335            // Moderator routes.
336            $router->attach('', '/tree/{tree}', static function (Map $router) {
337                $router->extras([
338                    'middleware' => [
339                        AuthModerator::class,
340                    ],
341                ]);
342                $router->post(PendingChangesAcceptTree::class, '/accept', PendingChangesAcceptTree::class);
343                $router->post(PendingChangesAcceptRecord::class, '/accept/{xref}', PendingChangesAcceptRecord::class);
344                $router->post(PendingChangesAcceptChange::class, '/accept/{xref}/{change}', PendingChangesAcceptChange::class);
345                $router->get(PendingChanges::class, '/pending', PendingChanges::class);
346                $router->post(PendingChangesRejectTree::class, '/reject', PendingChangesRejectTree::class);
347                $router->post(PendingChangesRejectRecord::class, '/reject/{xref}', PendingChangesRejectRecord::class);
348                $router->post(PendingChangesRejectChange::class, '/reject/{xref}/{change}', PendingChangesRejectChange::class);
349            });
350
351            // Editor routes.
352            $router->attach('', '/tree/{tree}', static function (Map $router) {
353                $router->extras([
354                    'middleware' => [
355                        AuthEditor::class,
356                    ],
357                ]);
358
359                $router->get('add-child-to-family', '/add-child-to-family', 'EditFamilyController::addChild');
360                $router->post('add-child-to-family-action', '/add-child-to-family', 'EditFamilyController::addChildAction');
361                $router->get(AddNewFact::class, '/add-fact/{xref}/{fact}', AddNewFact::class);
362                $router->post(SelectNewFact::class, '/add-fact/{xref}', SelectNewFact::class);
363                $router->get('add-media-file', '/add-media-file', 'EditMediaController::addMediaFile');
364                $router->post('add-media-file-update', '/add-media-file', 'EditMediaController::addMediaFileAction');
365                $router->get('add-name', '/add-name', 'EditIndividualController::addName');
366                $router->post('add-name-action', '/add-name-update/{xref}', 'EditIndividualController::addNameAction');
367                $router->get('add-spouse-to-family', '/add-spouse-to-family', 'EditFamilyController::addSpouse');
368                $router->post('add-spouse-to-family-action', '/add-spouse-to-family', 'EditFamilyController::addSpouseAction');
369                $router->get('change-family-members', '/change-family-members', 'EditFamilyController::changeFamilyMembers');
370                $router->post('change-family-members-action', '/change-family-members', 'EditFamilyController::changeFamilyMembersAction');
371                $router->get(CreateMediaObjectModal::class, '/create-media-object', CreateMediaObjectModal::class);
372                $router->post(CreateMediaObjectAction::class, '/create-media-object', CreateMediaObjectAction::class);
373                $router->post('create-media-from-file', '/create-media-from-file', 'EditMediaController::createMediaObjectFromFileAction');
374                $router->post(CopyFact::class, '/copy/{xref}/{fact_id}', CopyFact::class);
375                $router->get(CreateNoteModal::class, '/create-note-object', CreateNoteModal::class);
376                $router->post(CreateNoteAction::class, '/create-note-object', CreateNoteAction::class);
377                $router->get(CreateRepositoryModal::class, '/create-repository', CreateRepositoryModal::class);
378                $router->post(CreateRepositoryAction::class, '/create-repository', CreateRepositoryAction::class);
379                $router->get(CreateSourceModal::class, '/create-source', CreateSourceModal::class);
380                $router->post(CreateSourceAction::class, '/create-source', CreateSourceAction::class);
381                $router->get(CreateSubmitterModal::class, '/create-submitter', CreateSubmitterModal::class);
382                $router->post(CreateSubmitterAction::class, '/create-submitter', CreateSubmitterAction::class);
383                $router->post(DeleteRecord::class, '/delete/{xref}', DeleteRecord::class);
384                $router->post(DeleteFact::class, '/delete/{xref}/{fact_id}', DeleteFact::class);
385                $router->get(EditFact::class, '/edit-fact', EditFact::class);
386                $router->get('edit-media-file', '/edit-media-file', 'EditMediaController::editMediaFile');
387                $router->post('edit-media-file-update', '/edit-media-file', 'EditMediaController::editMediaFileAction');
388                $router->get('edit-note-object', '/edit-note-object/{xref}', 'EditNoteController::editNoteObject');
389                $router->post('edit-note-object-action', '/edit-note-object/{xref}', 'EditNoteController::updateNoteObject');
390                $router->get(EditRawFactPage::class, '/edit-raw/{xref}/{fact_id}', EditRawFactPage::class);
391                $router->post(EditRawFactAction::class, '/edit-raw/{xref}/{fact_id}', EditRawFactAction::class);
392                $router->get(EditRawRecordPage::class, '/edit-raw/{xref}', EditRawRecordPage::class);
393                $router->post(EditRawRecordAction::class, '/edit-raw/{xref}', EditRawRecordAction::class);
394                $router->get('link-media-to-individual', '/link-media-to-individual', 'EditMediaController::linkMediaToIndividual');
395                $router->get('link-media-to-family', '/link-media-to-family', 'EditMediaController::linkMediaToFamily');
396                $router->get('link-media-to-source', '/link-media-to-source', 'EditMediaController::linkMediaToSource');
397                $router->post('link-media-to-record', '/link-media-to-record/{xref}', 'EditMediaController::linkMediaToRecordAction');
398                $router->post(PasteFact::class, '/paste-fact/{xref}', PasteFact::class);
399                $router->get(ReorderChildrenPage::class, '/reorder-children/{xref}', ReorderChildrenPage::class);
400                $router->post(ReorderChildrenAction::class, '/reorder-children/{xref}', ReorderChildrenAction::class);
401                $router->get(ReorderMediaPage::class, '/reorder-media/{xref}', ReorderMediaPage::class);
402                $router->post(ReorderMediaAction::class, '/reorder-media/{xref}', ReorderMediaAction::class);
403                $router->get(ReorderNamesPage::class, '/reorder-names/{xref}', ReorderNamesPage::class);
404                $router->post(ReorderNamesAction::class, '/reorder-names/{xref}', ReorderNamesAction::class);
405                $router->get(ReorderFamiliesPage::class, '/reorder-spouses/{xref}', ReorderFamiliesPage::class);
406                $router->post(ReorderFamiliesAction::class, '/reorder-spouses/{xref}', ReorderFamiliesAction::class);
407                $router->get(SearchReplacePage::class, '/search-replace', SearchReplacePage::class);
408                $router->post(SearchReplaceAction::class, '/search-replace', SearchReplaceAction::class);
409                $router->get('add-child-to-individual', '/add-child-to-individual', 'EditIndividualController::addChild');
410                $router->post('add-child-to-individual-action', '/add-child-to-individual', 'EditIndividualController::addChildAction');
411                $router->get('add-parent-to-individual', '/add-parent-to-individual', 'EditIndividualController::addParent');
412                $router->post('add-parent-to-individual-action', '/add-parent-to-individual', 'EditIndividualController::addParentAction');
413                $router->get('add-spouse-to-individual', '/add-spouse-to-individual', 'EditIndividualController::addSpouse');
414                $router->post('add-spouse-to-individual-action', '/add-spouse-to-individual', 'EditIndividualController::addSpouseAction');
415                $router->get('add-unlinked-individual', '/add-unlinked-individual', 'EditIndividualController::addUnlinked');
416                $router->post('add-unlinked-individual-action', '/add-unlinked-individual', 'EditIndividualController::addUnlinkedAction');
417                $router->get('link-child-to-family', '/link-child-to-family', 'EditIndividualController::linkChildToFamily');
418                $router->post('link-child-to-family-action', '/link-child-to-family', 'EditIndividualController::linkChildToFamilyAction');
419                $router->get('link-spouse-to-individual', '/link-spouse-to-individual', 'EditIndividualController::linkSpouseToIndividual');
420                $router->post('link-spouse-to-individual-action', '/link-spouse-to-individual', 'EditIndividualController::linkSpouseToIndividualAction');
421                $router->get('edit-name', '/edit-name/{xref}/{fact_id}', 'EditIndividualController::editName');
422                $router->post('edit-name-action', '/edit-name-update/{xref}/{fact_id}', 'EditIndividualController::editNameAction');
423                $router->post('update-fact', '/update-fact/{xref}{/fact_id}', 'EditGedcomRecordController::updateFact');
424            });
425
426            // Member routes.
427            $router->attach('', '/tree/{tree}', static function (Map $router) {
428                $router->extras([
429                    'middleware' => [
430                        AuthMember::class,
431                    ],
432                ]);
433
434                $router->get('user-page', '/my-page', 'HomePageController::userPage');
435                $router->get('user-page-block', '/my-page-block', 'HomePageController::userPageBlock');
436                $router->get('user-page-edit', '/my-page-edit', 'HomePageController::userPageEdit');
437                $router->post('user-page-update', '/my-page-edit', 'HomePageController::userPageUpdate');
438                $router->get('user-page-block-edit', '/my-page-block-edit', 'HomePageController::userPageBlockEdit');
439                $router->post('user-page-block-update', '/my-page-block-edit', 'HomePageController::userPageBlockUpdate');
440            });
441
442            // User routes.
443            $router->attach('', '', static function (Map $router) {
444                $router->extras([
445                    'middleware' => [
446                        AuthLoggedIn::class,
447                    ],
448                ]);
449
450                $router->get(AccountEdit::class, '/my-account{/tree}', AccountEdit::class);
451                $router->post(AccountUpdate::class, '/my-account{/tree}', AccountUpdate::class);
452                $router->post(AccountDelete::class, '/my-account-delete', AccountDelete::class);
453            });
454
455            // Visitor routes - with an optional tree (for sites with no public trees).
456            $router->attach('', '', static function (Map $router) {
457                $router->get(LoginPage::class, '/login{/tree}', LoginPage::class);
458                $router->post(LoginAction::class, '/login{/tree}', LoginAction::class);
459                $router->get(PasswordRequestPage::class, '/password-request{/tree}', PasswordRequestPage::class);
460                $router->post(PasswordRequestAction::class, '/password-request{/tree}', PasswordRequestAction::class);
461                $router->get(RegisterPage::class, '/register{/tree}', RegisterPage::class);
462                $router->post(RegisterAction::class, '/register{/tree}', RegisterAction::class);
463                $router->get(PasswordResetPage::class, '/password-reset/{token}{/tree}', PasswordResetPage::class);
464                $router->post(PasswordResetAction::class, '/password-reset/{token}{/tree}', PasswordResetAction::class);
465                $router->get(VerifyEmail::class, '/verify/{username}/{token}{/tree}', VerifyEmail::class);
466            });
467
468            // Visitor routes with a tree.
469            $router->attach('', '/tree/{tree}', static function (Map $router) {
470                $router->extras([
471                    'middleware' => [
472                        AuthVisitor::class,
473                    ],
474                ]);
475
476                $router->get('tree-page', '', 'HomePageController::treePage');
477                $router->get('autocomplete-folder', '/autocomplete-folder', 'AutocompleteController::folder');
478                $router->get('autocomplete-page', '/autocomplete-page', 'AutocompleteController::page');
479                $router->get('autocomplete-place', '/autocomplete-place', 'AutocompleteController::place');
480                $router->get('calendar', '/calendar/{view}', 'CalendarController::page');
481                $router->post('calendar-select', '/calendar/{view}', 'CalendarController::select');
482                $router->get('calendar-events', '/calendar-events/{view}', 'CalendarController::calendar');
483                $router->get(ContactPage::class, '/contact', ContactPage::class);
484                $router->post(ContactAction::class, '/contact', ContactAction::class);
485                $router->get(FamilyPage::class, '/family/{xref}{/slug}', FamilyPage::class);
486                $router->get(IndividualPage::class, '/individual/{xref}{/slug}', IndividualPage::class);
487                $router->get('media-thumbnail', '/media-thumbnail', 'MediaFileController::mediaThumbnail');
488                $router->get('media-download', '/media-download', 'MediaFileController::mediaDownload');
489                $router->get(MediaPage::class, '/media/{xref}{/slug}', MediaPage::class);
490                $router->post(MessageSelect::class, '/message-select', MessageSelect::class);
491                $router->get(MessagePage::class, '/message-compose', MessagePage::class);
492                $router->post(MessageAction::class, '/message-send', MessageAction::class);
493                $router->get(NotePage::class, '/note/{xref}{/slug}', NotePage::class);
494                $router->get(GedcomRecordPage::class, '/record/{xref}{/slug}', GedcomRecordPage::class);
495                $router->get(RepositoryPage::class, '/repository/{xref}{/slug}', RepositoryPage::class);
496                $router->get(ReportListPage::class, '/report', ReportListPage::class);
497                $router->post(ReportListAction::class, '/report', ReportListAction::class);
498                $router->get(ReportSetupPage::class, '/report/{report}', ReportSetupPage::class);
499                $router->post(ReportSetupAction::class, '/report/{report}', ReportSetupAction::class);
500                $router->get(ReportGenerate::class, '/report-run/{report}', ReportGenerate::class);
501                $router->get(SearchAdvancedPage::class, '/search-advanced', SearchAdvancedPage::class);
502                $router->post(SearchAdvancedAction::class, '/search-advanced', SearchAdvancedAction::class);
503                $router->get(SearchGeneralPage::class, '/search-general', SearchGeneralPage::class);
504                $router->post(SearchGeneralAction::class, '/search-general', SearchGeneralAction::class);
505                $router->get(SearchPhoneticPage::class, '/search-phonetic', SearchPhoneticPage::class);
506                $router->post(SearchPhoneticAction::class, '/search-phonetic', SearchPhoneticAction::class);
507                $router->post(SearchQuickAction::class, '/search-quick', SearchQuickAction::class);
508                $router->post(Select2Family::class, '/select2-family', Select2Family::class);
509                $router->post(Select2Individual::class, '/select2-individual', Select2Individual::class);
510                $router->post(Select2MediaObject::class, '/select2-media', Select2MediaObject::class);
511                $router->post(Select2Note::class, '/select2-note', Select2Note::class);
512                $router->post(Select2Source::class, '/select2-source', Select2Source::class);
513                $router->post(Select2Submitter::class, '/select2-submitter', Select2Submitter::class);
514                $router->post(Select2Repository::class, '/select2-repository', Select2Repository::class);
515                $router->get(SourcePage::class, '/source/{xref}{/slug}', SourcePage::class);
516                $router->get(SubmitterPage::class, '/submitter/{xref}{/slug}', SubmitterPage::class);
517                $router->get('tree-page-block', '/tree-page-block', 'HomePageController::treePageBlock');
518                $router->get('example', '/…');
519            });
520
521            $router->get('module', '/module/{module}/{action}{/tree}', ModuleAction::class)
522                ->allows(RequestMethodInterface::METHOD_POST);
523
524            $router->get(HelpText::class, '/help/{topic}', HelpText::class);
525            $router->post(SelectLanguage::class, '/language/{language}', SelectLanguage::class);
526            $router->post(Logout::class, '/logout', Logout::class);
527            $router->get(Ping::class, '/ping', Ping::class);
528            $router->get(RobotsTxt::class, '/robots.txt', RobotsTxt::class);
529            $router->post(SelectTheme::class, '/theme/{theme}', SelectTheme::class);
530            $router->get(HomePage::class, '/', HomePage::class);
531
532            // Legacy URLs from older software.
533            $router->get(RedirectFamilyPhp::class, '/family.php', RedirectFamilyPhp::class);
534            $router->get(RedirectGedRecordPhp::class, '/gedrecord.php', RedirectGedRecordPhp::class);
535            $router->get(RedirectIndividualPhp::class, '/individual.php', RedirectIndividualPhp::class);
536            $router->get(RedirectMediaViewerPhp::class, '/mediaviewer.php', RedirectMediaViewerPhp::class);
537            $router->get(RedirectNotePhp::class, '/note.php', RedirectNotePhp::class);
538            $router->get(RedirectRepoPhp::class, '/repository.php', RedirectRepoPhp::class);
539            $router->get(RedirectSourcePhp::class, '/source.php', RedirectSourcePhp::class);
540        });
541    }
542}
543