20 August 2005 * * @package webtrees * @subpackage Charts * @version $Id$ */ define('WT_SCRIPT_NAME', 'relationship.php'); require './includes/session.php'; require_once WT_ROOT.'includes/functions/functions_charts.php'; require_once WT_ROOT.'includes/classes/class_person.php'; $show_full=$PEDIGREE_FULL_DETAILS; if (isset($_REQUEST['show_full'])) $show_full = $_REQUEST['show_full']; if (!isset($_REQUEST['path_to_find'])) { $path_to_find = 0; $pretty = 1; unset($_SESSION["relationships"]); } else $path_to_find = $_REQUEST['path_to_find']; if ($path_to_find == -1) { $path_to_find = 0; unset($_SESSION["relationships"]); } //-- previously these variables were set in theme.php, now they are no longer required to be set there $Dbasexoffset = 0; $Dbaseyoffset = 0; if ($show_full==false) { $Dbheight=25; $Dbwidth-=40; } $bwidth = $Dbwidth; $bheight = $Dbheight; $title_string = ""; $pid1=safe_GET_xref('pid1'); $pid2=safe_GET_xref('pid2'); if (!isset($_REQUEST['followspouse'])) $followspouse = 0; else $followspouse = $_REQUEST['followspouse']; if (!isset($_REQUEST['pretty'])) $pretty = 0; else $pretty = $_REQUEST['pretty']; if (!isset($_REQUEST['asc'])) $asc=1; else $asc = $_REQUEST['asc']; if ($asc=="") $asc=1; if (empty($pid1)) { $followspouse = 1; $pretty = 1; } $check_node = true; $disp = true; $title_string .= i18n::translate('Relationship Chart'); // -- print html header information print_header($title_string); if ($ENABLE_AUTOCOMPLETE) require WT_ROOT.'js/autocomplete.js.htm'; // Lbox additions if installed --------------------------------------------------------------------------------------------- if (WT_USE_LIGHTBOX) { require WT_ROOT.'modules/lightbox/lb_defaultconfig.php'; require_once WT_ROOT.'modules/lightbox/functions/lb_call_js.php'; } // ------------------------------------------------------------------------------------------------------------------------------ if ($pid1) { //-- check if the id is valid $indirec = Person::getInstance($pid1); // Allow entry of i123 instead of I123 if (!$indirec && $pid1!=strtoupper($pid1)) { $pid1=strtoupper($pid1); $indirec=Person::getInstance($pid1); } // Allow user to specify person without the prefix if (!$indirec && $GEDCOM_ID_PREFIX) { $pid1=$GEDCOM_ID_PREFIX.$pid1; $indirec=Person::getInstance($pid1); } if ($indirec) { $title_string.=':
'.$indirec->getFullName(); } else { $pid1=''; } if (!empty($_SESSION["pid1"]) && ($_SESSION["pid1"]!=$pid1)) { unset($_SESSION["relationships"]); $path_to_find=0; } } if ($pid2) { //-- check if the id is valid $indirec = Person::getInstance($pid2); // Allow entry of i123 instead of I123 if (!$indirec && $pid2!=strtoupper($pid2)) { $pid1=strtoupper($pid2); $indirec=Person::getInstance($pid2); } // Allow user to specify person without the prefix if (!$indirec && $GEDCOM_ID_PREFIX) { $pid2=$GEDCOM_ID_PREFIX.$pid2; $indirec = Person::getInstance($pid2); } if ($indirec) { $title_string.=' '.i18n::translate('and').' '.$indirec->getFullName(); } else { $pid2=''; } if (!empty($_SESSION["pid2"]) && ($_SESSION["pid2"]!=$pid2)) { unset($_SESSION["relationships"]); $path_to_find=0; } } ?>
" style="position: relative; z-index:90; width:98%;">


; margin:0;"> "; } else { if ((!empty($pid1))&&(!empty($pid2))) { if ((!displayDetailsById($pid1))&&(!showLivingNameById($pid1))) { $disp = false; } elseif ((!displayDetailsById($pid2))&&(!showLivingNameById($pid2))) { $disp = false; } if ($disp) { echo i18n::translate('Show path'), ": "; echo "\n\t\t"; $prt = true; } } if (!isset($prt)) { echo " "; } } ?> "; if (($disp)&&(!$check_node)) { echo ""; } else { echo "\n"; } $pass = true; } if ($pass == false) echo "";?>
 
"; print "";?>
  />
     
">
"> />
$node) { if ($i==0) print i18n::translate('Show path').": "; if ($i>0) print " | "; if ($i==$path_to_find){ print "".($i+1).""; $new_path=false; } else { print "".($i+1)."\n"; } $i++; } if (($new_path)&&($path_to_find<$i+1)&&($check_node)) print " | ".($i+1).""; print ""; echo " "; $check_node = get_relationship($pid1, $pid2, $followspouse, 0, true, $path_to_find); echo $check_node ? "1" : " ".i18n::translate('No results found.'), "  />
"; if (isset($_SESSION["relationships"])) { if ($path_to_find==0) { echo "", i18n::translate('No link between the two individuals could be found.'), "
"; } else { echo "", i18n::translate('No other link between the two individuals could be found.'), "
"; } } if (!$followspouse) { ?> "; } echo "
 
', i18n::translate('Click on any of the boxes to get more information about that person.'), '
'; } ?>
" style="position:relative; z-index:1; width:98%;">
"; print_privacy_error(); } else { if (isset($_SESSION["relationships"][$path_to_find])) $node = $_SESSION["relationships"][$path_to_find]; else $node = get_relationship($pid1, $pid2, $followspouse, 0, true, $path_to_find); if ($node!==false) { $_SESSION["pid1"] = $pid1; $_SESSION["pid2"] = $pid2; if (!isset($_SESSION["relationships"])) $_SESSION["relationships"] = array(); $_SESSION["relationships"][$path_to_find] = $node; $yoffset = $Dbaseyoffset + 20; $xoffset = $Dbasexoffset; $colNum = 0; $rowNum = 0; $boxNum = 0; $previous=""; $previous2=""; $xs = $Dbxspacing+70; $ys = $Dbyspacing+50; // step1 = tree depth calculation if ($pretty) { $dmin=0; $dmax=0; $depth=0; foreach($node["path"] as $index=>$pid) { if ($node["relations"][$index]=="father" || $node["relations"][$index]=="mother" || $node["relations"][$index]=="parent") { $depth++; if ($depth>$dmax) $dmax=$depth; if ($asc==0) $asc=1; // the first link is a parent link } if ($node["relations"][$index]=="son" || $node["relations"][$index]=="daughter" || $node["relations"][$index]=="child") { $depth--; if ($depth<$dmin) $dmin=$depth; if ($asc==0) $asc=-1; // the first link is a child link } } $depth=$dmax+$dmin; // need more yoffset before the first box ? if ($asc==1) $yoffset -= $dmin*($Dbheight+$ys); if ($asc==-1) $yoffset += $dmax*($Dbheight+$ys); $rowNum = ($asc==-1) ? $depth : 0; } $maxxoffset = -1*$Dbwidth-20; $maxyoffset = $yoffset; if ($TEXT_DIRECTION=="ltr") { $rArrow = $WT_IMAGES["rarrow"]["other"]; $lArrow = $WT_IMAGES["larrow"]["other"]; } else { $rArrow = $WT_IMAGES["larrow"]["other"]; $lArrow = $WT_IMAGES["rarrow"]["other"]; } foreach($node["path"] as $index=>$pid) { print "\r\n\r\n\r\n"; $linex = $xoffset; $liney = $yoffset; $mfstyle = "NN"; $indirec = find_person_record($pid, WT_GED_ID); if (strpos($indirec, "1 SEX F")!==false) $mfstyle="F"; if (strpos($indirec, "1 SEX M")!==false) $mfstyle=""; $arrow_img = $WT_IMAGE_DIR."/".$WT_IMAGES["darrow"]["other"]; if ($node["relations"][$index]=="father" || $node["relations"][$index]=="mother" || $node["relations"][$index]=="parent") { $line = $WT_IMAGES["vline"]["other"]; $liney += $Dbheight; $linex += $Dbwidth/2; $lh = 54; $lw = 3; //check for paternal grandparent relationship if ($pretty) { if ($asc==0) $asc=1; if ($asc==-1) $arrow_img = $WT_IMAGE_DIR."/".$WT_IMAGES["uarrow"]["other"]; $lh=$ys; $linex=$xoffset+$Dbwidth/2; // put the box up or down ? $yoffset += $asc*($Dbheight+$lh); $rowNum += $asc; if ($asc==1) $liney = $yoffset-$lh; else $liney = $yoffset+$Dbheight; // need to draw a joining line ? if ($previous=="child" and $previous2!="parent") { $joinh = 3; $joinw = $xs/2+2; $xoffset += $Dbwidth+$xs; $colNum ++; //$rowNum is inherited from the box immediately to the left $linex = $xoffset-$xs/2; if ($asc==-1) $liney=$yoffset+$Dbheight; else $liney=$yoffset-$lh; $joinx = $xoffset-$xs; $joiny = $liney-2-($asc-1)/2*$lh; echo "
\"\"
\n"; $joinw = $xs/2+2; $joinx = $joinx+$xs/2; $joiny = $joiny+$asc*$lh; echo "
\"\"
\n"; } $previous2=$previous; $previous="parent"; } else $yoffset += $Dbheight+$Dbyspacing+50; } if ($node["relations"][$index]=="brother" || $node["relations"][$index]=="sister" || $node["relations"][$index]=="sibling") { $arrow_img = $WT_IMAGE_DIR."/".$rArrow; $xoffset += $Dbwidth+$Dbxspacing+70; $colNum ++; //$rowNum is inherited from the box immediately to the left $line = $WT_IMAGES["hline"]["other"]; $linex += $Dbwidth; $liney += $Dbheight/2; $lh = 3; $lw = 70; if ($pretty) { $lw = $xs; $linex = $xoffset-$lw; $liney = $yoffset+$Dbheight/4; $previous2=$previous; $previous=""; } } if ($node["relations"][$index]=="husband" || $node["relations"][$index]=="wife" || $node["relations"][$index]=="spouse") { $arrow_img = $WT_IMAGE_DIR."/".$rArrow; $xoffset += $Dbwidth+$Dbxspacing+70; $colNum ++; //$rowNum is inherited from the box immediately to the left $line = $WT_IMAGES["hline"]["other"]; $linex += $Dbwidth; $liney += $Dbheight/2; $lh = 3; $lw = 70; if ($pretty) { $lw = $xs; $linex = $xoffset-$lw; $liney = $yoffset+$Dbheight/4; $previous2=$previous; $previous=""; } } if ($node["relations"][$index]=="son" || $node["relations"][$index]=="daughter" || $node["relations"][$index]=="child") { $line = $WT_IMAGES["vline"]["other"]; $liney += $Dbheight; $linex += $Dbwidth/2; $lh = 54; $lw = 3; if ($pretty) { if ($asc==0) $asc=-1; if ($asc==1) $arrow_img = $WT_IMAGE_DIR."/".$WT_IMAGES["uarrow"]["other"]; $lh=$ys; $linex = $xoffset+$Dbwidth/2; // put the box up or down ? $yoffset -= $asc*($Dbheight+$lh); $rowNum -= $asc; if ($asc==-1) $liney = $yoffset-$lh; else $liney = $yoffset+$Dbheight; // need to draw a joining line ? if ($previous=="parent" and $previous2!="child") { $joinh = 3; $joinw = $xs/2+2; $xoffset += $Dbwidth+$xs; $colNum ++; //$rowNum is inherited from the box immediately to the left $linex = $xoffset-$xs/2; if ($asc==1) $liney=$yoffset+$Dbheight; else $liney=$yoffset-($lh+$Dbyspacing); $joinx = $xoffset-$xs; $joiny = $liney-2+($asc+1)/2*$lh; print "
\"\"
\n"; $joinw = $xs/2+2; $joinx = $joinx+$xs/2; $joiny = $joiny-$asc*$lh; print "
\"\"
\n"; } $previous2=$previous; $previous="child"; } else $yoffset += $Dbheight+$Dbyspacing+50; } if ($yoffset > $maxyoffset) $maxyoffset = $yoffset; $plinex = $linex; $pxoffset = $xoffset; // Adjust all box positions for proper placement with respect to other page elements if ($BROWSERTYPE=="mozilla" && $TEXT_DIRECTION=="rtl") $pxoffset += 10; else $pxoffset -= 3; $pyoffset = $yoffset - 2; if ($index>0) { if ($TEXT_DIRECTION=="rtl" && $line!=$WT_IMAGES["hline"]["other"]) { print "
"; print "\"\"\n"; print "
"; print i18n::translate($node["relations"][$index])."\n"; print "\"\"\n"; } else { print "
\"\"\n"; print "
"; print "\"\"\n"; if ($lh == 3) print "
"; // note: $lh==3 means horiz arrow print i18n::translate($node["relations"][$index])."\n"; } print "
\n"; } // Determine the z-index for this box $boxNum ++; if ($TEXT_DIRECTION=="rtl" && $BROWSERTYPE=="mozilla") { if ($pretty) $zIndex = ($colNum * $depth - $rowNum + $depth); else $zIndex = $boxNum; } else { if ($pretty) $zIndex = 200 - ($colNum * $depth + $rowNum); else $zIndex = 200 - $boxNum; } print "
"; print_pedigree_person($pid, 1, ($view!="preview")); print "
\n"; } print "
"; echo '

', i18n::translate('Relationship: %s', get_relationship_name($node)), '

'; } } } $maxyoffset += 100; ?>