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();
$father = $family->getHusband();
$mother = $family->getWife();
$children = $family->getChildren();
$gedrec = $family->getGedcom();
$updated = false;
//-- add the new father link
if (isset($_REQUEST['HUSB'])) $HUSB = $_REQUEST['HUSB'];
if (!empty($HUSB) && (is_null($father) || $father->getXref()!=$HUSB)) {
if (strstr($gedrec, "1 HUSB")!==false) {
$gedrec = preg_replace("/1 HUSB @.*@/", "1 HUSB @$HUSB@", $gedrec);
} else {
$gedrec .= "\n1 HUSB @$HUSB@";
}
$indirec = $father->getGedcom();
if (!empty($indirec) && (strpos($indirec, "1 FAMS @$xref@")===false)) {
$indirec .= "\n1 FAMS @$xref@";
$father->updateRecord($indirec, $update_CHAN);
}
$updated = true;
}
//-- remove the father link
if (empty($HUSB)) {
$pos1 = strpos($gedrec, "1 HUSB @");
if ($pos1!==false) {
$pos2 = strpos($gedrec, "\n1", $pos1+5);
if ($pos2===false) {
$pos2 = strlen($gedrec);
} else {
$pos2++;
}
$gedrec = substr($gedrec, 0, $pos1) . substr($gedrec, $pos2);
}
$updated = true;
}
//-- remove the FAMS link from the old father
if (!is_null($father) && $father->getXref()!=$HUSB) {
$indirec = find_gedcom_record($father->getXref(), WT_GED_ID, true);
$pos1 = strpos($indirec, "1 FAMS @$xref@");
if ($pos1!==false) {
$pos2 = strpos($indirec, "\n1", $pos1+5);
if ($pos2===false) {
$pos2 = strlen($indirec);
} else {
$pos2++;
}
$indirec = substr($indirec, 0, $pos1) . substr($indirec, $pos2);
$father->updateRecord($indirec, $update_CHAN);
}
}
//-- add the new mother link
if (isset($_REQUEST['WIFE'])) $WIFE = $_REQUEST['WIFE'];
if (!empty($WIFE) && (is_null($mother) || $mother->getXref()!=$WIFE)) {
if (strstr($gedrec, "1 WIFE")!==false) {
$gedrec = preg_replace("/1 WIFE @.*@/", "1 WIFE @$WIFE@", $gedrec);
} else {
$gedrec .= "\n1 WIFE @$WIFE@";
}
$indirec = find_gedcom_record($WIFE, WT_GED_ID, true);
if (!empty($indirec) && (strpos($indirec, "1 FAMS @$xref@")===false)) {
$indirec .= "\n1 FAMS @$xref@";
$record = WT_GedcomRecord::getInstance($WI);
$record->updateRecord($indirec, $update_CHAN);
}
$updated = true;
}
//-- remove the father link
if (empty($WIFE)) {
$pos1 = strpos($gedrec, "1 WIFE @");
if ($pos1!==false) {
$pos2 = strpos($gedrec, "\n1", $pos1+5);
if ($pos2===false) {
$pos2 = strlen($gedrec);
} else {
$pos2++;
}
$gedrec = substr($gedrec, 0, $pos1) . substr($gedrec, $pos2);
}
$updated = true;
}
//-- remove the FAMS link from the old father
if (!is_null($mother) && $mother->getXref()!=$WIFE) {
$indirec = find_gedcom_record($mother->getXref(), WT_GED_ID, true);
$pos1 = strpos($indirec, "1 FAMS @$xref@");
if ($pos1!==false) {
$pos2 = strpos($indirec, "\n1", $pos1+5);
if ($pos2===false) {
$pos2 = strlen($indirec);
} else {
$pos2++;
}
$indirec = substr($indirec, 0, $pos1) . substr($indirec, $pos2);
$mother->updateRecord($indirec, $update_CHAN);
}
}
//-- update the children
$i=0;
$var = "CHIL".$i;
$newchildren = array();
while (isset($_REQUEST[$var])) {
$CHIL = $_REQUEST[$var];
if (!empty($CHIL)) {
$newchildren[] = $CHIL;
if (strpos($gedrec, "1 CHIL @$CHIL@")===false) {
$gedrec .= "\n1 CHIL @$CHIL@";
$updated = true;
$indirec = find_gedcom_record($CHIL, WT_GED_ID, true);
if (!empty($indirec) && (strpos($indirec, "1 FAMC @$xref@")===false)) {
$indirec .= "\n1 FAMC @$xref@";
$record = WT_GedcomRecord::getInstance($CHIL);
$record->updateRecord($indirec, $update_CHAN);
}
}
}
$i++;
$var = "CHIL".$i;
}
//-- remove the old children
foreach ($children as $key=>$child) {
if (!is_null($child)) {
if (!in_array($child->getXref(), $newchildren)) {
//-- remove the CHIL link from the family record
$pos1 = strpos($gedrec, "1 CHIL @".$child->getXref()."@");
if ($pos1!==false) {
$pos2 = strpos($gedrec, "\n1", $pos1+5);
if ($pos2===false) {
$pos2 = strlen($gedrec);
} else {
$pos2++;
}
$gedrec = substr($gedrec, 0, $pos1) . substr($gedrec, $pos2);
$updated = true;
}
//-- remove the FAMC link from the child record
$indirec = find_gedcom_record($child->getXref(), WT_GED_ID, true);
$pos1 = strpos($indirec, "1 FAMC @$xref@");
if ($pos1!==false) {
$pos2 = strpos($indirec, "\n1", $pos1+5);
if ($pos2===false) {
$pos2 = strlen($indirec);
} else {
$pos2++;
}
$indirec = substr($indirec, 0, $pos1) . substr($indirec, $pos2);
$child->updateRecord($indirec, $update_CHAN);
}
}
}
}
if ($updated) {
$record = WT_Family::getInstance($xref);
$record->updateRecord($gedrec, $update_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 "