-
Notifications
You must be signed in to change notification settings - Fork 0
/
Record.php
250 lines (209 loc) · 6.06 KB
/
Record.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<?php
/**
* webtrees: online genealogy
* Copyright (C) 2024 webtrees development team
* <http://webtrees.net>
*
* Fancy Research Links (webtrees custom module):
* Copyright (C) 2022 Carmen Just
* <https://justcarmen.nl>
*
* ExtendedImportExport (webtrees custom module):
* Copyright (C) 2024 Markus Hemprich
* <http://www.familienforschung-hemprich.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* ExtendedImportExport
*
* A weebtrees(https://webtrees.net) 2.1 custom module for advanced GEDCOM import, export
* and filter operations. The module also supports remote downloads/uploads via URL requests.
*
*/
declare(strict_types=1);
namespace Jefferson49\Webtrees\Module\ExtendedImportExport;
/**
* A structure to represent a (Gedcom) record with references to other records
*/
class Record
{
//The XREF of the record
private string $xref;
//Type of the record, i.e. INDI, FAM, ...
private string $type;
//A list of records, which contains references pointing to the record
//array<Record>
private array $other_records_referencing_record;
//A list of records, which the record is referencing
//array<Record>
private array $other_records_referenced_by_record;
//Whether the record is empty, i.e. does not contain a Gedcom substructure
private bool $is_empty;
//Whether the record is a minimal individual, i.e. INDI record with SEX, FAMC, FAMS or less
private bool $is_minimal_individual;
/**
* Constructor
*
* @param string $xref The XREF of the record
*
* @return void
*/
public function __construct($xref, $type = '')
{
$this->xref = $xref;
$this->type = $type;
$this->other_records_referencing_record = [];
$this->other_records_referenced_by_record = [];
$this->is_empty = false;
$this->is_minimal_individual = false;
}
/**
* Whether the records is referenced by other records, which point to it
*
* @return bool
*/
public function isReferenced(): bool {
return sizeof($this->other_records_referencing_record) > 0;
}
/**
* Whether the records is referencing (i.e. points to) other records
*
* @return bool
*/
public function isReferencing(): bool {
return sizeof($this->other_records_referenced_by_record) > 0;
}
/**
* Get list of records, which point to the record
*
* @return array<Record>
*/
public function getReferencingRecords(): array {
return $this->other_records_referencing_record;
}
/**
* Get list of records, to which the record points to
*
* @return array<Record>
*/
public function getReferencedRecords(): array {
return $this->other_records_referenced_by_record;
}
/**
* Set record to empty
*
* @return void
*/
public function setEmpty(): void {
$this->is_empty = true;
return;
}
/**
* Whether the records is empty, i.e. does not contain a Gedcom substructure
*
* @return bool
*/
public function isEmpty(): bool {
return $this->is_empty;
}
/**
* Set record as minimal individual
*
* @return void
*/
public function setMinimalIndividual(): void {
$this->is_minimal_individual = true;
return;
}
/**
* Whether the records is a minimal individual, i.e. INDI record with SEX, FAMC, FAMS or less
*
* @return bool
*/
public function isMinimalIndividual(): bool {
return $this->is_minimal_individual;
}
/**
* Add other record, which points to the record
*
* @param Record $record
*
* @return void
*/
public function addReferencingRecord(Record $record): void {
$this->other_records_referencing_record[] = $record;
return;
}
/**
* Add other record, which is references by the record
*
* @param Record $record
*
* @return void
*/
public function addReferencedRecord(Record $record): void {
$this->other_records_referenced_by_record[] = $record;
return;
}
/**
* Remove reference of other record, which points to the record
*
* @param Record $record
*
* @return void
*/
public function removeReferencingRecord(Record $record): void {
$key = array_search($record, $this->other_records_referencing_record);
unset($this->other_records_referencing_record[$key]);
return;
}
/**
* Remove other record, which is referenced by the record
*
* @param Record $record
*
* @return void
*/
public function removeReferencedRecord(Record $record): void {
$key = array_search($record, $this->other_records_referenced_by_record);
unset($this->other_records_referenced_by_record[$key]);
return;
}
/**
* Set record tpye
*
* @param string $type A record type, i.e. INDI, FAM, ...
*
* @return void
*/
public function setTpye(string $type): void {
$this->type = $type;
return;
}
/**
* Get the record tpye
*
* @return string
*/
public function type(): string {
return $this->type;
}
/**
* Get the record xref
*
* @return string
*/
public function xref(): string {
return $this->xref;
}
}