|
@@ 2427-2467 (lines=41) @@
|
| 2424 |
|
<?php |
| 2425 |
|
break; |
| 2426 |
|
|
| 2427 |
|
case 'reorder-media-save': |
| 2428 |
|
////////////////////////////////////////////////////////////////////////////// |
| 2429 |
|
// Change the order of media objects within an individual record |
| 2430 |
|
////////////////////////////////////////////////////////////////////////////// |
| 2431 |
|
$xref = Filter::post('xref', WT_REGEX_XREF); |
| 2432 |
|
$order = Filter::post('order'); |
| 2433 |
|
|
| 2434 |
|
if (!Filter::checkCsrf()) { |
| 2435 |
|
header('Location: edit_interface.php?action=reorder-names&xref=' . $xref); |
| 2436 |
|
break; |
| 2437 |
|
} |
| 2438 |
|
|
| 2439 |
|
$individual = Individual::getInstance($xref, $controller->tree()); |
| 2440 |
|
check_record_access($individual); |
| 2441 |
|
|
| 2442 |
|
$dummy_facts = ['0 @' . $individual->getXref() . '@ INDI']; |
| 2443 |
|
$sort_facts = []; |
| 2444 |
|
$keep_facts = []; |
| 2445 |
|
|
| 2446 |
|
// Split facts into CHIL and other |
| 2447 |
|
foreach ($individual->getFacts() as $fact) { |
| 2448 |
|
if ($fact->getTag() === 'OBJE') { |
| 2449 |
|
$sort_facts[$fact->getFactId()] = $fact->getGedcom(); |
| 2450 |
|
} else { |
| 2451 |
|
$keep_facts[] = $fact->getGedcom(); |
| 2452 |
|
} |
| 2453 |
|
} |
| 2454 |
|
|
| 2455 |
|
// Sort the facts |
| 2456 |
|
$order = (array) $order; |
| 2457 |
|
uksort($sort_facts, function ($x, $y) use ($order) { |
| 2458 |
|
return array_search($x, $order) - array_search($y, $order); |
| 2459 |
|
}); |
| 2460 |
|
|
| 2461 |
|
// Merge the facts |
| 2462 |
|
$gedcom = implode("\n", array_merge($dummy_facts, $sort_facts, $keep_facts)); |
| 2463 |
|
|
| 2464 |
|
$individual->updateRecord($gedcom, false); |
| 2465 |
|
|
| 2466 |
|
header('Location: ' . $individual->getRawUrl()); |
| 2467 |
|
break; |
| 2468 |
|
|
| 2469 |
|
case 'reorder-names': |
| 2470 |
|
////////////////////////////////////////////////////////////////////////////// |
|
@@ 2522-2562 (lines=41) @@
|
| 2519 |
|
<?php |
| 2520 |
|
break; |
| 2521 |
|
|
| 2522 |
|
case 'reorder-names-save': |
| 2523 |
|
////////////////////////////////////////////////////////////////////////////// |
| 2524 |
|
// Change the order of name/title facts within an individual record |
| 2525 |
|
////////////////////////////////////////////////////////////////////////////// |
| 2526 |
|
$xref = Filter::post('xref', WT_REGEX_XREF); |
| 2527 |
|
$order = Filter::post('order'); |
| 2528 |
|
|
| 2529 |
|
if (!Filter::checkCsrf()) { |
| 2530 |
|
header('Location: edit_interface.php?action=reorder-names&xref=' . $xref); |
| 2531 |
|
break; |
| 2532 |
|
} |
| 2533 |
|
|
| 2534 |
|
$individual = Individual::getInstance($xref, $controller->tree()); |
| 2535 |
|
check_record_access($individual); |
| 2536 |
|
|
| 2537 |
|
$dummy_facts = ['0 @' . $individual->getXref() . '@ INDI']; |
| 2538 |
|
$sort_facts = []; |
| 2539 |
|
$keep_facts = []; |
| 2540 |
|
|
| 2541 |
|
// Split facts into NAME/TITL and other |
| 2542 |
|
foreach ($individual->getFacts() as $fact) { |
| 2543 |
|
if ($fact->getTag() === 'NAME' || $fact->getTag() === 'TITL') { |
| 2544 |
|
$sort_facts[$fact->getFactId()] = $fact->getGedcom(); |
| 2545 |
|
} else { |
| 2546 |
|
$keep_facts[] = $fact->getGedcom(); |
| 2547 |
|
} |
| 2548 |
|
} |
| 2549 |
|
|
| 2550 |
|
// Sort the facts |
| 2551 |
|
$order = (array) $order; |
| 2552 |
|
uksort($sort_facts, function ($x, $y) use ($order) { |
| 2553 |
|
return array_search($x, $order) - array_search($y, $order); |
| 2554 |
|
}); |
| 2555 |
|
|
| 2556 |
|
// Merge the facts |
| 2557 |
|
$gedcom = implode("\n", array_merge($dummy_facts, $sort_facts, $keep_facts)); |
| 2558 |
|
|
| 2559 |
|
$individual->updateRecord($gedcom, false); |
| 2560 |
|
|
| 2561 |
|
header('Location: ' . $individual->getRawUrl()); |
| 2562 |
|
break; |
| 2563 |
|
|
| 2564 |
|
case 'reorder-children': |
| 2565 |
|
////////////////////////////////////////////////////////////////////////////// |
|
@@ 2623-2663 (lines=41) @@
|
| 2620 |
|
<?php |
| 2621 |
|
break; |
| 2622 |
|
|
| 2623 |
|
case 'reorder-children-save': |
| 2624 |
|
////////////////////////////////////////////////////////////////////////////// |
| 2625 |
|
// Change the order of FAMC records within a FAM record |
| 2626 |
|
////////////////////////////////////////////////////////////////////////////// |
| 2627 |
|
$xref = Filter::post('xref', WT_REGEX_XREF); |
| 2628 |
|
$order = Filter::post('order'); |
| 2629 |
|
|
| 2630 |
|
if (!Filter::checkCsrf()) { |
| 2631 |
|
header('Location: edit_interface.php?action=reorder-spouses&xref=' . $xref); |
| 2632 |
|
break; |
| 2633 |
|
} |
| 2634 |
|
|
| 2635 |
|
$family = Family::getInstance($xref, $controller->tree()); |
| 2636 |
|
check_record_access($family); |
| 2637 |
|
|
| 2638 |
|
$dummy_facts = ['0 @' . $family->getXref() . '@ FAM']; |
| 2639 |
|
$sort_facts = []; |
| 2640 |
|
$keep_facts = []; |
| 2641 |
|
|
| 2642 |
|
// Split facts into CHIL and other |
| 2643 |
|
foreach ($family->getFacts() as $fact) { |
| 2644 |
|
if ($fact->getTag() === 'CHIL') { |
| 2645 |
|
$sort_facts[$fact->getFactId()] = $fact->getGedcom(); |
| 2646 |
|
} else { |
| 2647 |
|
$keep_facts[] = $fact->getGedcom(); |
| 2648 |
|
} |
| 2649 |
|
} |
| 2650 |
|
|
| 2651 |
|
// Sort the facts |
| 2652 |
|
$order = (array) $order; |
| 2653 |
|
uksort($sort_facts, function ($x, $y) use ($order) { |
| 2654 |
|
return array_search($x, $order) - array_search($y, $order); |
| 2655 |
|
}); |
| 2656 |
|
|
| 2657 |
|
// Merge the facts |
| 2658 |
|
$gedcom = implode("\n", array_merge($dummy_facts, $sort_facts, $keep_facts)); |
| 2659 |
|
|
| 2660 |
|
$family->updateRecord($gedcom, false); |
| 2661 |
|
|
| 2662 |
|
header('Location: ' . $family->getRawUrl()); |
| 2663 |
|
break; |
| 2664 |
|
|
| 2665 |
|
case 'reorder-spouses': |
| 2666 |
|
////////////////////////////////////////////////////////////////////////////// |
|
@@ 2724-2764 (lines=41) @@
|
| 2721 |
|
<?php |
| 2722 |
|
break; |
| 2723 |
|
|
| 2724 |
|
case 'reorder-spouses-save': |
| 2725 |
|
////////////////////////////////////////////////////////////////////////////// |
| 2726 |
|
// Change the order of FAMS records within an INDI record |
| 2727 |
|
////////////////////////////////////////////////////////////////////////////// |
| 2728 |
|
$xref = Filter::post('xref', WT_REGEX_XREF); |
| 2729 |
|
$order = Filter::post('order'); |
| 2730 |
|
|
| 2731 |
|
if (!Filter::checkCsrf()) { |
| 2732 |
|
header('Location: edit_interface.php?action=reorder-spouses&xref=' . $xref); |
| 2733 |
|
break; |
| 2734 |
|
} |
| 2735 |
|
|
| 2736 |
|
$individual = Individual::getInstance($xref, $controller->tree()); |
| 2737 |
|
check_record_access($individual); |
| 2738 |
|
|
| 2739 |
|
$dummy_facts = ['0 @' . $individual->getXref() . '@ INDI']; |
| 2740 |
|
$sort_facts = []; |
| 2741 |
|
$keep_facts = []; |
| 2742 |
|
|
| 2743 |
|
// Split facts into FAMS and other |
| 2744 |
|
foreach ($individual->getFacts() as $fact) { |
| 2745 |
|
if ($fact->getTag() === 'FAMS') { |
| 2746 |
|
$sort_facts[$fact->getFactId()] = $fact->getGedcom(); |
| 2747 |
|
} else { |
| 2748 |
|
$keep_facts[] = $fact->getGedcom(); |
| 2749 |
|
} |
| 2750 |
|
} |
| 2751 |
|
|
| 2752 |
|
// Sort the facts |
| 2753 |
|
$order = (array) $order; |
| 2754 |
|
uksort($sort_facts, function ($x, $y) use ($order) { |
| 2755 |
|
return array_search($x, $order) - array_search($y, $order); |
| 2756 |
|
}); |
| 2757 |
|
|
| 2758 |
|
// Merge the facts |
| 2759 |
|
$gedcom = implode("\n", array_merge($dummy_facts, $sort_facts, $keep_facts)); |
| 2760 |
|
|
| 2761 |
|
$individual->updateRecord($gedcom, false); |
| 2762 |
|
|
| 2763 |
|
header('Location: ' . $individual->getRawUrl()); |
| 2764 |
|
break; |
| 2765 |
|
} |
| 2766 |
|
|
| 2767 |
|
/** |