';
break;
////////////////////////////////////////////////////////////////////////////////
case 'addnewparent':
$famtag = safe_GET('famtag', '(HUSB|WIFE)');
$famid = safe_GET('famid', WT_REGEX_XREF);
$pid = safe_GET('pid', WT_REGEX_XREF); // print_indi_form() uses this
$person = WT_Person::getInstance($pid);
if ($person) {
// Adding a parent to an individual
$name=$person->getFullName() . ' - ';
} else {
// Adding a spouse to a family
$name='';
}
if ($famtag=='WIFE') {
$controller->setPageTitle($name . WT_I18N::translate('Add a new mother'));
} else {
$controller->setPageTitle($name . WT_I18N::translate('Add a new father'));
}
$controller->pageHeader();
echo '
';
break;
////////////////////////////////////////////////////////////////////////////////
case 'addfamlink':
$person=WT_Person::getInstance($pid);
if ($famtag=='CHIL') {
$controller->setPageTitle($person->getFullName() . ' - ' . WT_I18N::translate('Link this person to an existing family as a child'));
} elseif ($person->getSex()=='F') {
$controller->setPageTitle($person->getFullName() . ' - ' . WT_I18N::translate('Link this person to an existing family as a wife'));
} else {
$controller->setPageTitle($person->getFullName() . ' - ' . WT_I18N::translate('Link this person to an existing family as a husband'));
}
$controller->pageHeader();
echo '
';
echo '
', $controller->getPageTitle(), '
';
echo '
getSex()=='F') {
$controller->setPageTitle($person->getFullName() . ' - ' . WT_I18N::translate('Add a husband using an existing person'));
} else {
$controller->setPageTitle($person->getFullName() . ' - ' . WT_I18N::translate('Add a wife using an existing person'));
}
$controller->pageHeader();
echo '
';
echo '
', $controller->getPageTitle(), '
';
init_calendar_popup();
echo '
setPageTitle($person->getFullName() . ' - ' . WT_I18N::translate('Link this person to an existing family as a child'));
} elseif ($person->getSex()=='F') {
$controller->setPageTitle($person->getFullName() . ' - ' . WT_I18N::translate('Link this person to an existing family as a wife'));
} else {
$controller->setPageTitle($person->getFullName() . ' - ' . WT_I18N::translate('Link this person to an existing family as a husband'));
}
$controller->pageHeader();
// Make sure we have the right ID (f123 vs. F123)
$famid=WT_Family::getInstance($famid)->getXref();
$famrec = find_gedcom_record($famid, WT_GED_ID, true);
$success=false;
if (!empty($famrec)) {
$itag = "FAMC";
if ($famtag=="HUSB" || $famtag=="WIFE") $itag="FAMS";
//-- update the individual record for the person
if (strpos($gedrec, "1 $itag @$famid@")===false) {
switch ($itag) {
case 'FAMC':
if (isset($_REQUEST['PEDI'])) {
$PEDI = $_REQUEST['PEDI'];
} else {
$PEDI='';
}
$gedrec.="\n".WT_Gedcom_Code_Pedi::createNewFamcPedi($PEDI, $famid);
break;
case 'FAMS':
$gedrec.="\n1 FAMS @$famid@";
break;
}
$success=replace_gedrec($pid, WT_GED_ID, $gedrec, $update_CHAN);
}
//-- if it is adding a new child to a family
if ($famtag=="CHIL") {
if (strpos($famrec, "1 $famtag @$pid@")===false) {
$famrec .= "\n1 $famtag @$pid@";
$success=replace_gedrec($famid, WT_GED_ID, $famrec, $update_CHAN);
}
} else {
//-- if it is adding a husband or wife
//-- check if the family already has a HUSB or WIFE
$ct = preg_match("/1 $famtag @(.*)@/", $famrec, $match);
if ($ct>0) {
//-- get the old ID
$spid = trim($match[1]);
//-- only continue if the old husb/wife is not the same as the current one
if ($spid!=$pid) {
//-- change a of the old ids to the new id
$famrec = str_replace("\n1 $famtag @$spid@", "\n1 $famtag @$pid@", $famrec);
$success=replace_gedrec($famid, WT_GED_ID, $famrec, $update_CHAN);
//-- remove the FAMS reference from the old husb/wife
if (!empty($spid)) {
$srec = find_gedcom_record($spid, WT_GED_ID, true);
if ($srec) {
$srec = str_replace("\n1 $itag @$famid@", "", $srec);
$success=replace_gedrec($spid, WT_GED_ID, $srec, $update_CHAN);
}
}
}
} else {
$famrec .= "\n1 $famtag @$pid@";
$success=replace_gedrec($famid, WT_GED_ID, $famrec, $update_CHAN);
}
}
} else {
echo "Family record not found";
}
if ($success && !WT_DEBUG) {
$controller->addInlineJavascript('closePopupAndReloadParent();');
}
break;
////////////////////////////////////////////////////////////////////////////////
case 'addnewsource':
$controller
->setPageTitle(WT_I18N::translate('Create a new source'))
->pageHeader();
echo '
';
echo '
', $controller->getPageTitle(), '
';
echo '';
?>
setPageTitle(WT_I18N::translate('Create a new source'))
->pageHeader();
$newgedrec = "0 @XREF@ SOUR";
if (isset($_REQUEST['EVEN'])) $EVEN = $_REQUEST['EVEN'];
if (!empty($EVEN) && count($EVEN)>0) {
$newgedrec .= "\n1 DATA";
$newgedrec .= "\n2 EVEN ".implode(",", $EVEN);
if (!empty($EVEN_DATE)) $newgedrec .= "\n3 DATE ".$EVEN_DATE;
if (!empty($EVEN_PLAC)) $newgedrec .= "\n3 PLAC ".$EVEN_PLAC;
if (!empty($AGNC)) $newgedrec .= "\n2 AGNC ".$AGNC;
}
if (isset($_REQUEST['ABBR'])) $ABBR = $_REQUEST['ABBR'];
if (isset($_REQUEST['TITL'])) $TITL = $_REQUEST['TITL'];
if (isset($_REQUEST['_HEB'])) $_HEB = $_REQUEST['_HEB'];
if (isset($_REQUEST['ROMN'])) $ROMN = $_REQUEST['ROMN'];
if (isset($_REQUEST['AUTH'])) $AUTH = $_REQUEST['AUTH'];
if (isset($_REQUEST['PUBL'])) $PUBL = $_REQUEST['PUBL'];
if (isset($_REQUEST['REPO'])) $REPO = $_REQUEST['REPO'];
if (isset($_REQUEST['CALN'])) $CALN = $_REQUEST['CALN'];
if (!empty($ABBR)) $newgedrec .= "\n1 ABBR $ABBR";
if (!empty($TITL)) {
$newgedrec .= "\n1 TITL $TITL";
if (!empty($_HEB)) $newgedrec .= "\n2 _HEB $_HEB";
if (!empty($ROMN)) $newgedrec .= "\n2 ROMN $ROMN";
}
if (!empty($AUTH)) $newgedrec .= "\n1 AUTH $AUTH";
if (!empty($PUBL)) {
foreach (preg_split("/\r?\n/", $PUBL) as $k=>$line) {
if ($k==0) {
$newgedrec .= "\n1 PUBL $line";
} else {
$newgedrec .= "\n2 CONT $line";
}
}
}
if (!empty($REPO)) {
$newgedrec .= "\n1 REPO @$REPO@";
if (!empty($CALN)) $newgedrec .= "\n2 CALN $CALN";
}
$xref = append_gedrec($newgedrec, WT_GED_ID);
if ($xref) {
$controller->addInlineJavascript('openerpasteid("' . $xref . '");');
}
break;
////////////////////////////////////////////////////////////////////////////////
case 'addnewnote':
$controller
->setPageTitle(WT_I18N::translate('Create a new Shared Note'))
->pageHeader();
echo '
';
echo '
', $controller->getPageTitle(), '
';
?>
setPageTitle(WT_I18N::translate('Create a new Shared Note'))
->pageHeader();
$newgedrec = "0 @XREF@ NOTE";
if (isset($_REQUEST['NOTE'])) $NOTE = $_REQUEST['NOTE'];
if (!empty($NOTE)) {
foreach (preg_split("/\r?\n/", $NOTE) as $k=>$line) {
if ($k==0) {
$newgedrec .= " {$line}";
} else {
$newgedrec .= "\n1 CONT {$line}";
}
}
}
$xref = append_gedrec($newgedrec, WT_GED_ID);
if ($xref) {
$controller->addInlineJavascript('openerpasteid("' . $xref . '");');
}
break;
////////////////////////////////////////////////////////////////////////////////
case 'addnewnote_assisted':
$controller
->setPageTitle(WT_I18N::translate('Create a new Shared Note using Assistant'))
->pageHeader();
echo '
';
echo '
', $controller->getPageTitle(), ' ';
// When more languages are added to the wiki, we can expand or redesign this
switch (WT_LOCALE) {
case 'fr':
echo wiki_help_link('/fr/Module_Assistant_Recensement');
break;
case 'en':
default:
echo wiki_help_link('/en/Census_Assistant_module');
break;
}
echo '
';
if (isset($_REQUEST['pid'])) $pid = $_REQUEST['pid'];
global $pid;
?>
setPageTitle(WT_I18N::translate('Create a new Shared Note using Assistant'))
->pageHeader();
echo '
';
break;
////////////////////////////////////////////////////////////////////////////////
case 'reorder_media_update': // Update sort using popup
$controller
->setPageTitle(WT_I18N::translate('Re-order media'))
->pageHeader();
if (isset($_REQUEST['order1'])) $order1 = $_REQUEST['order1'];
$lines = explode("\n", $gedrec);
$newgedrec = "";
foreach ($lines as $line) {
if (strpos($line, '1 _WT_OBJE_SORT')===false) {
$newgedrec .= $line."\n";
}
}
foreach ($order1 as $m_media=>$num) {
$newgedrec .= "\n1 _WT_OBJE_SORT @".$m_media."@";
}
$success=replace_gedrec($pid, WT_GED_ID, $newgedrec, $update_CHAN);
if ($success && !WT_DEBUG) {
$controller->addInlineJavascript('closePopupAndReloadParent();');
}
break;
////////////////////////////////////////////////////////////////////////////////
case 'al_reset_media_update': // Reset sort using Album Page
$controller
->setPageTitle(WT_I18N::translate('Re-order media'))
->pageHeader();
$lines = explode("\n", $gedrec);
$newgedrec = "";
foreach ($lines as $line) {
if (strpos($line, "1 _WT_OBJE_SORT")===false) {
$newgedrec .= $line."\n";
}
}
$success=replace_gedrec($pid, WT_GED_ID, $newgedrec, $update_CHAN);
if ($success && !WT_DEBUG) {
$controller->addInlineJavascript('closePopupAndReloadParent();');
}
break;
////////////////////////////////////////////////////////////////////////////////
case 'al_reorder_media_update': // Update sort using Album Page
$controller
->setPageTitle(WT_I18N::translate('Re-order media'))
->pageHeader();
if (isset($_REQUEST['order1'])) $order1 = $_REQUEST['order1'];
function SwapArray($Array) {
$Values = array();
while (list($Key, $Val) = each($Array))
$Values[$Val] = $Key;
return $Values;
}
if (isset($_REQUEST['order2'])) $order2 = $_REQUEST['order2'];
$order2 = SwapArray(explode(",", substr($order2, 0, -1)));
$lines = explode("\n", $gedrec);
$newgedrec = "";
foreach ($lines as $line) {
if (strpos($line, "1 _WT_OBJE_SORT")===false) {
$newgedrec .= $line."\n";
}
}
foreach ($order2 as $m_media=>$num) {
$newgedrec .= "\n1 _WT_OBJE_SORT @".$m_media."@";
}
$success=replace_gedrec($pid, WT_GED_ID, $newgedrec, $update_CHAN);
if ($success && !WT_DEBUG) {
$controller->addInlineJavascript('closePopupAndReloadParent();');
}
break;
////////////////////////////////////////////////////////////////////////////////
case 'reorder_children':
$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 children'))
->pageHeader();
echo '
';
echo '
', $controller->getPageTitle(), '
';
?>
setPageTitle(WT_I18N::translate('Change Family Members'))
->pageHeader();
echo '
';
echo '
', $controller->getPageTitle(), '
';
$father = $family->getHusband();
$mother = $family->getWife();
$children = $family->getChildren();
if (count($children)>0) {
if (!is_null($father)) {
if ($father->getSex()=="F") {
$father->setLabel(WT_I18N::translate('mother'));
} else {
$father->setLabel(WT_I18N::translate('father'));
}
}
if (!is_null($mother)) {
if ($mother->getSex()=="M") {
$mother->setLabel(WT_I18N::translate('father'));
} else {
$mother->setLabel(WT_I18N::translate('mother'));
}
}
for ($i=0; $igetSex()=="M") {
$children[$i]->setLabel(WT_I18N::translate('son'));
} elseif ($children[$i]->getSex()=="F") {
$children[$i]->setLabel(WT_I18N::translate('daughter'));
} else {
$children[$i]->setLabel(WT_I18N::translate('child'));
}
}
}
} else {
if (!is_null($father)) {
if ($father->getSex()=="F") {
$father->setLabel(WT_I18N::translate('wife'));
} elseif ($father->getSex()=="M") {
$father->setLabel(WT_I18N::translate('husband'));
} else {
$father->setLabel(WT_I18N::translate('spouse'));
}
}
if (!is_null($mother)) {
if ($mother->getSex()=="F") {
$mother->setLabel(WT_I18N::translate('wife'));
} elseif ($mother->getSex()=="M") {
$mother->setLabel(WT_I18N::translate('husband'));
} else {
$father->setLabel(WT_I18N::translate('spouse'));
}
}
}
?>
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();
$family = new WT_Family($gedrec);
$father = $family->getHusband();
$mother = $family->getWife();
$children = $family->getChildren();
$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 = find_gedcom_record($HUSB, WT_GED_ID, true);
if (!empty($indirec) && (strpos($indirec, "1 FAMS @$famid@")===false)) {
$indirec .= "\n1 FAMS @$famid@";
replace_gedrec($HUSB, WT_GED_ID, $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 @$famid@");
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);
replace_gedrec($father->getXref(), WT_GED_ID, $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 @$famid@")===false)) {
$indirec .= "\n1 FAMS @$famid@";
replace_gedrec($WIFE, WT_GED_ID, $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 @$famid@");
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);
replace_gedrec($mother->getXref(), WT_GED_ID, $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 @$famid@")===false)) {
$indirec .= "\n1 FAMC @$famid@";
replace_gedrec($CHIL, WT_GED_ID, $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 @$famid@");
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);
replace_gedrec($child->getXref(), WT_GED_ID, $indirec, $update_CHAN);
}
}
}
}
if ($updated) {
$success = replace_gedrec($famid, WT_GED_ID, $gedrec, $update_CHAN);
} else {
$success = false;
}
if ($success && !WT_DEBUG) {
$controller->addInlineJavascript('closePopupAndReloadParent();');
}
break;
////////////////////////////////////////////////////////////////////////////////
case 'reorder_update':
$controller
->setPageTitle(WT_I18N::translate('Re-order children'))
->pageHeader();
if (isset($_REQUEST['order'])) $order = $_REQUEST['order'];
asort($order);
reset($order);
$newgedrec = $gedrec;
foreach ($order as $child=>$num) {
// move each child subrecord to the bottom, in the order specified
$subrec = get_sub_record(1, '1 CHIL @'.$child.'@', $gedrec);
$subrec = trim($subrec, "\n");
$newgedrec = str_replace($subrec, '', $newgedrec);
$newgedrec .= "\n".$subrec."\n";
}
$success = replace_gedrec($pid, WT_GED_ID, $newgedrec, $update_CHAN);
if ($success && !WT_DEBUG) {
$controller->addInlineJavascript('closePopupAndReloadParent();');
}
break;
////////////////////////////////////////////////////////////////////////////////
case 'reorder_fams':
$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();
echo '
';
echo '
', $controller->getPageTitle(), '
';
?>
setPageTitle(WT_I18N::translate('Re-order families'))
->pageHeader();
if (isset($_REQUEST['order'])) $order = $_REQUEST['order'];
asort($order);
reset($order);
$lines = explode("\n", $gedrec);
$newgedrec = "";
foreach ($lines as $line) {
if (strpos($line, "1 FAMS")===false) {
$newgedrec .= $line."\n";
}
}
foreach ($order as $famid=>$num) {
$newgedrec .= "\n1 FAMS @".$famid."@";
}
$success = replace_gedrec($pid, WT_GED_ID, $newgedrec, $update_CHAN);
if ($success && !WT_DEBUG) {
$controller->addInlineJavascript('closePopupAndReloadParent();');
}
break;
}
// Keep the existing CHAN record when editing
function no_update_chan(WT_GedcomRecord $record) {
global $NO_UPDATE_CHAN;
$checked = $NO_UPDATE_CHAN ? ' checked="checked"' : '';
if (WT_USER_IS_ADMIN) {
return
'