Example #1
0
function print_descendency($pid, $count)
{
    global $show_spouse, $dgenerations, $bwidth, $bheight, $bhalfheight;
    global $TEXT_DIRECTION, $PGV_IMAGE_DIR, $PGV_IMAGES, $generations, $box_width, $view, $show_full, $pgv_lang;
    if ($count >= $dgenerations) {
        return 0;
    }
    print "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
    print "<tr>";
    print "<td width=\"" . ($bwidth - 2) . "\">\n";
    $numkids = 0;
    $famids = find_sfamily_ids($pid);
    if (count($famids) > 0) {
        $firstkids = 0;
        foreach ($famids as $indexval => $famid) {
            $famrec = find_family_record($famid, PGV_GED_ID);
            $ct = preg_match_all("/1 CHIL @(.*)@/", $famrec, $match, PREG_SET_ORDER);
            if ($ct > 0) {
                print "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
                for ($i = 0; $i < $ct; $i++) {
                    $rowspan = 2;
                    if ($i > 0 && $i < $ct - 1) {
                        $rowspan = 1;
                    }
                    $chil = trim($match[$i][1]);
                    print "<tr><td rowspan=\"{$rowspan}\" width=\"{$bwidth}\" style=\"padding-top: 2px;\">\n";
                    if ($count < $dgenerations - 1) {
                        $kids = print_descendency($chil, $count + 1);
                        if ($i == 0) {
                            $firstkids = $kids;
                        }
                        $numkids += $kids;
                    } else {
                        print_pedigree_person($chil);
                        $numkids++;
                    }
                    print "</td>\n";
                    $twidth = 7;
                    if ($ct == 1) {
                        $twidth += 3;
                    }
                    print "<td rowspan=\"{$rowspan}\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["hline"]["other"] . "\" width=\"{$twidth}\" height=\"3\" alt=\"\" /></td>\n";
                    if ($ct > 1) {
                        if ($i == 0) {
                            print "<td height=\"" . ($bhalfheight + 3) . "\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" width=\"3\" alt=\"\" /></td></tr>\n";
                            print "<tr><td height=\"" . ($bhalfheight + 3) . "\" style=\"background: url('" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["vline"]["other"] . "');\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" width=\"3\" alt=\"\" /></td>\n";
                        } else {
                            if ($i == $ct - 1) {
                                print "<td height=\"" . ($bhalfheight + 4) . "\" style=\"background: url('" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["vline"]["other"] . "');\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" width=\"3\" alt=\"\" /></td></tr>\n";
                                print "<tr><td height=\"" . ($bhalfheight + 4) . "\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" width=\"3\" alt=\"\" /></td>\n";
                            } else {
                                print "<td style=\"background: url('" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["vline"]["other"] . "');\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" width=\"3\" alt=\"\" /></td>\n";
                            }
                        }
                    }
                    print "</tr>\n";
                }
                print "</table>\n";
            }
        }
        print "</td>\n";
        print "<td width=\"{$bwidth}\">\n";
    }
    // NOTE: If statement OK
    if ($numkids == 0) {
        $numkids = 1;
        $tbwidth = $bwidth + 16;
        for ($j = $count; $j < $dgenerations; $j++) {
            print "</td>\n<td width=\"{$bwidth}\">\n";
        }
    }
    //-- add offset divs to make things line up better
    if ($show_spouse) {
        foreach ($famids as $indexval => $famid) {
            $famrec = find_family_record($famid, PGV_GED_ID);
            if (!empty($famrec)) {
                $marrec = get_sub_record(1, "1 MARR", $famrec);
                if (!empty($marrec)) {
                    print "<br />";
                }
                print "<div style=\"height: " . $bheight . "px; width: " . $bwidth . "px;\"><br /></div>\n";
            }
        }
    }
    print_pedigree_person($pid);
    // NOTE: If statement OK
    if ($show_spouse) {
        foreach ($famids as $indexval => $famid) {
            $famrec = find_family_record($famid, PGV_GED_ID);
            if (!empty($famrec)) {
                $parents = find_parents_in_record($famrec);
                $marrec = get_sub_record(1, "1 MARR", $famrec);
                if (!empty($marrec)) {
                    print "<br />";
                    $marriage = new Event($marrec);
                    $marriage->print_simple_fact();
                }
                if ($parents["HUSB"] != $pid) {
                    print_pedigree_person($parents["HUSB"]);
                } else {
                    print_pedigree_person($parents["WIFE"]);
                }
            }
        }
    }
    // NOTE: If statement OK
    if ($count == 0) {
        $indirec = find_person_record($pid, PGV_GED_ID);
        // NOTE: If statement OK
        if (displayDetailsById($pid, 'INDI') || showLivingNameById($pid)) {
            // -- print left arrow for decendants so that we can move down the tree
            $famids = find_sfamily_ids($pid);
            //-- make sure there is more than 1 child in the family with parents
            $cfamids = find_family_ids($pid);
            $num = 0;
            // NOTE: For statement OK
            for ($f = 0; $f < count($cfamids); $f++) {
                $famrec = find_family_record($cfamids[$f], PGV_GED_ID);
                if ($famrec) {
                    $num += preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                }
            }
            // NOTE: If statement OK
            if ($famids || $num > 1) {
                print "\n\t\t<div class=\"center\" id=\"childarrow.{$pid}\" dir=\"" . $TEXT_DIRECTION . "\"";
                print " style=\"position:absolute; width:" . $bwidth . "px; \">";
                if ($view != "preview") {
                    print "<a href=\"javascript: " . $pgv_lang["show"] . "\" onclick=\"return togglechildrenbox('{$pid}');\" onmouseover=\"swap_image('larrow.{$pid}',3);\" onmouseout=\"swap_image('larrow.{$pid}',3);\">";
                    print "<img id=\"larrow.{$pid}\" src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["darrow"]["other"] . "\" border=\"0\" alt=\"\" />";
                    print "</a>";
                }
                print "\n\t\t<div id=\"childbox.{$pid}\" dir=\"" . $TEXT_DIRECTION . "\" style=\"width:" . $bwidth . "px; height:" . $bheight . "px; visibility: hidden;\">";
                print "\n\t\t\t<table class=\"person_box\"><tr><td>";
                for ($f = 0; $f < count($famids); $f++) {
                    $famrec = find_family_record(trim($famids[$f]), PGV_GED_ID);
                    if ($famrec) {
                        $parents = find_parents($famids[$f]);
                        if ($parents) {
                            if ($pid != $parents["HUSB"]) {
                                $spid = $parents["HUSB"];
                            } else {
                                $spid = $parents["WIFE"];
                            }
                            $spouse = Person::getInstance($spid);
                            if ($spouse) {
                                $name = $spouse->getFullName();
                                print "\n\t\t\t\t<a href=\"" . encode_url("familybook.php?pid={$spid}&show_spouse={$show_spouse}&show_full={$show_full}&generations={$generations}&box_width={$box_width}") . "\"><span class=\"";
                                if (hasRTLText($name)) {
                                    print "name2";
                                } else {
                                    print "name1";
                                }
                                print "\">";
                                print PrintReady($name);
                                print "<br /></span></a>";
                            }
                        }
                        $num = preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                        for ($i = 0; $i < $num; $i++) {
                            //-- add the following line to stop a bad PHP bug
                            if ($i >= $num) {
                                break;
                            }
                            $cid = $smatch[$i][1];
                            $child = Person::getInstance($cid);
                            $name = $child->getFullName();
                            print "\n\t\t\t\t&nbsp;&nbsp;<a href=\"" . encode_url("familybook.php?pid={$cid}&show_spouse={$show_spouse}&show_full={$show_full}&generations={$generations}&box_width={$box_width}") . "\"><span class=\"";
                            if (hasRTLText($name)) {
                                print "name2";
                            } else {
                                print "name1";
                            }
                            print "\">&lt; ";
                            print PrintReady($name);
                            print "<br /></span></a>";
                        }
                    }
                }
                //-- print the siblings
                for ($f = 0; $f < count($cfamids); $f++) {
                    $famrec = find_family_record($cfamids[$f], PGV_GED_ID);
                    if ($famrec) {
                        $parents = find_parents($cfamids[$f]);
                        if ($parents) {
                            print "<span class=\"name1\"><br />" . $pgv_lang["parents"] . "<br /></span>";
                            if (!empty($parents["HUSB"])) {
                                $spid = $parents["HUSB"];
                                $spouse = Person::getInstance($spid);
                                $name = $spouse->getFullName();
                                print "\n\t\t\t\t&nbsp;&nbsp;<a href=\"" . encode_url("familybook.php?pid={$spid}&show_spouse={$show_spouse}&show_full={$show_full}&generations={$generations}&box_width={$box_width}") . "\"><span class=\"";
                                if (hasRTLText($name)) {
                                    print "name2";
                                } else {
                                    print "name1";
                                }
                                print "\">";
                                print PrintReady($name);
                                print "<br /></span></a>";
                            }
                            if (!empty($parents["WIFE"])) {
                                $spid = $parents["WIFE"];
                                $spouse = Person::getInstance($spid);
                                $name = $spouse->getFullName();
                                print "\n\t\t\t\t&nbsp;&nbsp;<a href=\"" . encode_url("familybook.php?pid={$spid}&show_spouse={$show_spouse}&show_full={$show_full}&generations={$generations}&box_width={$box_width}") . "\"><span class=\"";
                                if (hasRTLText($name)) {
                                    print "name2";
                                } else {
                                    print "name1";
                                }
                                print "\">";
                                print PrintReady($name);
                                print "<br /></span></a>";
                            }
                        }
                        $num = preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                        if ($num > 2) {
                            print "<span class=\"name1\"><br />" . $pgv_lang["siblings"] . "<br /></span>";
                        }
                        if ($num == 2) {
                            print "<span class=\"name1\"><br />" . $pgv_lang["sibling"] . "<br /></span>";
                        }
                        for ($i = 0; $i < $num; $i++) {
                            //-- add the following line to stop a bad PHP bug
                            if ($i >= $num) {
                                break;
                            }
                            $cid = $smatch[$i][1];
                            if ($cid != $pid) {
                                $child = Person::getInstance($cid);
                                $name = $child->getFullName();
                                print "\n\t\t\t\t&nbsp;&nbsp;<a href=\"familybook.php?pid={$cid}&amp;show_spouse={$show_spouse}&amp;show_full={$show_full}&amp;generations={$generations}&amp;box_width={$box_width}\"><span class=\"";
                                if (hasRTLText($name)) {
                                    print "name2";
                                } else {
                                    print "name1";
                                }
                                print "\"> ";
                                print PrintReady($name);
                                print "<br /></span></a>";
                            }
                        }
                    }
                }
                print "\n\t\t\t</td></tr></table>";
                print "\n\t\t</div>";
                print "\n\t\t</div>";
            }
        }
    }
    print "</td></tr>\n";
    print "</table>\n";
    return $numkids;
}