|
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
|
|
|
|
|
18
|
|
|
declare(strict_types=1); |
|
19
|
|
|
|
|
20
|
|
|
namespace Fisharebest\Webtrees\Http\RequestHandlers; |
|
21
|
|
|
|
|
22
|
|
|
use Fisharebest\Webtrees\Family; |
|
23
|
|
|
use Fisharebest\Webtrees\GedcomRecord; |
|
24
|
|
|
use Fisharebest\Webtrees\Http\ViewResponseTrait; |
|
25
|
|
|
use Fisharebest\Webtrees\I18N; |
|
26
|
|
|
use Fisharebest\Webtrees\Individual; |
|
27
|
|
|
use Fisharebest\Webtrees\Media; |
|
28
|
|
|
use Fisharebest\Webtrees\Note; |
|
29
|
|
|
use Fisharebest\Webtrees\Repository; |
|
30
|
|
|
use Fisharebest\Webtrees\Source; |
|
31
|
|
|
use Fisharebest\Webtrees\Tree; |
|
32
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
33
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
34
|
|
|
use Psr\Http\Server\RequestHandlerInterface; |
|
35
|
|
|
|
|
36
|
|
|
use function assert; |
|
37
|
|
|
use function e; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Merge records |
|
41
|
|
|
*/ |
|
42
|
|
|
class MergeRecordsPage implements RequestHandlerInterface |
|
43
|
|
|
{ |
|
44
|
|
|
use ViewResponseTrait; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Merge two genealogy records. |
|
48
|
|
|
* |
|
49
|
|
|
* @param ServerRequestInterface $request |
|
50
|
|
|
* |
|
51
|
|
|
* @return ResponseInterface |
|
52
|
|
|
*/ |
|
53
|
|
|
public function handle(ServerRequestInterface $request): ResponseInterface |
|
54
|
|
|
{ |
|
55
|
|
|
$this->layout = 'layouts/administration'; |
|
56
|
|
|
|
|
57
|
|
|
$tree = $request->getAttribute('tree'); |
|
58
|
|
|
assert($tree instanceof Tree); |
|
59
|
|
|
|
|
60
|
|
|
$xref1 = $request->getQueryParams()['xref1'] ?? ''; |
|
61
|
|
|
$xref2 = $request->getQueryParams()['xref2'] ?? ''; |
|
62
|
|
|
|
|
63
|
|
|
$record1 = GedcomRecord::getInstance($xref1, $tree); |
|
64
|
|
|
$record2 = GedcomRecord::getInstance($xref2, $tree); |
|
65
|
|
|
|
|
66
|
|
|
$title = I18N::translate('Merge records') . ' — ' . e($tree->title()); |
|
67
|
|
|
|
|
68
|
|
|
return $this->viewResponse('admin/merge-records-step-1', [ |
|
69
|
|
|
'individual1' => $record1 instanceof Individual ? $record1 : null, |
|
70
|
|
|
'individual2' => $record2 instanceof Individual ? $record2 : null, |
|
71
|
|
|
'family1' => $record1 instanceof Family ? $record1 : null, |
|
72
|
|
|
'family2' => $record2 instanceof Family ? $record2 : null, |
|
73
|
|
|
'source1' => $record1 instanceof Source ? $record1 : null, |
|
74
|
|
|
'source2' => $record2 instanceof Source ? $record2 : null, |
|
75
|
|
|
'repository1' => $record1 instanceof Repository ? $record1 : null, |
|
76
|
|
|
'repository2' => $record2 instanceof Repository ? $record2 : null, |
|
77
|
|
|
'media1' => $record1 instanceof Media ? $record1 : null, |
|
78
|
|
|
'media2' => $record2 instanceof Media ? $record2 : null, |
|
79
|
|
|
'note1' => $record1 instanceof Note ? $record1 : null, |
|
80
|
|
|
'note2' => $record2 instanceof Note ? $record2 : null, |
|
81
|
|
|
'title' => $title, |
|
82
|
|
|
'tree' => $tree, |
|
83
|
|
|
]); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|