Example #1
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;
 }
 /**
  * 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;
 }