Beispiel #1
0
/**
 * Print age of parents
 *
 * @param string $pid	child ID
 * @param string $bdate	child birthdate
 */
function print_parents_age($pid, $bdate)
{
    global $pgv_lang, $SHOW_PARENTS_AGE, $PGV_IMAGE_DIR, $PGV_IMAGES;
    if ($SHOW_PARENTS_AGE) {
        $famids = find_family_ids($pid);
        // dont show age of parents if more than one family (ADOPtion)
        if (count($famids) == 1) {
            print " <span class=\"age\">";
            $parents = find_parents($famids[0]);
            // father
            $spouse = $parents["HUSB"];
            if ($spouse and showFact("BIRT", $spouse)) {
                $age = get_age(find_person_record($spouse), $bdate, false);
                if (10 < $age and $age < 80) {
                    print "<img src=\"{$PGV_IMAGE_DIR}/" . $PGV_IMAGES["sex"]["small"] . "\" title=\"" . $pgv_lang["father"] . "\" alt=\"" . $pgv_lang["father"] . "\" class=\"sex_image\" />{$age}";
                }
            }
            // mother
            $spouse = $parents["WIFE"];
            if ($spouse and showFact("BIRT", $spouse)) {
                $age = get_age(find_person_record($spouse), $bdate, false);
                if (10 < $age and $age < 80) {
                    print "<img src=\"{$PGV_IMAGE_DIR}/" . $PGV_IMAGES["sexf"]["small"] . "\" title=\"" . $pgv_lang["mother"] . "\" alt=\"" . $pgv_lang["mother"] . "\" class=\"sex_image\" />{$age}";
                }
            }
            print "</span>";
        }
    }
}
 function add_ancestors_to_cart_families($pid, $level = "")
 {
     global $cart;
     $famids = find_family_ids($pid);
     if (count($famids) > 0) {
         foreach ($famids as $indexval => $famid) {
             if ($level == "" || $level > 0) {
                 if ($level != "") {
                     $level = $level - 1;
                 }
                 $clipping = array();
                 $clipping['type'] = "fam";
                 $clipping['id'] = $famid;
                 $ret = $this->add_clipping($clipping);
                 if ($ret) {
                     $parents = find_parents($famid);
                     if (!empty($parents["HUSB"])) {
                         $clipping = array();
                         $clipping['type'] = "indi";
                         $clipping['id'] = $parents["HUSB"];
                         $ret = $this->add_clipping($clipping);
                         $this->add_ancestors_to_cart_families($parents["HUSB"], $level);
                     }
                     if (!empty($parents["WIFE"])) {
                         $clipping = array();
                         $clipping['type'] = "indi";
                         $clipping['id'] = $parents["WIFE"];
                         $ret = $this->add_clipping($clipping);
                         $this->add_ancestors_to_cart_families($parents["WIFE"], $level);
                     }
                     $famrec = find_family_record($famid);
                     if ($famrec) {
                         $num = preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                         for ($i = 0; $i < $num; $i++) {
                             $clipping = array();
                             $clipping['type'] = "indi";
                             $clipping['id'] = $smatch[$i][1];
                             $this->add_clipping($clipping);
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #3
0
/**
 * print ancestors on a fan chart
 *
 * @param array $treeid ancestry pid
 * @param int $fanw fan width in px (default=640)
 * @param int $fandeg fan size in deg (default=270)
 */
function print_fan_chart($treeid, $fanw = 640, $fandeg = 270)
{
    global $PEDIGREE_GENERATIONS, $fan_width, $fan_style;
    global $name, $pgv_lang, $SHOW_ID_NUMBERS, $view, $TEXT_DIRECTION;
    global $stylesheet, $print_stylesheet;
    global $PGV_IMAGE_DIR, $PGV_IMAGES, $LINK_ICONS, $GEDCOM;
    // check for GD 2.x library
    if (!defined("IMG_ARC_PIE")) {
        print "<span class=\"error\">" . $pgv_lang["gd_library"] . "</span>";
        print " <a href=\"" . $pgv_lang["gd_helplink"] . "\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["help"]["small"] . "\" class=\"icon\" alt=\"\" /></a><br /><br />";
        return false;
    }
    if (!function_exists("ImageTtfBbox")) {
        print "<span class=\"error\">" . $pgv_lang["gd_freetype"] . "</span>";
        print " <a href=\"" . $pgv_lang["gd_helplink"] . "\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["help"]["small"] . "\" class=\"icon\" alt=\"\" /></a><br /><br />";
        return false;
    }
    // parse CSS file
    include "includes/cssparser.inc.php";
    $css = new cssparser(false);
    if ($view == "preview") {
        $css->Parse($print_stylesheet);
    } else {
        $css->Parse($stylesheet);
    }
    // check for fontfile
    $fontfile = $css->Get(".fan_chart", "font-family");
    $fontsize = $css->Get(".fan_chart", "font-size");
    $fontfile = str_replace("url(", "", $fontfile);
    $fontfile = str_replace(")", "", $fontfile);
    if (!file_exists($fontfile)) {
        if (!empty($fontfile)) {
            print "<span class=\"error\">" . $pgv_lang["fontfile_error"] . " : {$fontfile}</span>";
        }
        $fontfile = "./includes/fonts/DejaVuSans.ttf";
    }
    if ($fontfile[0] != '/') {
        $fontfile = dirname(__FILE__) . "/" . $fontfile;
    }
    if (!file_exists($fontfile)) {
        print "<span class=\"error\">" . $pgv_lang["fontfile_error"] . " : {$fontfile}</span>";
        return false;
    }
    if (intval($fontsize) < 2) {
        $fontsize = 7;
    }
    $treesize = count($treeid);
    if ($treesize < 1) {
        return;
    }
    // generations count
    $gen = log($treesize) / log(2) - 1;
    $sosa = $treesize - 1;
    // fan size
    if ($fandeg == 0) {
        $fandeg = 360;
    }
    $fandeg = min($fandeg, 360);
    $fandeg = max($fandeg, 90);
    $cx = $fanw / 2 - 1;
    // center x
    $cy = $cx;
    // center y
    $rx = $fanw - 1;
    $rw = $fanw / ($gen + 1);
    $fanh = $fanw;
    // fan height
    if ($fandeg == 180) {
        $fanh = round($fanh * ($gen + 1) / ($gen * 2));
    }
    if ($fandeg == 270) {
        $fanh = round($fanh * 0.86);
    }
    $scale = $fanw / 640;
    // image init
    $image = ImageCreate($fanw, $fanh);
    $black = ImageColorAllocate($image, 0, 0, 0);
    $white = ImageColorAllocate($image, 0xff, 0xff, 0xff);
    ImageFilledRectangle($image, 0, 0, $fanw, $fanh, $white);
    ImageColorTransparent($image, $white);
    $rgb = $css->Get(".fan_chart", "color");
    if (empty($rgb)) {
        $rgb = "#000000";
    }
    $color = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    $rgb = $css->Get(".fan_chart", "background-color");
    if (empty($rgb)) {
        $rgb = "#EEEEEE";
    }
    $bgcolor = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    $rgb = $css->Get(".fan_chart_box", "background-color");
    if (empty($rgb)) {
        $rgb = "#D0D0AC";
    }
    $bgcolorM = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    $rgb = $css->Get(".fan_chart_boxF", "background-color");
    if (empty($rgb)) {
        $rgb = "#D0ACD0";
    }
    $bgcolorF = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    // imagemap
    $imagemap = "<map id=\"fanmap\" name=\"fanmap\">";
    // loop to create fan cells
    while ($gen >= 0) {
        // clean current generation area
        $deg2 = 360 + ($fandeg - 180) / 2;
        $deg1 = $deg2 - $fandeg;
        ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bgcolor, IMG_ARC_PIE);
        $rx -= 3;
        // calculate new angle
        $p2 = pow(2, $gen);
        $angle = $fandeg / $p2;
        $deg2 = 360 + ($fandeg - 180) / 2;
        $deg1 = $deg2 - $angle;
        // special case for rootid cell
        if ($gen == 0) {
            $deg1 = 90;
            $deg2 = 360 + $deg1;
        }
        // draw each cell
        while ($sosa >= $p2) {
            $pid = $treeid[$sosa];
            if (!empty($pid)) {
                $indirec = find_person_record($pid);
                if (!$indirec) {
                    $indirec = find_updated_record($pid);
                }
                if ($sosa % 2) {
                    $bg = $bgcolorF;
                } else {
                    $bg = $bgcolorM;
                }
                if ($sosa == 1) {
                    $bg = $bgcolor;
                    // sex unknown
                    if (preg_match("/1 SEX F/", $indirec) > 0) {
                        $bg = $bgcolorF;
                    } else {
                        if (preg_match("/1 SEX M/", $indirec) > 0) {
                            $bg = $bgcolorM;
                        }
                    }
                }
                ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bg, IMG_ARC_PIE);
                $person = Person::getInstance($pid);
                $name = $person->getFullName();
                $addname = $person->getAddName();
                //$name = str_replace(array('<span class="starredname">', '</span>'), '', $name);
                //$addname = str_replace(array('<span class="starredname">', '</span>'), '', $addname);
                //$name = str_replace(array('<span class="starredname">', '</span>'), array('<u>', '</u>'), $name); //@@
                //$addname = str_replace(array('<span class="starredname">', '</span>'), array('<u>', '</u>'), $addname); //@@
                // ToDo - print starred names underlined - 1985154
                // Todo - print Arabic letters combined - 1360209
                $text = reverseText($name) . "\n";
                if (!empty($addname)) {
                    $text .= reverseText($addname) . "\n";
                }
                if (displayDetailsById($pid)) {
                    $birthrec = get_sub_record(1, "1 BIRT", $indirec);
                    $ct = preg_match("/2 DATE.*(\\d\\d\\d\\d)/", $birthrec, $match);
                    if ($ct > 0) {
                        $text .= trim($match[1]);
                    }
                    $deathrec = get_sub_record(1, "1 DEAT", $indirec);
                    $ct = preg_match("/2 DATE.*(\\d\\d\\d\\d)/", $deathrec, $match);
                    if ($ct > 0) {
                        $text .= "-" . trim($match[1]);
                    }
                }
                $text = unhtmlentitiesrtl($text);
                $text = strip_tags($text);
                //Do we still need?
                // split and center text by lines
                $wmax = floor($angle * 7 / $fontsize * $scale);
                $wmax = min($wmax, 35 * $scale);
                if ($gen == 0) {
                    $wmax = min($wmax, 17 * $scale);
                }
                $text = split_align_text($text, $wmax);
                // text angle
                $tangle = 270 - ($deg1 + $angle / 2);
                if ($gen == 0) {
                    $tangle = 0;
                }
                // calculate text position
                $bbox = ImageTtfBbox((double) $fontsize, 0, $fontfile, $text);
                $textwidth = $bbox[4];
                $deg = $deg1 + 0.44;
                if ($deg2 - $deg1 > 40) {
                    $deg = $deg1 + ($deg2 - $deg1) / 11;
                }
                if ($deg2 - $deg1 > 80) {
                    $deg = $deg1 + ($deg2 - $deg1) / 7;
                }
                if ($deg2 - $deg1 > 140) {
                    $deg = $deg1 + ($deg2 - $deg1) / 4;
                }
                if ($gen == 0) {
                    $deg = 180;
                }
                $rad = deg2rad($deg);
                $mr = ($rx - $rw / 4) / 2;
                if ($gen > 0 and $deg2 - $deg1 > 80) {
                    $mr = $rx / 2;
                }
                $tx = $cx + $mr * cos($rad);
                $ty = $cy - $mr * -sin($rad);
                if ($sosa == 1) {
                    $ty -= $mr / 2;
                }
                // print text
                ImageTtfText($image, (double) $fontsize, $tangle, $tx, $ty, $color, $fontfile, $text);
                $imagemap .= "<area shape=\"poly\" coords=\"";
                // plot upper points
                $mr = $rx / 2;
                $deg = $deg1;
                while ($deg <= $deg2) {
                    $rad = deg2rad($deg);
                    $tx = round($cx + $mr * cos($rad));
                    $ty = round($cy - $mr * -sin($rad));
                    $imagemap .= "{$tx}, {$ty}, ";
                    $deg += ($deg2 - $deg1) / 6;
                }
                // plot lower points
                $mr = ($rx - $rw) / 2;
                $deg = $deg2;
                while ($deg >= $deg1) {
                    $rad = deg2rad($deg);
                    $tx = round($cx + $mr * cos($rad));
                    $ty = round($cy - $mr * -sin($rad));
                    $imagemap .= "{$tx}, {$ty}, ";
                    $deg -= ($deg2 - $deg1) / 6;
                }
                // join first point
                $mr = $rx / 2;
                $deg = $deg1;
                $rad = deg2rad($deg);
                $tx = round($cx + $mr * cos($rad));
                $ty = round($cy - $mr * -sin($rad));
                $imagemap .= "{$tx}, {$ty}";
                // add action url
                $tempURL = "javascript://" . htmlspecialchars(strip_tags($name));
                if ($SHOW_ID_NUMBERS) {
                    $tempURL .= " (" . $pid . ")";
                }
                $imagemap .= "\" href=\"{$tempURL}\" ";
                $tempURL = "fanchart.php?rootid={$pid}&PEDIGREE_GENERATIONS={$PEDIGREE_GENERATIONS}&fan_width={$fan_width}&fan_style={$fan_style}";
                if (!empty($view)) {
                    $tempURL .= "&view={$view}";
                }
                $count = 0;
                $lbwidth = 200;
                print "<div id=\"I" . $pid . "." . $count . "links\" style=\"position:absolute; >";
                print "left:" . $tx . "px; top:" . $ty . "px; width: " . $lbwidth . "px; visibility:hidden; z-index:'100';\">";
                print "<table class=\"person_box\"><tr><td class=\"details1\">";
                print "<a href=\"individual.php?pid={$pid}\" class=\"name1\">" . PrintReady($name);
                if (!empty($addname)) {
                    print "<br />" . PrintReady($addname);
                }
                print "</a>";
                print "<br /><a href=\"pedigree.php?rootid={$pid}\" >" . $pgv_lang["index_header"] . "</a>";
                print "<br /><a href=\"descendancy.php?pid={$pid}\" >" . $pgv_lang["descend_chart"] . "</a>";
                if (PGV_USER_GEDCOM_ID) {
                    print "<br /><a href=\"" . encode_url("relationship.php?pid1=" . PGV_USER_GEDCOM_ID . "&pid2={$pid}&ged={$GEDCOM}") . "\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["relationship_to_me"] . "</a>";
                }
                print "<br /><a href=\"ancestry.php?rootid={$pid}\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["ancestry_chart"] . "</a>";
                print "<br /><a href=\"compact.php?rootid={$pid}\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["compact_chart"] . "</a>";
                print "<br /><a href=\"" . encode_url($tempURL) . "\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["fan_chart"] . "</a>";
                print "<br /><a href=\"hourglass.php?pid={$pid}\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["hourglass_chart"] . "</a>";
                if ($sosa >= 1) {
                    $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;
                    for ($f = 0; $f < count($cfamids); $f++) {
                        $famrec = find_family_record($cfamids[$f]);
                        if ($famrec) {
                            $num += preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                        }
                    }
                    if ($famids || $num > 1) {
                        //-- spouse(s) and children
                        for ($f = 0; $f < count($famids); $f++) {
                            $famrec = find_family_record(trim($famids[$f]));
                            if ($famrec) {
                                $parents = find_parents($famids[$f]);
                                if ($parents) {
                                    if ($pid != $parents["HUSB"]) {
                                        $spid = $parents["HUSB"];
                                    } else {
                                        $spid = $parents["WIFE"];
                                    }
                                    $person = Person::getInstance($spid);
                                    if ($person) {
                                        echo '<br /><a href="', $person->getLinkUrl(), '" class="name1">', $person->getFullName(), '</a>';
                                    }
                                }
                                $num = preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                                for ($i = 0; $i < $num; $i++) {
                                    $person = Person::getInstance($smatch[$i][1]);
                                    if ($person) {
                                        echo '<br />&nbsp;&nbsp;<a href="', $person->getLinkUrl(), '" class="name1">&lt; ', $person->getFullName(), '</a>';
                                    }
                                }
                            }
                        }
                        //-- siblings
                        for ($f = 0; $f < count($cfamids); $f++) {
                            $famrec = find_family_record($cfamids[$f]);
                            if ($famrec) {
                                $num = preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                                if ($num > 2) {
                                    print "<br /><span class=\"name1\">" . $pgv_lang["siblings"] . "</span>";
                                }
                                if ($num == 2) {
                                    print "<br /><span class=\"name1\">" . $pgv_lang["sibling"] . "</span>";
                                }
                                for ($i = 0; $i < $num; $i++) {
                                    $cpid = $smatch[$i][1];
                                    if ($cpid != $pid) {
                                        $person = Person::getInstance($cpid);
                                        if ($person) {
                                            echo '<br />&nbsp;&nbsp;<a href="', $person->getLinkUrl(), '" class="name1"> ', $person->getFullName(), '</a>';
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                print "</td></tr></table>";
                print "</div>";
                $imagemap .= " onclick=\"show_family_box('" . $pid . "." . $count . "', 'relatives'); return false;\"";
                $imagemap .= " onmouseout=\"family_box_timeout('" . $pid . "." . $count . "'); return false;\"";
                $imagemap .= " alt=\"" . PrintReady(strip_tags($name)) . "\" title=\"" . PrintReady(strip_tags($name)) . "\" />";
            }
            $deg1 -= $angle;
            $deg2 -= $angle;
            $sosa--;
        }
        $rx -= $rw;
        $gen--;
    }
    $imagemap .= "</map>";
    echo $imagemap;
    // PGV banner ;-)
    ImageStringUp($image, 1, $fanw - 10, $fanh / 3, PGV_PHPGEDVIEW_URL, $color);
    // here we cannot send image to browser ('header already sent')
    // and we dont want to use a tmp file
    // step 1. save image data in a session variable
    ob_start();
    ImagePng($image);
    $image_data = ob_get_contents();
    ob_end_clean();
    $image_data = serialize($image_data);
    unset($_SESSION['image_data']);
    $_SESSION['image_data'] = $image_data;
    // step 2. call imageflush.php to read this session variable and display image
    // note: arg "image_name=" is to avoid image miscaching
    $image_name = "V" . time();
    unset($_SESSION[$image_name]);
    // statisticsplot.php uses this to hold a file name to send to browser
    $image_title = preg_replace("~<.*>~", "", $name) . " " . $pgv_lang["fan_chart"];
    echo "<p align=\"center\" >";
    echo "<img src=\"imageflush.php?image_type=png&amp;image_name={$image_name}&amp;height={$fanh}&amp;width={$fanw}\" width=\"{$fanw}\" height=\"{$fanh}\" border=\"0\" alt=\"{$image_title}\" title=\"{$image_title}\" usemap=\"#fanmap\" />";
    echo "</p>";
    ImageDestroy($image);
}
Beispiel #4
0
function print_person_pedigree($pid, $count)
{
    global $generations, $SHOW_EMPTY_BOXES, $PGV_IMAGE_DIR, $PGV_IMAGES, $bheight, $bhalfheight;
    if ($count >= $generations) {
        return;
    }
    $famids = find_family_ids($pid);
    $hheight = ($bhalfheight + 3) * pow(2, $generations - $count - 1);
    foreach ($famids as $indexval => $famid) {
        print "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"empty-cells: show;\">\n";
        $parents = find_parents($famid);
        $height = "100%";
        print "<tr>";
        if ($count < $generations - 1) {
            print "<td height=\"" . $hheight . "\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" width=\"3\" alt=\"\" /></td>\n";
            print "<td rowspan=\"2\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["hline"]["other"] . "\" width=\"7\" height=\"3\" alt=\"\" /></td>\n";
        }
        print "<td rowspan=\"2\">\n";
        print_pedigree_person($parents["HUSB"]);
        print "</td>\n";
        print "<td rowspan=\"2\">\n";
        print_person_pedigree($parents["HUSB"], $count + 1);
        print "</td>\n";
        print "</tr>\n<tr>\n<td height=\"" . $hheight . "\"";
        if ($count < $generations - 1) {
            print " style=\"background: url('" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["vline"]["other"] . "');\" ";
        }
        print "><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" width=\"3\" alt=\"\" /></td></tr>\n<tr>\n";
        if ($count < $generations - 1) {
            print "<td height=\"" . $hheight . "\" style=\"background: url('" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["vline"]["other"] . "');\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" width=\"3\" alt=\"\" /></td>";
            print "<td rowspan=\"2\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["hline"]["other"] . "\" width=\"7\" height=\"3\" alt=\"\" /></td>\n";
        }
        print "<td rowspan=\"2\">\n";
        print_pedigree_person($parents["WIFE"]);
        print "</td>\n";
        print "<td rowspan=\"2\">\n";
        print_person_pedigree($parents["WIFE"], $count + 1);
        print "</td>\n";
        print "</tr>\n";
        if ($count < $generations - 1) {
            print "<tr>\n<td height=\"" . $hheight . "\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" width=\"3\" alt=\"\" /></td></tr>\n";
        }
        print "</table>\n";
    }
}
 /**
  * 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, $PGV_IMAGE_DIR, $PGV_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) {
         print "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"empty-cells: show;\">\n";
         $parents = find_parents($famid);
         $height = "100%";
         print "<tr>";
         print "<td valign=\"bottom\"><img name=\"pvline\" src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["vline"]["other"] . "\" width=\"3\" height=\"{$lh}\" alt=\"\" /></td>";
         print "<td><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["hline"]["other"] . "\" width=\"7\" height=\"3\" alt=\"\" /></td>";
         print "<td>";
         //-- print the father box
         print_pedigree_person($parents["HUSB"]);
         print "</td>";
         $ARID = $parents["HUSB"];
         print "<td id=\"td_" . $ARID . "\">";
         //-- 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))) {
             print "<a href=\"#\" onclick=\"return ChangeDiv('td_" . $ARID . "','" . $ARID . "','" . $this->show_full . "','" . $this->show_spouse . "','" . $this->box_width . "')\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["rarrow"]["other"] . "\" border=\"0\" alt=\"\" /></a> ";
         }
         //-- recursively get the father's family
         $this->print_person_pedigree($parents["HUSB"], $count + 1);
         print "</td>";
         print "</tr>\n<tr>\n";
         print "<td valign=\"top\"><img name=\"pvline\" src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["vline"]["other"] . "\" width=\"3\" height=\"{$lh}\" alt=\"\" /></td>";
         print "<td><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["hline"]["other"] . "\" width=\"7\" height=\"3\" alt=\"\" /></td>";
         print "<td>";
         //-- print the mother box
         print_pedigree_person($parents["WIFE"]);
         print "</td>";
         $ARID = $parents["WIFE"];
         print "<td id=\"td_" . $ARID . "\">";
         //-- 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))) {
             print "<a href=\"#\" onclick=\"ChangeDiv('td_" . $ARID . "','" . $ARID . "','" . $this->show_full . "','" . $this->show_spouse . "','" . $this->box_width . "'); return false;\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["rarrow"]["other"] . "\" border=\"0\" alt=\"\" /></a> ";
         }
         //-- recursively print the mother's family
         $this->print_person_pedigree($parents["WIFE"], $count + 1);
         print "</td>";
         print "</tr>";
         print "</table>";
         break;
     }
 }
/**
 * 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"];
    }
}
Beispiel #7
0
 function init()
 {
     global $Dbwidth, $bwidth, $pbwidth, $pbheight, $bheight, $GEDCOM, $pgv_lang, $CONTACT_EMAIL, $show_famlink, $pgv_changes;
     $bwidth = $Dbwidth;
     $pbwidth = $bwidth + 12;
     $pbheight = $bheight + 14;
     $show_famlink = $this->view != 'preview';
     $this->famid = safe_GET_xref('famid');
     $this->family = Family::getInstance($this->famid);
     if (empty($this->famrec)) {
         $ct = preg_match("/(\\w+):(.+)/", $this->famid, $match);
         if ($ct > 0) {
             $servid = trim($match[1]);
             $remoteid = trim($match[2]);
             include_once 'includes/classes/class_serviceclient.php';
             $service = ServiceClient::getInstance($servid);
             if (!is_null($service)) {
                 $newrec = $service->mergeGedcomRecord($remoteid, "0 @" . $this->famid . "@ FAM\n1 RFN " . $this->famid, false);
                 $this->famrec = $newrec;
             }
         }
         //-- if no record was found create a default empty one
         if (isset($pgv_changes[$this->famid . "_" . $GEDCOM])) {
             $this->famrec = "0 @" . $this->famid . "@ FAM\n";
             $this->family = new Family($this->famrec);
         } else {
             if (empty($this->family)) {
                 return false;
             }
         }
     }
     $this->famrec = $this->family->getGedcomRecord();
     $this->display = displayDetailsById($this->famid, 'FAM');
     //-- if the user can edit and there are changes then get the new changes
     if ($this->show_changes && PGV_USER_CAN_EDIT && isset($pgv_changes[$this->famid . "_" . $GEDCOM])) {
         $newrec = find_updated_record($this->famid);
         if (empty($newrec)) {
             $newrec = find_family_record($this->famid);
         }
         $this->difffam = new Family($newrec);
         $this->difffam->setChanged(true);
         $this->family->diffMerge($this->difffam);
         //$this->famrec = $newrec;
         //$this->family = new Family($this->famrec);
     }
     $this->parents = array('HUSB' => $this->family->getHusbId(), 'WIFE' => $this->family->getWifeId());
     //-- check if we can display both parents
     if ($this->display == false) {
         $this->showLivingHusb = showLivingNameById($this->parents['HUSB']);
         $this->showLivingWife = showLivingNameById($this->parents['WIFE']);
     }
     //-- add favorites action
     if ($this->action == 'addfav' && !empty($_REQUEST['gid']) && PGV_USER_NAME) {
         $_REQUEST['gid'] = strtoupper($_REQUEST['gid']);
         $indirec = find_family_record($_REQUEST['gid']);
         if ($indirec) {
             $favorite = array('username' => PGV_USER_NAME, 'gid' => $_REQUEST['gid'], 'type' => 'FAM', 'file' => $GEDCOM, 'url' => '', 'note' => '', 'title' => '');
             addFavorite($favorite);
         }
     }
     if (PGV_USER_CAN_ACCEPT) {
         if ($this->action == 'accept') {
             if (accept_changes($_REQUEST['famid'] . '_' . $GEDCOM)) {
                 $this->show_changes = false;
                 $this->accept_success = true;
                 //-- check if we just deleted the record and redirect to index
                 $famrec = find_family_record($_REQUEST['famid']);
                 if (empty($famrec)) {
                     header("Location: index.php?ctype=gedcom");
                     exit;
                 }
                 $this->family = new Family($famrec);
                 $this->parents = find_parents($_REQUEST['famid']);
             }
         }
         if ($this->action == 'undo') {
             $this->family->undoChange();
             $this->parents = find_parents($_REQUEST['famid']);
         }
     }
     //-- make sure we have the true id from the record
     $ct = preg_match("/0 @(.*)@/", $this->famrec, $match);
     if ($ct > 0) {
         $this->famid = trim($match[1]);
     }
     if ($this->showLivingHusb == false && $this->showLivingWife == false) {
         print_header($pgv_lang['private'] . " " . $pgv_lang['family_info']);
         print_privacy_error($CONTACT_EMAIL);
         print_footer();
         exit;
     }
     $this->title = $this->family->getFullName();
     if (empty($this->parents['HUSB']) || empty($this->parents['WIFE'])) {
         $this->link_relation = 0;
     } else {
         $this->link_relation = 1;
     }
 }
<?php 
    //------------------------------------------- FAMILY AS CHILD TABS ------------------------
    $i++;
    for ($j = 1; $j <= count($cfams); $j++) {
        ?>
<div id="tab<?php 
        echo $i;
        ?>
" style="display: none;">
<table class="<?php 
        echo $TEXT_DIRECTION;
        ?>
 width80">
<?php 
        $famreqdfacts = preg_split("/[,; ]/", $QUICK_REQUIRED_FAMFACTS);
        $parents = find_parents($cfams[$j - 1]);
        $famid = $cfams[$j - 1];
        $family = Family::getInstance($famid);
        if (!isset($pgv_changes[$famid . "_" . PGV_GEDCOM])) {
            $famrec = find_family_record($famid, PGV_GED_ID);
        } else {
            $famrec = find_updated_record($famid, PGV_GED_ID);
        }
        if ($family) {
            $subrecords = $family->getFacts(array("HUSB", "WIFE", "CHIL"));
        } else {
            $subrecords = array();
        }
        $famfacts = array();
        foreach ($subrecords as $ind => $eventObj) {
            $fact = $eventObj->getTag();
 /**
  * print a family descendancy
  *
  * @param string $pid individual Gedcom Id
  * @param Family $famid family record
  * @param int $depth the descendancy depth to show
  */
 function print_family_descendancy(&$person, &$family, $depth)
 {
     global $pgv_lang, $factarray;
     global $GEDCOM, $PGV_IMAGE_DIR, $PGV_IMAGES, $Dindent, $personcount;
     if (is_null($family)) {
         return;
     }
     if (is_null($person)) {
         return;
     }
     $famrec = $family->getGedcomRecord();
     $famid = $family->getXref();
     $parents = find_parents($famid);
     if ($parents) {
         // spouse id
         $id = $parents["WIFE"];
         if ($id == $person->getXref()) {
             $id = $parents["HUSB"];
         }
         // print marriage info
         print "<li>";
         print "<img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" height=\"2\" width=\"" . ($Dindent + 4) . "\" border=\"0\" alt=\"\" />";
         print "<span class=\"details1\" style=\"white-space: nowrap; \" >";
         print "<a href=\"#\" onclick=\"expand_layer('" . $famid . $personcount . "'); return false;\" class=\"top\"><img id=\"" . $famid . $personcount . "_img\" src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["minus"]["other"] . "\" align=\"middle\" hspace=\"0\" vspace=\"3\" border=\"0\" alt=\"" . $pgv_lang["view_family"] . "\" /></a> ";
         echo '<a href="', encode_url("family.php?famid={$famid}&ged={$GEDCOM}"), '" class="details1">';
         $marriage = $family->getMarriage();
         if ($marriage->canShow()) {
             $marriage->print_simple_fact();
         } else {
             print $pgv_lang["private"];
         }
         echo "</a>";
         print "</span>";
         // print spouse
         print "<ul style=\"list-style: none; display: block;\" id=\"" . $famid . $personcount . "\">";
         print "<li>";
         print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td>";
         print_pedigree_person($id, 1, $this->view != "preview", '' . $personcount);
         print "</td>";
         // check if spouse has parents and add an arrow
         print "<td>&nbsp;</td>";
         print "<td>";
         $sfamids = find_family_ids($id);
         foreach ($sfamids as $indexval => $sfamid) {
             $parents = find_parents($sfamid);
             if ($parents) {
                 $parid = $parents["HUSB"];
                 if ($parid == "") {
                     $parid = $parents["WIFE"];
                 }
                 if ($parid != "") {
                     print_url_arrow($parid . $personcount . $person->getXref(), encode_url("?pid={$parid}&generations={$this->generations}&show_full={$this->show_full}&box_width={$this->box_width}"), $pgv_lang["start_at_parents"], 2);
                     $personcount++;
                 }
             }
         }
         if ($this->show_full) {
             print "<br /><br />&nbsp;";
         }
         print "</td></tr>";
         // children
         $children = $family->getChildren();
         print "<tr><td colspan=\"3\" class=\"details1\" >&nbsp;&nbsp;";
         if (count($children) < 1) {
             print $pgv_lang["no_children"];
         } else {
             print $factarray["NCHI"] . ": " . count($children);
         }
         print "</td></tr></table>";
         print "</li>\r\n";
         if ($depth > 0) {
             foreach ($children as $child) {
                 $personcount++;
                 $this->print_child_descendancy($child, $depth - 1);
             }
         }
         print "</ul>\r\n";
         print "</li>\r\n";
     }
 }
Beispiel #10
0
/**
 * Generate iCalendar events for all living family descendants
 *
 * @param string $pid individual Gedcom Id
 * @param Family $famid family record
 * @param int $depth the descendancy depth to show
 */
function generateFamilyDescendancyIcal(&$person, &$family, $depth)
{
    global $pgv_lang, $factarray;
    global $GEDCOM, $PGV_IMAGE_DIR, $PGV_IMAGES, $Dindent, $personcount;
    global $icalEvents;
    if (is_null($family)) {
        return;
    }
    $famrec = $family->getGedcomRecord();
    $famid = $family->getXref();
    $parents = find_parents($famid);
    if ($parents) {
        // spouse id
        $id = $parents["WIFE"];
        if ($id == $person->getXref()) {
            $id = $parents["HUSB"];
        }
        // get marriage info
        $icalEvents[$family->getXref()] = getFamilyAnniversaryIcalEvent($family);
        // get spouse
        $person = Person::getInstance($id);
        $icalEvents[$person->getXref()] = getIndiBDIcalEvent($person);
        // children
        $children = $family->getChildren();
        if ($depth > 0) {
            foreach ($children as $childid => $child) {
                generateChildDescendancyIcal($child, $depth - 1);
            }
        }
    }
}