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