/**
 * print cousins list
 *
 * @param string $famid family ID
 */
function print_cousins($famid, $personcount = "1")
{
    global $show_full, $bheight, $bwidth;
    global $PGV_IMAGE_DIR, $PGV_IMAGES, $pgv_lang, $TEXT_DIRECTION;
    $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 "<td valign=\"middle\" height=\"100%\">";
    if ($kids) {
        print "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" ><tr valign=\"middle\">";
        if ($kids > 1) {
            print "<td rowspan=\"" . $kids . "\" valign=\"middle\" align=\"right\"><img width=\"3px\" height=\"" . ($bheight + 5) * ($kids - 1) . "px\" src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["vline"]["other"] . "\" alt=\"\" /></td>";
        }
        $ctkids = count($fchildren);
        $i = 1;
        foreach ($fchildren as $indexval => $fchil) {
            print "<td><img width=\"10px\" height=\"3px\" style=\"padding-";
            if ($TEXT_DIRECTION == "ltr") {
                print "right";
            } else {
                print "left";
            }
            print ": 2px;\" src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["hline"]["other"] . "\" alt=\"\" /></td><td>";
            print_pedigree_person($fchil, 1, false, 0, $personcount);
            $personcount++;
            print "</td></tr>";
            if ($i < $ctkids) {
                print "<tr>";
                $i++;
            }
        }
        print "</table>";
    } else {
        $famrec = find_family_record($famid);
        $ct = preg_match("/1 NCHI (\\w+)/", $famrec, $match);
        if ($ct > 0) {
            $nchi = $match[1];
        } else {
            $nchi = "";
        }
        if ($nchi == "0") {
            print "&nbsp;<img src=\"images/small/childless.gif\" alt=\"" . $pgv_lang["childless_family"] . "\" title=\"" . $pgv_lang["childless_family"] . "\" />";
        }
    }
    $show_full = $save_show_full;
    if ($save_show_full) {
        $bheight *= 4;
        $bwidth += 40;
    }
    print "</td>\n";
}
Example #2
0
            }
        }
        // Fetch all data, regardless of privacy
        $rows = get_SOUR_rows($WT_TREE, $term);
        // Filter for privacy
        foreach ($rows as $row) {
            $source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
            if ($source->canShowName()) {
                $data[] = array('value' => $source->getXref(), 'label' => $source->getFullName());
            }
        }
        // Fetch all data, regardless of privacy
        $rows = get_FAM_rows($WT_TREE, $term);
        // Filter for privacy
        foreach ($rows as $row) {
            $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
            if ($family->canShowName()) {
                $marriage_year = $family->getMarriageYear();
                if ($marriage_year) {
                    $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>');
                } else {
                    $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName());
                }
            }
        }
        echo json_encode($data);
        return;
}
/**
 * Find family records from the database.
 *
    $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();
            $event = $eventObj->getDetail();
            if ($fact == "EVEN" || $fact == "FACT") {
Example #4
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;
     }
 }
Example #5
0
function fact_NMR_localisation_sl($fact, &$fid)
{
    global $factarray;
    $family = Family::getInstance($fid);
    $husb = $family->getHusband();
    $wife = $family->getWife();
    if ($fact == "_NMR") {
        if (empty($wife) && !empty($husb)) {
            $factarray[$fact] = "Samski";
        } else {
            if (empty($husb) && !empty($wife)) {
                $factarray[$fact] = "Samska";
            }
        }
        // ženska
    } else {
        if ($fact == "_NMAR") {
            if (empty($wife) && !empty($husb)) {
                $factarray[$fact] = "Nikoli poroèen";
            } else {
                if (empty($husb) && !empty($wife)) {
                    $factarray[$fact] = "Nikoli poroèena";
                }
            }
            // ženska
        }
    }
}
Example #6
0
function fact_NMR_localisation_pl($fact, &$fid)
{
    global $factarray;
    $family = Family::getInstance($fid);
    $husb = $family->getHusband();
    $wife = $family->getWife();
    if ($fact == "_NMR") {
        if (empty($wife) && !empty($husb)) {
            $factarray[$fact] = "Nieżonaty";
        } else {
            if (empty($husb) && !empty($wife)) {
                $factarray[$fact] = "Niezamężna";
            }
        }
        // kobieta
    } else {
        if ($fact == "_NMAR") {
            if (empty($wife) && !empty($husb)) {
                $factarray[$fact] = "Nigdy nieżonaty";
            } else {
                if (empty($husb) && !empty($wife)) {
                    $factarray[$fact] = "Nigdy niezamężna";
                }
            }
            // kobieta
        }
    }
}
 /**
  * Compairs familys and then returns true if the have 50% or more chance of being the same family.
  * Other wise it returns false.
  */
 function CompairForUpdateFamily($family1, $family2)
 {
     // Values used to calculate the Percent of likley hood that the family is the same.
     $ChanceSameFamily = 0.0;
     $CountFamily1 = 0.0;
     $CountFamily2 = 0.0;
     $ChanceSame = 0.0;
     $firstTimeChildren = true;
     $famrec1 = find_family_record($family1);
     $ct = preg_match("/(\\w+):(.+)/", $family2, $match);
     if ($ct > 0) {
         $servid = trim($match[1]);
         $remoteid = trim($match[2]);
         $famrec2 = $this->getRemoteRecord($remoteid);
     } else {
         return false;
     }
     $family1 = Family::getInstance($family1);
     if (is_null($family1)) {
         return false;
     }
     $family2 = new Family($famrec2);
     if (!is_null($family1)) {
         // Creat the fathers if their is some
         $father1 = $family1->getHusband();
         $CountFamily1 += 1.0;
         $mother1 = $family1->getWife();
         $CountFamily1 += 1.0;
     }
     $father2 = $family2->getHusband();
     $CountFamily2 += 1.0;
     if (empty($father1)) {
         unset($father1);
         $CountFamily1 -= 1.0;
     }
     if (empty($father2)) {
         unset($father2);
         $CountFamily2 -= 1.0;
     }
     // Creat the mothers if their is some
     $mother2 = $family2->getWife();
     $CountFamily2 += 1.0;
     if (empty($mother1)) {
         unset($mother1);
         $CountFamily1 -= 1.0;
     }
     if (empty($mother2)) {
         unset($mother2);
         $CountFamily2 -= 1.0;
     }
     // Creat an array of Children
     $children1 = $family1->getChildren();
     $children2 = $family2->getChildren();
     // finds the probablity that they are the same family Bassed of both sites information
     $CountFamily1 += count($children1);
     $CountFamily2 += count($children2);
     foreach ($children1 as $childID1 => $Person1) {
         if (!empty($Person1)) {
             foreach ($children2 as $childID2 => $Person2) {
                 if (!empty($Person2)) {
                     if ($this->ComparePeople($Person1, $Person2)) {
                         $ChanceSameFamily += 1.0;
                         //print "<br />".$Person1->getXref()." equals ".$Person2->getXref();
                         break;
                     }
                 }
             }
         }
     }
     if (empty($father1)) {
     } elseif (empty($father2)) {
     } else {
         if ($this->ComparePeople($father1, $father2)) {
             $ChanceSameFamily += 1.0;
         }
     }
     if (empty($mother1)) {
     } elseif (empty($mother2)) {
     } else {
         if ($this->ComparePeople($mother1, $mother2)) {
             $ChanceSameFamily += 1.0;
         }
     }
     if ($CountFamily1 != 0 && $CountFamily2 != 0) {
         $ChanceSame = ($ChanceSameFamily / $CountFamily1 + $ChanceSameFamily / $CountFamily2) / 2;
         //print "<br />chancesame=".$ChanceSameFamily." count1=".$CountFamily1." count2=".$CountFamily2." ".$family1->getXref()." compared to ".$family2->getXref()." is ".$ChanceSame;
     } else {
         return false;
     }
     if ($ChanceSame < 0.5) {
         // If the probabilty is less then 0.5 or 50% then the current family is stored here to be added later
         return false;
     } else {
         return true;
     }
 }
Example #8
0
/**
* returns FAM:SOUR:PAGE matching filter
* @return Array of string
*/
function autocomplete_FAM_SOUR_PAGE($FILTER, $OPTION)
{
    $rows = get_autocomplete_FAM_SOUR_PAGE($FILTER, $OPTION);
    $data = array();
    foreach ($rows as $row) {
        $family = Family::getInstance($row);
        if ($family->canDisplayDetails()) {
            // a single FAM may have multiple level 1 and level 2 sources
            for ($level = 1; $level <= 2; $level++) {
                $i = 1;
                do {
                    $srec = get_sub_record("SOUR @{$OPTION}@", $level, $family->gedrec, $i++);
                    $page = get_gedcom_value("PAGE", $level + 1, $srec);
                    if (stripos($page, $FILTER) !== false || empty($FILTER)) {
                        $data[] = $page;
                    }
                } while ($srec);
            }
        }
    }
    return $data;
}
Example #9
0
 function _topTenGrandFamilyQuery($type = 'list', $params = null)
 {
     global $TBLPREFIX, $TEXT_DIRECTION, $pgv_lang;
     if ($params !== null && isset($params[0])) {
         $total = $params[0];
     } else {
         $total = 10;
     }
     $rows = self::_runSQL('' . ' SELECT' . ' COUNT(*) AS tot,' . ' f_id AS id' . ' FROM' . " {$TBLPREFIX}families" . ' JOIN' . " {$TBLPREFIX}link AS children ON children.l_file = {$this->_ged_id}" . ' JOIN' . " {$TBLPREFIX}link AS mchildren ON mchildren.l_file = {$this->_ged_id}" . ' JOIN' . " {$TBLPREFIX}link AS gchildren ON gchildren.l_file = {$this->_ged_id}" . ' WHERE' . " f_file={$this->_ged_id} AND" . " children.l_from=f_id AND" . " children.l_type='CHIL' AND" . " children.l_to=mchildren.l_from AND" . " mchildren.l_type='FAMS' AND" . " mchildren.l_to=gchildren.l_from AND" . " gchildren.l_type='CHIL'" . ' GROUP BY' . ' id' . ' ORDER BY' . ' tot DESC', $total);
     if (!isset($rows[0])) {
         return '';
     }
     $top10 = array();
     foreach ($rows as $row) {
         $family = Family::getInstance($row['id']);
         if ($family->canDisplayDetails()) {
             if ($type == 'list') {
                 $top10[] = "\t<li><a href=\"" . encode_url($family->getLinkUrl()) . "\">" . PrintReady($family->getFullName()) . "</a> [{$row['tot']} {$pgv_lang['grandchildren']}]</li>\n";
             } else {
                 $top10[] = "<a href=\"" . encode_url($family->getLinkUrl()) . "\">" . PrintReady($family->getFullName()) . "</a> [{$row['tot']} {$pgv_lang['grandchildren']}]";
             }
         }
     }
     if ($type == 'list') {
         $top10 = join("\n", $top10);
     } else {
         $top10 = join(';&nbsp; ', $top10);
     }
     if ($TEXT_DIRECTION == 'rtl') {
         $top10 = str_replace(array('[', ']', '(', ')', '+'), array('&rlm;[', '&rlm;]', '&rlm;(', '&rlm;)', '&rlm;+'), $top10);
     }
     if ($type == 'list') {
         return "<ul>\n{$top10}</ul>\n";
     }
     return $top10;
 }
Example #10
0
/**
* returns FAM:SOUR:PAGE matching filter
* @return Array of string
*/
function autocomplete_FAM_SOUR_PAGE($FILTER, $OPTION)
{
    global $TBLPREFIX, $gBitDb;
    $sql = "SELECT 'FAM' AS type, f_id AS xref, f_file AS ged_id, f_gedcom AS gedrec, f_husb, f_wife, f_chil, f_numchil FROM {$TBLPREFIX}families WHERE f_gedcom LIKE ? AND f_file=?";
    $rows = $gBitDb->query($sql, array("% SOUR @{$OPTION}@% PAGE %{$FILTER}%", PGV_GED_ID), PGV_AUTOCOMPLETE_LIMIT);
    $data = array();
    while ($row = $rows->fetchRows()) {
        $family = Family::getInstance($row);
        if ($family->canDisplayDetails()) {
            // a single FAM may have multiple level 1 and level 2 sources
            for ($level = 1; $level <= 2; $level++) {
                $i = 1;
                do {
                    $srec = get_sub_record("SOUR @{$OPTION}@", $level, $family->gedrec, $i++);
                    $page = get_gedcom_value("PAGE", $level + 1, $srec);
                    if (stripos($page, $FILTER) !== false || empty($FILTER)) {
                        $data[] = $page;
                    }
                } while ($srec);
            }
        }
    }
    return $data;
}
Example #11
0
function get_anniversary_events($jd, $facts = '', $ged_id = PGV_GED_ID)
{
    global $TBLPREFIX, $gBitDb;
    // If no facts specified, get all except these
    $skipfacts = "CHAN,BAPL,SLGC,SLGS,ENDL,CENS,RESI,NOTE,ADDR,OBJE,SOUR,PAGE,DATA,TEXT";
    if ($facts != '_TODO') {
        $skipfacts .= ',_TODO';
    }
    $found_facts = array();
    foreach (array(new GregorianDate($jd), new JulianDate($jd), new FrenchRDate($jd), new JewishDate($jd), new HijriDate($jd)) as $anniv) {
        // Build a SQL where clause to match anniversaries in the appropriate calendar.
        $where = "WHERE d_type='" . $anniv->CALENDAR_ESCAPE() . "'";
        // SIMPLE CASES:
        // a) Non-hebrew anniversaries
        // b) Hebrew months TVT, SHV, IYR, SVN, TMZ, AAV, ELL
        if ($anniv->CALENDAR_ESCAPE() != '@#DHEBREW@' || in_array($anniv->m, array(1, 5, 9, 10, 11, 12, 13))) {
            // Dates without days go on the first day of the month
            // Dates with invalid days go on the last day of the month
            if ($anniv->d == 1) {
                $where .= " AND d_day<=1";
            } else {
                if ($anniv->d == $anniv->DaysInMonth()) {
                    $where .= " AND d_day>={$anniv->d}";
                } else {
                    $where .= " AND d_day={$anniv->d}";
                }
            }
            $where .= " AND d_mon={$anniv->m}";
        } else {
            // SPECIAL CASES:
            switch ($anniv->m) {
                case 2:
                    // 29 CSH does not include 30 CSH (but would include an invalid 31 CSH if there were no 30 CSH)
                    if ($anniv->d == 1) {
                        $where .= " AND d_day<=1 AND d_mon=2";
                    } elseif ($anniv->d == 30) {
                        $where .= " AND d_day>=30 AND d_mon=2";
                    } elseif ($anniv->d == 29 && $anniv->DaysInMonth() == 29) {
                        $where .= " AND (d_day=29 OR d_day>30) AND d_mon=2";
                    } else {
                        $where .= " AND d_day={$anniv->d} AND d_mon=2";
                    }
                    break;
                case 3:
                    // 1 KSL includes 30 CSH (if this year didn't have 30 CSH)
                    // 29 KSL does not include 30 KSL (but would include an invalid 31 KSL if there were no 30 KSL)
                    if ($anniv->d == 1) {
                        $tmp = new JewishDate(array($anniv->y, 'csh', 1));
                        if ($tmp->DaysInMonth() == 29) {
                            $where .= " AND (d_day<=1 AND d_mon=3 OR d_day=30 AND d_mon=2)";
                        } else {
                            $where .= " AND d_day<=1 AND d_mon=3";
                        }
                    } else {
                        if ($anniv->d == 30) {
                            $where .= " AND d_day>=30 AND d_mon=3";
                        } elseif ($anniv->d == 29 && $anniv->DaysInMonth() == 29) {
                            $where .= " AND (d_day=29 OR d_day>30) AND d_mon=3";
                        } else {
                            $where .= " AND d_day={$anniv->d} AND d_mon=3";
                        }
                    }
                    break;
                case 4:
                    // 1 TVT includes 30 KSL (if this year didn't have 30 KSL)
                    if ($anniv->d == 1) {
                        $tmp = new JewishDate($anniv->y, 'ksl', 1);
                        if ($tmp->DaysInMonth() == 29) {
                            $where .= " AND (d_day<=1 AND d_mon=4 OR d_day=30 AND d_mon=3)";
                        } else {
                            $where .= " AND d_day<=1 AND d_mon=4";
                        }
                    } else {
                        if ($anniv->d == $anniv->DaysInMonth()) {
                            $where .= " AND d_day>={$anniv->d} AND d_mon=4";
                        } else {
                            $where .= " AND d_day={$anniv->d} AND d_mon=4";
                        }
                    }
                    break;
                case 6:
                    // ADR (non-leap) includes ADS (leap)
                    if ($anniv->d == 1) {
                        $where .= " AND d_day<=1";
                    } elseif ($anniv->d == $anniv->DaysInMonth()) {
                        $where .= " AND d_day>={$anniv->d}";
                    } else {
                        $where .= " AND d_day={$anniv->d}";
                    }
                    if ($anniv->IsLeapYear()) {
                        $where .= " AND (d_mon=6 AND " . $gBitDb->mod_function("7*d_year+1", "19") . "<7)";
                    } else {
                        $where .= " AND (d_mon=6 OR d_mon=7)";
                    }
                    break;
                case 7:
                    // ADS includes ADR (non-leap)
                    if ($anniv->d == 1) {
                        $where .= " AND d_day<=1";
                    } elseif ($anniv->d == $anniv->DaysInMonth()) {
                        $where .= " AND d_day>={$anniv->d}";
                    } else {
                        $where .= " AND d_day={$anniv->d}";
                    }
                    $where .= " AND (d_mon=6 AND " . $gBitDb->mod_function("7*d_year+1", "19") . ">=7 OR d_mon=7)";
                    break;
                case 8:
                    // 1 NSN includes 30 ADR, if this year is non-leap
                    if ($anniv->d == 1) {
                        if ($anniv->IsLeapYear()) {
                            $where .= " AND d_day<=1 AND d_mon=8";
                        } else {
                            $where .= " AND (d_day<=1 AND d_mon=8 OR d_day=30 AND d_mon=6)";
                        }
                    } elseif ($anniv->d == $anniv->DaysInMonth()) {
                        $where .= " AND d_day>={$anniv->d} AND d_mon=8";
                    } else {
                        $where .= " AND d_day={$anniv->d} AND d_mon=8";
                    }
                    break;
            }
        }
        // Only events in the past (includes dates without a year)
        $where .= " AND d_year<={$anniv->y}";
        // Restrict to certain types of fact
        if (empty($facts)) {
            $excl_facts = "'" . preg_replace('/\\W+/', "','", $skipfacts) . "'";
            $where .= " AND d_fact NOT IN ({$excl_facts})";
        } else {
            $incl_facts = "'" . preg_replace('/\\W+/', "','", $facts) . "'";
            $where .= " AND d_fact IN ({$incl_facts})";
        }
        // Only get events from the current gedcom
        $where .= " AND d_file=" . $ged_id;
        // Now fetch these anniversaries
        $ind_sql = "SELECT DISTINCT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_isdead, i_sex, d_type, d_day, d_month, d_year, d_fact, d_type FROM {$TBLPREFIX}dates, {$TBLPREFIX}individuals {$where} AND d_gid=i_id AND d_file=i_file ORDER BY d_day ASC, d_year DESC";
        $fam_sql = "SELECT DISTINCT 'FAM' AS type, f_id AS xref, f_file AS ged_id, f_gedcom AS gedrec, f_husb, f_wife, f_chil, f_numchil, d_type, d_day, d_month, d_year, d_fact, d_type FROM {$TBLPREFIX}dates, {$TBLPREFIX}families {$where} AND d_gid=f_id AND d_file=f_file ORDER BY d_day ASC, d_year DESC";
        foreach (array($ind_sql, $fam_sql) as $sql) {
            $rows = $gBitDb->getAll($sql);
            foreach ($rows as $row) {
                if ($row['type'] == 'INDI') {
                    $record = Person::getInstance($row);
                } else {
                    $record = Family::getInstance($row);
                }
                // Generate a regex to match the retrieved date - so we can find it in the original gedcom record.
                // TODO having to go back to the original gedcom is lame.  This is why it is so slow, and needs
                // to be cached.  We should store the level1 fact here (or somewhere)
                if ($row['d_type'] == '@#DJULIAN@') {
                    if ($row['d_year'] < 0) {
                        $year_regex = $row['d_year'] . " ?[Bb]\\.? ?[Cc]\\.\\ ?";
                    } else {
                        $year_regex = "({$row['d_year']}|" . ($row['d_year'] - 1) . "\\/" . $row['d_year'] % 100 . ")";
                    }
                } else {
                    $year_regex = "0*" . $row['d_year'];
                }
                $ged_date_regex = "/2 DATE.*(" . ($row['d_day'] > 0 ? "0?{$row['d_day']}\\s*" : "") . $row['d_month'] . "\\s*" . ($row['d_year'] != 0 ? $year_regex : "") . ")/i";
                foreach (get_all_subrecords($row['gedrec'], $skipfacts, false, false) as $factrec) {
                    if (preg_match("/(^1 {$row['d_fact']}|^1 (FACT|EVEN).*\n2 TYPE {$row['d_fact']})/s", $factrec) && preg_match($ged_date_regex, $factrec) && preg_match('/2 DATE (.+)/', $factrec, $match)) {
                        $date = new GedcomDate($match[1]);
                        if (preg_match('/2 PLAC (.+)/', $factrec, $match)) {
                            $plac = $match[1];
                        } else {
                            $plac = '';
                        }
                        if (showFactDetails($row['d_fact'], $row['xref']) && !FactViewRestricted($row['xref'], $factrec)) {
                            $found_facts[] = array('record' => $record, 'id' => $row['xref'], 'objtype' => $row['type'], 'fact' => $row['d_fact'], 'factrec' => $factrec, 'jd' => $jd, 'anniv' => $row['d_year'] == 0 ? 0 : $anniv->y - $row['d_year'], 'date' => $date, 'plac' => $plac);
                        }
                    }
                }
            }
        }
    }
    return $found_facts;
}
Example #12
0
 /**
  * get an array of families with parents
  * @return array array of Family objects indexed by family id
  */
 function getChildFamilies()
 {
     global $pgv_lang, $SHOW_LIVING_NAMES;
     if (is_null($this->childFamilies)) {
         $this->childFamilies = array();
         foreach ($this->getChildFamilyIds() as $famid) {
             $family = Family::getInstance($famid);
             if (is_null($family)) {
                 echo '<span class="warning">', $pgv_lang['unable_to_find_family'], ' ', $famid, '</span>';
             } else {
                 // only include family if it is displayable by current user
                 if ($SHOW_LIVING_NAMES || $family->canDisplayDetails()) {
                     $this->childFamilies[$famid] = $family;
                 }
             }
         }
     }
     return $this->childFamilies;
 }
Example #13
0
    /**
     * Get the details for a person and their spouse
     * @param Person $person the person to print the details for
     */
    function getDetails(&$person)
    {
        global $pgv_lang, $factarray, $factAbbrev, $SHOW_ID_NUMBERS, $PGV_IMAGE_DIR, $PGV_IMAGES, $GEDCOM, $SERVER_URL;
        if (empty($person)) {
            $person = $this->rootPerson;
        }
        //if (!$person->canDisplayDetails()) return;
        $families = array();
        if (!empty($_REQUEST['famid'])) {
            $famid = $_REQUEST['famid'];
            if ($famid != 'all') {
                $family = Family::getInstance($_REQUEST['famid']);
                if (!empty($family)) {
                    $families[] = $family;
                }
            } else {
                $fams = $person->getSpouseFamilies();
                foreach ($fams as $fam) {
                    $families[] = $fam;
                }
            }
        } else {
            if ($this->allSpouses) {
                $fams = $person->getSpouseFamilies();
                foreach ($fams as $fam) {
                    $families[] = $fam;
                }
            } else {
                $fams = $person->getSpouseFamilies();
                $families[] = end($fams);
            }
        }
        $name = $person->getFullName();
        if ($SHOW_ID_NUMBERS) {
            $name .= " (" . $person->getXref() . ")";
        }
        ?>
		<span class="name1">
		<?php 
        print $this->getThumbnail($person);
        ?>
		<a href="<?php 
        print $person->getLinkUrl();
        ?>
" onclick="if (!<?php 
        print $this->name;
        ?>
.collapseBox) return false;"><?php 
        print $person->getSexImage() . PrintReady($name);
        ?>
</a>
		<img src="<?php 
        print $SERVER_URL . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["gedcom"]["small"];
        ?>
" border="0" width="15" onclick="<?php 
        print $this->name;
        ?>
.newRoot('<?php 
        print $person->getXref();
        ?>
', <?php 
        print $this->name;
        ?>
.innerPort, '<?php 
        print htmlentities($GEDCOM, ENT_COMPAT, 'UTF-8');
        ?>
');" />
		</span><br />
		<div class="details1 indent">
			<b><?php 
        if (isset($factAbbrev["BIRT"])) {
            print $factAbbrev["BIRT"];
        } else {
            print get_first_letter($factarray['BIRT']);
        }
        ?>
:</b>
				<?php 
        echo $person->getBirthDate()->Display(), ' ', PrintReady($person->getBirthPlace());
        ?>
			<br />
			<b><?php 
        if ($person->isDead()) {
            if (isset($factAbbrev["DEAT"])) {
                print $factAbbrev["DEAT"];
            } else {
                print get_first_letter($factarray['DEAT']);
            }
            ?>
:</b>
				<?php 
            echo $person->getDeathDate()->Display(), ' ', PrintReady($person->getDeathPlace());
        }
        ?>
		</div>
		<br />
		<span class="name1"><?php 
        foreach ($families as $family) {
            if (!empty($family)) {
                $spouse = $family->getSpouse($person);
            }
            if (!empty($spouse)) {
                $name = $spouse->getFullName();
                if ($SHOW_ID_NUMBERS) {
                    $name .= " (" . $spouse->getXref() . ")";
                }
                ?>
				<?php 
                print $this->getThumbnail($spouse);
                ?>
				<a href="<?php 
                print $spouse->getLinkUrl();
                ?>
" onclick="if (!<?php 
                print $this->name;
                ?>
.collapseBox) return false;">
				<?php 
                print $spouse->getSexImage() . PrintReady($name);
                ?>
</a>
				<img src="<?php 
                print $SERVER_URL . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["gedcom"]["small"];
                ?>
" border="0" width="15" onclick="<?php 
                print $this->name;
                ?>
.newRoot('<?php 
                print $spouse->getXref();
                ?>
', <?php 
                print $this->name;
                ?>
.innerPort, '<?php 
                print htmlentities($GEDCOM, ENT_COMPAT, 'UTF-8');
                ?>
');" />
				<br />
				<div class="details1 indent">
				<b><?php 
                if (isset($factAbbrev["BIRT"])) {
                    print $factAbbrev["BIRT"];
                } else {
                    print get_first_letter($factarray['BIRT']);
                }
                ?>
:</b>
				<?php 
                echo $spouse->getBirthDate()->Display(), ' ', PrintReady($spouse->getBirthPlace());
                ?>
				<br />
				<b><?php 
                if (isset($factAbbrev["MARR"])) {
                    print $factAbbrev["MARR"];
                } else {
                    print get_first_letter($factarray['MARR']);
                }
                ?>
:</b>
				<?php 
                $mdate = $family->getMarriageDate();
                if (!is_null($mdate)) {
                    print $mdate->Display() . " ";
                }
                $place = '';
                $place = $family->getMarriagePlace();
                if (!empty($place)) {
                    print PrintReady($place);
                }
                ?>
					<a href="family.php?famid=<?php 
                print $family->getXref();
                ?>
" onclick="if (!<?php 
                print $this->name;
                ?>
.collapseBox) return false;"><img id="d_<?php 
                print $family->getXref();
                ?>
" alt="<?php 
                print $family->getXref();
                ?>
" class="draggable" src="<?php 
                print $SERVER_URL . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES['family']['button'];
                ?>
" border="0" /></a>
				<br />
				<b><?php 
                if ($spouse->isDead()) {
                    if (isset($factAbbrev["DEAT"])) {
                        echo $factAbbrev["DEAT"];
                    } else {
                        echo get_first_letter($factarray['DEAT']);
                    }
                    ?>
:</b>
					<?php 
                    echo $spouse->getDeathDate()->Display(), ' ', PrintReady($spouse->getDeathPlace());
                }
                ?>
				</div>
				<?php 
            } else {
                print "<br />\n";
            }
        }
        ?>
		</span>
		<?php 
    }