\n";
print_simple_footer();
exit;
}
//-- privatize the record so that line numbers etc. match what was in the display
//-- data that is hidden because of privacy is stored in the $pgv_private_records array
//-- any private data will be restored when the record is replaced
if (isset($gedrec)) {
$gedrec = privatize_gedcom($gedrec);
}
if (!isset($type)) {
$type="";
}
$level0type = $type;
if ($type=="INDI") {
$record=Person::getInstance($pid);
echo "", PrintReady($record->getFullName()), " ";
}
elseif ($type=="FAM") {
if (!empty($pid)) {
$record=Family::getInstance($pid);
} else {
$record=Family::getInstance($famid);
}
echo "", PrintReady($record->getFullName()), " ";
} elseif ($type=="SOUR") {
$record=Source::getInstance($pid);
echo "", PrintReady($record->getFullName()), " ";
if ($TEXT_DIRECTION=="rtl") {
echo getRLM();
}
echo "(", $pid, ")";
if ($TEXT_DIRECTION=="rtl") {
echo getRLM();
}
echo " ";
}
if (strstr($action, "addchild")) {
if (empty($famid)) {
echo '', i18n::translate('Add an unlinked person'), '', help_link('edit_add_unlinked_person');
}
else {
echo '', i18n::translate('Add child'), '', help_link('edit_add_child');
}
} else if (strstr($action, "addspouse")) {
if ($famtag=="WIFE") {
echo '', i18n::translate('Add wife'), '';
} else {
echo '', i18n::translate('Add husband'), '';
}
echo help_link('edit_add_spouse');
} else if (strstr($action, "addnewparent")) {
if ($famtag=="WIFE") {
echo '', i18n::translate('Add a new mother'), '';
} else {
echo '', i18n::translate('Add a new father'), '';
}
echo help_link('edit_add_parent');
}else if (strstr($action, "addopfchild")) {
echo '', i18n::translate('Add a child to create a one-parent family'), '', help_link('edit_add_child');
} else {
echo '', i18n::translate($type), '';
}
//------------------------------------------------------------------------------
switch ($action) {
case 'delete':
if (WT_DEBUG) {
phpinfo(INFO_VARIABLES);
}
if (!empty($linenum)) {
if ($linenum===0) {
if (delete_gedrec($pid)) {
echo i18n::translate('GEDCOM record successfully deleted.');
}
}
else {
$mediaid='';
if (isset($_REQUEST['mediaid'])) {
$mediaid = $_REQUEST['mediaid'];
}
//-- when deleting a media link
//-- $linenum comes is an OBJE and the $mediaid to delete should be set
if (!is_numeric($linenum)) {
$newged = remove_subrecord($gedrec, $linenum, $mediaid);
} else {
$newged = remove_subline($gedrec, $linenum);
}
$success = (replace_gedrec($pid, $newged, $update_CHAN));
if ($success) {
echo "
", i18n::translate('GEDCOM record successfully deleted.');
}
}
}
break;
//------------------------------------------------------------------------------
//-- echo a form to edit the raw gedcom record in a large textarea
case 'editraw':
if (!checkFactEdit($gedrec)) {
echo " ", i18n::translate('Privacy settings prevent you from editing this record.');
if (!empty($pid)) {
echo " ", i18n::translate('You have no access to'), " pid $pid.";
}
if (!empty($famid)) {
echo " ", i18n::translate('You have no access to'), " famid $famid.";
}
print_simple_footer();
exit;
}
else {
echo " ", i18n::translate('Edit raw GEDCOM record'), '', help_link('edit_edit_raw');
echo "";
echo WT_JS_START;
echo "textbox = document.getElementById('newgedrec');";
echo "savebutton = document.getElementById('savebutton');";
echo "if (textbox && savebutton) {";
echo " window.resizeTo(textbox.offsetLeft+textbox.offsetWidth+100, savebutton.offsetTop+savebutton.offsetHeight+150);";
echo "}";
echo WT_JS_END;
}
break;
//------------------------------------------------------------------------------
//-- edit a fact record in a form
case 'edit':
init_calendar_popup();
echo "\n";
break;
//------------------------------------------------------------------------------
case 'add':
//
// Start of add section...
//
init_calendar_popup();
echo "\n";
// }
break;
//------------------------------------------------------------------------------
case 'addchild':
print_indi_form("addchildaction", $famid, "", "", "CHIL", @$_REQUEST["gender"]);
break;
//------------------------------------------------------------------------------
case 'addspouse':
print_indi_form("addspouseaction", $famid, "", "", $famtag);
break;
//------------------------------------------------------------------------------
case 'addnewparent':
print_indi_form("addnewparentaction", $famid, "", "", $famtag);
break;
//------------------------------------------------------------------------------
case 'addopfchild':
print_indi_form('addopfchildaction', $famid, '', '', 'CHIL');
break;
//------------------------------------------------------------------------------
case 'addfamlink':
echo "\n";
break;
//------------------------------------------------------------------------------
case 'linkspouse':
init_calendar_popup();
echo "\n";
break;
//------------------------------------------------------------------------------
case 'linkfamaction':
// Make sure we have the right ID (f123 vs. F123)
$famid=Family::getInstance($famid)->getXref();
if (WT_DEBUG) {
phpinfo(INFO_VARIABLES);
}
if (!isset($pgv_changes[$famid."_".WT_GEDCOM])) $famrec = find_gedcom_record($famid, WT_GED_ID);
else $famrec = find_updated_record($famid, WT_GED_ID);
$famrec = trim($famrec);
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) {
$gedrec .= "\n";
if ($itag=="FAMC") {
$pedigree="";
if (isset($_REQUEST['pedigree'])) $pedigree = $_REQUEST['pedigree'];
switch ($pedigree) {
case 'birth':
$gedrec .= "1 FAMC @$famid@\n2 PEDI $pedigree";
break;
case 'adopted':
$gedrec .= "1 FAMC @$famid@\n2 PEDI $pedigree\n1 ADOP\n2 FAMC @$famid@\n3 ADOP BOTH";
break;
case 'sealing':
$gedrec .= "1 FAMC @$famid@\n2 PEDI $pedigree\n1 SLGC\n2 FAMC @$famid@";
break;
case 'foster':
$gedrec .= "1 FAMC @$famid@\n2 PEDI $pedigree\n1 EVEN\n2 TYPE $pedigree";
break;
default:
$gedrec .= "1 FAMC @$famid@";
break;
}
} else {
$gedrec .= "1 FAMS @$famid@";
}
replace_gedrec($pid, $gedrec, $update_CHAN);
}
//-- if it is adding a new child to a family
if ($famtag=="CHIL") {
if (strpos($famrec, "1 $famtag @$pid@")===false) {
$famrec = trim($famrec) . "\n1 $famtag @$pid@\n";
replace_gedrec($famid, $famrec, $update_CHAN);
}
}
//-- if it is adding a husband or wife
else {
//-- 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("1 $famtag @$spid@", "1 $famtag @$pid@", $famrec);
if (WT_DEBUG) {
echo "
$famrec
";
}
replace_gedrec($famid, $famrec, $update_CHAN);
//-- remove the FAMS reference from the old husb/wife
if (!empty($spid)) {
if (!isset($pgv_changes[$spid."_".WT_GEDCOM])) $srec = find_gedcom_record($spid, WT_GED_ID);
else $srec = find_updated_record($spid, WT_GED_ID);
if ($srec) {
$srec = str_replace("1 $itag @$famid@", "", $srec);
if (WT_DEBUG) {
echo "
\n";
if ($NO_UPDATE_CHAN) {
echo "\n";
} else {
echo "\n";
}
echo i18n::translate('Do not update the CHAN (Last Change) record'), " \n";
$event = new Event(get_sub_record(1, "1 CHAN", $gedrec));
echo format_fact_date($event, false, true);
echo "
\n";
}
echo "
";
print_add_layer("NOTE");
print_add_layer("SHARED_NOTE");
print_add_layer("OBJE");
//-- RESN missing in new structure, RESN can be added to all level 1 tags
if ($tag && !in_array("RESN", $tags)) print_add_layer("RESN");
echo "
\n";
echo "\n";
break;
//------------------------------------------------------------------------------
//-- edit a Shared Note
case 'editnote':
echo WT_JS_START;
?>
function check_form(frm) {
if (frm.TITL.value=="") {
alert('');
frm.TITL.focus();
return false;
}
return true;
}
function check_form(frm) {
if (frm.NAME.value=="") {
alert('');
frm.NAME.focus();
return false;
}
return true;
}
$line) {
if ( $k==0 ) {
$newgedrec .= "1 ADDR {$line}\n";
} else {
$newgedrec .= "2 CONT {$line}\n";
}
}
}
if (!empty($PHON)) $newgedrec .= "1 PHON $PHON\n";
if (!empty($FAX)) $newgedrec .= "1 FAX $FAX\n";
if (!empty($EMAIL)) $newgedrec .= "1 EMAIL $EMAIL\n";
if (!empty($WWW)) $newgedrec .= "1 WWW $WWW\n";
if (WT_DEBUG) {
echo "
", i18n::translate('Update successful');
break;
//----------------------------------------------------------------------------------
//-- reconstruct the gedcom from the incoming fields and store it in the file
case 'update':
/* -----------------------------------------------------------------------------
* $pids_array is a text file passed via js from the CENS GEDFact Assistant
* to the hidden field id=\"pids_array\" in the case 'add'.
* The subsequent array ($cens_pids), after exploding this text file,
* is an array of indi id's within the Census Transcription
* If $cens_pids is set, then this allows the array to "copy" the new CENS event
* using the foreach loop to these id's
* If $cens_pids is not set, then the array created is just the current $pid.
* -----------------------------------------------------------------------------
*/
if (isset($_REQUEST['pids_array_add'])) $pids_array = $_REQUEST['pids_array_add'];
if (isset($_REQUEST['pids_array_edit'])) $pids_array = $_REQUEST['pids_array_edit'];
if (isset($pids_array) && $pids_array!="no_array") {
$cens_pids=explode(', ', $pids_array);
}
if (!isset($cens_pids)){
$cens_pids = array($pid);
$idnums="";
}else{
$cens_pids = $cens_pids;
$idnums="multi";
}
// Cycle through each individual concerned defined by $cens_pids array.
foreach ($cens_pids as $pid) {
if (isset($pid)) {
$gedrec = find_updated_record($pid, WT_GED_ID);
if (empty($gedrec)) $gedrec = find_gedcom_record($pid, WT_GED_ID);
} else if (isset($famid)) {
$gedrec = find_updated_record($famid, WT_GED_ID);
if (empty($gedrec)) $gedrec = find_gedcom_record($famid, WT_GED_ID);
}
if (WT_DEBUG) {
phpinfo(INFO_VARIABLES);
echo "
$gedrec
";
echo "
";
}
// add or remove Y
if ($text[0]=="Y" or $text[0]=="y") $text[0]="";
if (in_array($tag[0], $emptyfacts) && array_unique($text)==array("") && !$islink[0]) $text[0]="Y";
//-- check for photo update
if (count($_FILES)>0) {
if (isset($_REQUEST['folder'])) $folder = $_REQUEST['folder'];
$uploaded_files = array();
if (substr($folder, 0, 1) == "/") $folder = substr($folder, 1);
if (substr($folder, -1, 1) != "/") $folder .= "/";
foreach ($_FILES as $upload) {
if (!empty($upload['tmp_name'])) {
if (!move_uploaded_file($upload['tmp_name'], $MEDIA_DIRECTORY.$folder.basename($upload['name']))) {
$error .= " ".i18n::translate('There was an error uploading your file.')." ".file_upload_error_text($upload['error']);
$uploaded_files[] = "";
}
else {
$filename = $MEDIA_DIRECTORY.$folder.basename($upload['name']);
$uploaded_files[] = $MEDIA_DIRECTORY.$folder.basename($upload['name']);
if (!is_dir($MEDIA_DIRECTORY."thumbs/".$folder)) mkdir($MEDIA_DIRECTORY."thumbs/".$folder);
$thumbnail = $MEDIA_DIRECTORY."thumbs/".$folder.basename($upload['name']);
generate_thumbnail($filename, $thumbnail);
if (!empty($error)) {
echo "", $error, "";
}
}
}
else $uploaded_files[] = "";
}
}
$gedlines = explode("\n", trim($gedrec));
//-- for new facts set linenum to number of lines
if (!is_array($linenum)) {
if ($linenum=="new" || $idnums=="multi") {
$linenum = count($gedlines);
}
$newged = "";
for ($i=0; $i<$linenum; $i++) {
$newged .= $gedlines[$i]."\n";
}
//-- for edits get the level from the line
if (isset($gedlines[$linenum])) {
$fields = explode(' ', $gedlines[$linenum]);
$glevel = $fields[0];
$i++;
while (($i$glevel)) $i++;
}
if (!isset($glevels)) $glevels = array();
if (isset($_REQUEST['NAME'])) $NAME = $_REQUEST['NAME'];
if (isset($_REQUEST['TYPE'])) $TYPE = $_REQUEST['TYPE'];
if (isset($_REQUEST['NPFX'])) $NPFX = $_REQUEST['NPFX'];
if (isset($_REQUEST['GIVN'])) $GIVN = $_REQUEST['GIVN'];
if (isset($_REQUEST['NICK'])) $NICK = $_REQUEST['NICK'];
if (isset($_REQUEST['SPFX'])) $SPFX = $_REQUEST['SPFX'];
if (isset($_REQUEST['SURN'])) $SURN = $_REQUEST['SURN'];
if (isset($_REQUEST['NSFX'])) $NSFX = $_REQUEST['NSFX'];
if (isset($_REQUEST['ROMN'])) $ROMN = $_REQUEST['ROMN'];
if (isset($_REQUEST['FONE'])) $FONE = $_REQUEST['FONE'];
if (isset($_REQUEST['_HEB'])) $_HEB = $_REQUEST['_HEB'];
if (isset($_REQUEST['_AKA'])) $_AKA = $_REQUEST['_AKA'];
if (isset($_REQUEST['_MARNM'])) $_MARNM = $_REQUEST['_MARNM'];
if (!empty($NAME)) $newged .= "1 NAME $NAME\n";
if (!empty($TYPE)) $newged .= "2 TYPE $TYPE\n";
if (!empty($NPFX)) $newged .= "2 NPFX $NPFX\n";
if (!empty($GIVN)) $newged .= "2 GIVN $GIVN\n";
if (!empty($NICK)) $newged .= "2 NICK $NICK\n";
if (!empty($SPFX)) $newged .= "2 SPFX $SPFX\n";
if (!empty($SURN)) $newged .= "2 SURN $SURN\n";
if (!empty($NSFX)) $newged .= "2 NSFX $NSFX\n";
if (isset($_REQUEST['NOTE'])) $NOTE = $_REQUEST['NOTE'];
if (!empty($NOTE)) {
foreach (preg_split("/\r?\n/", $NOTE, -1 ) as $k=>$line) {
if ($k==0) {
$gedlines[$k] = "0 @{$pid}@ NOTE {$line}\n";
} else {
$gedlines[$k] = "1 CONT {$line}\n";
}
}
}
//-- Refer to Bug [ 1329644 ] Add Married Name - Wrong Sequence
//-- _HEB/ROMN/FONE have to be before _AKA, even if _AKA exists in input and the others are now added
if (!empty($ROMN)) $newged .= "2 ROMN $ROMN\n";
if (!empty($FONE)) $newged .= "2 FONE $FONE\n";
if (!empty($_HEB)) $newged .= "2 _HEB $_HEB\n";
$newged = handle_updates($newged);
if (!empty($_AKA)) $newged .= "2 _AKA $_AKA\n";
if (!empty($_MARNM)) $newged .= "2 _MARNM $_MARNM\n";
while ($i$glevel)) $i++;
}
if (!isset($glevels)) $glevels = array();
if (isset($_REQUEST['NAME'])) $NAME = $_REQUEST['NAME'];
if (isset($_REQUEST['TYPE'])) $TYPE = $_REQUEST['TYPE'];
if (isset($_REQUEST['NPFX'])) $NPFX = $_REQUEST['NPFX'];
if (isset($_REQUEST['GIVN'])) $GIVN = $_REQUEST['GIVN'];
if (isset($_REQUEST['NICK'])) $NICK = $_REQUEST['NICK'];
if (isset($_REQUEST['SPFX'])) $SPFX = $_REQUEST['SPFX'];
if (isset($_REQUEST['SURN'])) $SURN = $_REQUEST['SURN'];
if (isset($_REQUEST['NSFX'])) $NSFX = $_REQUEST['NSFX'];
if (isset($_REQUEST['ROMN'])) $ROMN = $_REQUEST['ROMN'];
if (isset($_REQUEST['FONE'])) $FONE = $_REQUEST['FONE'];
if (isset($_REQUEST['_HEB'])) $_HEB = $_REQUEST['_HEB'];
if (isset($_REQUEST['_AKA'])) $_AKA = $_REQUEST['_AKA'];
if (isset($_REQUEST['_MARNM'])) $_MARNM = $_REQUEST['_MARNM'];
if (!empty($NAME)) $newged .= "1 NAME $NAME\n";
if (!empty($TYPE)) $newged .= "2 TYPE $TYPE\n";
if (!empty($NPFX)) $newged .= "2 NPFX $NPFX\n";
if (!empty($GIVN)) $newged .= "2 GIVN $GIVN\n";
if (!empty($NICK)) $newged .= "2 NICK $NICK\n";
if (!empty($SPFX)) $newged .= "2 SPFX $SPFX\n";
if (!empty($SURN)) $newged .= "2 SURN $SURN\n";
if (!empty($NSFX)) $newged .= "2 NSFX $NSFX\n";
if (isset($_REQUEST['NOTE'])) $NOTE = $_REQUEST['NOTE'];
if (!empty($NOTE)) {
foreach (preg_split("/\r?\n/", $NOTE) as $k=>$line) {
if ($k==0) {
$gedlines[$k] = "0 @{$pid}@ NOTE {$line}\n";
} else {
$gedlines[$k] = "1 CONT {$line}\n";
}
}
}
//-- Refer to Bug [ 1329644 ] Add Married Name - Wrong Sequence
//-- _HEB/ROMN/FONE have to be before _AKA, even if _AKA exists in input and the others are now added
if (!empty($ROMN)) $newged .= "2 ROMN $ROMN\n";
if (!empty($FONE)) $newged .= "2 FONE $FONE\n";
if (!empty($_HEB)) $newged .= "2 _HEB $_HEB\n";
if (!empty($_AKA)) $newged .= "2 _AKA $_AKA\n";
if (!empty($_MARNM)) $newged .= "2 _MARNM $_MARNM\n";
$newged = handle_updates($newged);
$current = $editline;
break;
}
}
if (WT_DEBUG) {
echo "
", i18n::translate('Update successful');
$gedrec = "";
if (!empty($famid)) {
// Insert new child at the right place [ 1686246 ]
$newchild = Person::getInstance($xref);
$family = Family::getInstance($famid);
if ($family->getUpdatedFamily()) $family = $family->getUpdatedFamily();
$gedrec = $family->gedrec;
$done = false;
foreach ($family->getChildren() as $key=>$child) {
if (GedcomDate::Compare($newchild->getEstimatedBirthDate(), $child->getEstimatedBirthDate())<0) {
// new child is older : insert before
$gedrec = str_replace("1 CHIL @".$child->getXref()."@",
"1 CHIL @$xref@\n1 CHIL @".$child->getXref()."@",
$gedrec);
$done = true;
break;
}
}
// new child is the only one
if (count($family->getChildren())<1) $gedrec .= "\n1 CHIL @$xref@";
else if (!$done) {
// new child is the youngest or undated : insert after
$gedrec = str_replace("1 CHIL @".$child->getXref()."@",
"1 CHIL @".$child->getXref()."@\n1 CHIL @$xref@",
$gedrec);
}
if (WT_DEBUG) {
echo "
$gedrec
";
}
replace_gedrec($famid, $gedrec, $update_CHAN);
}
$success = true;
}
break;
//------------------------------------------------------------------------------
case 'addspouseaction':
if (WT_DEBUG) {
phpinfo(INFO_VARIABLES);
}
splitSOUR(); // separate SOUR record from the rest
$gedrec ="0 @REF@ INDI\n";
$gedrec.=addNewName();
$gedrec.=addNewSex ();
if (preg_match_all('/([A-Z0-9_]+)/', $QUICK_REQUIRED_FACTS, $matches)) {
foreach ($matches[1] as $match) {
$gedrec.=addNewFact($match);
}
}
if (safe_POST_bool('SOUR_INDI')) {
$gedrec = handle_updates($gedrec);
} else {
$gedrec = updateRest($gedrec);
}
if (WT_DEBUG) {
echo "
", i18n::translate('Update successful');
$success = true;
}
}
break;
//------------------------------------------------------------------------------
case 'deleteperson':
if (WT_DEBUG) {
phpinfo(INFO_VARIABLES);
echo "
$gedrec
";
}
if (!checkFactEdit($gedrec)) {
echo " ", i18n::translate('Privacy settings prevent you from editing this record.');
if (!empty($pid)) echo " ", i18n::translate('You have no access to'), " pid $pid.";
if (!empty($famid)) echo " ", i18n::translate('You have no access to'), " famid $famid.";
}
else {
if (delete_person($pid, $gedrec)) echo "
", i18n::translate('GEDCOM record successfully deleted.');
}
break;
//------------------------------------------------------------------------------
case 'deletefamily':
if (WT_DEBUG) {
phpinfo(INFO_VARIABLES);
echo "
$gedrec
";
}
if (!checkFactEdit($gedrec)) {
echo " ", i18n::translate('Privacy settings prevent you from editing this record.');
if (!empty($pid)) echo " ", i18n::translate('You have no access to'), " pid $pid.";
if (!empty($famid)) echo " ", i18n::translate('You have no access to'), " famid $famid.";
}
else
{
if (delete_family($famid, $gedrec)) echo "
", i18n::translate('GEDCOM record successfully deleted.');
}
break;
//----------------------------------------------------------------------------------
// This case will now delete Shared notes as well, as $pid is passed with call
// from source_ctrl.php or note_ctrl.php (line 208 submenu->addOnclick ..... etc)
// ---------------------------------------------------------------------------------
case 'deletenote':
case 'deletesource':
case 'deleterepo':
if (isset($_REQUEST['action'])) $action = $_REQUEST['action'];
if (WT_DEBUG) {
phpinfo(INFO_VARIABLES);
echo "
$gedrec
";
}
if (!empty($gedrec)) {
$success = true;
// Delete links to this record
foreach (fetch_all_links($pid, WT_GED_ID) as $xref) {
if (isset($pgv_changes[$xref.'_'.WT_GEDCOM])) {
$gedrec=find_updated_record($xref, WT_GED_ID);
} else {
$gedrec=find_gedcom_record($xref, WT_GED_ID);
}
$lines = explode("\n", $gedrec);
$newrec = "";
$skipline = false;
$glevel = 0;
foreach ($lines as $indexval => $line) {
if ((preg_match("/^\d ".WT_REGEX_TAG." @$pid@/", $line)==0)&&(!$skipline)) $newrec .= $line."\n";
else {
if (!$skipline) {
$glevel = $line{0};
$skipline = true;
}
else {
if ($line{0}<=$glevel) {
$skipline = false;
$newrec .= $line."\n";
}
}
}
}
if (WT_DEBUG) {
echo "
";
if (!file_exists(WT_ROOT.'modules/googlemap/defaultconfig.php')) {
$tabno = "7";
}else{
$tabno = "8";
}
echo WT_JS_START;
echo "location.href='individual.php?pid={$pid}&tab={$tabno}'";
echo WT_JS_END;
break;
//------------------------------------------------------------------------------
case 'al_reorder_media_update': // Update sort using Album Page
if (WT_DEBUG) {
phpinfo(INFO_VARIABLES);
}
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_OBJS")===false) {
$newgedrec .= $line."\n";
}
}
foreach ($order2 as $m_media=>$num) {
$newgedrec .= "1 _WT_OBJS @".$m_media."@\n";
}
if (WT_DEBUG) {
echo "
$newgedrec
";
}
$success = (replace_gedrec($pid, $newgedrec, $update_CHAN));
if ($success) {
if (!file_exists(WT_ROOT.'modules/googlemap/defaultconfig.php')) {
$tabno = "7";
}else{
$tabno = "8";
}
echo WT_JS_START;
echo "location.href='individual.php?pid={$pid}&tab={$tabno}'";
echo WT_JS_END;
}
break;
//LBox ===================================================
//------------------------------------------------------------------------------
case 'reorder_children':
require_once WT_ROOT.'js/prototype.js.htm';
require_once WT_ROOT.'js/scriptaculous.js.htm';
echo " ", i18n::translate('Re-order children'), "", help_link('reorder_children');
?>
getHusband();
$mother = $family->getWife();
$children = $family->getChildren();
if (count($children)>0) {
if (!is_null($father)) {
if ($father->getSex()=="F") $father->setLabel(i18n::translate('Mother'));
else $father->setLabel(i18n::translate('Father'));
}
if (!is_null($mother)) {
if ($mother->getSex()=="M") $mother->setLabel(i18n::translate('Father'));
else $mother->setLabel(i18n::translate('Mother'));
}
for ($i=0; $igetSex()=="M") {
$children[$i]->setLabel(i18n::translate('Son'));
} elseif ($children[$i]->getSex()=="F") {
$children[$i]->setLabel(i18n::translate('Daughter'));
} else {
$children[$i]->setLabel(i18n::translate('Child'));
}
}
}
}
else {
if (!is_null($father)) {
if ($father->getSex()=="F") {
$father->setLabel(i18n::translate('Wife'));
} elseif ($father->getSex()=="M") {
$father->setLabel(i18n::translate('Husband'));
} else {
$father->setLabel(i18n::translate('Spouse'));
}
}
if (!is_null($mother)) {
if ($mother->getSex()=="F") {
$mother->setLabel(i18n::translate('Wife'));
} elseif ($mother->getSex()=="M") {
$mother->setLabel(i18n::translate('Husband'));
} else {
$father->setLabel(i18n::translate('Spouse'));
}
}
}
echo WT_JS_START;
?>
var nameElement = null;
var remElement = null;
function pastename(name) {
if (nameElement) {
nameElement.innerHTML = name;
}
if (remElement) {
remElement.style.display = 'block';
}
}
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.'); ?>
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@\n";
if (isset($pgv_changes[$HUSB."_".WT_GEDCOM])) $indirec = find_updated_record($HUSB, WT_GED_ID);
else $indirec = find_person_record($HUSB, WT_GED_ID);
if (!empty($indirec) && (strpos($indirec, "1 FAMS @$famid@")===false)) {
$indirec .= "\n1 FAMS @$famid@\n";
replace_gedrec($HUSB, $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) {
if (isset($pgv_changes[$father->getXref()."_".WT_GEDCOM])) $indirec = find_updated_record($father->getXref(), WT_GED_ID);
else $indirec = find_person_record($father->getXref(), WT_GED_ID);
$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(), $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@\n";
if (isset($pgv_changes[$WIFE."_".WT_GEDCOM])) $indirec = find_updated_record($WIFE, WT_GED_ID);
else $indirec = find_person_record($WIFE, WT_GED_ID);
if (!empty($indirec) && (strpos($indirec, "1 FAMS @$famid@")===false)) {
$indirec .= "\n1 FAMS @$famid@\n";
replace_gedrec($WIFE, $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) {
if (isset($pgv_changes[$mother->getXref()."_".WT_GEDCOM])) $indirec = find_updated_record($mother->getXref(), WT_GED_ID);
else $indirec = find_person_record($mother->getXref(), WT_GED_ID);
$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(), $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@\n";
$updated = true;
if (isset($pgv_changes[$CHIL."_".WT_GEDCOM])) $indirec = find_updated_record($CHIL, WT_GED_ID);
else $indirec = find_person_record($CHIL, WT_GED_ID);
if (!empty($indirec) && (strpos($indirec, "1 FAMC @$famid@")===false)) {
$indirec .= "\n1 FAMC @$famid@\n";
replace_gedrec($CHIL, $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
if (isset($pgv_changes[$child->getXref()."_".WT_GEDCOM])) $indirec = find_updated_record($child->getXref(), WT_GED_ID);
else $indirec = find_person_record($child->getXref(), WT_GED_ID);
$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(), $indirec, $update_CHAN);
}
}
}
}
if ($updated) {
$success = replace_gedrec($famid, $gedrec, $update_CHAN);
if ($success) echo "
", i18n::translate('Update successful');
}
break;
//------------------------------------------------------------------------------
//-- edit a fact record in a form
case 'edit_family':
init_calendar_popup();
echo "\n";
break;
//------------------------------------------------------------------------------
case 'reorder_update':
if (WT_DEBUG) {
phpinfo(INFO_VARIABLES);
}
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");
if (WT_DEBUG) {
echo "