pid =safe_GET_xref('pid'); $this->show_full =safe_GET('show_full', array('0', '1'), $PEDIGREE_FULL_DETAILS); $this->show_spouse=safe_GET('show_spouse', array('0', '1'), '0'); $this->generations=safe_GET_integer('generations', 2, $MAX_DESCENDANCY_GENERATIONS, 3); $this->box_width =safe_GET_integer('box_width', 50, 300, 100); // This is passed as a global. A parameter would be better... $show_full=$this->show_full; if (!empty($_REQUEST["action"])) $this->action = $_REQUEST["action"]; if (!empty($rootid)) $this->pid = $rootid; //-- flip the arrows for RTL languages if ($TEXT_DIRECTION=="rtl") { $temp = $WT_IMAGES['larrow']; $WT_IMAGES['larrow'] = $WT_IMAGES['rarrow']; $WT_IMAGES['rarrow'] = $temp; } //-- get the width and height of the arrow images for adjusting spacing if (file_exists($WT_IMAGES['larrow'])) { $temp = getimagesize($WT_IMAGES['larrow']); $this->arrwidth = $temp[0]; $this->arrheight= $temp[1]; } // -- Sets the sizes of the boxes if (!$this->show_full) $bwidth *= $this->box_width / 150; else $bwidth*=$this->box_width/100; if (!$this->show_full) $bheight = (int)($bheight / 2); $bhalfheight = (int)($bheight / 2); // Validate parameters $this->pid=check_rootid($this->pid); $this->hourPerson = Person::getInstance($this->pid); $this->name=$this->hourPerson->getFullName(); //Checks how many generations of descendency is for the person for formatting purposes $this->dgenerations = $this->max_descendency_generations($this->pid, 0); if ($this->dgenerations<1) $this->dgenerations=1; } /** * Prints pedigree of the person passed in. Which is the descendancy * * @param mixed $pid ID of person to print the pedigree for * @param mixed $count generation count, so it recursively calls itself * @access public * @return void */ function print_person_pedigree($pid, $count) { global $SHOW_EMPTY_BOXES, $WT_IMAGES, $bhalfheight; if ($count>=$this->generations) return; $person = Person::getInstance($pid); if (is_null($person)) return; $families = $person->getChildFamilies(); //-- calculate how tall the lines should be $lh = ($bhalfheight+3) * pow(2, ($this->generations-$count-1)); foreach ($families as $famid => $family) { echo ""; $parents = find_parents($famid); $height="100%"; echo ""; echo ""; echo ""; echo ""; $ARID = $parents["HUSB"]; echo ""; echo ""; echo ""; echo ""; echo ""; $ARID = $parents["WIFE"]; echo ""; echo ""; echo "
\"\"\"\""; //-- print the father box print_pedigree_person($parents["HUSB"]); echo ""; //-- print an Ajax arrow on the last generation of the adult male if ($count==$this->generations-1 && (count(find_family_ids($ARID))>0) && !is_null (find_family_ids($ARID))) { echo "show_full."','".$this->show_spouse."','".$this->box_width."')\">\"\" "; } //-- recursively get the father's family $this->print_person_pedigree($parents["HUSB"], $count+1); echo "
\"\"\"\""; //-- print the mother box print_pedigree_person($parents["WIFE"]); echo ""; //-- print an ajax arrow on the last generation of the adult female if ($count==$this->generations-1 && (count(find_family_ids($ARID))>0) && !is_null (find_family_ids($ARID))) { echo "show_full."','".$this->show_spouse."','".$this->box_width."'); return false;\">\"\" "; } //-- recursively print the mother's family $this->print_person_pedigree($parents["WIFE"], $count+1); echo "
"; break; } } /** * Prints descendency of passed in person * * @param mixed $pid ID of person to print descendency for * @param mixed $count count of generations to print * @access public * @return void */ function print_descendency($pid, $count, $showNav=true) { global $TEXT_DIRECTION, $WT_IMAGES, $bheight, $bwidth, $bhalfheight, $lastGenSecondFam; if ($count>$this->dgenerations) return 0; $person = Person::getInstance($pid); if (is_null($person)) return; $tablealign = "right"; $otablealign = "left"; if ($TEXT_DIRECTION=="rtl") { $tablealign = "left"; $otablealign = "right"; } echo ""; //-- put a space between families on the last generation if ($count==$this->dgenerations-1) { if (isset($lastGenSecondFam)) echo "
"; $lastGenSecondFam = true; } echo ""; echo ""; echo ""; echo ""; echo "
"; $numkids = 0; $families = $person->getSpouseFamilies(); $famcount = count($families); $famNum = 0; $kidNum = 0; $children = array(); if ($count < $this->dgenerations) { //-- put all of the children in a common array foreach ($families as $famid => $family) { $famNum ++; $chs = $family->getChildren(); foreach ($chs as $c=>$child) $children[] = $child; } $ct = count($children); if ($ct>0) { echo ""; for ($i=0; $i<$ct; $i++) { if (($i>0)&&($i<$ct-1)) $rowspan=1; /* @var $person2 Person */ $person2 = $children[$i]; $chil = $person2->getXref(); echo ""; echo ""; //-- print the lines $twidth = 7; if ($ct==1) $twidth+=3; if ($ct>1) { if ($i==0) { //-- adjust for the number of kids $h = ($bhalfheight+3)*$numkids; echo ""; } else if ($i==$ct-1) { $h = ($bhalfheight+3)*$kids; if ($count<$this->dgenerations-1) { if ($this->show_spouse) $h-=15; else $h += 15; } echo ""; } else { echo ""; } } echo ""; } echo "
"; $kids = $this->print_descendency($chil, $count+1); $numkids += $kids; echo "\"\"\"\"\"\"
"; } echo "
"; } // Print the descendency expansion arrow if ($count==$this->dgenerations) { $numkids = 1; $tbwidth = $bwidth+16; for ($j=$count; $j<$this->dgenerations; $j++) { echo "

"; } $kcount = 0; foreach ($families as $famid=>$family) $kcount+=$family->getNumberOfChildren(); if ($kcount==0) { echo "
arrwidth)."px;\">
"; } else { echo "
arrwidth)."px;\">show_full."','".$this->show_spouse."','".$this->box_width."')\">\"\"
"; //-- move the arrow up to line up with the correct box if ($this->show_spouse) { foreach ($families as $famid => $family) { /* @var $family Family */ if (!is_null($family)) { $spouse = $family->getSpouse($person); if ($spouse!=null) { echo "


"; } } } } echo "
"; } } echo ""; } } } //-- add offset divs to make things line up better if ($count==$this->dgenerations) echo "
"; print_pedigree_person($pid); echo "\"\""; //----- Print the spouse if ($this->show_spouse) { foreach ($families as $famid => $family) { /* @var $family Family */ if (!is_null($family)) { $spouse = $family->getSpouse($person); if ($spouse!=null) { echo "
"; //-- shrink the box for the spouses $tempw = $bwidth; $temph = $bheight; $bwidth -= 10; $bheight -= 10; print_pedigree_person($spouse->getXref()); $bwidth = $tempw; $bheight = $temph; $numkids += 0.95; echo "

"; } echo "
"; // For the root person, print a down arrow that allows changing the root of tree if ($showNav && $count==1) { // NOTE: If statement OK if ($person->canDisplayName()) { // -- print left arrow for decendants so that we can move down the tree $famids = $person->getSpouseFamilies(); //-- make sure there is more than 1 child in the family with parents $cfamids = $person->getChildFamilies(); $num=0; foreach ($cfamids as $famid=>$family) { if (!is_null($family)) { $num += $family->getNumberOfChildren(); } } // NOTE: If statement OK if ($num>0) { echo "
"; echo ""; echo "\"\""; echo "
"; echo "
"; echo "
"; foreach ($famids as $famid=>$family) { if (!is_null($family)) { $spouse = $family->getSpouse($person); if (!empty($spouse)) { $spid = $spouse->getXref(); echo "show_spouse}&show_full={$this->show_full}&generations={$this->generations}&box_width={$this->box_width}\">getFullName(); $name = rtrim($name); if (hasRTLText($name)) echo "class=\"name2\">"; else echo "class=\"name1\">"; echo PrintReady($name); echo "
"; } $children = $family->getChildren(); foreach ($children as $id=>$child) { $cid = $child->getXref(); echo "  show_spouse}&show_full={$this->show_full}&generations={$this->generations}&box_width={$this->box_width}\">getFullName(); $name = rtrim($name); if (hasRTLText($name)) echo "class=\"name2\">< "; else echo "class=\"name1\">< "; echo PrintReady($name); echo "
"; } } } //-- do we need to print this arrow? echo "\"\" "; //-- print the siblings foreach ($cfamids as $famid=>$family) { if (!is_null($family)) { if (!is_null($family->getHusband()) || !is_null($family->getWife())) { echo "
".i18n::translate('Parents')."
"; $husb = $family->getHusband(); if (!empty($husb)) { $spid = $husb->getXref(); echo "  show_spouse}&show_full={$this->show_full}&generations={$this->generations}&box_width={$this->box_width}\">getFullName(); $name = rtrim($name); if (hasRTLText($name)) echo "class=\"name2\">"; else echo "class=\"name1\">"; echo PrintReady($name); echo "
"; } $husb = $family->getWife(); if (!empty($husb)) { $spid = $husb->getXref(); echo "  show_spouse}&show_full={$this->show_full}&generations={$this->generations}&box_width={$this->box_width}\">getFullName(); $name = rtrim($name); if (hasRTLText($name)) echo "class=\"name2\">"; else echo "class=\"name1\">"; echo PrintReady($name); echo "
"; } } $children = $family->getChildren(); $num = $family->getNumberOfChildren(); if ($num>2) echo "
".i18n::translate('Siblings')."
"; if ($num==2) echo "
".i18n::translate('Sibling')."
"; foreach ($children as $id=>$child) { $cid = $child->getXref(); if ($cid!=$pid) { echo "  show_spouse}&show_full={$this->show_full}&generations={$this->generations}&box_width={$this->box_width}\">getFullName(); $name = rtrim($name); if (hasRTLText($name)) echo "class=\"name2\"> "; else echo "class=\"name1\"> "; echo PrintReady($name); echo "
"; } } } } echo "
"; echo "
"; echo "
"; } } } echo "
"; return $numkids; } /** * Calculates number of generations a person has * * @param mixed $pid ID of person to see how far down the descendency goes * @param mixed $depth Pass in 0 and it calculates how far down descendency goes * @access public * @return maxdc Amount of generations the descendency actually goes */ function max_descendency_generations($pid, $depth) { if ($depth > $this->generations) return $depth; $person = Person::getInstance($pid); if (is_null($person)) return $depth; $famids = $person->getSpouseFamilies(); if ($person->getNumberOfChildren()==0) return $depth-1; $maxdc = $depth; foreach ($famids as $famid => $family) { $ct = preg_match_all("/1 CHIL @(.*)@/", $family->getGedcomRecord(), $match, PREG_SET_ORDER); for ($i=0; $i<$ct; $i++) { $chil = trim($match[$i][1]); $dc = $this->max_descendency_generations($chil, $depth+1); if ($dc >= $this->generations) return $dc; if ($dc > $maxdc) $maxdc = $dc; } } $maxdc++; if ($maxdc==1) $maxdc++; return $maxdc; } /** * setup all of the javascript that is needed for the hourglass chart * */ function setupJavascript() { global $bhalfheight; ?>