示例#1
0
 /**
  * Print fact DATE/TIME
  *
  * @param Fact $event event containing the date/age
  * @param GedcomRecord $record the person (or couple) whose ages should be printed
  * @param bool $anchor option to print a link to calendar
  * @param bool $time option to print TIME value
  *
  * @return string
  */
 public static function formatFactDate(Fact $event, GedcomRecord $record, $anchor, $time)
 {
     global $pid;
     $factrec = $event->getGedcom();
     $html = '';
     // Recorded age
     if (preg_match('/\\n2 AGE (.+)/', $factrec, $match)) {
         $fact_age = $match[1];
     } else {
         $fact_age = '';
     }
     if (preg_match('/\\n2 HUSB\\n3 AGE (.+)/', $factrec, $match)) {
         $husb_age = $match[1];
     } else {
         $husb_age = '';
     }
     if (preg_match('/\\n2 WIFE\\n3 AGE (.+)/', $factrec, $match)) {
         $wife_age = $match[1];
     } else {
         $wife_age = '';
     }
     // Calculated age
     if (preg_match('/\\n2 DATE (.+)/', $factrec, $match)) {
         $date = new Date($match[1]);
         $html .= ' ' . $date->display($anchor);
         // time
         if ($time && preg_match('/\\n3 TIME (.+)/', $factrec, $match)) {
             $html .= ' – <span class="date">' . $match[1] . '</span>';
         }
         $fact = $event->getTag();
         if ($record instanceof Individual) {
             if ($fact === 'BIRT' && $record->getTree()->getPreference('SHOW_PARENTS_AGE')) {
                 // age of parents at child birth
                 $html .= self::formatParentsAges($record, $date);
             } elseif ($fact !== 'CHAN' && $fact !== '_TODO') {
                 // age at event
                 $birth_date = $record->getBirthDate();
                 // Can't use getDeathDate(), as this also gives BURI/CREM events, which
                 // wouldn't give the correct "days after death" result for people with
                 // no DEAT.
                 $death_event = $record->getFirstFact('DEAT');
                 if ($death_event) {
                     $death_date = $death_event->getDate();
                 } else {
                     $death_date = new Date('');
                 }
                 $ageText = '';
                 if (Date::compare($date, $death_date) <= 0 || !$record->isDead() || $fact == 'DEAT') {
                     // Before death, print age
                     $age = Date::getAgeGedcom($birth_date, $date);
                     // Only show calculated age if it differs from recorded age
                     if ($age != '') {
                         if ($fact_age != '' && $fact_age != $age || $fact_age == '' && $husb_age == '' && $wife_age == '' || $husb_age != '' && $record->getSex() == 'M' && $husb_age != $age || $wife_age != '' && $record->getSex() == 'F' && $wife_age != $age) {
                             if ($age != "0d") {
                                 $ageText = '(' . I18N::translate('Age') . ' ' . FunctionsDate::getAgeAtEvent($age, false) . ')';
                             }
                         }
                     }
                 }
                 if ($fact != 'DEAT' && Date::compare($date, $death_date) >= 0) {
                     // After death, print time since death
                     $age = FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($death_date, $date), true);
                     if ($age != '') {
                         if (Date::getAgeGedcom($death_date, $date) == "0d") {
                             $ageText = '(' . I18N::translate('on the date of death') . ')';
                         } else {
                             $ageText = '(' . $age . ' ' . I18N::translate('after death') . ')';
                             // Family events which occur after death are probably errors
                             if ($event->getParent() instanceof Family) {
                                 $ageText .= '<i class="icon-warning"></i>';
                             }
                         }
                     }
                 }
                 if ($ageText) {
                     $html .= ' <span class="age">' . $ageText . '</span>';
                 }
             }
         } elseif ($record instanceof Family) {
             $indi = Individual::getInstance($pid, $record->getTree());
             if ($indi) {
                 $birth_date = $indi->getBirthDate();
                 $death_date = $indi->getDeathDate();
                 $ageText = '';
                 if (Date::compare($date, $death_date) <= 0) {
                     $age = Date::getAgeGedcom($birth_date, $date);
                     // Only show calculated age if it differs from recorded age
                     if ($age != '' && $age > 0) {
                         if ($fact_age != '' && $fact_age != $age || $fact_age == '' && $husb_age == '' && $wife_age == '' || $husb_age != '' && $indi->getSex() == 'M' && $husb_age != $age || $wife_age != '' && $indi->getSex() == 'F' && $wife_age != $age) {
                             $ageText = '(' . I18N::translate('Age') . ' ' . FunctionsDate::getAgeAtEvent($age, false) . ')';
                         }
                     }
                 }
                 if ($ageText) {
                     $html .= ' <span class="age">' . $ageText . '</span>';
                 }
             }
         }
     } else {
         // 1 DEAT Y with no DATE => print YES
         // 1 BIRT 2 SOUR @S1@ => print YES
         // 1 DEAT N is not allowed
         // It is not proper GEDCOM form to use a N(o) value with an event tag to infer that it did not happen.
         $factdetail = explode(' ', trim($factrec));
         if (isset($factdetail) && (count($factdetail) == 3 && strtoupper($factdetail[2]) == 'Y') || count($factdetail) == 4 && $factdetail[2] == 'SOUR') {
             $html .= I18N::translate('yes');
         }
     }
     // print gedcom ages
     foreach (array(GedcomTag::getLabel('AGE') => $fact_age, GedcomTag::getLabel('HUSB') => $husb_age, GedcomTag::getLabel('WIFE') => $wife_age) as $label => $age) {
         if ($age != '') {
             $html .= ' <span class="label">' . $label . ':</span> <span class="age">' . FunctionsDate::getAgeAtEvent($age, false) . '</span>';
         }
     }
     return $html;
 }
示例#2
0
 /**
  * Print a fact for an individual.
  *
  * @param Fact $event
  */
 public function printTimeFact(Fact $event)
 {
     global $basexoffset, $baseyoffset, $factcount, $placements;
     $desc = $event->getValue();
     // check if this is a family fact
     $gdate = $event->getDate();
     $date = $gdate->minimumDate();
     $date = $date->convertToCalendar('gregorian');
     $year = $date->y;
     $month = max(1, $date->m);
     $day = max(1, $date->d);
     $xoffset = $basexoffset + 22;
     $yoffset = $baseyoffset + ($year - $this->baseyear) * $this->scale - $this->scale;
     $yoffset = $yoffset + $month / 12 * $this->scale;
     $yoffset = $yoffset + $day / 30 * ($this->scale / 12);
     $yoffset = (int) $yoffset;
     $place = (int) ($yoffset / $this->bheight);
     $i = 1;
     $j = 0;
     $tyoffset = 0;
     while (isset($placements[$place])) {
         if ($i === $j) {
             $tyoffset = $this->bheight * $i;
             $i++;
         } else {
             $tyoffset = -1 * $this->bheight * $j;
             $j++;
         }
         $place = (int) (($yoffset + $tyoffset) / $this->bheight);
     }
     $yoffset += $tyoffset;
     $xoffset += abs($tyoffset);
     $placements[$place] = $yoffset;
     echo "<div id=\"fact{$factcount}\" style=\"position:absolute; " . (I18N::direction() === 'ltr' ? 'left: ' . $xoffset : 'right: ' . $xoffset) . 'px; top:' . $yoffset . "px; font-size: 8pt; height: " . $this->bheight . "px;\" onmousedown=\"factMouseDown(this, '" . $factcount . "', " . ($yoffset - $tyoffset) . ");\">";
     echo '<table cellspacing="0" cellpadding="0" border="0" style="cursor: hand;"><tr><td>';
     echo '<img src="' . Theme::theme()->parameter('image-hline') . '" name="boxline' . $factcount . '" id="boxline' . $factcount . '" height="3" width="10" style="padding-';
     if (I18N::direction() === 'ltr') {
         echo 'left: 3px;">';
     } else {
         echo 'right: 3px;">';
     }
     $col = array_search($event->getParent(), $this->people);
     if ($col === false) {
         // Marriage event - use the color of the husband
         $col = array_search($event->getParent()->getHusband(), $this->people);
     }
     if ($col === false) {
         // Marriage event - use the color of the wife
         $col = array_search($event->getParent()->getWife(), $this->people);
     }
     $col = $col % 6;
     echo '</td><td class="person' . $col . '">';
     if (count($this->people) > 6) {
         // We only have six colours, so show naes if more than this number
         echo $event->getParent()->getFullName() . ' — ';
     }
     $record = $event->getParent();
     echo $event->getLabel();
     echo ' — ';
     if ($record instanceof Individual) {
         echo FunctionsPrint::formatFactDate($event, $record, false, false);
     } elseif ($record instanceof Family) {
         echo $gdate->display();
         if ($record->getHusband() && $record->getHusband()->getBirthDate()->isOK()) {
             $ageh = FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($record->getHusband()->getBirthDate(), $gdate));
         } else {
             $ageh = null;
         }
         if ($record->getWife() && $record->getWife()->getBirthDate()->isOK()) {
             $agew = FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($record->getWife()->getBirthDate(), $gdate));
         } else {
             $agew = null;
         }
         if ($ageh && $agew) {
             echo '<span class="age"> ', I18N::translate('Husband’s age'), ' ', $ageh, ' ', I18N::translate('Wife’s age'), ' ', $agew, '</span>';
         } elseif ($ageh) {
             echo '<span class="age"> ', I18N::translate('Age'), ' ', $ageh, '</span>';
         } elseif ($agew) {
             echo '<span class="age"> ', I18N::translate('Age'), ' ', $ageh, '</span>';
         }
     }
     echo ' ' . Filter::escapeHtml($desc);
     if (!$event->getPlace()->isEmpty()) {
         echo ' — ' . $event->getPlace()->getShortName();
     }
     // Print spouses names for family events
     if ($event->getParent() instanceof Family) {
         echo ' — <a href="', $event->getParent()->getHtmlUrl(), '">', $event->getParent()->getFullName(), '</a>';
     }
     echo '</td></tr></table>';
     echo '</div>';
     if (I18N::direction() === 'ltr') {
         $img = 'image-dline2';
         $ypos = '0%';
     } else {
         $img = 'image-dline';
         $ypos = '100%';
     }
     $dyoffset = $yoffset - $tyoffset + $this->bheight / 3;
     if ($tyoffset < 0) {
         $dyoffset = $yoffset + $this->bheight / 3;
         if (I18N::direction() === 'ltr') {
             $img = 'image-dline';
             $ypos = '100%';
         } else {
             $img = 'image-dline2';
             $ypos = '0%';
         }
     }
     // Print the diagonal line
     echo '<div id="dbox' . $factcount . '" style="position:absolute; ' . (I18N::direction() === 'ltr' ? 'left: ' . ($basexoffset + 25) : 'right: ' . ($basexoffset + 25)) . 'px; top:' . $dyoffset . 'px; font-size: 8pt; height: ' . abs($tyoffset) . 'px; width: ' . abs($tyoffset) . 'px;';
     echo ' background-image: url(\'' . Theme::theme()->parameter($img) . '\');';
     echo ' background-position: 0% ' . $ypos . ';">';
     echo '</div>';
 }
示例#3
0
 /**
  * Find the ages between siblings.
  *
  * @param string   $type
  * @param string[] $params
  *
  * @return string
  */
 private function ageBetweenSiblingsQuery($type = 'list', $params = array())
 {
     if (isset($params[0])) {
         $total = (int) $params[0];
     } else {
         $total = 10;
     }
     if (isset($params[1])) {
         $one = $params[1];
     } else {
         $one = false;
     }
     // each family only once if true
     $rows = $this->runSql(" SELECT SQL_CACHE DISTINCT" . " link1.l_from AS family," . " link1.l_to AS ch1," . " link2.l_to AS ch2," . " child1.d_julianday2-child2.d_julianday2 AS age" . " FROM `##link` AS link1" . " LEFT JOIN `##dates` AS child1 ON child1.d_file = {$this->tree->getTreeId()}" . " LEFT JOIN `##dates` AS child2 ON child2.d_file = {$this->tree->getTreeId()}" . " LEFT JOIN `##link` AS link2 ON link2.l_file = {$this->tree->getTreeId()}" . " WHERE" . " link1.l_file = {$this->tree->getTreeId()} AND" . " link1.l_from = link2.l_from AND" . " link1.l_type = 'CHIL' AND" . " child1.d_gid = link1.l_to AND" . " child1.d_fact = 'BIRT' AND" . " link2.l_type = 'CHIL' AND" . " child2.d_gid = link2.l_to AND" . " child2.d_fact = 'BIRT' AND" . " child1.d_julianday2 > child2.d_julianday2 AND" . " child2.d_julianday2 <> 0 AND" . " child1.d_gid <> child2.d_gid" . " ORDER BY age DESC" . " LIMIT " . $total);
     if (!isset($rows[0])) {
         return '';
     }
     $top10 = array();
     $dist = array();
     foreach ($rows as $fam) {
         $family = Family::getInstance($fam['family'], $this->tree);
         $child1 = Individual::getInstance($fam['ch1'], $this->tree);
         $child2 = Individual::getInstance($fam['ch2'], $this->tree);
         if ($type == 'name') {
             if ($child1->canShow() && $child2->canShow()) {
                 $return = '<a href="' . $child2->getHtmlUrl() . '">' . $child2->getFullName() . '</a> ';
                 $return .= I18N::translate('and') . ' ';
                 $return .= '<a href="' . $child1->getHtmlUrl() . '">' . $child1->getFullName() . '</a>';
                 $return .= ' <a href="' . $family->getHtmlUrl() . '">[' . I18N::translate('View family') . ']</a>';
             } else {
                 $return = I18N::translate('This information is private and cannot be shown.');
             }
             return $return;
         }
         $age = $fam['age'];
         if ((int) ($age / 365.25) > 0) {
             $age = (int) ($age / 365.25) . 'y';
         } elseif ((int) ($age / 30.4375) > 0) {
             $age = (int) ($age / 30.4375) . 'm';
         } else {
             $age = $age . 'd';
         }
         $age = FunctionsDate::getAgeAtEvent($age, true);
         if ($type == 'age') {
             return $age;
         }
         if ($type == 'list') {
             if ($one && !in_array($fam['family'], $dist)) {
                 if ($child1->canShow() && $child2->canShow()) {
                     $return = "<li>";
                     $return .= "<a href=\"" . $child2->getHtmlUrl() . "\">" . $child2->getFullName() . "</a> ";
                     $return .= I18N::translate('and') . " ";
                     $return .= "<a href=\"" . $child1->getHtmlUrl() . "\">" . $child1->getFullName() . "</a>";
                     $return .= " (" . $age . ")";
                     $return .= " <a href=\"" . $family->getHtmlUrl() . "\">[" . I18N::translate('View family') . "]</a>";
                     $return .= '</li>';
                     $top10[] = $return;
                     $dist[] = $fam['family'];
                 }
             } elseif (!$one && $child1->canShow() && $child2->canShow()) {
                 $return = "<li>";
                 $return .= "<a href=\"" . $child2->getHtmlUrl() . "\">" . $child2->getFullName() . "</a> ";
                 $return .= I18N::translate('and') . " ";
                 $return .= "<a href=\"" . $child1->getHtmlUrl() . "\">" . $child1->getFullName() . "</a>";
                 $return .= " (" . $age . ")";
                 $return .= " <a href=\"" . $family->getHtmlUrl() . "\">[" . I18N::translate('View family') . "]</a>";
                 $return .= '</li>';
                 $top10[] = $return;
             }
         } else {
             if ($child1->canShow() && $child2->canShow()) {
                 $return = $child2->formatList('span', false, $child2->getFullName());
                 $return .= "<br>" . I18N::translate('and') . "<br>";
                 $return .= $child1->formatList('span', false, $child1->getFullName());
                 $return .= "<br><a href=\"" . $family->getHtmlUrl() . "\">[" . I18N::translate('View family') . "]</a>";
                 return $return;
             } else {
                 return I18N::translate('This information is private and cannot be shown.');
             }
         }
     }
     if ($type === 'list') {
         $top10 = implode('', $top10);
     }
     if (I18N::direction() === 'rtl') {
         $top10 = str_replace(array('[', ']', '(', ')', '+'), array('&rlm;[', '&rlm;]', '&rlm;(', '&rlm;)', '&rlm;+'), $top10);
     }
     if ($type === 'list') {
         return '<ul>' . $top10 . '</ul>';
     }
     return $top10;
 }
示例#4
0
 /**
  * Print the lifespan of this person
  * 
  * @param type $person
  * @param type $is_spouse
  * @return string
  */
 private function printLifespan($person, $is_spouse = false)
 {
     $html = '';
     $birthdate = $person->getBirthDate();
     $deathdate = $person->getDeathdate();
     $ageOfdeath = FunctionsDate::getAgeAtEvent(Date::GetAgeGedcom($birthdate, $deathdate), false);
     $birthdata = false;
     if ($birthdate->isOK() || $person->getBirthPlace() != '') {
         $birthdata = true;
         $bapm = $person->getFirstFact('BAPM');
         $chr = $person->getFirstFact('CHR');
         $birt = $person->getFirstFact('BIRT');
         if ($birt) {
             $html .= $this->printBirthText($person, 'BIRT', $is_spouse);
             $html .= $this->printDate($birt);
         } else {
             if ($bapm || $chr) {
                 $html .= $this->printBirthText($person, 'BAPM', $is_spouse);
                 $html .= $bapm ? $this->printDate($bapm) : $this->printDate($chr);
             }
         }
         if ($person->getBirthPlace() != '') {
             $html .= $this->printPlace($person->getBirthPlace(), $person->getTree());
         }
     }
     $deathdata = false;
     if ($deathdate->isOK() || $person->getDeathPlace() != '') {
         $deathdata = true;
         if ($birthdata) {
             $html .= ' ' . I18N::translate('and ');
             $person->getSex() == 'F' ? $html .= I18N::translateContext('FEMALE', 'died') : ($html .= I18N::translateContext('MALE', 'died'));
         } else {
             $person->getSex() == 'F' ? $html .= '. ' . I18N::translate('She died') : ($html .= '. ' . I18N::translate('He died'));
         }
         $deat = $person->getFirstFact('DEAT');
         if ($deat) {
             $html .= $this->printDate($deat);
         }
         if ($person->getDeathPlace() != '') {
             $html .= $this->printPlace($person->getDeathPlace(), $person->getTree());
         }
         if ($birthdate->isOK() && $deathdate->isOK() && $this->isDateDMY($birt) && $this->isDateDMY($deat)) {
             if (Date::getAge($birthdate, $deathdate, 0) < 2) {
                 $html .= ' ' . I18N::translateContext('age in days/months', 'at the age of %s', $ageOfdeath);
             } else {
                 $html .= ' ' . I18N::translateContext('age in years', 'at the age of %s', $ageOfdeath);
             }
         }
     }
     return $html;
 }
示例#5
0
if ($controller->record->canShow()) {
    // Highlight image or silhouette
    echo '<div id="indi_mainimage">', $controller->record->displayImage(), '</div>';
    echo '<div id="header_accordion1">';
    // contain accordions for names
    echo '<h3 class="name_one ', $controller->getPersonStyle($controller->record), '"><span>', $controller->record->getFullName(), '</span>';
    // First name accordion header
    $bdate = $controller->record->getBirthDate();
    $ddate = $controller->record->getDeathDate();
    echo '<span class="header_age">';
    if ($bdate->isOK() && !$controller->record->isDead()) {
        // If living display age
        echo GedcomTag::getLabelValue('AGE', FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($bdate), true), $controller->record, 'span');
    } elseif ($bdate->isOK() && $ddate->isOK()) {
        // If dead, show age at death
        echo GedcomTag::getLabelValue('AGE', FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($bdate, $ddate), false), $controller->record, 'span');
    }
    echo '</span>';
    // Display summary birth/death info.
    echo '<span id="dates">', $controller->record->getLifeSpan(), '</span>';
    // Display gender icon
    foreach ($controller->record->getFacts() as $fact) {
        if ($fact->getTag() == 'SEX') {
            $controller->printSexRecord($fact);
        }
    }
    echo '</h3>';
    // close first name accordion header
    // Display name details
    foreach ($controller->record->getFacts() as $fact) {
        if ($fact->getTag() == 'NAME') {
 /**
  * XML <AgeAtDeath /> element handler
  */
 private function ageAtDeathStartHandler()
 {
     // This duplicates functionality in FunctionsPrint::format_fact_date()
     global $factrec, $WT_TREE;
     $match = array();
     if (preg_match("/0 @(.+)@/", $this->gedrec, $match)) {
         $person = Individual::getInstance($match[1], $WT_TREE);
         // Recorded age
         if (preg_match('/\\n2 AGE (.+)/', $factrec, $match)) {
             $fact_age = $match[1];
         } else {
             $fact_age = '';
         }
         if (preg_match('/\\n2 HUSB\\n3 AGE (.+)/', $factrec, $match)) {
             $husb_age = $match[1];
         } else {
             $husb_age = '';
         }
         if (preg_match('/\\n2 WIFE\\n3 AGE (.+)/', $factrec, $match)) {
             $wife_age = $match[1];
         } else {
             $wife_age = '';
         }
         // Calculated age
         $birth_date = $person->getBirthDate();
         // Can't use getDeathDate(), as this also gives BURI/CREM events, which
         // wouldn't give the correct "days after death" result for people with
         // no DEAT.
         $death_event = $person->getFirstFact('DEAT');
         if ($death_event) {
             $death_date = $death_event->getDate();
         } else {
             $death_date = new Date('');
         }
         $value = '';
         if (Date::compare($birth_date, $death_date) <= 0 || !$person->isDead()) {
             $age = Date::getAgeGedcom($birth_date, $death_date);
             // Only show calculated age if it differs from recorded age
             if ($age != '' && $age != "0d") {
                 if ($fact_age != '' && $fact_age != $age || $fact_age == '' && $husb_age == '' && $wife_age == '' || $husb_age != '' && $person->getSex() == 'M' && $husb_age != $age || $wife_age != '' && $person->getSex() == 'F' && $wife_age != $age) {
                     $value = FunctionsDate::getAgeAtEvent($age);
                     $abbrev = substr($value, 0, strpos($value, ' ') + 5);
                     if ($value !== $abbrev) {
                         $value = $abbrev . '.';
                     }
                 }
             }
         }
         $this->current_element->addText($value);
     }
 }
示例#7
0
		<input type="hidden" name="action" value="addnoteaction_assisted">
		<input type="hidden" name="noteid" value="newnote">
		<input id="pid_array" type="hidden" name="pid_array" value="none">
		<input id="xref" type="hidden" name="xref" value=<?php 
echo $xref;
?>
>
		<?php 
echo Filter::getCsrf();
$summary = $person->formatFirstMajorFact(WT_EVENTS_BIRT, 2);
if (!$person->isDead()) {
    // If alive display age
    $bdate = $person->getBirthDate();
    $age = Date::getAgeGedcom($bdate);
    if ($age != "") {
        $summary .= "<span class=\"label\">" . I18N::translate('Age') . ":</span><span class=\"field\"> " . FunctionsDate::getAgeAtEvent($age, true) . "</span>";
    }
}
$summary .= $person->formatFirstMajorFact(WT_EVENTS_DEAT, 2);
global $summary, $censyear, $censdate;
$censdate = new Date('31 MAR 1901');
$censyear = $censdate->minimumDate()->y;
$ctry = 'UK';
// === Set $married to "Not married as we only want the Birth name here" ===
$married = -1;
$nam = $person->getAllNames();
if ($person->getDeathYear() == 0) {
    $DeathYr = '';
} else {
    $DeathYr = $person->getDeathYear();
}
 /**
  * Print the age at death/bury
  * @param type $bfact
  * @param type $dfact
  * @return string
  */
 private function printAgeOfDeath($bfact, $dfact)
 {
     $bdate = $bfact->getDate();
     $ddate = $dfact->getDate();
     $html = '';
     if ($bdate->isOK() && $ddate->isOK() && $this->isDateDMY($bfact) && $this->isDateDMY($dfact)) {
         $ageOfdeath = FunctionsDate::getAgeAtEvent(Date::GetAgeGedcom($bdate, $ddate), false);
         if (Date::getAge($bdate, $ddate, 0) < 2) {
             $html .= ' ' . I18N::translateContext('age in days/months', 'at the age of %s', $ageOfdeath);
         } else {
             $html .= ' ' . I18N::translateContext('age in years', 'at the age of %s', $ageOfdeath);
         }
     }
     return $html;
 }