";
}
break;
//------------------------------------------------------------------------------
//-- add new Shared Note census event using GEDFact assistant
case 'addnewnote_assisted':
if (isset($_REQUEST['pid'])) $pid = $_REQUEST['pid'];
global $pid;
?>
privatizeGedcom(WT_USER_ACCESS_LEVEL);
init_calendar_popup();
echo '';
break;
//------------------------------------------------------------------------------
//-- edit a Shared Note
case 'editnote':
// Hide the private data
$tmp=new WT_GedcomRecord($gedrec);
list($gedrec)=$tmp->privatizeGedcom(WT_USER_ACCESS_LEVEL);
?>
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";
$xref = append_gedrec($newgedrec, WT_GED_ID);
$link = "repo.php?rid=$xref";
if ($xref) {
echo '
';
echo "", WT_I18N::translate('Paste the following Repository ID into your editing fields to reference this Repository '), " $xref";
}
break;
//------------------------------------------------------------------------------
//-- get the new incoming raw gedcom record and store it in the file
case 'updateraw':
// Retrieve the private data
$tmp=new WT_GedcomRecord($gedrec);
list(, $private_gedrec)=$tmp->privatizeGedcom(WT_USER_ACCESS_LEVEL);
if (isset($_POST['newgedrec1']) && isset($_POST['newgedrec2'])) {
$newgedrec = $_POST['newgedrec1']."\n".$_POST['newgedrec2'];
if (replace_gedrec($pid, WT_GED_ID, $newgedrec.$private_gedrec, $update_CHAN)) {
$success=true;
}
}
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($_REQUEST['num_note_lines'])) $num_note_lines = $_REQUEST['num_note_lines'];
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_gedcom_record($pid, WT_GED_ID, true);
} elseif (isset($famid)) {
$gedrec = find_gedcom_record($famid, WT_GED_ID, true);
}
// Retrieve the private data
$tmp=new WT_GedcomRecord($gedrec);
list($gedrec, $private_gedrec)=$tmp->privatizeGedcom(WT_USER_ACCESS_LEVEL);
// If the fact has a DATE or PLAC, then delete any value of Y
if ($text[0]=='Y') {
for ($n=1; $n0) {
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 .= " ".WT_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 (isset($_REQUEST['NOTE'])) $NOTE = $_REQUEST['NOTE'];
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 (!empty($NOTE)) {
$cmpfunc = create_function('$e', 'return strpos($e,"0 @N") !==0 && strpos($e,"1 CONT") !==0;');
$gedlines = array_filter($gedlines, $cmpfunc);
$tempnote = preg_split('/\r?\n/', trim($NOTE) . "\n"); // make sure only one line ending on the end
$title[] = "0 @$pid@ NOTE " . array_shift($tempnote);
foreach($tempnote as &$line) {
$line = trim("1 CONT " . $line,' ');
}
$gedlines = array_merge($title,$tempnote,$gedlines);
}
//-- 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 (isset($_REQUEST['NOTE'])) $NOTE = $_REQUEST['NOTE'];
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 (!empty($NOTE)) {
$cmpfunc = create_function('$e', 'return strpos($e,"0 @N") !==0 && strpos($e,"1 CONT") !==0;');
$gedlines = array_filter($gedlines, $cmpfunc);
$tempnote = preg_split('/\r?\n/', trim($NOTE) . "\n"); // make sure only one line ending on the end
$title[] = "0 @$pid@ NOTE " . array_shift($tempnote);
foreach($tempnote as &$line) {
$line = trim("1 CONT " . $line,' ');
}
$gedlines = array_merge($title,$tempnote,$gedlines);
}
//-- 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 (replace_gedrec($pid, WT_GED_ID, $newged.$private_gedrec, $update_CHAN)) {
$success=true;
}
} // end foreach $cens_pids -------------
break;
//------------------------------------------------------------------------------
case 'addchildaction':
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 (!empty($famid)) {
$gedrec .= "\n";
$PEDI="";
if (isset($_REQUEST['PEDI'])) $PEDI = $_REQUEST['PEDI'];
switch ($PEDI) {
case 'birth':
$gedrec.="1 FAMC @$famid@\n2 PEDI $PEDI";
break;
case 'adopted':
$gedrec.="1 FAMC @$famid@\n2 PEDI $PEDI\n1 ADOP\n2 FAMC @$famid@\n3 ADOP BOTH";
break;
case 'sealing':
$gedrec.="1 FAMC @$famid@\n2 PEDI $PEDI\n1 SLGC\n2 FAMC @$famid@";
break;
case 'foster':
$gedrec.="1 FAMC @$famid@\n2 PEDI $PEDI\n1 EVEN\n2 TYPE $PEDI";
break;
default:
$gedrec.="1 FAMC @$famid@";
break;
}
$gedrec .= "\n";
}
if (safe_POST_bool('SOUR_INDI')) {
$gedrec = handle_updates($gedrec);
} else {
$gedrec = updateRest($gedrec);
}
$xref = append_gedrec($gedrec, WT_GED_ID);
$link = "individual.php?pid=$xref";
if ($xref) {
echo "
", WT_I18N::translate('Update successful');
$gedrec = "";
if (!empty($famid)) {
// Insert new child at the right place [ 1686246 ]
$newchild = WT_Person::getInstance($xref);
$gedrec=find_gedcom_record($famid, WT_GED_ID, true);
$family=new WT_Family($gedrec);
$done = false;
foreach ($family->getChildren() as $key=>$child) {
if (WT_Date::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@";
} elseif (!$done) {
// new child is the youngest or undated : insert after
$gedrec = str_replace("\n1 CHIL @".$child->getXref()."@",
"\n1 CHIL @".$child->getXref()."@\n1 CHIL @$xref@",
$gedrec);
}
if (replace_gedrec($famid, WT_GED_ID, $gedrec, $update_CHAN)) {
$success=true;
}
}
}
break;
//------------------------------------------------------------------------------
case 'addspouseaction':
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);
}
$xref = append_gedrec($gedrec, WT_GED_ID);
$link = "individual.php?pid=$xref";
if ($xref) {
echo "
", WT_I18N::translate('Update successful');
} else {
exit;
}
$success = true;
if ($famid=="new") {
$famrec = "0 @new@ FAM\n";
$SEX=safe_POST('SEX', '[MF]', 'U');
if ($SEX=="M") $famtag = "HUSB";
if ($SEX=="F") $famtag = "WIFE";
if ($famtag=="HUSB") {
$famrec .= "1 HUSB @$xref@\n";
$famrec .= "1 WIFE @$pid@\n";
} else {
$famrec .= "1 WIFE @$xref@\n";
$famrec .= "1 HUSB @$pid@\n";
}
if (preg_match_all('/([A-Z0-9_]+)/', $QUICK_REQUIRED_FAMFACTS, $matches)) {
foreach ($matches[1] as $match) {
$famrec.=addNewFact($match);
}
}
if (safe_POST_bool('SOUR_FAM')) {
$famrec = handle_updates($famrec);
} else {
$famrec = updateRest($famrec);
}
$famid = append_gedrec($famrec, WT_GED_ID);
} elseif (!empty($famid)) {
$famrec = find_gedcom_record($famid, WT_GED_ID, true);
if (!empty($famrec)) {
$famrec = trim($famrec) . "\n1 $famtag @$xref@\n";
if (preg_match_all('/([A-Z0-9_]+)/', $QUICK_REQUIRED_FAMFACTS, $matches)) {
foreach ($matches[1] as $match) {
$famrec.=addNewFact($match);
}
}
if (safe_POST_bool('SOUR_FAM')) {
$famrec = handle_updates($famrec);
} else {
$famrec = updateRest($famrec);
}
if (replace_gedrec($famid, WT_GED_ID, $famrec, $update_CHAN)) {
$success=true;
}
}
}
if ((!empty($famid))&&($famid!="new")) {
$gedrec = find_gedcom_record($xref, WT_GED_ID, true) . "\n1 FAMS @$famid@";
if (replace_gedrec($xref, WT_GED_ID, $gedrec, $update_CHAN)) {
$success=true;
}
}
if (!empty($pid)) {
$indirec = find_gedcom_record($pid, WT_GED_ID, true);
if ($indirec) {
$indirec = trim($indirec) . "\n1 FAMS @$famid@\n";
if (replace_gedrec($pid, WT_GED_ID, $indirec, $update_CHAN)) {
$success=true;
}
}
}
break;
//------------------------------------------------------------------------------
case 'linkspouseaction':
splitSOUR(); // separate SOUR record from the rest
if (isset($_REQUEST['spid'])) $spid = $_REQUEST['spid'];
if (!empty($spid)) {
$gedrec = find_gedcom_record($spid, WT_GED_ID, true);
if ($gedrec) {
if ($famid=="new") {
$famrec = "0 @new@ FAM\n";
$SEX = get_gedcom_value("SEX", 1, $gedrec, '', false);
if ($SEX=="M") $famtag = "HUSB";
if ($SEX=="F") $famtag = "WIFE";
if ($famtag=="HUSB") {
$famrec .= "1 HUSB @$spid@\n";
$famrec .= "1 WIFE @$pid@\n";
} else {
$famrec .= "1 WIFE @$spid@\n";
$famrec .= "1 HUSB @$pid@\n";
}
$famrec.=addNewFact('MARR');
if (safe_POST_bool('SOUR_FAM') || count($tagSOUR)>0) {
// before adding 2 SOUR it needs to add 1 MARR Y first
if (addNewFact('MARR')=='') {
$famrec .= "1 MARR Y\n";
}
$famrec = handle_updates($famrec);
} else {
// before adding level 2 facts it needs to add 1 MARR Y first
if (addNewFact('MARR')=='') {
$famrec .= "1 MARR Y\n";
}
$famrec = updateRest($famrec);
}
$famid = append_gedrec($famrec, WT_GED_ID);
}
if ((!empty($famid))&&($famid!="new")) {
$gedrec .= "\n1 FAMS @$famid@\n";
if (replace_gedrec($spid, WT_GED_ID, $gedrec, $update_CHAN)) {
$success=true;
}
}
if (!empty($pid)) {
$indirec = find_gedcom_record($pid, WT_GED_ID, true);
if (!empty($indirec)) {
$indirec = trim($indirec) . "\n1 FAMS @$famid@\n";
if (replace_gedrec($pid, WT_GED_ID, $indirec, $update_CHAN)) {
$success=true;
}
}
}
}
}
break;
//------------------------------------------------------------------------------
case 'addnewparentaction':
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);
}
$xref = append_gedrec($gedrec, WT_GED_ID);
$link = "individual.php?pid=$xref";
if ($xref) {
echo "
', WT_I18N::translate('Update successful');
}
break;
//------------------------------------------------------------------------------
case 'deleteperson':
if (delete_person($pid, $gedrec)) {
$success=true;
}
break;
//------------------------------------------------------------------------------
case 'deletefamily':
if (delete_family($famid, $gedrec)) {
$success=true;
}
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 (!empty($gedrec)) {
// Delete links to this record
foreach (fetch_all_links($pid, WT_GED_ID) as $xref) {
$gedrec=find_gedcom_record($xref, WT_GED_ID, true);
$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 (replace_gedrec($xref, WT_GED_ID, $newrec, $update_CHAN)) {
$success=true;
}
}
delete_gedrec($pid, WT_GED_ID);
$success=true;
}
break;
//------------------------------------------------------------------------------
case 'editname':
// Hide the private data
$tmp=new WT_GedcomRecord($gedrec);
list($gedrec)=$tmp->privatizeGedcom(WT_USER_ACCESS_LEVEL);
$gedlines = explode("\n", trim($gedrec));
$fields = explode(' ', $gedlines[$linenum]);
$glevel = $fields[0];
$i = $linenum+1;
$namerec = $gedlines[$linenum];
while (($i$glevel)) {
$namerec.="\n".$gedlines[$i];
$i++;
}
print_indi_form("update", "", $linenum, $namerec);
break;
//------------------------------------------------------------------------------
case 'addname':
print_indi_form("update", "", "new", "NEW");
break;
//------------------------------------------------------------------------------
case 'copy':
//-- handle media differently now :P
if ($linenum=='media') {
$factrec = "1 OBJE @".$pid."@";
$type="all";
echo " ";
} else {
$gedlines = explode("\n", trim($gedrec));
$fields = explode(' ', $gedlines[$linenum]);
$glevel = $fields[0];
$i = $linenum+1;
$factrec = $gedlines[$linenum];
while (($i$glevel)) {
$factrec.="\n".$gedlines[$i];
$i++;
}
}
if (!isset($_SESSION["clipboard"])) $_SESSION["clipboard"] = array();
$ft = preg_match("/1 (_?[A-Z]{3,5})(.*)/", $factrec, $match);
if ($ft>0) {
$fact = trim($match[1]);
if ($fact=="EVEN" || $fact=="FACT") {
$ct = preg_match("/2 TYPE (.*)/", $factrec, $match);
if ($ct>0) $fact = trim($match[1]);
}
if (count($_SESSION["clipboard"])>9) array_pop($_SESSION["clipboard"]);
$_SESSION["clipboard"][] = array("type"=>$type, "factrec"=>$factrec, "fact"=>$fact);
echo "", WT_I18N::translate('Record copied to clipboard'), "";
$success = true;
}
break;
//------------------------------------------------------------------------------
case 'paste':
$gedrec .= "\n".$_SESSION["clipboard"][$fact]["factrec"]."\n";
if (replace_gedrec($pid, WT_GED_ID, $gedrec, $NO_UPDATE_CHAN)) {
$success=true;
}
break;
//LBox Reorder Media ========================================================
//------------------------------------------------------------------------------
case 'reorder_media': // Sort page using Popup
require_once WT_ROOT.'js/prototype.js.htm';
require_once WT_ROOT.'js/scriptaculous.js.htm';
require_once WT_ROOT.'includes/media_reorder.php';
break;
//------------------------------------------------------------------------------
case 'reset_media_update': // Reset sort using popup
$lines = explode("\n", $gedrec);
$newgedrec = "";
foreach ($lines as $line) {
if (strpos($line, "1 _WT_OBJE_SORT")===false) {
$newgedrec .= $line."\n";
}
}
if (replace_gedrec($pid, WT_GED_ID, $newgedrec, $update_CHAN)) {
$success=true;
}
break;
//------------------------------------------------------------------------------
case 'reorder_media_update': // Update sort using popup
if (isset($_REQUEST['order1'])) $order1 = $_REQUEST['order1'];
if (isset($_POST['currtab'])) $currtab = $_POST['currtab'];
$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 .= "1 _WT_OBJE_SORT @".$m_media."@\n";
}
if (replace_gedrec($pid, WT_GED_ID, $newgedrec, $update_CHAN)) {
$success=true;
}
echo " ", WT_I18N::translate('Update successful'), "
";
if ($currtab=="album") {
$link = "individual.php?pid=$pid#lightbox";
} else {
$link = "individual.php?pid=$pid#media";
}
echo WT_JS_START;
echo "edit_close('{$link}')";
echo WT_JS_END;
break;
//------------------------------------------------------------------------------
case 'al_reset_media_update': // Reset sort using Album Page
if (isset($_POST['currtab'])) $currtab = $_POST['currtab'];
$lines = explode("\n", $gedrec);
$newgedrec = "";
foreach ($lines as $line) {
if (strpos($line, "1 _WT_OBJE_SORT")===false) {
$newgedrec .= $line."\n";
}
}
if (replace_gedrec($pid, WT_GED_ID, $newgedrec, $update_CHAN)) {
$success=true;
}
echo " ", WT_I18N::translate('Update successful'), "
";
if ($currtab=="album") {
$link = "individual.php?pid=$pid#lightbox";
} else {
$link = "individual.php?pid=$pid#media";
}
echo WT_JS_START;
echo "edit_close('{$link}')";
echo WT_JS_END;
break;
//------------------------------------------------------------------------------
case 'al_reorder_media_update': // Update sort using Album Page
if (isset($_REQUEST['order1'])) $order1 = $_REQUEST['order1'];
if (isset($_POST['currtab'])) $currtab = $_POST['currtab'];
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 .= "1 _WT_OBJE_SORT @".$m_media."@\n";
}
if (replace_gedrec($pid, WT_GED_ID, $newgedrec, $update_CHAN)) {
$success=true;
}
if ($currtab=="album") {
$link = "individual.php?pid=$pid#lightbox";
} else {
$link = "individual.php?pid=$pid#media";
}
echo WT_JS_START;
echo "edit_close('{$link}')";
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 ' ', WT_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(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'));
}
}
}
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";
}
$indirec = find_gedcom_record($HUSB, WT_GED_ID, true);
if (!empty($indirec) && (strpos($indirec, "1 FAMS @$famid@")===false)) {
$indirec .= "\n1 FAMS @$famid@\n";
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@\n";
}
$indirec = find_gedcom_record($WIFE, WT_GED_ID, true);
if (!empty($indirec) && (strpos($indirec, "1 FAMS @$famid@")===false)) {
$indirec .= "\n1 FAMS @$famid@\n";
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@\n";
$updated = true;
$indirec = find_gedcom_record($CHIL, WT_GED_ID, true);
if (!empty($indirec) && (strpos($indirec, "1 FAMC @$famid@")===false)) {
$indirec .= "\n1 FAMC @$famid@\n";
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) {
replace_gedrec($famid, WT_GED_ID, $gedrec, $update_CHAN);
$success = true;
}
break;
//------------------------------------------------------------------------------
case 'reorder_update':
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";
}
if (replace_gedrec($pid, WT_GED_ID, $newgedrec, $update_CHAN)) {
$success=true;
}
break;
//------------------------------------------------------------------------------
case 'reorder_fams':
require_once WT_ROOT.'js/prototype.js.htm';
require_once WT_ROOT.'js/scriptaculous.js.htm';
echo " ", WT_I18N::translate('Reorder families'), "", help_link('reorder_families');
?>
$num) {
$newgedrec .= "1 FAMS @".$famid."@\n";
}
if (replace_gedrec($pid, WT_GED_ID, $newgedrec, $update_CHAN)) {
$success=true;
}
echo "
", WT_I18N::translate('Update successful');
break;
}
// Redirect to new record, if requested
if (isset($_REQUEST['goto'])) {
$goto = $_REQUEST['goto'];
}
if (isset($_REQUEST['link'])) {
$link = $_REQUEST['link'];
}
if (empty($goto) || empty($link)) {
$link='';
}
// autoclose window when update successful unless debug on
if ($success && !WT_DEBUG ) {
echo WT_JS_START;
if ($action=="copy") {
echo "window.close();";
} elseif (isset($closeparent) && $closeparent=="yes" ) {
// echo "window.opener.close(); window.opener.edit_close('{$link}'); window.close(); ";
echo "window.close(); ";
} else {
echo "edit_close('{$link}');";
}
echo WT_JS_END;
}
// Decide whether to print footer or not
if ($action == 'addmedia_links' || $action == 'addnewnote_assisted' ) {
// Do not print footer.
echo "