@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | " OR descriptive_title LIKE CONCAT('%', :search_2, '%'))" . |
153 | 153 | " AND multimedia_file_refn NOT LIKE 'http://%'" . |
154 | 154 | " AND multimedia_file_refn NOT LIKE 'https://%'"; |
155 | - $ARGS1 = [ |
|
155 | + $ARGS1 = [ |
|
156 | 156 | 'media_path_1' => $media_path, |
157 | 157 | 'media_folder' => $media_folder, |
158 | 158 | 'media_path_2' => Database::escapeLike($media_path), |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | " AND multimedia_file_refn LIKE CONCAT(:media_path_3, '%')" . |
170 | 170 | " AND multimedia_file_refn NOT LIKE 'http://%'" . |
171 | 171 | " AND multimedia_file_refn NOT LIKE 'https://%'"; |
172 | - $ARGS2 = [ |
|
172 | + $ARGS2 = [ |
|
173 | 173 | 'media_folder' => $media_folder, |
174 | 174 | 'media_path_3' => $media_path, |
175 | 175 | ]; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $ARGS2['media_path_4'] = Database::escapeLike($media_path); |
182 | 182 | } |
183 | 183 | |
184 | - $order = $request->get('order', []); |
|
184 | + $order = $request->get('order', []); |
|
185 | 185 | $SELECT1 .= " ORDER BY "; |
186 | 186 | if ($order) { |
187 | 187 | foreach ($order as $key => $value) { |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | if ($length > 0) { |
208 | - $SELECT1 .= " LIMIT :length OFFSET :start"; |
|
208 | + $SELECT1 .= " LIMIT :length OFFSET :start"; |
|
209 | 209 | $ARGS1['length'] = $length; |
210 | 210 | $ARGS1['start'] = $start; |
211 | 211 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | " JOIN `##media_file` USING (m_id, m_file)" . |
239 | 239 | " WHERE (multimedia_file_refn LIKE 'http://%' OR multimedia_file_refn LIKE 'https://%')" . |
240 | 240 | " AND (multimedia_file_refn LIKE CONCAT('%', :search_1, '%') OR descriptive_title LIKE CONCAT('%', :search_2, '%'))"; |
241 | - $ARGS1 = [ |
|
241 | + $ARGS1 = [ |
|
242 | 242 | 'search_1' => Database::escapeLike($search), |
243 | 243 | 'search_2' => Database::escapeLike($search), |
244 | 244 | ]; |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | } |
275 | 275 | |
276 | 276 | if ($length > 0) { |
277 | - $SELECT1 .= " LIMIT :length OFFSET :start"; |
|
277 | + $SELECT1 .= " LIMIT :length OFFSET :start"; |
|
278 | 278 | $ARGS1['length'] = $length; |
279 | 279 | $ARGS1['start'] = $start; |
280 | 280 | } |
@@ -193,7 +193,7 @@ |
||
193 | 193 | |
194 | 194 | // Username already exists |
195 | 195 | if (User::findByUserName($username) !== null) { |
196 | - throw new Exception(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.'.$username)); |
|
196 | + throw new Exception(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.' . $username)); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | // Email already exists |
@@ -975,8 +975,8 @@ |
||
975 | 975 | // For backwards compatibility with webtrees 1.x we store the two calendar formats in one variable |
976 | 976 | // e.g. "gregorian_and_jewish" |
977 | 977 | $tree->setPreference('CALENDAR_FORMAT', implode('_and_', array_unique([ |
978 | - $request->get('CALENDAR_FORMAT0', 'none'), |
|
979 | - $request->get('CALENDAR_FORMAT1', 'none'), |
|
978 | + $request->get('CALENDAR_FORMAT0', 'none'), |
|
979 | + $request->get('CALENDAR_FORMAT1', 'none'), |
|
980 | 980 | ]))); |
981 | 981 | $tree->setPreference('CHART_BOX_TAGS', implode(',', $request->get('CHART_BOX_TAGS', []))); |
982 | 982 | $tree->setPreference('CONTACT_USER_ID', $request->get('CONTACT_USER_ID')); |
@@ -46,7 +46,7 @@ |
||
46 | 46 | <select name="tree_name" class="form-control" id="import-server-file"> |
47 | 47 | <option value=""></option> |
48 | 48 | <?php foreach ($gedcom_files as $gedcom_file): ?> |
49 | - <option value="<?= e($gedcom_file) ?>" <?= $gedcom_file === $default_gedcom_file? 'selected' : '' ?>> |
|
49 | + <option value="<?= e($gedcom_file) ?>" <?= $gedcom_file === $default_gedcom_file ? 'selected' : '' ?>> |
|
50 | 50 | <?= e($gedcom_file) ?> |
51 | 51 | </option> |
52 | 52 | <?php endforeach ?> |
@@ -1604,7 +1604,7 @@ |
||
1604 | 1604 | $height = (int) $attrs['height']; |
1605 | 1605 | } |
1606 | 1606 | |
1607 | - $person = Individual::getInstance($id, $this->tree); |
|
1607 | + $person = Individual::getInstance($id, $this->tree); |
|
1608 | 1608 | $media_file = $person->findHighlightedMediaFile(); |
1609 | 1609 | |
1610 | 1610 | if ($media_file !== null && $media_file->fileExists()) { |
@@ -255,35 +255,35 @@ discard block |
||
255 | 255 | |
256 | 256 | $args = []; |
257 | 257 | if ($search) { |
258 | - $sql .= " AND log_message LIKE CONCAT('%', :search, '%')"; |
|
258 | + $sql .= " AND log_message LIKE CONCAT('%', :search, '%')"; |
|
259 | 259 | $args['search'] = $search; |
260 | 260 | } |
261 | 261 | if ($from) { |
262 | - $sql .= " AND log_time >= :from"; |
|
262 | + $sql .= " AND log_time >= :from"; |
|
263 | 263 | $args['from'] = $from; |
264 | 264 | } |
265 | 265 | if ($to) { |
266 | - $sql .= " AND log_time < TIMESTAMPADD(DAY, 1 , :to)"; // before end of the day |
|
266 | + $sql .= " AND log_time < TIMESTAMPADD(DAY, 1 , :to)"; // before end of the day |
|
267 | 267 | $args['to'] = $to; |
268 | 268 | } |
269 | 269 | if ($type) { |
270 | - $sql .= " AND log_type = :type"; |
|
270 | + $sql .= " AND log_type = :type"; |
|
271 | 271 | $args['type'] = $type; |
272 | 272 | } |
273 | 273 | if ($text) { |
274 | - $sql .= " AND log_message LIKE CONCAT('%', :text, '%')"; |
|
274 | + $sql .= " AND log_message LIKE CONCAT('%', :text, '%')"; |
|
275 | 275 | $args['text'] = $text; |
276 | 276 | } |
277 | 277 | if ($ip) { |
278 | - $sql .= " AND ip_address LIKE CONCAT('%', :ip, '%')"; |
|
278 | + $sql .= " AND ip_address LIKE CONCAT('%', :ip, '%')"; |
|
279 | 279 | $args['ip'] = $ip; |
280 | 280 | } |
281 | 281 | if ($username) { |
282 | - $sql .= " AND user_name LIKE CONCAT('%', :user, '%')"; |
|
282 | + $sql .= " AND user_name LIKE CONCAT('%', :user, '%')"; |
|
283 | 283 | $args['user'] = $username; |
284 | 284 | } |
285 | 285 | if ($gedc) { |
286 | - $sql .= " AND gedcom_name = :gedc"; |
|
286 | + $sql .= " AND gedcom_name = :gedc"; |
|
287 | 287 | $args['gedc'] = $gedc; |
288 | 288 | } |
289 | 289 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | } |
310 | 310 | |
311 | 311 | if ($length) { |
312 | - $sql .= " LIMIT :limit OFFSET :offset"; |
|
312 | + $sql .= " LIMIT :limit OFFSET :offset"; |
|
313 | 313 | $args['limit'] = $length; |
314 | 314 | $args['offset'] = $start; |
315 | 315 | } |
@@ -361,35 +361,35 @@ discard block |
||
361 | 361 | |
362 | 362 | $args = []; |
363 | 363 | if ($search) { |
364 | - $sql .= " AND log_message LIKE CONCAT('%', :search, '%')"; |
|
364 | + $sql .= " AND log_message LIKE CONCAT('%', :search, '%')"; |
|
365 | 365 | $args['search'] = $search; |
366 | 366 | } |
367 | 367 | if ($from) { |
368 | - $sql .= " AND log_time >= :from"; |
|
368 | + $sql .= " AND log_time >= :from"; |
|
369 | 369 | $args['from'] = $from; |
370 | 370 | } |
371 | 371 | if ($to) { |
372 | - $sql .= " AND log_time < TIMESTAMPADD(DAY, 1 , :to)"; // before end of the day |
|
372 | + $sql .= " AND log_time < TIMESTAMPADD(DAY, 1 , :to)"; // before end of the day |
|
373 | 373 | $args['to'] = $to; |
374 | 374 | } |
375 | 375 | if ($type) { |
376 | - $sql .= " AND log_type = :type"; |
|
376 | + $sql .= " AND log_type = :type"; |
|
377 | 377 | $args['type'] = $type; |
378 | 378 | } |
379 | 379 | if ($text) { |
380 | - $sql .= " AND log_message LIKE CONCAT('%', :text, '%')"; |
|
380 | + $sql .= " AND log_message LIKE CONCAT('%', :text, '%')"; |
|
381 | 381 | $args['text'] = $text; |
382 | 382 | } |
383 | 383 | if ($ip) { |
384 | - $sql .= " AND ip_address LIKE CONCAT('%', :ip, '%')"; |
|
384 | + $sql .= " AND ip_address LIKE CONCAT('%', :ip, '%')"; |
|
385 | 385 | $args['ip'] = $ip; |
386 | 386 | } |
387 | 387 | if ($username) { |
388 | - $sql .= " AND user_name LIKE CONCAT('%', :user, '%')"; |
|
388 | + $sql .= " AND user_name LIKE CONCAT('%', :user, '%')"; |
|
389 | 389 | $args['user'] = $username; |
390 | 390 | } |
391 | 391 | if ($gedc) { |
392 | - $sql .= " AND gedcom_name = :gedc"; |
|
392 | + $sql .= " AND gedcom_name = :gedc"; |
|
393 | 393 | $args['gedc'] = $gedc; |
394 | 394 | } |
395 | 395 | |
@@ -421,37 +421,37 @@ discard block |
||
421 | 421 | |
422 | 422 | $args = []; |
423 | 423 | if ($from) { |
424 | - $sql .= " AND log_time >= :from"; |
|
424 | + $sql .= " AND log_time >= :from"; |
|
425 | 425 | $args['from'] = $from; |
426 | 426 | } |
427 | 427 | if ($to) { |
428 | - $sql .= " AND log_time < TIMESTAMPADD(DAY, 1 , :to)"; // before end of the day |
|
428 | + $sql .= " AND log_time < TIMESTAMPADD(DAY, 1 , :to)"; // before end of the day |
|
429 | 429 | $args['to'] = $to; |
430 | 430 | } |
431 | 431 | if ($type) { |
432 | - $sql .= " AND log_type = :type"; |
|
432 | + $sql .= " AND log_type = :type"; |
|
433 | 433 | $args['type'] = $type; |
434 | 434 | } |
435 | 435 | if ($text) { |
436 | - $sql .= " AND log_message LIKE CONCAT('%', :text, '%')"; |
|
436 | + $sql .= " AND log_message LIKE CONCAT('%', :text, '%')"; |
|
437 | 437 | $args['text'] = $text; |
438 | 438 | } |
439 | 439 | if ($ip) { |
440 | - $sql .= " AND ip_address LIKE CONCAT('%', :ip, '%')"; |
|
440 | + $sql .= " AND ip_address LIKE CONCAT('%', :ip, '%')"; |
|
441 | 441 | $args['ip'] = $ip; |
442 | 442 | } |
443 | 443 | if ($username) { |
444 | - $sql .= " AND user_name LIKE CONCAT('%', :user, '%')"; |
|
444 | + $sql .= " AND user_name LIKE CONCAT('%', :user, '%')"; |
|
445 | 445 | $args['user'] = $username; |
446 | 446 | } |
447 | 447 | if ($gedc) { |
448 | - $sql .= " AND gedcom_name = :gedc"; |
|
448 | + $sql .= " AND gedcom_name = :gedc"; |
|
449 | 449 | $args['gedc'] = $gedc; |
450 | 450 | } |
451 | 451 | |
452 | 452 | $sql .= " ORDER BY log_id"; |
453 | 453 | |
454 | - $rows = Database::prepare($sql )->execute($args)->fetchAll(); |
|
454 | + $rows = Database::prepare($sql)->execute($args)->fetchAll(); |
|
455 | 455 | |
456 | 456 | $data = ''; |
457 | 457 |
@@ -165,7 +165,7 @@ |
||
165 | 165 | public function getFileAction(Request $request): Response { |
166 | 166 | $file = $request->get('file', ''); |
167 | 167 | |
168 | - if (!preg_match('/^(\d+)-([imnrs])-(\d+)$/', $file, $match)) { |
|
168 | + if (!preg_match('/^(\d+)-([imnrs])-(\d+)$/', $file, $match)) { |
|
169 | 169 | throw new NotFoundHttpException('Bad sitemap file'); |
170 | 170 | } |
171 | 171 |
@@ -165,7 +165,7 @@ |
||
165 | 165 | public function getFileAction(Request $request): Response { |
166 | 166 | $file = $request->get('file', ''); |
167 | 167 | |
168 | - if (!preg_match('/^(\d+)-([imnrs])-(\d+)$/', $file, $match)) { |
|
168 | + if (!preg_match('/^(\d+)-([imnrs])-(\d+)$/', $file, $match)) { |
|
169 | 169 | throw new NotFoundHttpException('Bad sitemap file'); |
170 | 170 | } |
171 | 171 |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | // Create a source, to indicate the source of the data. |
233 | 233 | $filetext .= "0 @WEBTREES@ SOUR\n1 TITL " . WT_BASE_URL . "\n"; |
234 | - $author = User::find($tree->getPreference('CONTACT_EMAIL')); |
|
234 | + $author = User::find($tree->getPreference('CONTACT_EMAIL')); |
|
235 | 235 | if ($author !== null) { |
236 | 236 | $filetext .= '1 AUTH ' . $author->getRealName() . "\n"; |
237 | 237 | } |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | |
609 | 609 | $xref = $request->get('xref'); |
610 | 610 | |
611 | - $media = Media::getInstance($xref, $tree); |
|
611 | + $media = Media::getInstance($xref, $tree); |
|
612 | 612 | |
613 | 613 | if ($media === null) { |
614 | 614 | throw new NotFoundHttpException; |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | /** @var Tree $tree */ |
650 | 650 | $tree = $request->attributes->get('tree'); |
651 | 651 | |
652 | - $xref = $request->get('xref'); |
|
652 | + $xref = $request->get('xref'); |
|
653 | 653 | |
654 | 654 | $media = Media::getInstance($xref, $tree); |
655 | 655 | |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | |
674 | 674 | $xref = $request->get('xref'); |
675 | 675 | |
676 | - $note = Note::getInstance($xref, $tree); |
|
676 | + $note = Note::getInstance($xref, $tree); |
|
677 | 677 | |
678 | 678 | if ($note === null) { |
679 | 679 | throw new NotFoundHttpException; |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | /** @var Tree $tree */ |
715 | 715 | $tree = $request->attributes->get('tree'); |
716 | 716 | |
717 | - $xref = $request->get('xref'); |
|
717 | + $xref = $request->get('xref'); |
|
718 | 718 | |
719 | 719 | $note = Note::getInstance($xref, $tree); |
720 | 720 | |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | |
739 | 739 | $xref = $request->get('xref'); |
740 | 740 | |
741 | - $repository = Repository::getInstance($xref, $tree); |
|
741 | + $repository = Repository::getInstance($xref, $tree); |
|
742 | 742 | |
743 | 743 | if ($repository === null) { |
744 | 744 | throw new NotFoundHttpException; |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | /** @var Tree $tree */ |
780 | 780 | $tree = $request->attributes->get('tree'); |
781 | 781 | |
782 | - $xref = $request->get('xref'); |
|
782 | + $xref = $request->get('xref'); |
|
783 | 783 | |
784 | 784 | $repository = Repository::getInstance($xref, $tree); |
785 | 785 | |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | |
804 | 804 | $xref = $request->get('xref'); |
805 | 805 | |
806 | - $source = Source::getInstance($xref, $tree); |
|
806 | + $source = Source::getInstance($xref, $tree); |
|
807 | 807 | |
808 | 808 | if ($source === null) { |
809 | 809 | throw new NotFoundHttpException; |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | $records = array_filter($records); |
890 | 890 | |
891 | 891 | // Group and sort. |
892 | - uasort($records, function(GedcomRecord $x, GedcomRecord $y) { |
|
892 | + uasort($records, function (GedcomRecord $x, GedcomRecord $y) { |
|
893 | 893 | return $x::RECORD_TYPE <=> $y::RECORD_TYPE ?: GedcomRecord::compare($x, $y); |
894 | 894 | }); |
895 | 895 |
@@ -93,7 +93,7 @@ |
||
93 | 93 | echo view('cards/add-source-citation', [ |
94 | 94 | 'level' => 2, |
95 | 95 | 'full_citations' => $controller->tree()->getPreference('FULL_SOURCES'), |
96 | - ]); } |
|
96 | + ]); } |
|
97 | 97 | if ($level1type !== 'OBJE') { |
98 | 98 | if ($controller->tree()->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($controller->tree())) { |
99 | 99 | echo view('cards/add-media-object', [ |
@@ -30,47 +30,47 @@ discard block |
||
30 | 30 | $controller = new PageController; |
31 | 31 | |
32 | 32 | switch ($action) { |
33 | -case 'edit': |
|
34 | - ////////////////////////////////////////////////////////////////////////////// |
|
35 | - // Edit a fact |
|
36 | - ////////////////////////////////////////////////////////////////////////////// |
|
37 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
38 | - $fact_id = Filter::get('fact_id'); |
|
39 | - |
|
40 | - $record = GedcomRecord::getInstance($xref, $controller->tree()); |
|
41 | - check_record_access($record); |
|
42 | - |
|
43 | - // Find the fact to edit |
|
44 | - $edit_fact = null; |
|
45 | - foreach ($record->getFacts() as $fact) { |
|
46 | - if ($fact->getFactId() === $fact_id && $fact->canEdit()) { |
|
47 | - $edit_fact = $fact; |
|
33 | + case 'edit': |
|
34 | + ////////////////////////////////////////////////////////////////////////////// |
|
35 | + // Edit a fact |
|
36 | + ////////////////////////////////////////////////////////////////////////////// |
|
37 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
38 | + $fact_id = Filter::get('fact_id'); |
|
39 | + |
|
40 | + $record = GedcomRecord::getInstance($xref, $controller->tree()); |
|
41 | + check_record_access($record); |
|
42 | + |
|
43 | + // Find the fact to edit |
|
44 | + $edit_fact = null; |
|
45 | + foreach ($record->getFacts() as $fact) { |
|
46 | + if ($fact->getFactId() === $fact_id && $fact->canEdit()) { |
|
47 | + $edit_fact = $fact; |
|
48 | + break; |
|
49 | + } |
|
50 | + } |
|
51 | + if (!$edit_fact) { |
|
52 | + header('Location: ' . $record->url()); |
|
48 | 53 | break; |
49 | 54 | } |
50 | - } |
|
51 | - if (!$edit_fact) { |
|
52 | - header('Location: ' . $record->url()); |
|
53 | - break; |
|
54 | - } |
|
55 | 55 | |
56 | - $controller |
|
57 | - ->setPageTitle($record->getFullName() . ' - ' . GedcomTag::getLabel($edit_fact->getTag())) |
|
58 | - ->pageHeader(); |
|
59 | - |
|
60 | - echo '<h2>', $controller->getPageTitle(), '</h2>'; |
|
61 | - FunctionsPrint::initializeCalendarPopup(); |
|
62 | - echo '<form name="editform" method="post" enctype="multipart/form-data">'; |
|
63 | - echo '<input type="hidden" name="ged" value="', e($controller->tree()->getName()), '">'; |
|
64 | - echo '<input type="hidden" name="action" value="update">'; |
|
65 | - echo '<input type="hidden" name="fact_id" value="', $fact_id, '">'; |
|
66 | - echo '<input type="hidden" name="xref" value="', $xref, '">'; |
|
67 | - echo '<input type="hidden" name="prev_action" value="edit">'; |
|
68 | - echo Filter::getCsrf(); |
|
69 | - FunctionsEdit::createEditForm($edit_fact); |
|
70 | - echo keep_chan($record); |
|
71 | - |
|
72 | - $level1type = $edit_fact->getTag(); |
|
73 | - switch ($record::RECORD_TYPE) { |
|
56 | + $controller |
|
57 | + ->setPageTitle($record->getFullName() . ' - ' . GedcomTag::getLabel($edit_fact->getTag())) |
|
58 | + ->pageHeader(); |
|
59 | + |
|
60 | + echo '<h2>', $controller->getPageTitle(), '</h2>'; |
|
61 | + FunctionsPrint::initializeCalendarPopup(); |
|
62 | + echo '<form name="editform" method="post" enctype="multipart/form-data">'; |
|
63 | + echo '<input type="hidden" name="ged" value="', e($controller->tree()->getName()), '">'; |
|
64 | + echo '<input type="hidden" name="action" value="update">'; |
|
65 | + echo '<input type="hidden" name="fact_id" value="', $fact_id, '">'; |
|
66 | + echo '<input type="hidden" name="xref" value="', $xref, '">'; |
|
67 | + echo '<input type="hidden" name="prev_action" value="edit">'; |
|
68 | + echo Filter::getCsrf(); |
|
69 | + FunctionsEdit::createEditForm($edit_fact); |
|
70 | + echo keep_chan($record); |
|
71 | + |
|
72 | + $level1type = $edit_fact->getTag(); |
|
73 | + switch ($record::RECORD_TYPE) { |
|
74 | 74 | case 'REPO': |
75 | 75 | // REPO:NAME facts may take a NOTE (but the REPO record may not). |
76 | 76 | if ($level1type === 'NAME') { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | default: |
128 | 128 | // Other types of record do not have these lower-level records |
129 | 129 | break; |
130 | - } |
|
130 | + } |
|
131 | 131 | |
132 | 132 | ?> |
133 | 133 | <div class="row form-group"> |
@@ -156,518 +156,518 @@ discard block |
||
156 | 156 | echo view('modals/ajax'); |
157 | 157 | break; |
158 | 158 | |
159 | -case 'add': |
|
160 | - ////////////////////////////////////////////////////////////////////////////// |
|
161 | - // Add a new fact |
|
162 | - ////////////////////////////////////////////////////////////////////////////// |
|
163 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
164 | - $fact = Filter::get('fact', WT_REGEX_TAG); |
|
165 | - |
|
166 | - $record = GedcomRecord::getInstance($xref, $controller->tree()); |
|
167 | - check_record_access($record); |
|
168 | - |
|
169 | - $controller |
|
170 | - ->setPageTitle($record->getFullName() . ' - ' . GedcomTag::getLabel($fact, $record)) |
|
171 | - ->pageHeader(); |
|
172 | - |
|
173 | - $level0type = $record::RECORD_TYPE; |
|
174 | - |
|
175 | - echo '<h2>', $controller->getPageTitle(), '</h2>'; |
|
176 | - |
|
177 | - FunctionsPrint::initializeCalendarPopup(); |
|
178 | - echo '<form name="addform" method="post" enctype="multipart/form-data">'; |
|
179 | - echo '<input type="hidden" name="ged" value="', e($controller->tree()->getName()), '">'; |
|
180 | - echo '<input type="hidden" name="action" value="update">'; |
|
181 | - echo '<input type="hidden" name="xref" value="', $xref, '">'; |
|
182 | - echo '<input type="hidden" name="prev_action" value="add">'; |
|
183 | - echo '<input type="hidden" name="fact_type" value="' . $fact . '">'; |
|
184 | - echo Filter::getCsrf(); |
|
185 | - FunctionsEdit::createAddForm($fact); |
|
186 | - echo keep_chan($record); |
|
187 | - |
|
188 | - // Genealogical facts (e.g. for INDI and FAM records) can have 2 SOUR/NOTE/OBJE/ASSO/RESN ... |
|
189 | - if ($level0type === 'INDI' || $level0type === 'FAM') { |
|
190 | - // ... but not facts which are simply links to other records |
|
191 | - if ($fact !== 'OBJE' && $fact !== 'NOTE' && $fact !== 'SHARED_NOTE' && $fact !== 'REPO' && $fact !== 'SOUR' && $fact !== 'SUBM' && $fact !== 'ASSO' && $fact !== 'ALIA' && $fact !== 'SEX') { |
|
192 | - echo view('cards/add-source-citation', [ |
|
193 | - 'level' => 2, |
|
194 | - 'full_citations' => $controller->tree()->getPreference('FULL_SOURCES'), |
|
195 | - ]); |
|
196 | - if ($controller->tree()->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($controller->tree())) { |
|
197 | - echo view('cards/add-media-object', [ |
|
198 | - 'level' => 2, |
|
199 | - ]); |
|
200 | - } |
|
201 | - // Don’t add notes to notes! |
|
202 | - if ($fact !== 'NOTE') { |
|
203 | - echo view('cards/add-note', [ |
|
204 | - 'level' => 2, |
|
159 | + case 'add': |
|
160 | + ////////////////////////////////////////////////////////////////////////////// |
|
161 | + // Add a new fact |
|
162 | + ////////////////////////////////////////////////////////////////////////////// |
|
163 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
164 | + $fact = Filter::get('fact', WT_REGEX_TAG); |
|
165 | + |
|
166 | + $record = GedcomRecord::getInstance($xref, $controller->tree()); |
|
167 | + check_record_access($record); |
|
168 | + |
|
169 | + $controller |
|
170 | + ->setPageTitle($record->getFullName() . ' - ' . GedcomTag::getLabel($fact, $record)) |
|
171 | + ->pageHeader(); |
|
172 | + |
|
173 | + $level0type = $record::RECORD_TYPE; |
|
174 | + |
|
175 | + echo '<h2>', $controller->getPageTitle(), '</h2>'; |
|
176 | + |
|
177 | + FunctionsPrint::initializeCalendarPopup(); |
|
178 | + echo '<form name="addform" method="post" enctype="multipart/form-data">'; |
|
179 | + echo '<input type="hidden" name="ged" value="', e($controller->tree()->getName()), '">'; |
|
180 | + echo '<input type="hidden" name="action" value="update">'; |
|
181 | + echo '<input type="hidden" name="xref" value="', $xref, '">'; |
|
182 | + echo '<input type="hidden" name="prev_action" value="add">'; |
|
183 | + echo '<input type="hidden" name="fact_type" value="' . $fact . '">'; |
|
184 | + echo Filter::getCsrf(); |
|
185 | + FunctionsEdit::createAddForm($fact); |
|
186 | + echo keep_chan($record); |
|
187 | + |
|
188 | + // Genealogical facts (e.g. for INDI and FAM records) can have 2 SOUR/NOTE/OBJE/ASSO/RESN ... |
|
189 | + if ($level0type === 'INDI' || $level0type === 'FAM') { |
|
190 | + // ... but not facts which are simply links to other records |
|
191 | + if ($fact !== 'OBJE' && $fact !== 'NOTE' && $fact !== 'SHARED_NOTE' && $fact !== 'REPO' && $fact !== 'SOUR' && $fact !== 'SUBM' && $fact !== 'ASSO' && $fact !== 'ALIA' && $fact !== 'SEX') { |
|
192 | + echo view('cards/add-source-citation', [ |
|
193 | + 'level' => 2, |
|
194 | + 'full_citations' => $controller->tree()->getPreference('FULL_SOURCES'), |
|
205 | 195 | ]); |
206 | - echo view('cards/add-shared-note', [ |
|
207 | - 'level' => 2, |
|
208 | - ]); |
|
209 | - } |
|
210 | - echo view('cards/add-associate', [ |
|
211 | - 'id' => Uuid::uuid4()->toString(), |
|
212 | - 'level' => 2, |
|
213 | - ]); |
|
214 | - // allow to add godfather and godmother for CHR fact or best man and bridesmaid for MARR fact in one window |
|
215 | - if (in_array($fact, Config::twoAssociates())) { |
|
196 | + if ($controller->tree()->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($controller->tree())) { |
|
197 | + echo view('cards/add-media-object', [ |
|
198 | + 'level' => 2, |
|
199 | + ]); |
|
200 | + } |
|
201 | + // Don’t add notes to notes! |
|
202 | + if ($fact !== 'NOTE') { |
|
203 | + echo view('cards/add-note', [ |
|
204 | + 'level' => 2, |
|
205 | + ]); |
|
206 | + echo view('cards/add-shared-note', [ |
|
207 | + 'level' => 2, |
|
208 | + ]); |
|
209 | + } |
|
216 | 210 | echo view('cards/add-associate', [ |
217 | 211 | 'id' => Uuid::uuid4()->toString(), |
218 | 212 | 'level' => 2, |
219 | 213 | ]); |
214 | + // allow to add godfather and godmother for CHR fact or best man and bridesmaid for MARR fact in one window |
|
215 | + if (in_array($fact, Config::twoAssociates())) { |
|
216 | + echo view('cards/add-associate', [ |
|
217 | + 'id' => Uuid::uuid4()->toString(), |
|
218 | + 'level' => 2, |
|
219 | + ]); |
|
220 | + } |
|
221 | + echo view('cards/add-restriction', [ |
|
222 | + 'level' => 2, |
|
223 | + ]); |
|
220 | 224 | } |
221 | - echo view('cards/add-restriction', [ |
|
222 | - 'level' => 2, |
|
223 | - ]); |
|
224 | 225 | } |
225 | - } |
|
226 | - ?> |
|
226 | + ?> |
|
227 | 227 | <div class="row form-group"> |
228 | 228 | <div class="col-sm-9 offset-sm-3"> |
229 | 229 | <button class="btn btn-primary" type="submit"> |
230 | 230 | <?= FontAwesome::decorativeIcon('save') ?> |
231 | - <?= /* I18N: A button label. */ |
|
232 | - I18N::translate('save') ?> |
|
231 | + <?= /* I18N: A button label. */ |
|
232 | + I18N::translate('save') ?> |
|
233 | 233 | </button> |
234 | 234 | <a class="btn btn-secondary" href="<?= e($record->url()) ?>"> |
235 | 235 | <?= FontAwesome::decorativeIcon('cancel') ?> |
236 | - <?= /* I18N: A button label. */ |
|
237 | - I18N::translate('cancel') ?> |
|
236 | + <?= /* I18N: A button label. */ |
|
237 | + I18N::translate('cancel') ?> |
|
238 | 238 | </a> |
239 | 239 | </div> |
240 | 240 | </div> |
241 | 241 | </form> |
242 | 242 | <?php |
243 | - echo view('modals/on-screen-keyboard'); |
|
244 | - echo view('modals/ajax'); |
|
243 | + echo view('modals/on-screen-keyboard'); |
|
244 | + echo view('modals/ajax'); |
|
245 | 245 | |
246 | - break; |
|
246 | + break; |
|
247 | 247 | |
248 | -case 'update': |
|
249 | - ////////////////////////////////////////////////////////////////////////////// |
|
250 | - // Save a new/updated fact |
|
251 | - ////////////////////////////////////////////////////////////////////////////// |
|
252 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
253 | - $fact_id = Filter::post('fact_id'); |
|
254 | - $keep_chan = Filter::postBool('keep_chan'); |
|
255 | - |
|
256 | - $record = GedcomRecord::getInstance($xref, $controller->tree()); |
|
257 | - check_record_access($record); |
|
258 | - |
|
259 | - // Arrays for each GEDCOM line |
|
260 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
261 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
262 | - $text = Filter::postArray('text'); |
|
263 | - $islink = Filter::postArray('islink', '[01]'); |
|
264 | - |
|
265 | - // If the fact has a DATE or PLAC, then delete any value of Y |
|
266 | - if ($text[0] === 'Y') { |
|
267 | - foreach ($tag as $n => $value) { |
|
268 | - if ($glevels[$n] == 2 && ($value === 'DATE' || $value === 'PLAC') && $text[$n] !== '') { |
|
269 | - $text[0] = ''; |
|
270 | - break; |
|
248 | + case 'update': |
|
249 | + ////////////////////////////////////////////////////////////////////////////// |
|
250 | + // Save a new/updated fact |
|
251 | + ////////////////////////////////////////////////////////////////////////////// |
|
252 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
253 | + $fact_id = Filter::post('fact_id'); |
|
254 | + $keep_chan = Filter::postBool('keep_chan'); |
|
255 | + |
|
256 | + $record = GedcomRecord::getInstance($xref, $controller->tree()); |
|
257 | + check_record_access($record); |
|
258 | + |
|
259 | + // Arrays for each GEDCOM line |
|
260 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
261 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
262 | + $text = Filter::postArray('text'); |
|
263 | + $islink = Filter::postArray('islink', '[01]'); |
|
264 | + |
|
265 | + // If the fact has a DATE or PLAC, then delete any value of Y |
|
266 | + if ($text[0] === 'Y') { |
|
267 | + foreach ($tag as $n => $value) { |
|
268 | + if ($glevels[$n] == 2 && ($value === 'DATE' || $value === 'PLAC') && $text[$n] !== '') { |
|
269 | + $text[0] = ''; |
|
270 | + break; |
|
271 | + } |
|
271 | 272 | } |
272 | 273 | } |
273 | - } |
|
274 | 274 | |
275 | - $newged = ''; |
|
276 | - if (!empty($_POST['NAME'])) { |
|
277 | - $newged .= "\n1 NAME " . $_POST['NAME']; |
|
278 | - $name_facts = ['TYPE', 'NPFX', 'GIVN', 'NICK', 'SPFX', 'SURN', 'NSFX']; |
|
279 | - foreach ($name_facts as $name_fact) { |
|
280 | - if (!empty($_POST[$name_fact])) { |
|
281 | - $newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact]; |
|
275 | + $newged = ''; |
|
276 | + if (!empty($_POST['NAME'])) { |
|
277 | + $newged .= "\n1 NAME " . $_POST['NAME']; |
|
278 | + $name_facts = ['TYPE', 'NPFX', 'GIVN', 'NICK', 'SPFX', 'SURN', 'NSFX']; |
|
279 | + foreach ($name_facts as $name_fact) { |
|
280 | + if (!empty($_POST[$name_fact])) { |
|
281 | + $newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact]; |
|
282 | + } |
|
282 | 283 | } |
283 | 284 | } |
284 | - } |
|
285 | 285 | |
286 | - if (isset($_POST['NOTE'])) { |
|
287 | - $NOTE = $_POST['NOTE']; |
|
288 | - } |
|
289 | - if (!empty($NOTE)) { |
|
290 | - $tempnote = preg_split('/\r?\n/', trim($NOTE) . "\n"); // make sure only one line ending on the end |
|
291 | - $title[] = '0 @' . $xref . '@ NOTE ' . array_shift($tempnote); |
|
292 | - foreach ($tempnote as &$line) { |
|
293 | - $line = trim('1 CONT ' . $line, ' '); |
|
286 | + if (isset($_POST['NOTE'])) { |
|
287 | + $NOTE = $_POST['NOTE']; |
|
288 | + } |
|
289 | + if (!empty($NOTE)) { |
|
290 | + $tempnote = preg_split('/\r?\n/', trim($NOTE) . "\n"); // make sure only one line ending on the end |
|
291 | + $title[] = '0 @' . $xref . '@ NOTE ' . array_shift($tempnote); |
|
292 | + foreach ($tempnote as &$line) { |
|
293 | + $line = trim('1 CONT ' . $line, ' '); |
|
294 | + } |
|
294 | 295 | } |
295 | - } |
|
296 | 296 | |
297 | - $newged = FunctionsEdit::handleUpdates($newged); |
|
297 | + $newged = FunctionsEdit::handleUpdates($newged); |
|
298 | 298 | |
299 | - // Add new names after existing names |
|
300 | - if (!empty($_POST['NAME'])) { |
|
301 | - preg_match_all('/[_0-9A-Z]+/', $controller->tree()->getPreference('ADVANCED_NAME_FACTS'), $match); |
|
302 | - $name_facts = array_unique(array_merge(['_MARNM'], $match[0])); |
|
303 | - foreach ($name_facts as $name_fact) { |
|
304 | - // Ignore advanced facts that duplicate standard facts. |
|
305 | - if (!in_array($name_fact, ['TYPE', 'NPFX', 'GIVN', 'NICK', 'SPFX', 'SURN', 'NSFX']) && !empty($_POST[$name_fact])) { |
|
306 | - $newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact]; |
|
299 | + // Add new names after existing names |
|
300 | + if (!empty($_POST['NAME'])) { |
|
301 | + preg_match_all('/[_0-9A-Z]+/', $controller->tree()->getPreference('ADVANCED_NAME_FACTS'), $match); |
|
302 | + $name_facts = array_unique(array_merge(['_MARNM'], $match[0])); |
|
303 | + foreach ($name_facts as $name_fact) { |
|
304 | + // Ignore advanced facts that duplicate standard facts. |
|
305 | + if (!in_array($name_fact, ['TYPE', 'NPFX', 'GIVN', 'NICK', 'SPFX', 'SURN', 'NSFX']) && !empty($_POST[$name_fact])) { |
|
306 | + $newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact]; |
|
307 | + } |
|
307 | 308 | } |
308 | 309 | } |
309 | - } |
|
310 | 310 | |
311 | - $newged = substr($newged, 1); // Remove leading newline |
|
311 | + $newged = substr($newged, 1); // Remove leading newline |
|
312 | 312 | |
313 | - /** @var CensusAssistantModule $census_assistant */ |
|
314 | - $census_assistant = Module::getModuleByName('GEDFact_assistant'); |
|
315 | - if ($census_assistant !== null && $record instanceof Individual) { |
|
316 | - $newged = $census_assistant->updateCensusAssistant($record, $fact_id, $newged, $keep_chan); |
|
317 | - } |
|
313 | + /** @var CensusAssistantModule $census_assistant */ |
|
314 | + $census_assistant = Module::getModuleByName('GEDFact_assistant'); |
|
315 | + if ($census_assistant !== null && $record instanceof Individual) { |
|
316 | + $newged = $census_assistant->updateCensusAssistant($record, $fact_id, $newged, $keep_chan); |
|
317 | + } |
|
318 | 318 | |
319 | - $record->updateFact($fact_id, $newged, !$keep_chan); |
|
319 | + $record->updateFact($fact_id, $newged, !$keep_chan); |
|
320 | 320 | |
321 | - // For the GEDFact_assistant module |
|
322 | - $pid_array = Filter::post('pid_array'); |
|
323 | - if ($pid_array) { |
|
324 | - foreach (explode(',', $pid_array) as $pid) { |
|
325 | - if ($pid !== $xref) { |
|
326 | - $indi = Individual::getInstance($pid, $controller->tree()); |
|
327 | - if ($indi && $indi->canEdit()) { |
|
328 | - $indi->updateFact($fact_id, $newged, !$keep_chan); |
|
321 | + // For the GEDFact_assistant module |
|
322 | + $pid_array = Filter::post('pid_array'); |
|
323 | + if ($pid_array) { |
|
324 | + foreach (explode(',', $pid_array) as $pid) { |
|
325 | + if ($pid !== $xref) { |
|
326 | + $indi = Individual::getInstance($pid, $controller->tree()); |
|
327 | + if ($indi && $indi->canEdit()) { |
|
328 | + $indi->updateFact($fact_id, $newged, !$keep_chan); |
|
329 | + } |
|
329 | 330 | } |
330 | 331 | } |
331 | 332 | } |
332 | - } |
|
333 | 333 | |
334 | - header('Location: ' . $record->url()); |
|
335 | - break; |
|
334 | + header('Location: ' . $record->url()); |
|
335 | + break; |
|
336 | 336 | |
337 | -case 'add_child_to_family_action': |
|
338 | - ////////////////////////////////////////////////////////////////////////////// |
|
339 | - // Add a child to an existing family |
|
340 | - ////////////////////////////////////////////////////////////////////////////// |
|
341 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
342 | - $PEDI = Filter::post('PEDI'); |
|
343 | - $keep_chan = Filter::postBool('keep_chan'); |
|
344 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
345 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
346 | - $text = Filter::postArray('text'); |
|
347 | - $islink = Filter::postArray('islink', '[01]'); |
|
348 | - |
|
349 | - $family = Family::getInstance($xref, $controller->tree()); |
|
350 | - check_record_access($family); |
|
351 | - |
|
352 | - FunctionsEdit::splitSource(); |
|
353 | - $gedrec = '0 @REF@ INDI'; |
|
354 | - $gedrec .= FunctionsEdit::addNewName(); |
|
355 | - $gedrec .= FunctionsEdit::addNewSex(); |
|
356 | - if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
357 | - foreach ($matches[1] as $match) { |
|
358 | - $gedrec .= FunctionsEdit::addNewFact($match); |
|
337 | + case 'add_child_to_family_action': |
|
338 | + ////////////////////////////////////////////////////////////////////////////// |
|
339 | + // Add a child to an existing family |
|
340 | + ////////////////////////////////////////////////////////////////////////////// |
|
341 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
342 | + $PEDI = Filter::post('PEDI'); |
|
343 | + $keep_chan = Filter::postBool('keep_chan'); |
|
344 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
345 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
346 | + $text = Filter::postArray('text'); |
|
347 | + $islink = Filter::postArray('islink', '[01]'); |
|
348 | + |
|
349 | + $family = Family::getInstance($xref, $controller->tree()); |
|
350 | + check_record_access($family); |
|
351 | + |
|
352 | + FunctionsEdit::splitSource(); |
|
353 | + $gedrec = '0 @REF@ INDI'; |
|
354 | + $gedrec .= FunctionsEdit::addNewName(); |
|
355 | + $gedrec .= FunctionsEdit::addNewSex(); |
|
356 | + if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
357 | + foreach ($matches[1] as $match) { |
|
358 | + $gedrec .= FunctionsEdit::addNewFact($match); |
|
359 | + } |
|
360 | + } |
|
361 | + $gedrec .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $xref); |
|
362 | + if (Filter::postBool('SOUR_INDI')) { |
|
363 | + $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
364 | + } else { |
|
365 | + $gedrec = FunctionsEdit::updateRest($gedrec); |
|
359 | 366 | } |
360 | - } |
|
361 | - $gedrec .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $xref); |
|
362 | - if (Filter::postBool('SOUR_INDI')) { |
|
363 | - $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
364 | - } else { |
|
365 | - $gedrec = FunctionsEdit::updateRest($gedrec); |
|
366 | - } |
|
367 | 367 | |
368 | - // Create the new child |
|
369 | - $new_child = $family->getTree()->createRecord($gedrec); |
|
370 | - |
|
371 | - // Insert new child at the right place |
|
372 | - $done = false; |
|
373 | - foreach ($family->getFacts('CHIL') as $fact) { |
|
374 | - $old_child = $fact->getTarget(); |
|
375 | - if ($old_child && Date::compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate()) < 0) { |
|
376 | - // Insert before this child |
|
377 | - $family->updateFact($fact->getFactId(), '1 CHIL @' . $new_child->getXref() . "@\n" . $fact->getGedcom(), !$keep_chan); |
|
378 | - $done = true; |
|
379 | - break; |
|
368 | + // Create the new child |
|
369 | + $new_child = $family->getTree()->createRecord($gedrec); |
|
370 | + |
|
371 | + // Insert new child at the right place |
|
372 | + $done = false; |
|
373 | + foreach ($family->getFacts('CHIL') as $fact) { |
|
374 | + $old_child = $fact->getTarget(); |
|
375 | + if ($old_child && Date::compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate()) < 0) { |
|
376 | + // Insert before this child |
|
377 | + $family->updateFact($fact->getFactId(), '1 CHIL @' . $new_child->getXref() . "@\n" . $fact->getGedcom(), !$keep_chan); |
|
378 | + $done = true; |
|
379 | + break; |
|
380 | + } |
|
381 | + } |
|
382 | + if (!$done) { |
|
383 | + // Append child at end |
|
384 | + $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan); |
|
380 | 385 | } |
381 | - } |
|
382 | - if (!$done) { |
|
383 | - // Append child at end |
|
384 | - $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan); |
|
385 | - } |
|
386 | 386 | |
387 | - if (Filter::post('goto') === 'new') { |
|
388 | - header('Location: ' . $new_child->url()); |
|
389 | - } else { |
|
390 | - header('Location: ' . $family->url()); |
|
391 | - } |
|
392 | - break; |
|
387 | + if (Filter::post('goto') === 'new') { |
|
388 | + header('Location: ' . $new_child->url()); |
|
389 | + } else { |
|
390 | + header('Location: ' . $family->url()); |
|
391 | + } |
|
392 | + break; |
|
393 | 393 | |
394 | -case 'add_child_to_individual_action': |
|
395 | - ////////////////////////////////////////////////////////////////////////////// |
|
396 | - // Add a child to an existing individual (creating a one-parent family) |
|
397 | - ////////////////////////////////////////////////////////////////////////////// |
|
398 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
399 | - $PEDI = Filter::post('PEDI'); |
|
400 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
401 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
402 | - $text = Filter::postArray('text'); |
|
403 | - $islink = Filter::postArray('islink', '[01]'); |
|
404 | - |
|
405 | - $person = Individual::getInstance($xref, $controller->tree()); |
|
406 | - check_record_access($person); |
|
407 | - |
|
408 | - // Create a family |
|
409 | - if ($person->getSex() === 'F') { |
|
410 | - $gedcom = "0 @NEW@ FAM\n1 WIFE @" . $person->getXref() . '@'; |
|
411 | - } else { |
|
412 | - $gedcom = "0 @NEW@ FAM\n1 HUSB @" . $person->getXref() . '@'; |
|
413 | - } |
|
414 | - $family = $person->getTree()->createRecord($gedcom); |
|
394 | + case 'add_child_to_individual_action': |
|
395 | + ////////////////////////////////////////////////////////////////////////////// |
|
396 | + // Add a child to an existing individual (creating a one-parent family) |
|
397 | + ////////////////////////////////////////////////////////////////////////////// |
|
398 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
399 | + $PEDI = Filter::post('PEDI'); |
|
400 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
401 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
402 | + $text = Filter::postArray('text'); |
|
403 | + $islink = Filter::postArray('islink', '[01]'); |
|
404 | + |
|
405 | + $person = Individual::getInstance($xref, $controller->tree()); |
|
406 | + check_record_access($person); |
|
407 | + |
|
408 | + // Create a family |
|
409 | + if ($person->getSex() === 'F') { |
|
410 | + $gedcom = "0 @NEW@ FAM\n1 WIFE @" . $person->getXref() . '@'; |
|
411 | + } else { |
|
412 | + $gedcom = "0 @NEW@ FAM\n1 HUSB @" . $person->getXref() . '@'; |
|
413 | + } |
|
414 | + $family = $person->getTree()->createRecord($gedcom); |
|
415 | 415 | |
416 | - // Link the parent to the family |
|
417 | - $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
416 | + // Link the parent to the family |
|
417 | + $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
418 | 418 | |
419 | - // Create a child |
|
420 | - FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
419 | + // Create a child |
|
420 | + FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
421 | 421 | |
422 | - $gedcom = '0 @NEW@ INDI'; |
|
423 | - $gedcom .= FunctionsEdit::addNewName(); |
|
424 | - $gedcom .= FunctionsEdit::addNewSex(); |
|
425 | - $gedcom .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $family->getXref()); |
|
426 | - if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
427 | - foreach ($matches[1] as $match) { |
|
428 | - $gedcom .= FunctionsEdit::addNewFact($match); |
|
422 | + $gedcom = '0 @NEW@ INDI'; |
|
423 | + $gedcom .= FunctionsEdit::addNewName(); |
|
424 | + $gedcom .= FunctionsEdit::addNewSex(); |
|
425 | + $gedcom .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $family->getXref()); |
|
426 | + if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
427 | + foreach ($matches[1] as $match) { |
|
428 | + $gedcom .= FunctionsEdit::addNewFact($match); |
|
429 | + } |
|
430 | + } |
|
431 | + if (Filter::postBool('SOUR_INDI')) { |
|
432 | + $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
433 | + } else { |
|
434 | + $gedcom = FunctionsEdit::updateRest($gedcom); |
|
429 | 435 | } |
430 | - } |
|
431 | - if (Filter::postBool('SOUR_INDI')) { |
|
432 | - $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
433 | - } else { |
|
434 | - $gedcom = FunctionsEdit::updateRest($gedcom); |
|
435 | - } |
|
436 | 436 | |
437 | - $child = $person->getTree()->createRecord($gedcom); |
|
437 | + $child = $person->getTree()->createRecord($gedcom); |
|
438 | 438 | |
439 | - // Link the family to the child |
|
440 | - $family->createFact('1 CHIL @' . $child->getXref() . '@', true); |
|
439 | + // Link the family to the child |
|
440 | + $family->createFact('1 CHIL @' . $child->getXref() . '@', true); |
|
441 | 441 | |
442 | - if (Filter::post('goto') === 'new') { |
|
443 | - header('Location: ' . $child->url()); |
|
444 | - } else { |
|
445 | - header('Location: ' . $person->url()); |
|
446 | - } |
|
447 | - break; |
|
442 | + if (Filter::post('goto') === 'new') { |
|
443 | + header('Location: ' . $child->url()); |
|
444 | + } else { |
|
445 | + header('Location: ' . $person->url()); |
|
446 | + } |
|
447 | + break; |
|
448 | 448 | |
449 | -case 'add_parent_to_individual_action': |
|
450 | - ////////////////////////////////////////////////////////////////////////////// |
|
451 | - // Add a new parent to an existing individual (creating a one-parent family) |
|
452 | - ////////////////////////////////////////////////////////////////////////////// |
|
453 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
454 | - $PEDI = Filter::post('PEDI'); |
|
455 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
456 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
457 | - $text = Filter::postArray('text'); |
|
458 | - $islink = Filter::postArray('islink', '[01]'); |
|
459 | - |
|
460 | - $person = Individual::getInstance($xref, $controller->tree()); |
|
461 | - check_record_access($person); |
|
462 | - |
|
463 | - // Create a new family |
|
464 | - $gedcom = "0 @NEW@ FAM\n1 CHIL @" . $person->getXref() . '@'; |
|
465 | - $family = $person->getTree()->createRecord($gedcom); |
|
466 | - |
|
467 | - // Link the child to the family |
|
468 | - $person->createFact('1 FAMC @' . $family->getXref() . '@', true); |
|
469 | - |
|
470 | - // Create a child |
|
471 | - FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
472 | - |
|
473 | - $gedcom = '0 @NEW@ INDI'; |
|
474 | - $gedcom .= FunctionsEdit::addNewName(); |
|
475 | - $gedcom .= FunctionsEdit::addNewSex(); |
|
476 | - if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
477 | - foreach ($matches[1] as $match) { |
|
478 | - $gedcom .= FunctionsEdit::addNewFact($match); |
|
449 | + case 'add_parent_to_individual_action': |
|
450 | + ////////////////////////////////////////////////////////////////////////////// |
|
451 | + // Add a new parent to an existing individual (creating a one-parent family) |
|
452 | + ////////////////////////////////////////////////////////////////////////////// |
|
453 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
454 | + $PEDI = Filter::post('PEDI'); |
|
455 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
456 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
457 | + $text = Filter::postArray('text'); |
|
458 | + $islink = Filter::postArray('islink', '[01]'); |
|
459 | + |
|
460 | + $person = Individual::getInstance($xref, $controller->tree()); |
|
461 | + check_record_access($person); |
|
462 | + |
|
463 | + // Create a new family |
|
464 | + $gedcom = "0 @NEW@ FAM\n1 CHIL @" . $person->getXref() . '@'; |
|
465 | + $family = $person->getTree()->createRecord($gedcom); |
|
466 | + |
|
467 | + // Link the child to the family |
|
468 | + $person->createFact('1 FAMC @' . $family->getXref() . '@', true); |
|
469 | + |
|
470 | + // Create a child |
|
471 | + FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
472 | + |
|
473 | + $gedcom = '0 @NEW@ INDI'; |
|
474 | + $gedcom .= FunctionsEdit::addNewName(); |
|
475 | + $gedcom .= FunctionsEdit::addNewSex(); |
|
476 | + if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
477 | + foreach ($matches[1] as $match) { |
|
478 | + $gedcom .= FunctionsEdit::addNewFact($match); |
|
479 | + } |
|
479 | 480 | } |
480 | - } |
|
481 | - if (Filter::postBool('SOUR_INDI')) { |
|
482 | - $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
483 | - } else { |
|
484 | - $gedcom = FunctionsEdit::updateRest($gedcom); |
|
485 | - } |
|
486 | - $gedcom .= "\n1 FAMS @" . $family->getXref() . '@'; |
|
481 | + if (Filter::postBool('SOUR_INDI')) { |
|
482 | + $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
483 | + } else { |
|
484 | + $gedcom = FunctionsEdit::updateRest($gedcom); |
|
485 | + } |
|
486 | + $gedcom .= "\n1 FAMS @" . $family->getXref() . '@'; |
|
487 | 487 | |
488 | - $parent = $person->getTree()->createRecord($gedcom); |
|
488 | + $parent = $person->getTree()->createRecord($gedcom); |
|
489 | 489 | |
490 | - // Link the family to the child |
|
491 | - if ($parent->getSex() === 'F') { |
|
492 | - $family->createFact('1 WIFE @' . $parent->getXref() . '@', true); |
|
493 | - } else { |
|
494 | - $family->createFact('1 HUSB @' . $parent->getXref() . '@', true); |
|
495 | - } |
|
490 | + // Link the family to the child |
|
491 | + if ($parent->getSex() === 'F') { |
|
492 | + $family->createFact('1 WIFE @' . $parent->getXref() . '@', true); |
|
493 | + } else { |
|
494 | + $family->createFact('1 HUSB @' . $parent->getXref() . '@', true); |
|
495 | + } |
|
496 | 496 | |
497 | - if (Filter::post('goto') === 'new') { |
|
498 | - header('Location: ' . $parent->url()); |
|
499 | - } else { |
|
500 | - header('Location: ' . $person->url()); |
|
501 | - } |
|
502 | - break; |
|
497 | + if (Filter::post('goto') === 'new') { |
|
498 | + header('Location: ' . $parent->url()); |
|
499 | + } else { |
|
500 | + header('Location: ' . $person->url()); |
|
501 | + } |
|
502 | + break; |
|
503 | 503 | |
504 | -case 'add_unlinked_indi_action': |
|
505 | - ////////////////////////////////////////////////////////////////////////////// |
|
506 | - // Add a new, unlinked individual |
|
507 | - ////////////////////////////////////////////////////////////////////////////// |
|
508 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
509 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
510 | - $text = Filter::postArray('text'); |
|
511 | - $islink = Filter::postArray('islink', '[01]'); |
|
512 | - |
|
513 | - FunctionsEdit::splitSource(); |
|
514 | - $gedrec = '0 @REF@ INDI'; |
|
515 | - $gedrec .= FunctionsEdit::addNewName(); |
|
516 | - $gedrec .= FunctionsEdit::addNewSex(); |
|
517 | - if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
518 | - foreach ($matches[1] as $match) { |
|
519 | - $gedrec .= FunctionsEdit::addNewFact($match); |
|
504 | + case 'add_unlinked_indi_action': |
|
505 | + ////////////////////////////////////////////////////////////////////////////// |
|
506 | + // Add a new, unlinked individual |
|
507 | + ////////////////////////////////////////////////////////////////////////////// |
|
508 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
509 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
510 | + $text = Filter::postArray('text'); |
|
511 | + $islink = Filter::postArray('islink', '[01]'); |
|
512 | + |
|
513 | + FunctionsEdit::splitSource(); |
|
514 | + $gedrec = '0 @REF@ INDI'; |
|
515 | + $gedrec .= FunctionsEdit::addNewName(); |
|
516 | + $gedrec .= FunctionsEdit::addNewSex(); |
|
517 | + if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
518 | + foreach ($matches[1] as $match) { |
|
519 | + $gedrec .= FunctionsEdit::addNewFact($match); |
|
520 | + } |
|
521 | + } |
|
522 | + if (Filter::postBool('SOUR_INDI')) { |
|
523 | + $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
524 | + } else { |
|
525 | + $gedrec = FunctionsEdit::updateRest($gedrec); |
|
520 | 526 | } |
521 | - } |
|
522 | - if (Filter::postBool('SOUR_INDI')) { |
|
523 | - $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
524 | - } else { |
|
525 | - $gedrec = FunctionsEdit::updateRest($gedrec); |
|
526 | - } |
|
527 | 527 | |
528 | - $new_indi = $controller->tree()->createRecord($gedrec); |
|
528 | + $new_indi = $controller->tree()->createRecord($gedrec); |
|
529 | 529 | |
530 | - if (Filter::post('goto') === 'new') { |
|
531 | - header('Location: ' . $new_indi->url()); |
|
532 | - } else { |
|
533 | - header('Location: ' . route('admin-trees')); |
|
534 | - } |
|
535 | - break; |
|
530 | + if (Filter::post('goto') === 'new') { |
|
531 | + header('Location: ' . $new_indi->url()); |
|
532 | + } else { |
|
533 | + header('Location: ' . route('admin-trees')); |
|
534 | + } |
|
535 | + break; |
|
536 | 536 | |
537 | -case 'add_spouse_to_individual_action': |
|
538 | - ////////////////////////////////////////////////////////////////////////////// |
|
539 | - // Add a spouse to an existing individual (creating a new family) |
|
540 | - ////////////////////////////////////////////////////////////////////////////// |
|
541 | - $xref = Filter::post('xref'); // Add a spouse to this individual |
|
542 | - $sex = Filter::post('SEX', '[MFU]', 'U'); |
|
543 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
544 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
545 | - $text = Filter::postArray('text'); |
|
546 | - $islink = Filter::postArray('islink', '[01]'); |
|
547 | - |
|
548 | - $person = Individual::getInstance($xref, $controller->tree()); |
|
549 | - check_record_access($person); |
|
550 | - |
|
551 | - FunctionsEdit::splitSource(); |
|
552 | - $indi_gedcom = '0 @REF@ INDI'; |
|
553 | - $indi_gedcom .= FunctionsEdit::addNewName(); |
|
554 | - $indi_gedcom .= FunctionsEdit::addNewSex(); |
|
555 | - if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
556 | - foreach ($matches[1] as $match) { |
|
557 | - $indi_gedcom .= FunctionsEdit::addNewFact($match); |
|
537 | + case 'add_spouse_to_individual_action': |
|
538 | + ////////////////////////////////////////////////////////////////////////////// |
|
539 | + // Add a spouse to an existing individual (creating a new family) |
|
540 | + ////////////////////////////////////////////////////////////////////////////// |
|
541 | + $xref = Filter::post('xref'); // Add a spouse to this individual |
|
542 | + $sex = Filter::post('SEX', '[MFU]', 'U'); |
|
543 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
544 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
545 | + $text = Filter::postArray('text'); |
|
546 | + $islink = Filter::postArray('islink', '[01]'); |
|
547 | + |
|
548 | + $person = Individual::getInstance($xref, $controller->tree()); |
|
549 | + check_record_access($person); |
|
550 | + |
|
551 | + FunctionsEdit::splitSource(); |
|
552 | + $indi_gedcom = '0 @REF@ INDI'; |
|
553 | + $indi_gedcom .= FunctionsEdit::addNewName(); |
|
554 | + $indi_gedcom .= FunctionsEdit::addNewSex(); |
|
555 | + if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
556 | + foreach ($matches[1] as $match) { |
|
557 | + $indi_gedcom .= FunctionsEdit::addNewFact($match); |
|
558 | + } |
|
559 | + } |
|
560 | + if (Filter::postBool('SOUR_INDI')) { |
|
561 | + $indi_gedcom = FunctionsEdit::handleUpdates($indi_gedcom); |
|
562 | + } else { |
|
563 | + $indi_gedcom = FunctionsEdit::updateRest($indi_gedcom); |
|
558 | 564 | } |
559 | - } |
|
560 | - if (Filter::postBool('SOUR_INDI')) { |
|
561 | - $indi_gedcom = FunctionsEdit::handleUpdates($indi_gedcom); |
|
562 | - } else { |
|
563 | - $indi_gedcom = FunctionsEdit::updateRest($indi_gedcom); |
|
564 | - } |
|
565 | 565 | |
566 | - $fam_gedcom = ''; |
|
567 | - if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) { |
|
568 | - foreach ($matches[1] as $match) { |
|
569 | - $fam_gedcom .= FunctionsEdit::addNewFact($match); |
|
566 | + $fam_gedcom = ''; |
|
567 | + if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) { |
|
568 | + foreach ($matches[1] as $match) { |
|
569 | + $fam_gedcom .= FunctionsEdit::addNewFact($match); |
|
570 | + } |
|
571 | + } |
|
572 | + if (Filter::postBool('SOUR_FAM')) { |
|
573 | + $fam_gedcom = FunctionsEdit::handleUpdates($fam_gedcom); |
|
574 | + } else { |
|
575 | + $fam_gedcom = FunctionsEdit::updateRest($fam_gedcom); |
|
570 | 576 | } |
571 | - } |
|
572 | - if (Filter::postBool('SOUR_FAM')) { |
|
573 | - $fam_gedcom = FunctionsEdit::handleUpdates($fam_gedcom); |
|
574 | - } else { |
|
575 | - $fam_gedcom = FunctionsEdit::updateRest($fam_gedcom); |
|
576 | - } |
|
577 | 577 | |
578 | - // Create the new spouse |
|
579 | - $spouse = $person->getTree()->createRecord($indi_gedcom); |
|
580 | - // Create a new family |
|
581 | - if ($sex === 'F') { |
|
582 | - $family = $spouse->getTree()->createRecord("0 @NEW@ FAM\n1 WIFE @" . $spouse->getXref() . "@\n1 HUSB @" . $person->getXref() . '@' . $fam_gedcom); |
|
583 | - } else { |
|
584 | - $family = $spouse->getTree()->createRecord("0 @NEW@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@' . $fam_gedcom); |
|
585 | - } |
|
586 | - // Link the spouses to the family |
|
587 | - $spouse->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
588 | - $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
578 | + // Create the new spouse |
|
579 | + $spouse = $person->getTree()->createRecord($indi_gedcom); |
|
580 | + // Create a new family |
|
581 | + if ($sex === 'F') { |
|
582 | + $family = $spouse->getTree()->createRecord("0 @NEW@ FAM\n1 WIFE @" . $spouse->getXref() . "@\n1 HUSB @" . $person->getXref() . '@' . $fam_gedcom); |
|
583 | + } else { |
|
584 | + $family = $spouse->getTree()->createRecord("0 @NEW@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@' . $fam_gedcom); |
|
585 | + } |
|
586 | + // Link the spouses to the family |
|
587 | + $spouse->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
588 | + $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
589 | 589 | |
590 | - if (Filter::post('goto') === 'new') { |
|
591 | - header('Location: ' . $spouse->url()); |
|
592 | - } else { |
|
593 | - header('Location: ' . $person->url()); |
|
594 | - } |
|
595 | - break; |
|
590 | + if (Filter::post('goto') === 'new') { |
|
591 | + header('Location: ' . $spouse->url()); |
|
592 | + } else { |
|
593 | + header('Location: ' . $person->url()); |
|
594 | + } |
|
595 | + break; |
|
596 | 596 | |
597 | -case 'add_spouse_to_family_action': |
|
598 | - ////////////////////////////////////////////////////////////////////////////// |
|
599 | - // Add a spouse to an existing family |
|
600 | - ////////////////////////////////////////////////////////////////////////////// |
|
601 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
602 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
603 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
604 | - $text = Filter::postArray('text'); |
|
605 | - $islink = Filter::postArray('islink', '[01]'); |
|
606 | - |
|
607 | - $family = Family::getInstance($xref, $controller->tree()); |
|
608 | - check_record_access($family); |
|
609 | - |
|
610 | - // Create the new spouse |
|
611 | - FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
612 | - |
|
613 | - $gedrec = '0 @REF@ INDI'; |
|
614 | - $gedrec .= FunctionsEdit::addNewName(); |
|
615 | - $gedrec .= FunctionsEdit::addNewSex(); |
|
616 | - if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
617 | - foreach ($matches[1] as $match) { |
|
618 | - $gedrec .= FunctionsEdit::addNewFact($match); |
|
597 | + case 'add_spouse_to_family_action': |
|
598 | + ////////////////////////////////////////////////////////////////////////////// |
|
599 | + // Add a spouse to an existing family |
|
600 | + ////////////////////////////////////////////////////////////////////////////// |
|
601 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
602 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
603 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
604 | + $text = Filter::postArray('text'); |
|
605 | + $islink = Filter::postArray('islink', '[01]'); |
|
606 | + |
|
607 | + $family = Family::getInstance($xref, $controller->tree()); |
|
608 | + check_record_access($family); |
|
609 | + |
|
610 | + // Create the new spouse |
|
611 | + FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
612 | + |
|
613 | + $gedrec = '0 @REF@ INDI'; |
|
614 | + $gedrec .= FunctionsEdit::addNewName(); |
|
615 | + $gedrec .= FunctionsEdit::addNewSex(); |
|
616 | + if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
617 | + foreach ($matches[1] as $match) { |
|
618 | + $gedrec .= FunctionsEdit::addNewFact($match); |
|
619 | + } |
|
619 | 620 | } |
620 | - } |
|
621 | 621 | |
622 | - if (Filter::postBool('SOUR_INDI')) { |
|
623 | - $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
624 | - } else { |
|
625 | - $gedrec = FunctionsEdit::updateRest($gedrec); |
|
626 | - } |
|
627 | - $gedrec .= "\n1 FAMS @" . $family->getXref() . '@'; |
|
628 | - $spouse = $family->getTree()->createRecord($gedrec); |
|
622 | + if (Filter::postBool('SOUR_INDI')) { |
|
623 | + $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
624 | + } else { |
|
625 | + $gedrec = FunctionsEdit::updateRest($gedrec); |
|
626 | + } |
|
627 | + $gedrec .= "\n1 FAMS @" . $family->getXref() . '@'; |
|
628 | + $spouse = $family->getTree()->createRecord($gedrec); |
|
629 | 629 | |
630 | - // Update the existing family - add marriage, etc |
|
631 | - if ($family->getFirstFact('HUSB')) { |
|
632 | - $family->createFact('1 WIFE @' . $spouse->getXref() . '@', true); |
|
633 | - } else { |
|
634 | - $family->createFact('1 HUSB @' . $spouse->getXref() . '@', true); |
|
635 | - } |
|
636 | - $famrec = ''; |
|
637 | - if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) { |
|
638 | - foreach ($matches[1] as $match) { |
|
639 | - $famrec .= FunctionsEdit::addNewFact($match); |
|
630 | + // Update the existing family - add marriage, etc |
|
631 | + if ($family->getFirstFact('HUSB')) { |
|
632 | + $family->createFact('1 WIFE @' . $spouse->getXref() . '@', true); |
|
633 | + } else { |
|
634 | + $family->createFact('1 HUSB @' . $spouse->getXref() . '@', true); |
|
640 | 635 | } |
641 | - } |
|
642 | - if (Filter::postBool('SOUR_FAM')) { |
|
643 | - $famrec = FunctionsEdit::handleUpdates($famrec); |
|
644 | - } else { |
|
645 | - $famrec = FunctionsEdit::updateRest($famrec); |
|
646 | - } |
|
647 | - $family->createFact(trim($famrec), true); // trim leading \n |
|
636 | + $famrec = ''; |
|
637 | + if (preg_match_all('/([A-Z0-9_]+)/', $controller->tree()->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) { |
|
638 | + foreach ($matches[1] as $match) { |
|
639 | + $famrec .= FunctionsEdit::addNewFact($match); |
|
640 | + } |
|
641 | + } |
|
642 | + if (Filter::postBool('SOUR_FAM')) { |
|
643 | + $famrec = FunctionsEdit::handleUpdates($famrec); |
|
644 | + } else { |
|
645 | + $famrec = FunctionsEdit::updateRest($famrec); |
|
646 | + } |
|
647 | + $family->createFact(trim($famrec), true); // trim leading \n |
|
648 | 648 | |
649 | - if (Filter::post('goto') === 'new') { |
|
650 | - header('Location: ' . $spouse->url()); |
|
651 | - } else { |
|
652 | - header('Location: ' . $family->url()); |
|
653 | - } |
|
654 | - break; |
|
649 | + if (Filter::post('goto') === 'new') { |
|
650 | + header('Location: ' . $spouse->url()); |
|
651 | + } else { |
|
652 | + header('Location: ' . $family->url()); |
|
653 | + } |
|
654 | + break; |
|
655 | 655 | |
656 | -case 'addfamlink': |
|
657 | - ////////////////////////////////////////////////////////////////////////////// |
|
658 | - // Link an individual to an existing family, as a child |
|
659 | - ////////////////////////////////////////////////////////////////////////////// |
|
660 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
656 | + case 'addfamlink': |
|
657 | + ////////////////////////////////////////////////////////////////////////////// |
|
658 | + // Link an individual to an existing family, as a child |
|
659 | + ////////////////////////////////////////////////////////////////////////////// |
|
660 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
661 | 661 | |
662 | - $person = Individual::getInstance($xref, $controller->tree()); |
|
663 | - check_record_access($person); |
|
662 | + $person = Individual::getInstance($xref, $controller->tree()); |
|
663 | + check_record_access($person); |
|
664 | 664 | |
665 | - $controller |
|
666 | - ->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Link this individual to an existing family as a child')) |
|
667 | - ->pageHeader(); |
|
665 | + $controller |
|
666 | + ->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Link this individual to an existing family as a child')) |
|
667 | + ->pageHeader(); |
|
668 | 668 | |
669 | - ?> |
|
670 | - <h2><?= $controller->getPageTitle() ?></h2> |
|
669 | + ?> |
|
670 | + <h2><?= $controller->getPageTitle() ?></h2> |
|
671 | 671 | <form method="post"> |
672 | 672 | <input type="hidden" name="ged" value="<?= e($controller->tree()->getName()) ?>"> |
673 | 673 | <input type="hidden" name="action" value="linkfamaction"> |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | </label> |
690 | 690 | <div class="col-sm-9"> |
691 | 691 | <?= Bootstrap4::select(GedcomCodePedi::getValues($person), '', ['id' => 'PEDI', 'name' => 'PEDI']) ?> |
692 | - <p class="small text-muted"> |
|
692 | + <p class="small text-muted"> |
|
693 | 693 | <?= I18N::translate('A child may have more than one set of parents. The relationship between the child and the parents can be biological, legal, or based on local culture and tradition. If no pedigree is specified, then a biological relationship will be assumed.') ?> |
694 | 694 | </p> |
695 | 695 | </div> |
@@ -701,83 +701,83 @@ discard block |
||
701 | 701 | <div class="col-sm-9 offset-sm-3"> |
702 | 702 | <button class="btn btn-primary" type="submit"> |
703 | 703 | <?= FontAwesome::decorativeIcon('save') ?> |
704 | - <?= /* I18N: A button label. */ |
|
705 | - I18N::translate('save') ?> |
|
704 | + <?= /* I18N: A button label. */ |
|
705 | + I18N::translate('save') ?> |
|
706 | 706 | </button> |
707 | 707 | <a class="btn btn-secondary" href="<?= e($person->url()) ?>"> |
708 | 708 | <?= FontAwesome::decorativeIcon('cancel') ?> |
709 | - <?= /* I18N: A button label. */ |
|
710 | - I18N::translate('cancel') ?> |
|
709 | + <?= /* I18N: A button label. */ |
|
710 | + I18N::translate('cancel') ?> |
|
711 | 711 | </a> |
712 | 712 | </div> |
713 | 713 | </div> |
714 | 714 | </form> |
715 | 715 | <?php |
716 | - break; |
|
716 | + break; |
|
717 | 717 | |
718 | -case 'linkfamaction': |
|
719 | - ////////////////////////////////////////////////////////////////////////////// |
|
720 | - // Link an individual to an existing family, as a child |
|
721 | - ////////////////////////////////////////////////////////////////////////////// |
|
722 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
723 | - $famid = Filter::post('famid', WT_REGEX_XREF); |
|
724 | - $PEDI = Filter::post('PEDI'); |
|
725 | - |
|
726 | - $person = Individual::getInstance($xref, $controller->tree()); |
|
727 | - $family = Family::getInstance($famid, $controller->tree()); |
|
728 | - check_record_access($person); |
|
729 | - check_record_access($family); |
|
730 | - |
|
731 | - // Replace any existing child->family link (we may be changing the PEDI); |
|
732 | - $fact_id = null; |
|
733 | - foreach ($person->getFacts('FAMC') as $fact) { |
|
734 | - if ($family === $fact->getTarget()) { |
|
735 | - $fact_id = $fact->getFactId(); |
|
736 | - break; |
|
718 | + case 'linkfamaction': |
|
719 | + ////////////////////////////////////////////////////////////////////////////// |
|
720 | + // Link an individual to an existing family, as a child |
|
721 | + ////////////////////////////////////////////////////////////////////////////// |
|
722 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
723 | + $famid = Filter::post('famid', WT_REGEX_XREF); |
|
724 | + $PEDI = Filter::post('PEDI'); |
|
725 | + |
|
726 | + $person = Individual::getInstance($xref, $controller->tree()); |
|
727 | + $family = Family::getInstance($famid, $controller->tree()); |
|
728 | + check_record_access($person); |
|
729 | + check_record_access($family); |
|
730 | + |
|
731 | + // Replace any existing child->family link (we may be changing the PEDI); |
|
732 | + $fact_id = null; |
|
733 | + foreach ($person->getFacts('FAMC') as $fact) { |
|
734 | + if ($family === $fact->getTarget()) { |
|
735 | + $fact_id = $fact->getFactId(); |
|
736 | + break; |
|
737 | + } |
|
737 | 738 | } |
738 | - } |
|
739 | 739 | |
740 | - $gedcom = GedcomCodePedi::createNewFamcPedi($PEDI, $famid); |
|
741 | - $person->updateFact($fact_id, $gedcom, true); |
|
740 | + $gedcom = GedcomCodePedi::createNewFamcPedi($PEDI, $famid); |
|
741 | + $person->updateFact($fact_id, $gedcom, true); |
|
742 | 742 | |
743 | - // Only set the family->child link if it does not already exist |
|
744 | - $edit_fact = null; |
|
745 | - foreach ($family->getFacts('CHIL') as $fact) { |
|
746 | - if ($person === $fact->getTarget()) { |
|
747 | - $edit_fact = $fact; |
|
748 | - break; |
|
743 | + // Only set the family->child link if it does not already exist |
|
744 | + $edit_fact = null; |
|
745 | + foreach ($family->getFacts('CHIL') as $fact) { |
|
746 | + if ($person === $fact->getTarget()) { |
|
747 | + $edit_fact = $fact; |
|
748 | + break; |
|
749 | + } |
|
750 | + } |
|
751 | + if (!$edit_fact) { |
|
752 | + $family->createFact('1 CHIL @' . $person->getXref() . '@', true); |
|
749 | 753 | } |
750 | - } |
|
751 | - if (!$edit_fact) { |
|
752 | - $family->createFact('1 CHIL @' . $person->getXref() . '@', true); |
|
753 | - } |
|
754 | 754 | |
755 | - header('Location: ' . $person->url()); |
|
756 | - break; |
|
755 | + header('Location: ' . $person->url()); |
|
756 | + break; |
|
757 | 757 | |
758 | -case 'linkspouse': |
|
759 | - ////////////////////////////////////////////////////////////////////////////// |
|
760 | - // Link and individual to an existing individual as a spouse |
|
761 | - ////////////////////////////////////////////////////////////////////////////// |
|
762 | - $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
763 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
758 | + case 'linkspouse': |
|
759 | + ////////////////////////////////////////////////////////////////////////////// |
|
760 | + // Link and individual to an existing individual as a spouse |
|
761 | + ////////////////////////////////////////////////////////////////////////////// |
|
762 | + $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
763 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
764 | 764 | |
765 | - $person = Individual::getInstance($xref, $controller->tree()); |
|
766 | - check_record_access($person); |
|
765 | + $person = Individual::getInstance($xref, $controller->tree()); |
|
766 | + check_record_access($person); |
|
767 | 767 | |
768 | - if ($person->getSex() === 'F') { |
|
769 | - $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual')); |
|
770 | - $label = I18N::translate('Husband'); |
|
771 | - } else { |
|
772 | - $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual')); |
|
773 | - $label = I18N::translate('Wife'); |
|
774 | - } |
|
768 | + if ($person->getSex() === 'F') { |
|
769 | + $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual')); |
|
770 | + $label = I18N::translate('Husband'); |
|
771 | + } else { |
|
772 | + $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual')); |
|
773 | + $label = I18N::translate('Wife'); |
|
774 | + } |
|
775 | 775 | |
776 | - $controller->pageHeader(); |
|
777 | - FunctionsPrint::initializeCalendarPopup(); |
|
776 | + $controller->pageHeader(); |
|
777 | + FunctionsPrint::initializeCalendarPopup(); |
|
778 | 778 | |
779 | - ?> |
|
780 | - <h2><?= $controller->getPageTitle() ?></h2> |
|
779 | + ?> |
|
780 | + <h2><?= $controller->getPageTitle() ?></h2> |
|
781 | 781 | |
782 | 782 | <form method="post"> |
783 | 783 | <input type="hidden" name="ged" value="<?= e($controller->tree()->getName()) ?>"> |
@@ -795,117 +795,117 @@ discard block |
||
795 | 795 | </div> |
796 | 796 | |
797 | 797 | <?= FunctionsEdit::addSimpleTag('0 MARR Y') ?> |
798 | - <?= FunctionsEdit::addSimpleTag('0 DATE', 'MARR') ?> |
|
799 | - <?= FunctionsEdit::addSimpleTag('0 PLAC', 'MARR') ?> |
|
798 | + <?= FunctionsEdit::addSimpleTag('0 DATE', 'MARR') ?> |
|
799 | + <?= FunctionsEdit::addSimpleTag('0 PLAC', 'MARR') ?> |
|
800 | 800 | |
801 | 801 | <div class="row form-group"> |
802 | 802 | <div class="col-sm-9 offset-sm-3"> |
803 | 803 | <button class="btn btn-primary" type="submit"> |
804 | 804 | <?= FontAwesome::decorativeIcon('save') ?> |
805 | - <?= /* I18N: A button label. */ I18N::translate('save') ?> |
|
805 | + <?= /* I18N: A button label. */ I18N::translate('save') ?> |
|
806 | 806 | </button> |
807 | 807 | <a class="btn btn-secondary" href="<?= e($person->url()) ?>"> |
808 | 808 | <?= FontAwesome::decorativeIcon('cancel') ?> |
809 | - <?= /* I18N: A button label. */ I18N::translate('cancel') ?> |
|
809 | + <?= /* I18N: A button label. */ I18N::translate('cancel') ?> |
|
810 | 810 | </a> |
811 | 811 | </div> |
812 | 812 | </div> |
813 | 813 | </form> |
814 | 814 | <?php |
815 | - break; |
|
816 | - |
|
817 | -case 'linkspouseaction': |
|
818 | - ////////////////////////////////////////////////////////////////////////////// |
|
819 | - // Link and individual to an existing individual as a spouse |
|
820 | - ////////////////////////////////////////////////////////////////////////////// |
|
821 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
822 | - $spid = Filter::post('spid', WT_REGEX_XREF); |
|
823 | - $famtag = Filter::post('famtag', 'HUSB|WIFE'); |
|
824 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
825 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
826 | - $text = Filter::postArray('text'); |
|
827 | - $islink = Filter::postArray('islink', '[01]'); |
|
828 | - |
|
829 | - $person = Individual::getInstance($xref, $controller->tree()); |
|
830 | - $spouse = Individual::getInstance($spid, $controller->tree()); |
|
831 | - check_record_access($person); |
|
832 | - check_record_access($spouse); |
|
833 | - |
|
834 | - if ($person->getSex() === 'F') { |
|
835 | - $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual')); |
|
836 | - } else { |
|
837 | - $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual')); |
|
838 | - } |
|
815 | + break; |
|
839 | 816 | |
840 | - if ($person->getSex() === 'M') { |
|
841 | - $gedcom = "0 @new@ FAM\n1 HUSB @" . $person->getXref() . "@\n1 WIFE @" . $spouse->getXref() . '@'; |
|
842 | - } else { |
|
843 | - $gedcom = "0 @new@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@'; |
|
844 | - } |
|
845 | - FunctionsEdit::splitSource(); |
|
846 | - $gedcom .= FunctionsEdit::addNewFact('MARR'); |
|
817 | + case 'linkspouseaction': |
|
818 | + ////////////////////////////////////////////////////////////////////////////// |
|
819 | + // Link and individual to an existing individual as a spouse |
|
820 | + ////////////////////////////////////////////////////////////////////////////// |
|
821 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
822 | + $spid = Filter::post('spid', WT_REGEX_XREF); |
|
823 | + $famtag = Filter::post('famtag', 'HUSB|WIFE'); |
|
824 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
825 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
826 | + $text = Filter::postArray('text'); |
|
827 | + $islink = Filter::postArray('islink', '[01]'); |
|
828 | + |
|
829 | + $person = Individual::getInstance($xref, $controller->tree()); |
|
830 | + $spouse = Individual::getInstance($spid, $controller->tree()); |
|
831 | + check_record_access($person); |
|
832 | + check_record_access($spouse); |
|
833 | + |
|
834 | + if ($person->getSex() === 'F') { |
|
835 | + $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual')); |
|
836 | + } else { |
|
837 | + $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual')); |
|
838 | + } |
|
847 | 839 | |
848 | - if (Filter::postBool('SOUR_FAM') || count($tagSOUR) > 0) { |
|
849 | - // before adding 2 SOUR it needs to add 1 MARR Y first |
|
850 | - if (FunctionsEdit::addNewFact('MARR') === '') { |
|
851 | - $gedcom .= "\n1 MARR Y"; |
|
840 | + if ($person->getSex() === 'M') { |
|
841 | + $gedcom = "0 @new@ FAM\n1 HUSB @" . $person->getXref() . "@\n1 WIFE @" . $spouse->getXref() . '@'; |
|
842 | + } else { |
|
843 | + $gedcom = "0 @new@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@'; |
|
852 | 844 | } |
853 | - $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
854 | - } else { |
|
855 | - // before adding level 2 facts it needs to add 1 MARR Y first |
|
856 | - if (FunctionsEdit::addNewFact('MARR') === '') { |
|
857 | - $gedcom .= "\n1 MARR Y"; |
|
845 | + FunctionsEdit::splitSource(); |
|
846 | + $gedcom .= FunctionsEdit::addNewFact('MARR'); |
|
847 | + |
|
848 | + if (Filter::postBool('SOUR_FAM') || count($tagSOUR) > 0) { |
|
849 | + // before adding 2 SOUR it needs to add 1 MARR Y first |
|
850 | + if (FunctionsEdit::addNewFact('MARR') === '') { |
|
851 | + $gedcom .= "\n1 MARR Y"; |
|
852 | + } |
|
853 | + $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
854 | + } else { |
|
855 | + // before adding level 2 facts it needs to add 1 MARR Y first |
|
856 | + if (FunctionsEdit::addNewFact('MARR') === '') { |
|
857 | + $gedcom .= "\n1 MARR Y"; |
|
858 | + } |
|
859 | + $gedcom = FunctionsEdit::updateRest($gedcom); |
|
858 | 860 | } |
859 | - $gedcom = FunctionsEdit::updateRest($gedcom); |
|
860 | - } |
|
861 | 861 | |
862 | - $family = $person->getTree()->createRecord($gedcom); |
|
863 | - $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
864 | - $spouse->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
862 | + $family = $person->getTree()->createRecord($gedcom); |
|
863 | + $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
864 | + $spouse->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
865 | 865 | |
866 | - header('Location: ' . $person->url()); |
|
867 | - break; |
|
866 | + header('Location: ' . $person->url()); |
|
867 | + break; |
|
868 | 868 | |
869 | -case 'addmedia_links': |
|
870 | - ////////////////////////////////////////////////////////////////////////////// |
|
871 | - // |
|
872 | - ////////////////////////////////////////////////////////////////////////////// |
|
873 | - $pid = Filter::get('pid', WT_REGEX_XREF); |
|
869 | + case 'addmedia_links': |
|
870 | + ////////////////////////////////////////////////////////////////////////////// |
|
871 | + // |
|
872 | + ////////////////////////////////////////////////////////////////////////////// |
|
873 | + $pid = Filter::get('pid', WT_REGEX_XREF); |
|
874 | 874 | |
875 | - $person = Individual::getInstance($pid, $controller->tree()); |
|
876 | - check_record_access($person); |
|
875 | + $person = Individual::getInstance($pid, $controller->tree()); |
|
876 | + check_record_access($person); |
|
877 | 877 | |
878 | - $controller |
|
879 | - ->setPageTitle(I18N::translate('Family navigator') . ' — ' . $person->getFullName()) |
|
880 | - ->pageHeader(); |
|
878 | + $controller |
|
879 | + ->setPageTitle(I18N::translate('Family navigator') . ' — ' . $person->getFullName()) |
|
880 | + ->pageHeader(); |
|
881 | 881 | |
882 | - ?> |
|
883 | - <h2><?= $controller->getPageTitle() ?></h2> |
|
882 | + ?> |
|
883 | + <h2><?= $controller->getPageTitle() ?></h2> |
|
884 | 884 | |
885 | 885 | <form method="post" action="edit_interface.php?xref=<?= $person->getXref() ?>" onsubmit="findindi()"> |
886 | 886 | <input type="hidden" name="ged" value="<?= e($controller->tree()->getName()) ?>"> |
887 | 887 | <input type="hidden" name="action" value="addmedia_links"> |
888 | 888 | <input type="hidden" name="noteid" value="newnote"> |
889 | 889 | <?= Filter::getCsrf() ?> |
890 | - <?php require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/MEDIA_ctrl.php' ?> |
|
891 | - </form> |
|
890 | + <?php require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/MEDIA_ctrl.php' ?> |
|
891 | + </form> |
|
892 | 892 | <?php |
893 | - break; |
|
893 | + break; |
|
894 | 894 | |
895 | -case 'add-media-link': |
|
896 | - ////////////////////////////////////////////////////////////////////////////// |
|
897 | - // Link a media object to a record. |
|
898 | - ////////////////////////////////////////////////////////////////////////////// |
|
899 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
900 | - $record = GedcomRecord::getInstance($xref, $controller->tree()); |
|
901 | - check_record_access($record); |
|
895 | + case 'add-media-link': |
|
896 | + ////////////////////////////////////////////////////////////////////////////// |
|
897 | + // Link a media object to a record. |
|
898 | + ////////////////////////////////////////////////////////////////////////////// |
|
899 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
900 | + $record = GedcomRecord::getInstance($xref, $controller->tree()); |
|
901 | + check_record_access($record); |
|
902 | 902 | |
903 | - $controller |
|
904 | - ->setPageTitle($record->getFullName() . ' — ' . I18N::translate('Add a media object')) |
|
905 | - ->pageHeader(); |
|
903 | + $controller |
|
904 | + ->setPageTitle($record->getFullName() . ' — ' . I18N::translate('Add a media object')) |
|
905 | + ->pageHeader(); |
|
906 | 906 | |
907 | - ?> |
|
908 | - <h2><?= $controller->getPageTitle() ?></h2> |
|
907 | + ?> |
|
908 | + <h2><?= $controller->getPageTitle() ?></h2> |
|
909 | 909 | |
910 | 910 | <form method="post"> |
911 | 911 | <input type="hidden" name="ged" value="<?= e($record->getTree()->getName()) ?>"> |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | </button> |
928 | 928 | </span> |
929 | 929 | <?php endif ?> |
930 | - <?= FunctionsEdit::formControlMediaObject($controller->tree(), null, ['id' => 'media-xref', 'name' => 'media-xref', 'data-element-id' => 'media-xref']) ?> |
|
930 | + <?= FunctionsEdit::formControlMediaObject($controller->tree(), null, ['id' => 'media-xref', 'name' => 'media-xref', 'data-element-id' => 'media-xref']) ?> |
|
931 | 931 | </div> |
932 | 932 | </div> |
933 | 933 | </div> |
@@ -936,55 +936,55 @@ discard block |
||
936 | 936 | <div class="col-sm-9 offset-sm-3"> |
937 | 937 | <button class="btn btn-primary" type="submit"> |
938 | 938 | <?= FontAwesome::decorativeIcon('save') ?> |
939 | - <?= /* I18N: A button label. */ |
|
940 | - I18N::translate('save') ?> |
|
939 | + <?= /* I18N: A button label. */ |
|
940 | + I18N::translate('save') ?> |
|
941 | 941 | </button> |
942 | 942 | <a class="btn btn-secondary" href="<?= e($record->url()) ?>"> |
943 | 943 | <?= FontAwesome::decorativeIcon('cancel') ?> |
944 | - <?= /* I18N: A button label. */ |
|
945 | - I18N::translate('cancel') ?> |
|
944 | + <?= /* I18N: A button label. */ |
|
945 | + I18N::translate('cancel') ?> |
|
946 | 946 | </a> |
947 | 947 | </div> |
948 | 948 | </div> |
949 | 949 | </form> |
950 | 950 | <?= view('modals/ajax') ?> |
951 | - <?php |
|
952 | - break; |
|
951 | + <?php |
|
952 | + break; |
|
953 | 953 | |
954 | -case 'save-media-link': |
|
955 | - ////////////////////////////////////////////////////////////////////////////// |
|
956 | - // Link a media object to a record. |
|
957 | - ////////////////////////////////////////////////////////////////////////////// |
|
958 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
959 | - $media_xref = Filter::post('media-xref', WT_REGEX_XREF); |
|
960 | - $record = GedcomRecord::getInstance($xref, $controller->tree()); |
|
961 | - check_record_access($record); |
|
954 | + case 'save-media-link': |
|
955 | + ////////////////////////////////////////////////////////////////////////////// |
|
956 | + // Link a media object to a record. |
|
957 | + ////////////////////////////////////////////////////////////////////////////// |
|
958 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
959 | + $media_xref = Filter::post('media-xref', WT_REGEX_XREF); |
|
960 | + $record = GedcomRecord::getInstance($xref, $controller->tree()); |
|
961 | + check_record_access($record); |
|
962 | 962 | |
963 | - $gedcom = '1 OBJE @' . $media_xref . '@'; |
|
963 | + $gedcom = '1 OBJE @' . $media_xref . '@'; |
|
964 | 964 | |
965 | - $record->createFact($gedcom, true); |
|
965 | + $record->createFact($gedcom, true); |
|
966 | 966 | |
967 | - header('Location: ' . $record->url()); |
|
968 | - break; |
|
967 | + header('Location: ' . $record->url()); |
|
968 | + break; |
|
969 | 969 | |
970 | -case 'changefamily': |
|
971 | - ////////////////////////////////////////////////////////////////////////////// |
|
972 | - // Change the members of a family record |
|
973 | - ////////////////////////////////////////////////////////////////////////////// |
|
974 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
970 | + case 'changefamily': |
|
971 | + ////////////////////////////////////////////////////////////////////////////// |
|
972 | + // Change the members of a family record |
|
973 | + ////////////////////////////////////////////////////////////////////////////// |
|
974 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
975 | 975 | |
976 | - $family = Family::getInstance($xref, $controller->tree()); |
|
977 | - check_record_access($family); |
|
976 | + $family = Family::getInstance($xref, $controller->tree()); |
|
977 | + check_record_access($family); |
|
978 | 978 | |
979 | - $controller |
|
980 | - ->setPageTitle(I18N::translate('Change family members') . ' – ' . $family->getFullName()) |
|
981 | - ->pageHeader(); |
|
979 | + $controller |
|
980 | + ->setPageTitle(I18N::translate('Change family members') . ' – ' . $family->getFullName()) |
|
981 | + ->pageHeader(); |
|
982 | 982 | |
983 | - $father = $family->getHusband(); |
|
984 | - $mother = $family->getWife(); |
|
985 | - $children = $family->getChildren(); |
|
986 | - ?> |
|
987 | - <h2><?= $controller->getPageTitle() ?></h2> |
|
983 | + $father = $family->getHusband(); |
|
984 | + $mother = $family->getWife(); |
|
985 | + $children = $family->getChildren(); |
|
986 | + ?> |
|
987 | + <h2><?= $controller->getPageTitle() ?></h2> |
|
988 | 988 | |
989 | 989 | <div id="changefam"> |
990 | 990 | <form name="changefamform" method="post"> |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | <td class="descriptionbox"> |
999 | 999 | <b> |
1000 | 1000 | <?php |
1001 | - switch ($father->getSex()) { |
|
1001 | + switch ($father->getSex()) { |
|
1002 | 1002 | case 'M': |
1003 | 1003 | echo I18N::translate('husband'); |
1004 | 1004 | break; |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | default: |
1009 | 1009 | echo I18N::translate('spouse'); |
1010 | 1010 | break; |
1011 | - } |
|
1011 | + } |
|
1012 | 1012 | ?> |
1013 | 1013 | </b> |
1014 | 1014 | <input type="hidden" name="HUSB" value="<?= $father->getXref() ?>"> |
@@ -1140,110 +1140,110 @@ discard block |
||
1140 | 1140 | <?php |
1141 | 1141 | break; |
1142 | 1142 | |
1143 | -case 'changefamily_update': |
|
1144 | - ////////////////////////////////////////////////////////////////////////////// |
|
1145 | - // Change the members of a family record |
|
1146 | - ////////////////////////////////////////////////////////////////////////////// |
|
1147 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
1148 | - $HUSB = Filter::post('HUSB', WT_REGEX_XREF); |
|
1149 | - $WIFE = Filter::post('WIFE', WT_REGEX_XREF); |
|
1150 | - $keep_chan = Filter::postBool('keep_chan'); |
|
1151 | - |
|
1152 | - $CHIL = []; |
|
1153 | - for ($i = 0; isset($_POST['CHIL' . $i]); ++$i) { |
|
1154 | - $CHIL[] = Filter::post('CHIL' . $i, WT_REGEX_XREF); |
|
1155 | - } |
|
1143 | + case 'changefamily_update': |
|
1144 | + ////////////////////////////////////////////////////////////////////////////// |
|
1145 | + // Change the members of a family record |
|
1146 | + ////////////////////////////////////////////////////////////////////////////// |
|
1147 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
1148 | + $HUSB = Filter::post('HUSB', WT_REGEX_XREF); |
|
1149 | + $WIFE = Filter::post('WIFE', WT_REGEX_XREF); |
|
1150 | + $keep_chan = Filter::postBool('keep_chan'); |
|
1151 | + |
|
1152 | + $CHIL = []; |
|
1153 | + for ($i = 0; isset($_POST['CHIL' . $i]); ++$i) { |
|
1154 | + $CHIL[] = Filter::post('CHIL' . $i, WT_REGEX_XREF); |
|
1155 | + } |
|
1156 | 1156 | |
1157 | - $family = Family::getInstance($xref, $controller->tree()); |
|
1158 | - check_record_access($family); |
|
1157 | + $family = Family::getInstance($xref, $controller->tree()); |
|
1158 | + check_record_access($family); |
|
1159 | 1159 | |
1160 | - // Current family members |
|
1161 | - $old_father = $family->getHusband(); |
|
1162 | - $old_mother = $family->getWife(); |
|
1163 | - $old_children = $family->getChildren(); |
|
1160 | + // Current family members |
|
1161 | + $old_father = $family->getHusband(); |
|
1162 | + $old_mother = $family->getWife(); |
|
1163 | + $old_children = $family->getChildren(); |
|
1164 | 1164 | |
1165 | - // New family members |
|
1166 | - $new_father = Individual::getInstance($HUSB, $controller->tree()); |
|
1167 | - $new_mother = Individual::getInstance($WIFE, $controller->tree()); |
|
1168 | - $new_children = []; |
|
1169 | - foreach ($CHIL as $child) { |
|
1170 | - $new_children[] = Individual::getInstance($child, $controller->tree()); |
|
1171 | - } |
|
1165 | + // New family members |
|
1166 | + $new_father = Individual::getInstance($HUSB, $controller->tree()); |
|
1167 | + $new_mother = Individual::getInstance($WIFE, $controller->tree()); |
|
1168 | + $new_children = []; |
|
1169 | + foreach ($CHIL as $child) { |
|
1170 | + $new_children[] = Individual::getInstance($child, $controller->tree()); |
|
1171 | + } |
|
1172 | 1172 | |
1173 | - if ($old_father !== $new_father) { |
|
1174 | - if ($old_father) { |
|
1175 | - // Remove old FAMS link |
|
1176 | - foreach ($old_father->getFacts('FAMS') as $fact) { |
|
1177 | - if ($fact->getTarget() === $family) { |
|
1178 | - $old_father->deleteFact($fact->getFactId(), !$keep_chan); |
|
1173 | + if ($old_father !== $new_father) { |
|
1174 | + if ($old_father) { |
|
1175 | + // Remove old FAMS link |
|
1176 | + foreach ($old_father->getFacts('FAMS') as $fact) { |
|
1177 | + if ($fact->getTarget() === $family) { |
|
1178 | + $old_father->deleteFact($fact->getFactId(), !$keep_chan); |
|
1179 | + } |
|
1179 | 1180 | } |
1180 | - } |
|
1181 | - // Remove old HUSB link |
|
1182 | - foreach ($family->getFacts('HUSB|WIFE') as $fact) { |
|
1183 | - if ($fact->getTarget() === $old_father) { |
|
1184 | - $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
1181 | + // Remove old HUSB link |
|
1182 | + foreach ($family->getFacts('HUSB|WIFE') as $fact) { |
|
1183 | + if ($fact->getTarget() === $old_father) { |
|
1184 | + $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
1185 | + } |
|
1185 | 1186 | } |
1186 | 1187 | } |
1188 | + if ($new_father) { |
|
1189 | + // Add new FAMS link |
|
1190 | + $new_father->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan); |
|
1191 | + // Add new HUSB link |
|
1192 | + $family->createFact('1 HUSB @' . $new_father->getXref() . '@', !$keep_chan); |
|
1193 | + } |
|
1187 | 1194 | } |
1188 | - if ($new_father) { |
|
1189 | - // Add new FAMS link |
|
1190 | - $new_father->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan); |
|
1191 | - // Add new HUSB link |
|
1192 | - $family->createFact('1 HUSB @' . $new_father->getXref() . '@', !$keep_chan); |
|
1193 | - } |
|
1194 | - } |
|
1195 | 1195 | |
1196 | - if ($old_mother !== $new_mother) { |
|
1197 | - if ($old_mother) { |
|
1198 | - // Remove old FAMS link |
|
1199 | - foreach ($old_mother->getFacts('FAMS') as $fact) { |
|
1200 | - if ($fact->getTarget() === $family) { |
|
1201 | - $old_mother->deleteFact($fact->getFactId(), !$keep_chan); |
|
1196 | + if ($old_mother !== $new_mother) { |
|
1197 | + if ($old_mother) { |
|
1198 | + // Remove old FAMS link |
|
1199 | + foreach ($old_mother->getFacts('FAMS') as $fact) { |
|
1200 | + if ($fact->getTarget() === $family) { |
|
1201 | + $old_mother->deleteFact($fact->getFactId(), !$keep_chan); |
|
1202 | + } |
|
1202 | 1203 | } |
1203 | - } |
|
1204 | - // Remove old WIFE link |
|
1205 | - foreach ($family->getFacts('HUSB|WIFE') as $fact) { |
|
1206 | - if ($fact->getTarget() === $old_mother) { |
|
1207 | - $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
1204 | + // Remove old WIFE link |
|
1205 | + foreach ($family->getFacts('HUSB|WIFE') as $fact) { |
|
1206 | + if ($fact->getTarget() === $old_mother) { |
|
1207 | + $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
1208 | + } |
|
1208 | 1209 | } |
1209 | 1210 | } |
1211 | + if ($new_mother) { |
|
1212 | + // Add new FAMS link |
|
1213 | + $new_mother->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan); |
|
1214 | + // Add new WIFE link |
|
1215 | + $family->createFact('1 WIFE @' . $new_mother->getXref() . '@', !$keep_chan); |
|
1216 | + } |
|
1210 | 1217 | } |
1211 | - if ($new_mother) { |
|
1212 | - // Add new FAMS link |
|
1213 | - $new_mother->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan); |
|
1214 | - // Add new WIFE link |
|
1215 | - $family->createFact('1 WIFE @' . $new_mother->getXref() . '@', !$keep_chan); |
|
1216 | - } |
|
1217 | - } |
|
1218 | 1218 | |
1219 | - foreach ($old_children as $old_child) { |
|
1220 | - if ($old_child && !in_array($old_child, $new_children)) { |
|
1221 | - // Remove old FAMC link |
|
1222 | - foreach ($old_child->getFacts('FAMC') as $fact) { |
|
1223 | - if ($fact->getTarget() === $family) { |
|
1224 | - $old_child->deleteFact($fact->getFactId(), !$keep_chan); |
|
1219 | + foreach ($old_children as $old_child) { |
|
1220 | + if ($old_child && !in_array($old_child, $new_children)) { |
|
1221 | + // Remove old FAMC link |
|
1222 | + foreach ($old_child->getFacts('FAMC') as $fact) { |
|
1223 | + if ($fact->getTarget() === $family) { |
|
1224 | + $old_child->deleteFact($fact->getFactId(), !$keep_chan); |
|
1225 | + } |
|
1225 | 1226 | } |
1226 | - } |
|
1227 | - // Remove old CHIL link |
|
1228 | - foreach ($family->getFacts('CHIL') as $fact) { |
|
1229 | - if ($fact->getTarget() === $old_child) { |
|
1230 | - $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
1227 | + // Remove old CHIL link |
|
1228 | + foreach ($family->getFacts('CHIL') as $fact) { |
|
1229 | + if ($fact->getTarget() === $old_child) { |
|
1230 | + $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
1231 | + } |
|
1231 | 1232 | } |
1232 | 1233 | } |
1233 | 1234 | } |
1234 | - } |
|
1235 | 1235 | |
1236 | - foreach ($new_children as $new_child) { |
|
1237 | - if ($new_child && !in_array($new_child, $old_children)) { |
|
1238 | - // Add new FAMC link |
|
1239 | - $new_child->createFact('1 FAMC @' . $family->getXref() . '@', !$keep_chan); |
|
1240 | - // Add new CHIL link |
|
1241 | - $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan); |
|
1236 | + foreach ($new_children as $new_child) { |
|
1237 | + if ($new_child && !in_array($new_child, $old_children)) { |
|
1238 | + // Add new FAMC link |
|
1239 | + $new_child->createFact('1 FAMC @' . $family->getXref() . '@', !$keep_chan); |
|
1240 | + // Add new CHIL link |
|
1241 | + $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan); |
|
1242 | + } |
|
1242 | 1243 | } |
1243 | - } |
|
1244 | 1244 | |
1245 | - header('Location: ' . $family->url()); |
|
1246 | - break; |
|
1245 | + header('Location: ' . $family->url()); |
|
1246 | + break; |
|
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | /** |