/** * Static Helper functions to sort events * * @param Event $a * @param Event $b * @return int */ static function CompareDate(&$a, &$b) { $adate = $a->getDate(); $bdate = $b->getDate(); //-- non-dated events should sort according to the preferred sort order if (is_null($adate) && !is_null($a->sortDate)) { $ret = $a->sortOrder - $b->sortOrder; } else { if (is_null($bdate) && !is_null($b->sortDate)) { $ret = $a->sortOrder - $b->sortOrder; } else { $ret = GedcomDate::Compare($adate, $bdate); } } if ($ret == 0) { $ret = $a->sortOrder - $b->sortOrder; //-- if dates are the same they should be ordered by their fact type if ($ret == 0) { $ret = Event::CompareType($a, $b); } } // print "[".$a->getTag().":".$adate->isOK().":".$adate->MinJD()."-".$adate->MaxJD()." ".$b->getTag().":".$bdate->isOK().":".$bdate->MinJD()."-".$bdate->MaxJD()." ".$ret."] "; return $ret; }
function compare_people($a, $b) { return GedcomDate::Compare($a->getEstimatedBirthDate(), $b->getEstimatedBirthDate()); }
static function CompareMarrDate($x, $y) { return GedcomDate::Compare($x->getMarriageDate(), $y->getMarriageDate()); }
static function GetAgeGedcom($d1, $d2 = null) { if (is_null($d2)) { return $d1->date1->GetAge(true, client_jd()); } else { // If dates overlap, then can't calculate age. if (GedcomDate::Compare($d1, $d2)) { return $d1->date1->GetAge(true, $d2->MinJD()); } if (GedcomDate::Compare($d1, $d2) == 0 && $d1->date1->minJD == $d2->MinJD()) { return '0d'; } else { return ''; } } }
$xref = append_gedrec($gedrec, $update_CHAN); $link = "individual.php?pid={$xref}&show_changes=yes"; if ($xref) { echo "<br /><br />", $pgv_lang["update_successful"]; $gedrec = ""; if (!empty($famid)) { // Insert new child at the right place [ 1686246 ] $newchild = Person::getInstance($xref); $family = Family::getInstance($famid); if ($family->getUpdatedFamily()) { $family = $family->getUpdatedFamily(); } $gedrec = $family->gedrec; $done = false; foreach ($family->getChildren() as $key => $child) { if (GedcomDate::Compare($newchild->getEstimatedBirthDate(), $child->getEstimatedBirthDate()) < 0) { // new child is older : insert before $gedrec = str_replace("1 CHIL @" . $child->getXref() . "@", "1 CHIL @{$xref}@\n1 CHIL @" . $child->getXref() . "@", $gedrec); $done = true; break; } } // new child is the only one if (count($family->getChildren()) < 1) { $gedrec .= "\n1 CHIL @{$xref}@"; } else { if (!$done) { // new child is the youngest or undated : insert after $gedrec = str_replace("1 CHIL @" . $child->getXref() . "@", "1 CHIL @" . $child->getXref() . "@\n1 CHIL @{$xref}@", $gedrec); } }
static function CompareDeathDate($x, $y) { return GedcomDate::Compare($x->getDeathDate(), $y->getDeathDate()); }
static function CompareChanDate($x, $y) { $chan_x = $x->getChangeEvent(); $chan_y = $y->getChangeEvent(); $tmp = GedcomDate::Compare($chan_x->getDate(), $chan_y->getDate()); if ($tmp) { return $tmp; } else { if (preg_match('/^\\d\\d:\\d\\d:\\d\\d/', get_gedcom_value('DATE:TIME', 2, $chan_x->getGedcomRecord(), '', false) . ':00', $match_x) && preg_match('/^\\d\\d:\\d\\d:\\d\\d/', get_gedcom_value('DATE:TIME', 2, $chan_y->getGedcomRecord(), '', false) . ':00', $match_y)) { return strcmp($match_x[0], $match_y[0]); } else { return 0; } } }
/** * add historical events to individual facts array * * @return records added to indifacts array * * Historical facts are imported from optional language file : histo.xx.php * where xx is language code * This file should contain records similar to : * * $histo[]="1 EVEN\n2 TYPE History\n2 DATE 11 NOV 1918\n2 NOTE WW1 Armistice"; * $histo[]="1 EVEN\n2 TYPE History\n2 DATE 8 MAY 1945\n2 NOTE WW2 Armistice"; * etc... * */ function add_historical_facts() { global $LANGUAGE, $lang_short_cut; global $SHOW_RELATIVES_EVENTS; if (!$SHOW_RELATIVES_EVENTS) { return; } // Only include events between birth and death $bDate = $this->getEstimatedBirthDate(); $dDate = $this->getEstimatedDeathDate(); if (!$bDate->isOK()) { return; } if ($SHOW_RELATIVES_EVENTS && file_exists('languages/histo.' . $lang_short_cut[$LANGUAGE] . '.php')) { include 'languages/histo.' . $lang_short_cut[$LANGUAGE] . '.php'; foreach ($histo as $indexval => $hrec) { $sdate = new GedcomDate(get_gedcom_value('DATE', 2, $hrec, '', false)); if ($sdate->isOK() && GedcomDate::Compare($this->getEstimatedBirthDate(), $sdate) <= 0 && GedcomDate::Compare($sdate, $this->getEstimatedDeathDate()) <= 0) { $event = new Event($hrec); $event->setParentObject($this); $this->indifacts[] = $event; } } } }