@@ -10,116 +10,116 @@ discard block |
||
10 | 10 | |
11 | 11 | <?php |
12 | 12 | if ($individual !== null) { |
13 | - $xref = $individual->getXref(); |
|
14 | - $cancel_url = $individual->url(); |
|
13 | + $xref = $individual->getXref(); |
|
14 | + $cancel_url = $individual->url(); |
|
15 | 15 | } elseif ($family !== null) { |
16 | - $xref = $family->getXref(); |
|
17 | - $cancel_url = $family->url(); |
|
16 | + $xref = $family->getXref(); |
|
17 | + $cancel_url = $family->url(); |
|
18 | 18 | } else { |
19 | - $cancel_url = route('admin-trees'); |
|
20 | - $xref = 'new'; |
|
19 | + $cancel_url = route('admin-trees'); |
|
20 | + $xref = 'new'; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | // Different cultures do surnames differently |
24 | 24 | $surname_tradition = SurnameTradition::create($tree->getPreference('SURNAME_TRADITION')); |
25 | 25 | |
26 | 26 | if ($name_fact !== null) { |
27 | - // Editing an existing name |
|
28 | - $name_fact_id = $name_fact->getFactId(); |
|
29 | - $namerec = $name_fact->getGedcom(); |
|
30 | - $name_fields = [ |
|
31 | - 'NAME' => $name_fact->getValue(), |
|
32 | - 'TYPE' => $name_fact->getAttribute('TYPE'), |
|
33 | - 'NPFX' => $name_fact->getAttribute('NPFX'), |
|
34 | - 'GIVN' => $name_fact->getAttribute('GIVN'), |
|
35 | - 'NICK' => $name_fact->getAttribute('NICK'), |
|
36 | - 'SPFX' => $name_fact->getAttribute('SPFX'), |
|
37 | - 'SURN' => $name_fact->getAttribute('SURN'), |
|
38 | - 'NSFX' => $name_fact->getAttribute('NSFX'), |
|
39 | - ]; |
|
40 | - |
|
41 | - // Populate any missing subfields from the NAME field |
|
42 | - $npfx_accept = implode('|', Config::namePrefixes()); |
|
43 | - if (preg_match('/(((' . $npfx_accept . ')\.? +)*)([^\n\/"]*)("(.*)")? *\/(([a-z]{2,3} +)*)(.*)\/ *(.*)/i', $name_fields['NAME'], $name_bits)) { |
|
44 | - $name_fields['NPFX'] = $name_fields['NPFX'] ?: $name_bits[1]; |
|
45 | - $name_fields['GIVN'] = $name_fields['GIVN'] ?: $name_bits[4]; |
|
46 | - $name_fields['NICK'] = $name_fields['NICK'] ?: $name_bits[6]; |
|
47 | - $name_fields['SPFX'] = $name_fields['SPFX'] ?: trim($name_bits[7]); |
|
48 | - $name_fields['SURN'] = $name_fields['SURN'] ?: preg_replace('~/[^/]*/~', ',', $name_bits[9]); |
|
49 | - $name_fields['NSFX'] = $name_fields['NSFX'] ?: $name_bits[10]; |
|
50 | - } |
|
27 | + // Editing an existing name |
|
28 | + $name_fact_id = $name_fact->getFactId(); |
|
29 | + $namerec = $name_fact->getGedcom(); |
|
30 | + $name_fields = [ |
|
31 | + 'NAME' => $name_fact->getValue(), |
|
32 | + 'TYPE' => $name_fact->getAttribute('TYPE'), |
|
33 | + 'NPFX' => $name_fact->getAttribute('NPFX'), |
|
34 | + 'GIVN' => $name_fact->getAttribute('GIVN'), |
|
35 | + 'NICK' => $name_fact->getAttribute('NICK'), |
|
36 | + 'SPFX' => $name_fact->getAttribute('SPFX'), |
|
37 | + 'SURN' => $name_fact->getAttribute('SURN'), |
|
38 | + 'NSFX' => $name_fact->getAttribute('NSFX'), |
|
39 | + ]; |
|
40 | + |
|
41 | + // Populate any missing subfields from the NAME field |
|
42 | + $npfx_accept = implode('|', Config::namePrefixes()); |
|
43 | + if (preg_match('/(((' . $npfx_accept . ')\.? +)*)([^\n\/"]*)("(.*)")? *\/(([a-z]{2,3} +)*)(.*)\/ *(.*)/i', $name_fields['NAME'], $name_bits)) { |
|
44 | + $name_fields['NPFX'] = $name_fields['NPFX'] ?: $name_bits[1]; |
|
45 | + $name_fields['GIVN'] = $name_fields['GIVN'] ?: $name_bits[4]; |
|
46 | + $name_fields['NICK'] = $name_fields['NICK'] ?: $name_bits[6]; |
|
47 | + $name_fields['SPFX'] = $name_fields['SPFX'] ?: trim($name_bits[7]); |
|
48 | + $name_fields['SURN'] = $name_fields['SURN'] ?: preg_replace('~/[^/]*/~', ',', $name_bits[9]); |
|
49 | + $name_fields['NSFX'] = $name_fields['NSFX'] ?: $name_bits[10]; |
|
50 | + } |
|
51 | 51 | } else { |
52 | - // Creating a new name |
|
53 | - $name_fact_id = ''; |
|
54 | - $namerec = ''; |
|
55 | - $name_fields = [ |
|
56 | - 'NAME' => '', |
|
57 | - 'TYPE' => '', |
|
58 | - 'NPFX' => '', |
|
59 | - 'GIVN' => '', |
|
60 | - 'NICK' => '', |
|
61 | - 'SPFX' => '', |
|
62 | - 'SURN' => '', |
|
63 | - 'NSFX' => '', |
|
64 | - ]; |
|
65 | - |
|
66 | - // Inherit surname from parents, spouse or child |
|
67 | - if ($family) { |
|
68 | - $father = $family->getHusband(); |
|
69 | - if ($father && $father->getFirstFact('NAME')) { |
|
70 | - $father_name = $father->getFirstFact('NAME')->getValue(); |
|
71 | - } else { |
|
72 | - $father_name = ''; |
|
73 | - } |
|
74 | - $mother = $family->getWife(); |
|
75 | - if ($mother && $mother->getFirstFact('NAME')) { |
|
76 | - $mother_name = $mother->getFirstFact('NAME')->getValue(); |
|
77 | - } else { |
|
78 | - $mother_name = ''; |
|
79 | - } |
|
80 | - } else { |
|
81 | - $father = null; |
|
82 | - $mother = null; |
|
83 | - $father_name = ''; |
|
84 | - $mother_name = ''; |
|
85 | - } |
|
86 | - if ($individual && $individual->getFirstFact('NAME')) { |
|
87 | - $indi_name = $individual->getFirstFact('NAME')->getValue(); |
|
88 | - } else { |
|
89 | - $indi_name = ''; |
|
90 | - } |
|
91 | - |
|
92 | - switch ($nextaction) { |
|
93 | - case 'add_child_to_family_action': |
|
94 | - $name_fields = array_merge($name_fields, $surname_tradition->newChildNames($father_name, $mother_name, $gender)); |
|
95 | - break; |
|
96 | - case 'add_child_to_individual_action': |
|
97 | - if ($individual->getSex() === 'F') { |
|
98 | - $name_fields = array_merge($name_fields, $surname_tradition->newChildNames('', $indi_name, $gender)); |
|
99 | - } else { |
|
100 | - $name_fields = array_merge($name_fields, $surname_tradition->newChildNames($indi_name, '', $gender)); |
|
101 | - } |
|
102 | - break; |
|
103 | - case 'add_parent_to_individual_action': |
|
104 | - $name_fields = array_merge($name_fields, $surname_tradition->newParentNames($indi_name, $gender)); |
|
105 | - break; |
|
106 | - case 'add_spouse_to_family_action': |
|
107 | - if ($father) { |
|
108 | - $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($father_name, $gender)); |
|
109 | - } else { |
|
110 | - $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($mother_name, $gender)); |
|
111 | - } |
|
112 | - break; |
|
113 | - case 'add_spouse_to_individual_action': |
|
114 | - $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($indi_name, $gender)); |
|
115 | - break; |
|
116 | - case 'add_unlinked_indi_action': |
|
117 | - case 'update': |
|
118 | - if ($surname_tradition->hasSurnames()) { |
|
119 | - $name_fields['NAME'] = '//'; |
|
120 | - } |
|
121 | - break; |
|
122 | - } |
|
52 | + // Creating a new name |
|
53 | + $name_fact_id = ''; |
|
54 | + $namerec = ''; |
|
55 | + $name_fields = [ |
|
56 | + 'NAME' => '', |
|
57 | + 'TYPE' => '', |
|
58 | + 'NPFX' => '', |
|
59 | + 'GIVN' => '', |
|
60 | + 'NICK' => '', |
|
61 | + 'SPFX' => '', |
|
62 | + 'SURN' => '', |
|
63 | + 'NSFX' => '', |
|
64 | + ]; |
|
65 | + |
|
66 | + // Inherit surname from parents, spouse or child |
|
67 | + if ($family) { |
|
68 | + $father = $family->getHusband(); |
|
69 | + if ($father && $father->getFirstFact('NAME')) { |
|
70 | + $father_name = $father->getFirstFact('NAME')->getValue(); |
|
71 | + } else { |
|
72 | + $father_name = ''; |
|
73 | + } |
|
74 | + $mother = $family->getWife(); |
|
75 | + if ($mother && $mother->getFirstFact('NAME')) { |
|
76 | + $mother_name = $mother->getFirstFact('NAME')->getValue(); |
|
77 | + } else { |
|
78 | + $mother_name = ''; |
|
79 | + } |
|
80 | + } else { |
|
81 | + $father = null; |
|
82 | + $mother = null; |
|
83 | + $father_name = ''; |
|
84 | + $mother_name = ''; |
|
85 | + } |
|
86 | + if ($individual && $individual->getFirstFact('NAME')) { |
|
87 | + $indi_name = $individual->getFirstFact('NAME')->getValue(); |
|
88 | + } else { |
|
89 | + $indi_name = ''; |
|
90 | + } |
|
91 | + |
|
92 | + switch ($nextaction) { |
|
93 | + case 'add_child_to_family_action': |
|
94 | + $name_fields = array_merge($name_fields, $surname_tradition->newChildNames($father_name, $mother_name, $gender)); |
|
95 | + break; |
|
96 | + case 'add_child_to_individual_action': |
|
97 | + if ($individual->getSex() === 'F') { |
|
98 | + $name_fields = array_merge($name_fields, $surname_tradition->newChildNames('', $indi_name, $gender)); |
|
99 | + } else { |
|
100 | + $name_fields = array_merge($name_fields, $surname_tradition->newChildNames($indi_name, '', $gender)); |
|
101 | + } |
|
102 | + break; |
|
103 | + case 'add_parent_to_individual_action': |
|
104 | + $name_fields = array_merge($name_fields, $surname_tradition->newParentNames($indi_name, $gender)); |
|
105 | + break; |
|
106 | + case 'add_spouse_to_family_action': |
|
107 | + if ($father) { |
|
108 | + $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($father_name, $gender)); |
|
109 | + } else { |
|
110 | + $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($mother_name, $gender)); |
|
111 | + } |
|
112 | + break; |
|
113 | + case 'add_spouse_to_individual_action': |
|
114 | + $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($indi_name, $gender)); |
|
115 | + break; |
|
116 | + case 'add_unlinked_indi_action': |
|
117 | + case 'update': |
|
118 | + if ($surname_tradition->hasSurnames()) { |
|
119 | + $name_fields['NAME'] = '//'; |
|
120 | + } |
|
121 | + break; |
|
122 | + } |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | $bdm = ''; // used to copy '1 SOUR' to '2 SOUR' for BIRT DEAT MARR |
@@ -141,196 +141,196 @@ discard block |
||
141 | 141 | <?php endif ?> |
142 | 142 | |
143 | 143 | <?php |
144 | - // First - standard name fields |
|
145 | - foreach ($name_fields as $tag => $value) { |
|
146 | - if (substr_compare($tag, '_', 0, 1) !== 0) { |
|
147 | - echo FunctionsEdit::addSimpleTag($tree, '0 ' . $tag . ' ' . $value, '', '', null, $individual); |
|
148 | - } |
|
149 | - } |
|
150 | - |
|
151 | - // Second - advanced name fields |
|
152 | - if ($surname_tradition->hasMarriedNames() || preg_match('/\n2 _MARNM /', $namerec)) { |
|
153 | - $adv_name_fields = ['_MARNM' => '']; |
|
154 | - } else { |
|
155 | - $adv_name_fields = []; |
|
156 | - } |
|
157 | - if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $tree->getPreference('ADVANCED_NAME_FACTS'), $match)) { |
|
158 | - foreach ($match[1] as $tag) { |
|
159 | - // Ignore advanced facts that duplicate standard facts |
|
160 | - if (!in_array($tag, ['TYPE', 'NPFX', 'GIVN', 'NICK', 'SPFX', 'SURN', 'NSFX'])) { |
|
161 | - $adv_name_fields[$tag] = ''; |
|
162 | - } |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - foreach (array_keys($adv_name_fields) as $tag) { |
|
167 | - // Edit existing tags, grouped together |
|
168 | - if (preg_match_all('/2 ' . $tag . ' (.+)/', $namerec, $match)) { |
|
169 | - foreach ($match[1] as $value) { |
|
170 | - echo FunctionsEdit::addSimpleTag($tree, '2 ' . $tag . ' ' . $value, '', GedcomTag::getLabel('NAME:' . $tag, $individual)); |
|
171 | - if ($tag === '_MARNM') { |
|
172 | - preg_match_all('/\/([^\/]*)\//', $value, $matches); |
|
173 | - echo FunctionsEdit::addSimpleTag($tree, '2 _MARNM_SURN ' . implode(',', $matches[1])); |
|
174 | - } |
|
175 | - } |
|
176 | - } |
|
177 | - // Allow a new tag to be entered |
|
178 | - if (!array_key_exists($tag, $name_fields)) { |
|
179 | - echo FunctionsEdit::addSimpleTag($tree, '0 ' . $tag, '', GedcomTag::getLabel('NAME:' . $tag, $individual)); |
|
180 | - if ($tag === '_MARNM') { |
|
181 | - echo FunctionsEdit::addSimpleTag($tree, '0 _MARNM_SURN'); |
|
182 | - } |
|
183 | - } |
|
184 | - } |
|
185 | - |
|
186 | - // Third - new/existing custom name fields |
|
187 | - foreach ($name_fields as $tag => $value) { |
|
188 | - if (substr_compare($tag, '_', 0, 1) === 0) { |
|
189 | - echo FunctionsEdit::addSimpleTag($tree, '0 ' . $tag . ' ' . $value); |
|
190 | - if ($tag === '_MARNM') { |
|
191 | - preg_match_all('/\/([^\/]*)\//', $value, $matches); |
|
192 | - echo FunctionsEdit::addSimpleTag($tree, '2 _MARNM_SURN ' . implode(',', $matches[1])); |
|
193 | - } |
|
194 | - } |
|
195 | - } |
|
196 | - |
|
197 | - // Fourth - SOUR, NOTE, _CUSTOM, etc. |
|
198 | - if ($namerec !== '') { |
|
199 | - $gedlines = explode("\n", $namerec); // -- find the number of lines in the record |
|
200 | - $fields = explode(' ', $gedlines[0]); |
|
201 | - $glevel = $fields[0]; |
|
202 | - $level = $glevel; |
|
203 | - $type = $fields[1]; |
|
204 | - $tags = []; |
|
205 | - $i = 0; |
|
206 | - do { |
|
207 | - if ($type !== 'TYPE' && !array_key_exists($type, $name_fields) && !array_key_exists($type, $adv_name_fields)) { |
|
208 | - $text = ''; |
|
209 | - for ($j = 2; $j < count($fields); $j++) { |
|
210 | - if ($j > 2) { |
|
211 | - $text .= ' '; |
|
212 | - } |
|
213 | - $text .= $fields[$j]; |
|
214 | - } |
|
215 | - while (($i + 1 < count($gedlines)) && (preg_match('/' . ($level + 1) . ' CONT ?(.*)/', $gedlines[$i + 1], $cmatch) > 0)) { |
|
216 | - $text .= "\n" . $cmatch[1]; |
|
217 | - $i++; |
|
218 | - } |
|
219 | - echo FunctionsEdit::addSimpleTag($tree, $level . ' ' . $type . ' ' . $text); |
|
220 | - } |
|
221 | - $tags[] = $type; |
|
222 | - $i++; |
|
223 | - if (isset($gedlines[$i])) { |
|
224 | - $fields = explode(' ', $gedlines[$i]); |
|
225 | - $level = $fields[0]; |
|
226 | - if (isset($fields[1])) { |
|
227 | - $type = $fields[1]; |
|
228 | - } |
|
229 | - } |
|
230 | - } while (($level > $glevel) && ($i < count($gedlines))); |
|
231 | - } |
|
232 | - |
|
233 | - // If we are adding a new individual, add the basic details |
|
234 | - if ($nextaction !== 'update') { |
|
235 | - echo '</table><br><table class="table wt-facts-table">'; |
|
236 | - // 1 SEX |
|
237 | - if ($famtag === 'HUSB' || $gender === 'M') { |
|
238 | - echo FunctionsEdit::addSimpleTag($tree, '0 SEX M'); |
|
239 | - } elseif ($famtag === 'WIFE' || $gender === 'F') { |
|
240 | - echo FunctionsEdit::addSimpleTag($tree, '0 SEX F'); |
|
241 | - } else { |
|
242 | - echo FunctionsEdit::addSimpleTag($tree, '0 SEX U'); |
|
243 | - } |
|
244 | - $bdm = 'BD'; |
|
245 | - if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
246 | - foreach ($matches[1] as $match) { |
|
247 | - if (!in_array($match, explode('|', WT_EVENTS_DEAT))) { |
|
248 | - FunctionsEdit::addSimpleTags($tree, $match); |
|
249 | - } |
|
250 | - } |
|
251 | - } |
|
252 | - //-- if adding a spouse add the option to add a marriage fact to the new family |
|
253 | - if ($nextaction === 'add_spouse_to_individual_action' || $nextaction === 'add_spouse_to_family_action') { |
|
254 | - $bdm .= 'M'; |
|
255 | - if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $tree->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) { |
|
256 | - foreach ($matches[1] as $match) { |
|
257 | - FunctionsEdit::addSimpleTags($tree, $match); |
|
258 | - } |
|
259 | - } |
|
260 | - } |
|
261 | - if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
262 | - foreach ($matches[1] as $match) { |
|
263 | - if (in_array($match, explode('|', WT_EVENTS_DEAT))) { |
|
264 | - FunctionsEdit::addSimpleTags($tree, $match); |
|
265 | - } |
|
266 | - } |
|
267 | - } |
|
268 | - } |
|
269 | - |
|
270 | - echo '</table>'; |
|
271 | - if ($nextaction === 'update') { |
|
272 | - // GEDCOM 5.5.1 spec says NAME doesn’t get a OBJE |
|
273 | - echo view('cards/add-source-citation', [ |
|
274 | - 'level' => 2, |
|
275 | - 'full_citations' => $tree->getPreference('FULL_SOURCES'), |
|
276 | - 'tree' => $tree, |
|
277 | - ]); |
|
278 | - echo view('cards/add-note', [ |
|
279 | - 'level' => 2, |
|
280 | - 'tree' => $tree, |
|
281 | - ]); |
|
282 | - echo view('cards/add-shared-note', [ |
|
283 | - 'level' => 2, |
|
284 | - 'tree' => $tree, |
|
285 | - ]); |
|
286 | - echo view('cards/add-restriction', [ |
|
287 | - 'level' => 2, |
|
288 | - 'tree' => $tree, |
|
289 | - ]); |
|
290 | - } else { |
|
291 | - echo view('cards/add-source-citation', [ |
|
292 | - 'bdm' => $bdm, |
|
293 | - 'level' => 1, |
|
294 | - 'full_citations' => $tree->getPreference('FULL_SOURCES'), |
|
295 | - 'prefer_level2_sources' => $tree->getPreference('PREFER_LEVEL2_SOURCES'), |
|
296 | - 'quick_required_facts' => $tree->getPreference('QUICK_REQUIRED_FACTS'), |
|
297 | - 'quick_required_famfacts' => $tree->getPreference('QUICK_REQUIRED_FAMFACTS'), |
|
298 | - 'tree' => $tree, |
|
299 | - ]); |
|
300 | - echo view('cards/add-note', [ |
|
301 | - 'level' => 1, |
|
302 | - 'tree' => $tree, |
|
303 | - ]); |
|
304 | - echo view('cards/add-shared-note', [ |
|
305 | - 'level' => 1, |
|
306 | - 'tree' => $tree, |
|
307 | - ]); |
|
308 | - echo view('cards/add-restriction', [ |
|
309 | - 'level' => 1, |
|
310 | - 'tree' => $tree, |
|
311 | - ]); |
|
312 | - } |
|
313 | - |
|
314 | - ?> |
|
144 | + // First - standard name fields |
|
145 | + foreach ($name_fields as $tag => $value) { |
|
146 | + if (substr_compare($tag, '_', 0, 1) !== 0) { |
|
147 | + echo FunctionsEdit::addSimpleTag($tree, '0 ' . $tag . ' ' . $value, '', '', null, $individual); |
|
148 | + } |
|
149 | + } |
|
150 | + |
|
151 | + // Second - advanced name fields |
|
152 | + if ($surname_tradition->hasMarriedNames() || preg_match('/\n2 _MARNM /', $namerec)) { |
|
153 | + $adv_name_fields = ['_MARNM' => '']; |
|
154 | + } else { |
|
155 | + $adv_name_fields = []; |
|
156 | + } |
|
157 | + if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $tree->getPreference('ADVANCED_NAME_FACTS'), $match)) { |
|
158 | + foreach ($match[1] as $tag) { |
|
159 | + // Ignore advanced facts that duplicate standard facts |
|
160 | + if (!in_array($tag, ['TYPE', 'NPFX', 'GIVN', 'NICK', 'SPFX', 'SURN', 'NSFX'])) { |
|
161 | + $adv_name_fields[$tag] = ''; |
|
162 | + } |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + foreach (array_keys($adv_name_fields) as $tag) { |
|
167 | + // Edit existing tags, grouped together |
|
168 | + if (preg_match_all('/2 ' . $tag . ' (.+)/', $namerec, $match)) { |
|
169 | + foreach ($match[1] as $value) { |
|
170 | + echo FunctionsEdit::addSimpleTag($tree, '2 ' . $tag . ' ' . $value, '', GedcomTag::getLabel('NAME:' . $tag, $individual)); |
|
171 | + if ($tag === '_MARNM') { |
|
172 | + preg_match_all('/\/([^\/]*)\//', $value, $matches); |
|
173 | + echo FunctionsEdit::addSimpleTag($tree, '2 _MARNM_SURN ' . implode(',', $matches[1])); |
|
174 | + } |
|
175 | + } |
|
176 | + } |
|
177 | + // Allow a new tag to be entered |
|
178 | + if (!array_key_exists($tag, $name_fields)) { |
|
179 | + echo FunctionsEdit::addSimpleTag($tree, '0 ' . $tag, '', GedcomTag::getLabel('NAME:' . $tag, $individual)); |
|
180 | + if ($tag === '_MARNM') { |
|
181 | + echo FunctionsEdit::addSimpleTag($tree, '0 _MARNM_SURN'); |
|
182 | + } |
|
183 | + } |
|
184 | + } |
|
185 | + |
|
186 | + // Third - new/existing custom name fields |
|
187 | + foreach ($name_fields as $tag => $value) { |
|
188 | + if (substr_compare($tag, '_', 0, 1) === 0) { |
|
189 | + echo FunctionsEdit::addSimpleTag($tree, '0 ' . $tag . ' ' . $value); |
|
190 | + if ($tag === '_MARNM') { |
|
191 | + preg_match_all('/\/([^\/]*)\//', $value, $matches); |
|
192 | + echo FunctionsEdit::addSimpleTag($tree, '2 _MARNM_SURN ' . implode(',', $matches[1])); |
|
193 | + } |
|
194 | + } |
|
195 | + } |
|
196 | + |
|
197 | + // Fourth - SOUR, NOTE, _CUSTOM, etc. |
|
198 | + if ($namerec !== '') { |
|
199 | + $gedlines = explode("\n", $namerec); // -- find the number of lines in the record |
|
200 | + $fields = explode(' ', $gedlines[0]); |
|
201 | + $glevel = $fields[0]; |
|
202 | + $level = $glevel; |
|
203 | + $type = $fields[1]; |
|
204 | + $tags = []; |
|
205 | + $i = 0; |
|
206 | + do { |
|
207 | + if ($type !== 'TYPE' && !array_key_exists($type, $name_fields) && !array_key_exists($type, $adv_name_fields)) { |
|
208 | + $text = ''; |
|
209 | + for ($j = 2; $j < count($fields); $j++) { |
|
210 | + if ($j > 2) { |
|
211 | + $text .= ' '; |
|
212 | + } |
|
213 | + $text .= $fields[$j]; |
|
214 | + } |
|
215 | + while (($i + 1 < count($gedlines)) && (preg_match('/' . ($level + 1) . ' CONT ?(.*)/', $gedlines[$i + 1], $cmatch) > 0)) { |
|
216 | + $text .= "\n" . $cmatch[1]; |
|
217 | + $i++; |
|
218 | + } |
|
219 | + echo FunctionsEdit::addSimpleTag($tree, $level . ' ' . $type . ' ' . $text); |
|
220 | + } |
|
221 | + $tags[] = $type; |
|
222 | + $i++; |
|
223 | + if (isset($gedlines[$i])) { |
|
224 | + $fields = explode(' ', $gedlines[$i]); |
|
225 | + $level = $fields[0]; |
|
226 | + if (isset($fields[1])) { |
|
227 | + $type = $fields[1]; |
|
228 | + } |
|
229 | + } |
|
230 | + } while (($level > $glevel) && ($i < count($gedlines))); |
|
231 | + } |
|
232 | + |
|
233 | + // If we are adding a new individual, add the basic details |
|
234 | + if ($nextaction !== 'update') { |
|
235 | + echo '</table><br><table class="table wt-facts-table">'; |
|
236 | + // 1 SEX |
|
237 | + if ($famtag === 'HUSB' || $gender === 'M') { |
|
238 | + echo FunctionsEdit::addSimpleTag($tree, '0 SEX M'); |
|
239 | + } elseif ($famtag === 'WIFE' || $gender === 'F') { |
|
240 | + echo FunctionsEdit::addSimpleTag($tree, '0 SEX F'); |
|
241 | + } else { |
|
242 | + echo FunctionsEdit::addSimpleTag($tree, '0 SEX U'); |
|
243 | + } |
|
244 | + $bdm = 'BD'; |
|
245 | + if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
246 | + foreach ($matches[1] as $match) { |
|
247 | + if (!in_array($match, explode('|', WT_EVENTS_DEAT))) { |
|
248 | + FunctionsEdit::addSimpleTags($tree, $match); |
|
249 | + } |
|
250 | + } |
|
251 | + } |
|
252 | + //-- if adding a spouse add the option to add a marriage fact to the new family |
|
253 | + if ($nextaction === 'add_spouse_to_individual_action' || $nextaction === 'add_spouse_to_family_action') { |
|
254 | + $bdm .= 'M'; |
|
255 | + if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $tree->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) { |
|
256 | + foreach ($matches[1] as $match) { |
|
257 | + FunctionsEdit::addSimpleTags($tree, $match); |
|
258 | + } |
|
259 | + } |
|
260 | + } |
|
261 | + if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
262 | + foreach ($matches[1] as $match) { |
|
263 | + if (in_array($match, explode('|', WT_EVENTS_DEAT))) { |
|
264 | + FunctionsEdit::addSimpleTags($tree, $match); |
|
265 | + } |
|
266 | + } |
|
267 | + } |
|
268 | + } |
|
269 | + |
|
270 | + echo '</table>'; |
|
271 | + if ($nextaction === 'update') { |
|
272 | + // GEDCOM 5.5.1 spec says NAME doesn’t get a OBJE |
|
273 | + echo view('cards/add-source-citation', [ |
|
274 | + 'level' => 2, |
|
275 | + 'full_citations' => $tree->getPreference('FULL_SOURCES'), |
|
276 | + 'tree' => $tree, |
|
277 | + ]); |
|
278 | + echo view('cards/add-note', [ |
|
279 | + 'level' => 2, |
|
280 | + 'tree' => $tree, |
|
281 | + ]); |
|
282 | + echo view('cards/add-shared-note', [ |
|
283 | + 'level' => 2, |
|
284 | + 'tree' => $tree, |
|
285 | + ]); |
|
286 | + echo view('cards/add-restriction', [ |
|
287 | + 'level' => 2, |
|
288 | + 'tree' => $tree, |
|
289 | + ]); |
|
290 | + } else { |
|
291 | + echo view('cards/add-source-citation', [ |
|
292 | + 'bdm' => $bdm, |
|
293 | + 'level' => 1, |
|
294 | + 'full_citations' => $tree->getPreference('FULL_SOURCES'), |
|
295 | + 'prefer_level2_sources' => $tree->getPreference('PREFER_LEVEL2_SOURCES'), |
|
296 | + 'quick_required_facts' => $tree->getPreference('QUICK_REQUIRED_FACTS'), |
|
297 | + 'quick_required_famfacts' => $tree->getPreference('QUICK_REQUIRED_FAMFACTS'), |
|
298 | + 'tree' => $tree, |
|
299 | + ]); |
|
300 | + echo view('cards/add-note', [ |
|
301 | + 'level' => 1, |
|
302 | + 'tree' => $tree, |
|
303 | + ]); |
|
304 | + echo view('cards/add-shared-note', [ |
|
305 | + 'level' => 1, |
|
306 | + 'tree' => $tree, |
|
307 | + ]); |
|
308 | + echo view('cards/add-restriction', [ |
|
309 | + 'level' => 1, |
|
310 | + 'tree' => $tree, |
|
311 | + ]); |
|
312 | + } |
|
313 | + |
|
314 | + ?> |
|
315 | 315 | <div class="row form-group"> |
316 | 316 | <div class="col-sm-9 offset-sm-3"> |
317 | 317 | <button class="btn btn-primary" type="submit"> |
318 | 318 | <?= FontAwesome::decorativeIcon('save') ?> |
319 | 319 | <?= /* I18N: A button label. */ |
320 | - I18N::translate('save') ?> |
|
320 | + I18N::translate('save') ?> |
|
321 | 321 | </button> |
322 | 322 | <?php if (preg_match('/^add_(child|spouse|parent|unlinked_indi)/', $nextaction)): ?> |
323 | 323 | |
324 | 324 | <button class="btn btn-primary" type="submit" name="goto" value="<?= $xref ?>"> |
325 | 325 | <?= FontAwesome::decorativeIcon('save') ?> |
326 | 326 | <?= /* I18N: A button label. */ |
327 | - I18N::translate('go to new individual') ?> |
|
327 | + I18N::translate('go to new individual') ?> |
|
328 | 328 | </button> |
329 | 329 | <?php endif ?> |
330 | 330 | <a class="btn btn-secondary" href="<?= e($cancel_url) ?>"> |
331 | 331 | <?= FontAwesome::decorativeIcon('cancel') ?> |
332 | 332 | <?= /* I18N: A button label. */ |
333 | - I18N::translate('cancel') ?> |
|
333 | + I18N::translate('cancel') ?> |
|
334 | 334 | </a> |
335 | 335 | |
336 | 336 | <?php if ($name_fact instanceof Fact && (Auth::isAdmin() || $tree->getPreference('SHOW_GEDCOM_RECORD'))): ?> |
@@ -21,12 +21,12 @@ |
||
21 | 21 | <button class="btn btn-primary" type="submit"> |
22 | 22 | <?= FontAwesome::decorativeIcon('save') ?> |
23 | 23 | <?= /* I18N: A button label. */ |
24 | - I18N::translate('save') ?> |
|
24 | + I18N::translate('save') ?> |
|
25 | 25 | </button> |
26 | 26 | <a class="btn btn-secondary" href="<?= e($note->url()) ?>"> |
27 | 27 | <?= FontAwesome::decorativeIcon('cancel') ?> |
28 | 28 | <?= /* I18N: A button label. */ |
29 | - I18N::translate('cancel') ?> |
|
29 | + I18N::translate('cancel') ?> |
|
30 | 30 | </a> |
31 | 31 | </div> |
32 | 32 | </div> |
@@ -25,12 +25,12 @@ |
||
25 | 25 | <button class="btn btn-primary" type="submit"> |
26 | 26 | <?= FontAwesome::decorativeIcon('save') ?> |
27 | 27 | <?= /* I18N: A button label. */ |
28 | - I18N::translate('save') ?> |
|
28 | + I18N::translate('save') ?> |
|
29 | 29 | </button> |
30 | 30 | <a class="btn btn-secondary" href="<?= e($individual->url()) ?>"> |
31 | 31 | <?= FontAwesome::decorativeIcon('cancel') ?> |
32 | 32 | <?= /* I18N: A button label. */ |
33 | - I18N::translate('cancel') ?> |
|
33 | + I18N::translate('cancel') ?> |
|
34 | 34 | </a> |
35 | 35 | </div> |
36 | 36 | </div> |
@@ -65,7 +65,7 @@ |
||
65 | 65 | return new Menu( |
66 | 66 | $this->getTitle(), |
67 | 67 | route('report-setup', ['ged' => $tree->getName(), |
68 | - 'report' => $this->getName(), |
|
68 | + 'report' => $this->getName(), |
|
69 | 69 | ]), |
70 | 70 | 'menu-report-' . $this->getName(), |
71 | 71 | ['rel' => 'nofollow'] |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types = 1); |
|
2 | +declare(strict_types=1); |
|
3 | 3 | /** |
4 | 4 | * webtrees: online genealogy |
5 | 5 | * Copyright (C) 2018 webtrees development team |
@@ -65,7 +65,7 @@ |
||
65 | 65 | return new Menu( |
66 | 66 | $this->getTitle(), |
67 | 67 | route('report-setup', ['ged' => $tree->getName(), |
68 | - 'report' => $this->getName(), |
|
68 | + 'report' => $this->getName(), |
|
69 | 69 | ]), |
70 | 70 | 'menu-report-' . $this->getName(), |
71 | 71 | ['rel' => 'nofollow'] |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types = 1); |
|
2 | +declare(strict_types=1); |
|
3 | 3 | /** |
4 | 4 | * webtrees: online genealogy |
5 | 5 | * Copyright (C) 2018 webtrees development team |
@@ -65,7 +65,7 @@ |
||
65 | 65 | return new Menu( |
66 | 66 | $this->getTitle(), |
67 | 67 | route('report-setup', ['ged' => $tree->getName(), |
68 | - 'report' => $this->getName(), |
|
68 | + 'report' => $this->getName(), |
|
69 | 69 | ]), |
70 | 70 | 'menu-report-' . $this->getName(), |
71 | 71 | ['rel' => 'nofollow'] |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types = 1); |
|
2 | +declare(strict_types=1); |
|
3 | 3 | /** |
4 | 4 | * webtrees: online genealogy |
5 | 5 | * Copyright (C) 2018 webtrees development team |
@@ -65,7 +65,7 @@ |
||
65 | 65 | return new Menu( |
66 | 66 | $this->getTitle(), |
67 | 67 | route('report-setup', ['ged' => $tree->getName(), |
68 | - 'report' => $this->getName(), |
|
68 | + 'report' => $this->getName(), |
|
69 | 69 | ]), |
70 | 70 | 'menu-report-' . $this->getName(), |
71 | 71 | ['rel' => 'nofollow'] |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types = 1); |
|
2 | +declare(strict_types=1); |
|
3 | 3 | /** |
4 | 4 | * webtrees: online genealogy |
5 | 5 | * Copyright (C) 2018 webtrees development team |
@@ -65,7 +65,7 @@ |
||
65 | 65 | return new Menu( |
66 | 66 | $this->getTitle(), |
67 | 67 | route('report-setup', ['ged' => $tree->getName(), |
68 | - 'report' => $this->getName(), |
|
68 | + 'report' => $this->getName(), |
|
69 | 69 | ]), |
70 | 70 | 'menu-report-' . $this->getName(), |
71 | 71 | ['rel' => 'nofollow'] |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types = 1); |
|
2 | +declare(strict_types=1); |
|
3 | 3 | /** |
4 | 4 | * webtrees: online genealogy |
5 | 5 | * Copyright (C) 2018 webtrees development team |
@@ -65,7 +65,7 @@ |
||
65 | 65 | return new Menu( |
66 | 66 | $this->getTitle(), |
67 | 67 | route('report-setup', ['ged' => $tree->getName(), |
68 | - 'report' => $this->getName(), |
|
68 | + 'report' => $this->getName(), |
|
69 | 69 | ]), |
70 | 70 | 'menu-report-' . $this->getName(), |
71 | 71 | ['rel' => 'nofollow'] |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types = 1); |
|
2 | +declare(strict_types=1); |
|
3 | 3 | /** |
4 | 4 | * webtrees: online genealogy |
5 | 5 | * Copyright (C) 2018 webtrees development team |