예제 #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
 /**
  * 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);
     }
 }
예제 #4
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') {
예제 #5
0
?>
	<form method="post" action="edit_interface.php" onsubmit="return check_form(this);">
		<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 {