Esempio n. 1
0
 /**
  * Draw a person name preceded by sex icon, with parents as tooltip
  *
  * @param Individual $individual an individual
  * @param string        $dashed     if = 'dashed' print dashed top border to separate multiple spuses
  *
  * @return string
  */
 private function drawPersonName(Individual $individual, $dashed = '')
 {
     if ($this->all_partners === 'true') {
         $family = $individual->getPrimaryChildFamily();
         if ($family) {
             $family_name = strip_tags($family->getFullName());
         } else {
             $family_name = I18N::translateContext('unknown family', 'unknown');
         }
         switch ($individual->getSex()) {
             case 'M':
                 $title = ' title="' . I18N::translate('Son of %s', $family_name) . '"';
                 break;
             case 'F':
                 $title = ' title="' . I18N::translate('Daughter of %s', $family_name) . '"';
                 break;
             default:
                 $title = ' title="' . I18N::translate('Child of %s', $family_name) . '"';
                 break;
         }
     } else {
         $title = '';
     }
     $sex = $individual->getSex();
     return '<div class="tv' . $sex . ' ' . $dashed . '"' . $title . '><a href="' . $individual->getHtmlUrl() . '"></a>' . $individual->getFullName() . ' <span class="dates">' . $individual->getLifeSpan() . '</span></div>';
 }
 /**
  * Forat the parents of an individual.
  *
  * @param Individual $person
  *
  * @return string
  */
 private function getParents(Individual $person)
 {
     $father = null;
     $mother = null;
     $html = sprintf(self::TTL, I18N::translate('Parents'));
     $family = $person->getPrimaryChildFamily();
     if ($person->canShowName() && $family !== null) {
         $father = $family->getHusband();
         $mother = $family->getWife();
         $html .= $this->getHTML($father) . $this->getHTML($mother);
         // Can only have a step parent if one & only one parent found at this point
         if ($father instanceof Individual xor $mother instanceof Individual) {
             $stepParents = '';
             foreach ($person->getChildStepFamilies() as $family) {
                 if (!$father instanceof Individual) {
                     $stepParents .= $this->getHTML($family->getHusband());
                 } else {
                     $stepParents .= $this->getHTML($family->getWife());
                 }
             }
             if ($stepParents) {
                 $relationship = $father instanceof Individual ? I18N::translateContext("father’s wife", "step-mother") : I18N::translateContext("mother’s husband", "step-father");
                 $html .= sprintf(self::TTL, $relationship) . $stepParents;
             }
         }
     }
     if (!($father instanceof Individual || $mother instanceof Individual)) {
         $html .= sprintf(self::MSG, I18N::translateContext('unknown family', 'unknown'));
     }
     return $html;
 }
Esempio n. 3
0
 /**
  * Recursive method to add individual to the Sosa table, and flush it regularly
  * @param Individual $indi Individual to add
  * @param int $sosa Individual's sosa
  */
 protected function addNode(Individual $indi, $sosa)
 {
     $birth_year = $indi->getEstimatedBirthDate()->gregorianYear();
     $death_year = $indi->getEstimatedDeathDate()->gregorianYear();
     $this->tmp_sosa_table[] = array('indi' => $indi->getXref(), 'sosa' => $sosa, 'birth_year' => $birth_year, 'death_year' => $death_year);
     $this->flushTmpSosaTable();
     if ($fam = $indi->getPrimaryChildFamily()) {
         if ($husb = $fam->getHusband()) {
             $this->addNode($husb, 2 * $sosa);
         }
         if ($wife = $fam->getWife()) {
             $this->addNode($wife, 2 * $sosa + 1);
         }
     }
 }
Esempio n. 4
0
 /**
  * Find the mother of an individual
  *
  * @param Individual $individual
  *
  * @return Individual|null
  */
 public function mother(Individual $individual)
 {
     $family = $individual->getPrimaryChildFamily();
     if ($family) {
         return $family->getWife();
     } else {
         return null;
     }
 }