getPageTitle(); ?>
For each member in the family, you can use the Change link to choose a different person to fill that role in the family. You can also use the Remove link to remove that person from the family.
When you have finished changing the family members, click the Save button to save the changes.'); ?>
setPageTitle(WT_I18N::translate('Change Family Members'))
->pageHeader();
// Current family members
$old_father = $family->getHusband();
$old_mother = $family->getWife();
$old_children = $family->getChildren();
// New family members
$new_father = WT_Individual::getInstance($HUSB);
$new_mother = WT_Individual::getInstance($WIFE);
$new_children = array();
if (is_array($CHIL)) {
foreach ($CHIL as $child) {
$new_children[] = WT_Individaul::getInstance($child);
}
}
if ($old_father !== $new_father) {
if ($old_father) {
// Remove old FAMS link
foreach ($old_father->getFacts('FAMS') as $fact) {
if ($fact->getTarget() === $family) {
$old_father->deleteFact($fact->getFactId(), !$keep_chan);
}
}
// Remove old HUSB link
foreach ($family->getFacts('HUSB|WIFE') as $fact) {
if ($fact->getTarget() === $old_father) {
$family->deleteFact($fact->getFactId(), !$keep_chan);
}
}
}
if ($new_father) {
// Add new FAMS link
$new_father->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan);
// Add new HUSB link
$family->createFact('1 HUSB @' . $new_father->getXref() . '@', !$keep_chan);
}
}
if ($old_mother !== $new_mother) {
if ($old_mother) {
// Remove old FAMS link
foreach ($old_mother->getFacts('FAMS') as $fact) {
if ($fact->getTarget() === $family) {
$old_mother->deleteFact($fact->getFactId(), !$keep_chan);
}
}
// Remove old WIFE link
foreach ($family->getFacts('HUSB|WIFE') as $fact) {
if ($fact->getTarget() === $old_mother) {
$family->deleteFact($fact->getFactId(), !$keep_chan);
}
}
}
if ($new_mother) {
// Add new FAMS link
$new_mother->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan);
// Add new WIFE link
$family->createFact('1 WIFE @' . $new_mother->getXref() . '@', !$keep_chan);
}
}
foreach ($old_children as $old_child) {
if (!in_array($old_child, $new_children)) {
// Remove old FAMC link
foreach ($old_child->getFacts('FAMC') as $fact) {
if ($fact->getTarget() === $family) {
$old_child->deleteFact($fact->getFactId(), !$keep_chan);
}
}
// Remove old CHIL link
foreach ($family->getFacts('CHIL') as $fact) {
if ($fact->getTarget() === $old_child) {
$family->deleteFact($fact->getFactId(), !$keep_chan);
}
}
}
}
foreach ($new_children as $new_child) {
if (!in_array($new_child, $old_children)) {
// Add new FAMC link
$new_child->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan);
// Add new CHIL link
$family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan);
}
}
$controller->addInlineJavascript('closePopupAndReloadParent();');
break;
////////////////////////////////////////////////////////////////////////////////
case 'reorder_update':
$xref = safe_POST('xref', WT_REGEX_XREF);
$order = safe_POST('order');
$keep_chan = safe_POST_bool('keep_chan');
$family = WT_Family::getInstance($xref);
check_record_access($family);
$controller
->setPageTitle(WT_I18N::translate('Re-order children'))
->pageHeader();
if (is_array($order)) {
$gedcom = array('0 @' . $family->getXref() . '@ FAM');
$facts = $family->getFacts();
// Move children to the end of the record
foreach ($order as $child=>$num) {
foreach ($facts as $n=>$fact) {
if ($fact->getValue() == '@'.$child.'@') {
$facts[]=$fact;
unset($facts[$n]);
break;
}
}
}
foreach ($facts as $fact) {
$gedcom[] = $fact->getGedcom();
}
$family->updateRecord(implode("\n", $gedcom), !$keep_chan);
}
$controller->addInlineJavascript('closePopupAndReloadParent();');
break;
////////////////////////////////////////////////////////////////////////////////
case 'reorder_fams':
$xref = safe_GET('xref', WT_REGEX_XREF);
$option = safe_GET('option');
$person = WT_Individual::getInstance($xref);
check_record_access($person);
$controller
->addInlineJavascript('jQuery("#reorder_list").sortable({forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"});')
//-- update the order numbers after drag-n-drop sorting is complete
->addInlineJavascript('jQuery("#reorder_list").bind("sortupdate", function(event, ui) { jQuery("#"+jQuery(this).attr("id")+" input").each( function (index, value) { value.value = index+1; }); });')
->setPageTitle(WT_I18N::translate('Re-order families'))
->pageHeader();
$fams = $person->getSpouseFamilies();
if ($option=='bymarriage') {
usort($fams, array('WT_Family', 'CompareMarrDate'));
}
?>
';
echo '
', $controller->getPageTitle(), '
';
init_calendar_popup();
echo "