1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* webtrees: online genealogy |
5
|
|
|
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>. |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
declare(strict_types=1); |
19
|
|
|
|
20
|
|
|
namespace Fisharebest\Webtrees\Elements; |
21
|
|
|
|
22
|
|
|
use Fisharebest\Webtrees\Family; |
23
|
|
|
use Fisharebest\Webtrees\I18N; |
24
|
|
|
use Fisharebest\Webtrees\Individual; |
25
|
|
|
use Fisharebest\Webtrees\Registry; |
26
|
|
|
|
27
|
|
|
use function uasort; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* EVENT_OR_FACT_CLASSIFICATION := {Size=1:15} |
31
|
|
|
* [ <EVENT_ATTRIBUTE_TYPE> ] |
32
|
|
|
* A code that indicates the type of event which was responsible for the source |
33
|
|
|
* entry being recorded. For example, if the entry was created to record a |
34
|
|
|
* birth of a child, then the type would be BIRT regardless of the assertions |
35
|
|
|
* made from that record, such as the mother's name or mother's birth date. |
36
|
|
|
* This will allow a prioritized best view choice and a determination of the |
37
|
|
|
* certainty associated with the source used in asserting the cited fact. |
38
|
|
|
*/ |
39
|
|
|
class EventTypeCitedFrom extends AbstractElement |
40
|
|
|
{ |
41
|
|
|
protected const MAXIMUM_LENGTH = 15; |
42
|
|
|
|
43
|
|
|
protected const FAMILY_EVENTS = [ |
44
|
|
|
'ANUL', |
45
|
|
|
'CENS', |
46
|
|
|
'DIV', |
47
|
|
|
'DIVF', |
48
|
|
|
'ENGA', |
49
|
|
|
'MARR', |
50
|
|
|
'MARB', |
51
|
|
|
'MARC', |
52
|
|
|
'MARL', |
53
|
|
|
'MARS', |
54
|
|
|
'EVEN', |
55
|
|
|
]; |
56
|
|
|
|
57
|
|
|
protected const INDIVIDUAL_EVENTS = [ |
58
|
|
|
'ADOP', |
59
|
|
|
'BIRT', |
60
|
|
|
'BAPM', |
61
|
|
|
'BARM', |
62
|
|
|
'BASM', |
63
|
|
|
'BLES', |
64
|
|
|
'BURI', |
65
|
|
|
'CENS', |
66
|
|
|
'CHR', |
67
|
|
|
'CHRA', |
68
|
|
|
'CONF', |
69
|
|
|
'CREM', |
70
|
|
|
'DEAT', |
71
|
|
|
'EMIG', |
72
|
|
|
'FCOM', |
73
|
|
|
'GRAD', |
74
|
|
|
'IMMI', |
75
|
|
|
'NATU', |
76
|
|
|
'ORDN', |
77
|
|
|
'RETI', |
78
|
|
|
'PROB', |
79
|
|
|
'WILL', |
80
|
|
|
'EVEN', |
81
|
|
|
]; |
82
|
|
|
|
83
|
|
|
protected const ATTRIBUTE_TYPES = [ |
84
|
|
|
'CAST', |
85
|
|
|
'EDUC', |
86
|
|
|
'NATI', |
87
|
|
|
'OCCU', |
88
|
|
|
'PROP', |
89
|
|
|
'RELI', |
90
|
|
|
'RESI', |
91
|
|
|
'TITL', |
92
|
|
|
'FACT', |
93
|
|
|
]; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* A list of controlled values for this element |
97
|
|
|
* |
98
|
|
|
* @return array<int|string,string> |
99
|
|
|
*/ |
100
|
|
|
public function values(): array |
101
|
|
|
{ |
102
|
|
|
$data = [ |
103
|
|
|
Family::RECORD_TYPE => static::FAMILY_EVENTS, |
104
|
|
|
Individual::RECORD_TYPE => array_merge(static::INDIVIDUAL_EVENTS, static::ATTRIBUTE_TYPES), |
105
|
|
|
]; |
106
|
|
|
|
107
|
|
|
$values = ['' => '']; |
108
|
|
|
|
109
|
|
|
foreach ($data as $record_type => $subtags) { |
110
|
|
|
foreach ($subtags as $subtag) { |
111
|
|
|
$element = Registry::elementFactory()->make($record_type . ':' . $subtag); |
112
|
|
|
|
113
|
|
|
if (!$element instanceof UnknownElement) { |
114
|
|
|
$values[$subtag] = $element->label(); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
uasort($values, I18N::comparator()); |
120
|
|
|
|
121
|
|
|
return $values; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|