"; echo getLRM(), $personLabel, getLRM(); if ($sosa != "1" && $pid != "") { if ($arrowDirection=="left") { $dir = 0; } elseif ($arrowDirection=="right") { $dir = 1; } elseif ($arrowDirection== "down") { $dir = 3; } else { $dir = 2; // either "blank" or "up" } echo "
"; print_url_arrow($pid, "#$pid", "$pid", $dir); // print " "; } echo ""; } /** * print family header * * @param string $famid family gedcom ID */ function print_family_header($famid) { $family=Family::getInstance($famid); if ($family) { echo '

', PrintReady($family->getFullName()), '

'; } } /** * print the parents table for a family * * @param string $famid family gedcom ID * @param int $sosa optional child sosa number * @param string $label optional indi label (descendancy booklet) * @param string $parid optional parent ID (descendancy booklet) * @param string $gparid optional gd-parent ID (descendancy booklet) */ function print_family_parents($famid, $sosa = 0, $label="", $parid="", $gparid="", $personcount="1") { global $view, $show_full, $show_famlink; global $TEXT_DIRECTION, $SHOW_EMPTY_BOXES, $SHOW_ID_NUMBERS; global $pbwidth, $pbheight; global $WT_IMAGE_DIR, $WT_IMAGES; global $show_changes, $GEDCOM; $ged_id=get_id_from_gedcom($GEDCOM); $family = Family::getInstance($famid); if (is_null($family)) return; $husb = $family->getHusband(); if (is_null($husb)) $husb = new Person(''); $wife = $family->getWife(); if (is_null($wife)) $wife = new Person(''); if (!is_null($husb)) { $tempID = $husb->getXref(); if (!empty($tempID)) print "\r\n"; } if (!is_null($wife)) { $tempID = $wife->getXref(); if (!empty($tempID)) print "\r\n"; } if ($sosa != 0) { print_family_header($famid); } // -- get the new record and parents if in editing show changes mode if (find_gedcom_record($famid, $ged_id) != find_gedcom_record($famid, $ged_id, WT_USER_CAN_EDIT)) { $newrec = find_gedcom_record($famid, $ged_id, true); $newparents = find_parents_in_record($newrec); } /** * husband side */ print "\n"; // husband's parents $hfams = $husb->getChildFamilies(); $hparents = false; $upfamid = ""; if (count($hfams) > 0 or ($sosa != 0 and $SHOW_EMPTY_BOXES)) { print ""; print ""; } if (!empty($upfamid) and ($sosa!=-1) and ($view != "preview")) { print "\n"; } if ($hparents or ($sosa != 0 and $SHOW_EMPTY_BOXES)) { // husband's mother print "\n"; } print "
"; print "\n\t"; if ($parid) { if ($husb->getXref()==$parid) print_sosa_number($label); else print_sosa_number($label, "", "blank"); } else if ($sosa > 0) print_sosa_number($sosa * 2); if (isset($newparents) && $husb->getXref() != $newparents["HUSB"]) { print "\n\t
"; print_pedigree_person($newparents['HUSB'], 1, $show_famlink, 2, $personcount); } else { print "\n\t"; print_pedigree_person($husb->getXref(), 1, $show_famlink, 2, $personcount); } print "
"; print "
\"\"\"\"\"\""; $hparents = false; foreach($hfams as $hfamid=>$hfamily) { if (!is_null($hfamily)) { $hparents = find_parents_in_record($hfamily->getGedcomRecord()); $upfamid = $hfamid; break; } } if ($hparents or ($sosa != 0 and $SHOW_EMPTY_BOXES)) { // husband's father print "\n\t"; if ($sosa > 0) print_sosa_number($sosa * 4, $hparents['HUSB'], "down"); if (!empty($gparid) and $hparents['HUSB']==$gparid) print_sosa_number(trim(substr($label,0,-3),".")."."); print "\n\t
"; print_pedigree_person($hparents['HUSB'], 1, $show_famlink, 4, $personcount); print "
"; } print "
"; print_url_arrow($upfamid, ($sosa==0 ? "?famid=$upfamid&show_full=$show_full" : "#$upfamid"), "$upfamid", 1); print "
\"\""; print "\n\t"; if ($sosa > 0) print_sosa_number($sosa * 4 + 1, $hparents['WIFE'], "down"); if (!empty($gparid) and $hparents['WIFE']==$gparid) print_sosa_number(trim(substr($label,0,-3),".")."."); print "\n\t
"; print_pedigree_person($hparents['WIFE'], 1, $show_famlink, 5, $personcount); print "
"; print "
\n\n"; if ($sosa!=0) { print ""; if ($SHOW_ID_NUMBERS) print getLRM() . "($famid)" . getLRM() . "  "; else print str_repeat(" ", 10); $marriage = $family->getMarriage(); if ($marriage->canShow()) { $marriage->print_simple_fact(); } else print i18n::translate('Private'); print ""; } else print "
\n"; /** * wife side */ print "\n"; // wife's parents $hfams = $wife->getChildFamilies(); $hparents = false; $upfamid = ""; if (count($hfams) > 0 or ($sosa != 0 and $SHOW_EMPTY_BOXES)) { print ""; print "\n"; } if (!empty($upfamid) and ($sosa!=-1) and ($view != "preview")) { print "\n"; } if ($hparents or ($sosa != 0 and $SHOW_EMPTY_BOXES)) { // wife's mother print "\n"; } print "
"; print "\n\t"; if ($parid) { if ($wife->getXref()==$parid) print_sosa_number($label); else print_sosa_number($label, "", "blank"); } else if ($sosa > 0) print_sosa_number($sosa * 2 + 1); if (isset($newparents) && $wife->getXref() != $newparents["WIFE"]) { print "\n\t
"; print_pedigree_person($newparents['WIFE'], 1, $show_famlink, 3, $personcount); } else { print "\n\t"; print_pedigree_person($wife->getXref(), 1, $show_famlink, 3, $personcount); } print "
"; print "
\"\"\"\"\"\""; $j = 0; foreach($hfams as $hfamid=>$hfamily) { if (!is_null($hfamily)) { $hparents = find_parents_in_record($hfamily->getGedcomRecord()); $upfamid = $hfamid; break; } } if ($hparents or ($sosa != 0 and $SHOW_EMPTY_BOXES)) { // wife's father print "\n\t"; if ($sosa > 0) print_sosa_number($sosa * 4 + 2, $hparents['HUSB'], "down"); if (!empty($gparid) and $hparents['HUSB']==$gparid) print_sosa_number(trim(substr($label,0,-3),".")."."); print "\n\t
"; print_pedigree_person($hparents['HUSB'], 1, $show_famlink, 6, $personcount); print "
"; } print "
"; print_url_arrow($upfamid, ($sosa==0 ? "?famid=$upfamid&show_full=$show_full" : "#$upfamid"), "$upfamid", 1); print "
\"\""; print "\n\t"; if ($sosa > 0) print_sosa_number($sosa * 4 + 3, $hparents['WIFE'], "down"); if (!empty($gparid) and $hparents['WIFE']==$gparid) print_sosa_number(trim(substr($label,0,-3),".")."."); print "\n\t
"; print_pedigree_person($hparents['WIFE'], 1, $show_famlink, 7, $personcount); print "
\n"; print "
\n\n"; } /** * print the children table for a family * * @param string $famid family gedcom ID * @param string $childid optional child ID * @param int $sosa optional child sosa number * @param string $label optional indi label (descendancy booklet) */ function print_family_children($famid, $childid = "", $sosa = 0, $label="", $personcount="1") { global $pbwidth, $pbheight, $view, $show_famlink, $show_cousins; global $WT_IMAGE_DIR, $WT_IMAGES, $show_changes, $GEDCOM, $SHOW_ID_NUMBERS, $TEXT_DIRECTION; $ged_id=get_id_from_gedcom($GEDCOM); $family=Family::getInstance($famid); $children=$family->getChildrenIds(); $numchil=$family->getNumberOfChildren(); print ""; if ($sosa>0) print ""; print ""; if ($sosa>0) print ""; print "\n"; $newchildren = array(); $oldchildren = array(); if (WT_USER_CAN_EDIT) { if (!isset($_REQUEST['show_changes']) || $_REQUEST['show_changes']=='yes') { $newrec = find_gedcom_record($famid, $ged_id, true); $ct = preg_match_all("/1 CHIL @(.*)@/", $newrec, $match, PREG_SET_ORDER); if ($ct > 0) { $oldchil = array(); for($i = 0; $i < $ct; $i++) { if (!in_array($match[$i][1], $children)) $newchildren[] = $match[$i][1]; else $oldchil[] = $match[$i][1]; } foreach($children as $indexval => $chil) { if (!in_array($chil, $oldchil)) $oldchildren[] = $chil; } //-- if there are no old or new children then the children were reordered if ((count($newchildren)==0)&&(count($oldchildren)==0)) { $children = array(); for($i = 0; $i < $ct; $i++) { $children[] = $match[$i][1]; } } } } } $nchi=1; if ((count($children) > 0) || (count($newchildren) > 0) || (count($oldchildren) > 0)) { foreach($children as $indexval => $chil) { if (!in_array($chil, $oldchildren)) { echo "\n"; if ($sosa != 0) { if ($chil == $childid) { print_sosa_number($sosa, $childid); } elseif (empty($label)) { print_sosa_number(""); } else { print_sosa_number($label.($nchi++)."."); } } echo ""; if ($sosa != 0) { // loop for all families where current child is a spouse $famids = find_sfamily_ids($chil); $maxfam = count($famids)-1; for ($f=0; $f<=$maxfam; $f++) { $famid = $famids[$f]; if (!$famid) continue; $parents = find_parents($famid); if (!$parents) continue; if ($parents["HUSB"] == $chil) $spouse = $parents["WIFE"]; else $spouse = $parents["HUSB"]; // multiple marriages if ($f>0) { print "\n"; print ""; } print "\n"; // spouse information print "\n"; // cousins if ($show_cousins) { print_cousins($famid, $personcount); $personcount++; } } } print "\n"; } } foreach($newchildren as $indexval => $chil) { print ""; print "\n"; } foreach($oldchildren as $indexval => $chil) { print ""; print "\n"; } // message 'no children' except for sosa } else if ($sosa<1) { print ""; } else { print "\n"; print_sosa_number($sosa, $childid); print "\n"; } print "
".i18n::translate('Children').""; echo '  ', getLRM(), '('; if ($numchil==0) { echo i18n::translate('No children'); } else if ($numchil==1) { echo i18n::translate('1 child'); } else { echo $numchil, ' ', i18n::translate('children'); } echo ')', getLRM(), ''; print "
"; // moved to top of list, changed from style to class, and font12 added by Nigel if ($view!="preview" && $sosa==0 && WT_USER_CAN_EDIT) { print "
"; print ""; print "" . i18n::translate('Add a child to this family') . ""; print " [".Person::sexImage('M', 'small', i18n::translate('Son' ))."]"; print " [".Person::sexImage('F', 'small', i18n::translate('Daughter'))."]"; print help_link('add_child'); print ""; print "

"; } print "
"; print_pedigree_person($chil, 1, $show_famlink, 8, $personcount); $personcount++; echo "
 "; else print " align=\"right\">"; //if ($f==$maxfam) print "\"\""; print ""; $divrec = ""; if (showFact("MARR", $famid)) { // marriage date $famrec = find_family_record($famid, $ged_id); $ct = preg_match("/2 DATE.*(\d\d\d\d)/", get_sub_record(1, "1 MARR", $famrec), $match); if ($ct>0) print "".trim($match[1]).""; // divorce date $divrec = get_sub_record(1, "1 DIV", $famrec); $ct = preg_match("/2 DATE.*(\d\d\d\d)/", $divrec, $match); if ($ct>0) print "-".trim($match[1]).""; } print "
\"\""; // family link if ($famid) { print "
"; print ""; if ($SHOW_ID_NUMBERS) print getLRM() . " ($famid) " . getLRM(); print ""; } print "
"; else print "\">"; print_pedigree_person($spouse, 1, $show_famlink, 9, $personcount); $personcount++; print "
\n"; print_pedigree_person($chil, 1, $show_famlink, 0, $personcount); $personcount++; print "
\n"; print_pedigree_person($chil, 1, $show_famlink, 0, $personcount); $personcount++; print "
"; $nchi = ""; $famrec = find_gedcom_record($famid, $ged_id, true); $ct = preg_match("/1 NCHI (\w+)/", $famrec, $match); if ($ct>0) $nchi = $match[1]; else { $famrec = find_family_record($famid, $ged_id); $ct = preg_match("/1 NCHI (\w+)/", $famrec, $match); if ($ct>0) $nchi = $match[1]; } if ($nchi=="0") print "\"".i18n::translate('This ".i18n::translate('This family remained childless'); // else print i18n::translate('No children'); print "
"; print_pedigree_person($childid, 1, $show_famlink, 0, $personcount); $personcount++; print "

"; } /** * print the facts table for a family * * @param string $famid family gedcom ID * @param int $sosa optional child sosa number */ function print_family_facts(&$family, $sosa = 0) { global $pbwidth, $pbheight, $view; global $nonfacts; global $TEXT_DIRECTION, $GEDCOM, $SHOW_ID_NUMBERS; global $show_changes; global $linkToID; $famid=$family->getXref(); // -- if both parents are displayable then print the marriage facts if ($family->canDisplayDetails()) { $linkToID = $famid; // -- Tell addmedia.php what to link to // -- array of GEDCOM elements that will be found but should not be displayed $nonfacts = array("FAMS", "FAMC", "MAY", "BLOB", "HUSB", "WIFE", "CHIL", ""); // -- find all the fact information $indifacts = $family->getFacts(); if (count($indifacts) > 0) { sort_facts($indifacts); print "\n\t" . i18n::translate('Family Group Information'); if ($SHOW_ID_NUMBERS and $famid != "") print "   ($famid)"; print "
\n\t"; /* @var $value Event */ foreach ($indifacts as $key => $value) { if ($value->getTag()!="SOUR" && $value->getTag()!="OBJE" && $value->getTag()!="NOTE") print_fact($value); } // do not print otheritems for sosa if ($sosa == 0) { foreach($indifacts as $key => $value) { $fact = $value->getTag(); // -- handle special source fact case if ($fact == "SOUR") { print_main_sources($value->getGedComRecord(), 1, $famid, $value->getLineNumber()); } // -- handle special note fact case else if ($fact == "NOTE") { print_main_notes($value->getGedComRecord(), 1, $famid, $value->getLineNumber()); } } // NOTE: Print the media print_main_media($famid); } } else { if ($sosa==0) { print "\n\t" . i18n::translate('Family Group Information'); if ($SHOW_ID_NUMBERS and $famid != "") print "   ($famid)"; print "
\n\t"; } print "
"; if ($sosa == 0) { print "\n"; } } // -- new fact link if ($view!="preview" && $sosa==0 && WT_USER_CAN_EDIT) { print_add_new_fact($famid, $indifacts, "FAM"); // -- new note print "\n"; // -- new shared note print "\n"; // -- new media print "\n"; // -- new source citation print "\n"; // -- end new objects } print "\n\t
"; print i18n::translate('No facts for this family.'); print "
"; print i18n::translate('Add Note'); print help_link('add_note'); print ""; print "" . i18n::translate('Add a new Note') . ""; print "
\n"; print "
"; print i18n::translate('Add Shared Note'); print help_link('add_shared_note'); print ""; print "" . i18n::translate('Add a new Shared Note') . ""; print "
\n"; print "
"; print i18n::translate('Add Media'); print help_link('add_media'); print ""; print "".i18n::translate('Add a new Media item').""; print "
\n"; print "".i18n::translate('Link to an existing Media item').""; print "
"; print i18n::translate('Add Source Citation'); print help_link('add_source'); print ""; print "" . i18n::translate('Add a new Source Citation') . ""; print "
\n"; print "
\n"; } } /** * print a family with Sosa-Stradonitz numbering system * ($rootid=1, father=2, mother=3 ...) * * @param string $famid family gedcom ID * @param string $childid tree root ID * @param string $sosa starting sosa number * @param string $label optional indi label (descendancy booklet) * @param string $parid optional parent ID (descendancy booklet) * @param string $gparid optional gd-parent ID (descendancy booklet) */ function print_sosa_family($famid, $childid, $sosa, $label="", $parid="", $gparid="", $personcount="1") { global $pbwidth, $pbheight, $view; if ($view != "preview") print "
"; print "\r\n\r\n

\r\n"; if (!empty($famid)) print"\r\n"; print_family_parents($famid, $sosa, $label, $parid, $gparid, $personcount); $personcount++; print "\n\t
\n"; print "
\n"; print_family_children($famid, $childid, $sosa, $label, $personcount); print ""; if ($sosa == 0) print_family_facts(Family::getInstance($famid), $sosa); print "
\n"; print "
"; } /** * check root id for pedigree tree * * @param string $rootid root ID * @return string $rootid validated root ID */ function check_rootid($rootid) { global $PEDIGREE_ROOT_ID, $USE_RIN; // -- if the $rootid is not already there then find the first person in the file and make him the root if (!find_person_record($rootid, WT_GED_ID)) { if (find_person_record(WT_USER_ROOT_ID, WT_GED_ID)) { $rootid=WT_USER_ROOT_ID; } else { if (find_person_record(WT_USER_GEDCOM_ID, WT_GED_ID)) { $rootid=WT_USER_GEDCOM_ID; } else { if (find_person_record($PEDIGREE_ROOT_ID, WT_GED_ID)) { $rootid=trim($PEDIGREE_ROOT_ID); } else { $rootid=get_first_xref('INDI', WT_GED_ID); // If there are no users in the gedcom, do something. if (!$rootid) { $rootid='I1'; } } } } } if ($USE_RIN) { $indirec = find_person_record($rootid, WT_GED_ID); if ($indirec == false) $rootid = find_rin_id($rootid); } return $rootid; } /** * creates an array with all of the individual ids to be displayed on an ascendancy chart * * the id in position 1 is the root person. The other positions are filled according to the following algorithm * if an individual is at position $i then individual $i's father will occupy position ($i*2) and $i's mother * will occupy ($i*2)+1 * * @param string $rootid * @return array $treeid */ function ancestry_array($rootid, $maxgen=0) { global $PEDIGREE_GENERATIONS, $SHOW_EMPTY_BOXES; // -- maximum size of the id array if ($maxgen==0) $maxgen = $PEDIGREE_GENERATIONS; $treesize = pow(2, ($maxgen)); $treeid = array(); $treeid[0] = ""; $treeid[1] = $rootid; // -- fill in the id array for($i = 1; $i < ($treesize / 2); $i++) { $treeid[($i * 2)] = false; // -- father $treeid[($i * 2) + 1] = false; // -- mother if (!empty($treeid[$i])) { $person = Person::getInstance($treeid[$i]); $family = $person->getPrimaryChildFamily(); // Store the prefered parents if (!empty($family)) { $treeid[($i * 2)] = $family->getHusbId(); $treeid[($i * 2) + 1] = $family->getWifeId(); } } } return $treeid; } /** * print an arrow to a new url * * @param string $id Id used for arrow img name (must be unique on the page) * @param string $url target url * @param string $label arrow label * @param string $dir arrow direction 0=left 1=right 2=up 3=down (default=2) */ function print_url_arrow($id, $url, $label, $dir=2) { global $view; global $WT_IMAGE_DIR, $WT_IMAGES; global $TEXT_DIRECTION; if ($id=="" or $url=="") return; if ($view=="preview") return; // arrow direction $adir=$dir; if ($TEXT_DIRECTION=="rtl" and $dir==0) $adir=1; if ($TEXT_DIRECTION=="rtl" and $dir==1) $adir=0; // arrow style 0 1 2 3 $array_style=array("larrow", "rarrow", "uarrow", "darrow"); $astyle=$array_style[$adir]; print "\"$label\""; } /** * builds and returns sosa relationship name in the active language * * @param string $sosa sosa number */ function get_sosa_name($sosa) { $relations=array(); while ($sosa>1) { if ($sosa%2==1) { $sosa-=1; array_unshift($relations, 'mother'); } else { array_unshift($relations, 'father'); } $sosa/=2; } array_unshift($relations, 'self'); $path=array('relations'=>$relations, 'path'=>$relations); // path is just a dummy return get_relationship_name($path); } /** * find last family ID where this person is a spouse * * @param string $pid individual ID * @return string last sfam ID */ function find_last_sfam($pid) { $famids = find_sfamily_ids($pid); $f = count($famids); if ($f<1) return false; else return $famids[$f-1]; } /** * find last spouse for this person * * @param string $pid individual ID * @return string last spouse ID */ function find_last_spouse($pid) { $famid = find_last_sfam($pid); if (!$famid) return false; $parents = find_parents($famid); if (!$parents) return false; if ($parents["HUSB"] == $pid) return $parents["WIFE"]; else return $parents["HUSB"]; } /** * print cousins list * * @param string $famid family ID */ function print_cousins($famid, $personcount="1") { global $show_full, $bheight, $bwidth; global $WT_IMAGE_DIR, $WT_IMAGES, $TEXT_DIRECTION; global $GEDCOM; $ged_id=get_id_from_gedcom($GEDCOM); $family=Family::getInstance($famid); $fchildren=$family->getChildrenIds(); $kids = count($fchildren); $save_show_full = $show_full; if ($save_show_full) { $bheight/=4; $bwidth-=40; } $show_full = false; print ""; if ($kids) { print ""; if ($kids>1) print ""; $ctkids = count($fchildren); $i = 1; foreach ($fchildren as $indexval => $fchil) { print ""; if ($i < $ctkids) { print ""; $i++; } } print "
\"\"\"\""; print_pedigree_person($fchil, 1 , false, 0, $personcount); $personcount++; print "
"; } else { $famrec = find_family_record($famid, $ged_id); $ct = preg_match("/1 NCHI (\w+)/", $famrec, $match); if ($ct>0) $nchi = $match[1]; else $nchi = ""; if ($nchi=="0") print " \"".i18n::translate('This"; } $show_full = $save_show_full; if ($save_show_full) { $bheight*=4; $bwidth+=40; } print "\n"; } ?>