コード例 #1
0
/**
 * Format age of parents in HTML
 *
 * @param WT_Individual $person child
 * @param WT_Date       $birth_date
 *
 * @return string HTML
 */
function format_parents_age(WT_Individual $person, WT_Date $birth_date)
{
    $html = '';
    $families = $person->getChildFamilies();
    // Multiple sets of parents (e.g. adoption) cause complications, so ignore.
    if ($birth_date->isOK() && count($families) == 1) {
        $family = current($families);
        foreach ($family->getSpouses() as $parent) {
            if ($parent->getBirthDate()->isOK()) {
                $sex = $parent->getSexImage();
                $age = WT_Date::getAge($parent->getBirthDate(), $birth_date, 2);
                $deatdate = $parent->getDeathDate();
                switch ($parent->getSex()) {
                    case 'F':
                        // Highlight mothers who die in childbirth or shortly afterwards
                        if ($deatdate->isOK() && $deatdate->MinJD() < $birth_date->MinJD() + 90) {
                            $html .= ' <span title="' . WT_Gedcom_Tag::getLabel('_DEAT_PARE', $parent) . '" class="parentdeath">' . $sex . $age . '</span>';
                        } else {
                            $html .= ' <span title="' . WT_I18N::translate('Mother’s age') . '">' . $sex . $age . '</span>';
                        }
                        break;
                    case 'M':
                        // Highlight fathers who die before the birth
                        if ($deatdate->isOK() && $deatdate->MinJD() < $birth_date->MinJD()) {
                            $html .= ' <span title="' . WT_Gedcom_Tag::getLabel('_DEAT_PARE', $parent) . '" class="parentdeath">' . $sex . $age . '</span>';
                        } else {
                            $html .= ' <span title="' . WT_I18N::translate('Father’s age') . '">' . $sex . $age . '</span>';
                        }
                        break;
                    default:
                        $html .= ' <span title="' . WT_I18N::translate('Parent’s age') . '">' . $sex . $age . '</span>';
                        break;
                }
            }
        }
        if ($html) {
            $html = '<span class="age">' . $html . '</span>';
        }
    }
    return $html;
}
コード例 #2
0
ファイル: module.php プロジェクト: brambravo/webtrees
 private static function parent_facts(WT_Individual $person, $sosa)
 {
     global $controller, $SHOW_RELATIVES_EVENTS;
     $facts = array();
     // Only include events between birth and death
     $birt_date = $controller->record->getEstimatedBirthDate();
     $deat_date = $controller->record->getEstimatedDeathDate();
     if ($sosa == 1) {
         foreach ($person->getChildFamilies() as $family) {
             // Add siblings
             foreach (self::child_facts($person, $family, '_SIBL', '') as $fact) {
                 $facts[] = $fact;
             }
             foreach ($family->getSpouses() as $spouse) {
                 foreach ($spouse->getSpouseFamilies() as $sfamily) {
                     if ($family !== $sfamily) {
                         // Add half-siblings
                         foreach (self::child_facts($person, $sfamily, '_HSIB', '') as $fact) {
                             $facts[] = $fact;
                         }
                     }
                 }
                 // Add grandparents
                 foreach (self::parent_facts($spouse, $spouse->getSex() == 'F' ? 3 : 2) as $fact) {
                     $facts[] = $fact;
                 }
             }
         }
         if (strstr($SHOW_RELATIVES_EVENTS, '_MARR_PARE')) {
             // add father/mother marriages
             foreach ($person->getChildFamilies() as $sfamily) {
                 foreach ($sfamily->getFacts(WT_EVENTS_MARR) as $fact) {
                     if ($fact->getDate()->isOK() && WT_Date::Compare($birt_date, $fact->getDate()) <= 0 && WT_Date::Compare($fact->getDate(), $deat_date) <= 0) {
                         // marriage of parents (to each other)
                         $rela_fact = clone $fact;
                         $rela_fact->setTag('_' . $fact->getTag() . '_FAMC');
                         $facts[] = $rela_fact;
                     }
                 }
             }
             foreach ($person->getChildStepFamilies() as $sfamily) {
                 foreach ($sfamily->getFacts(WT_EVENTS_MARR) as $fact) {
                     if ($fact->getDate()->isOK() && WT_Date::Compare($birt_date, $fact->getDate()) <= 0 && WT_Date::Compare($fact->getDate(), $deat_date) <= 0) {
                         // marriage of a parent (to another spouse)
                         // Convert the event to a close relatives event
                         $rela_fact = clone $fact;
                         $rela_fact->setTag('_' . $fact->getTag() . '_PARE');
                         $facts[] = $rela_fact;
                     }
                 }
             }
         }
     }
     foreach ($person->getChildFamilies() as $family) {
         foreach ($family->getSpouses() as $parent) {
             if (strstr($SHOW_RELATIVES_EVENTS, '_DEAT' . ($sosa == 1 ? '_PARE' : '_GPAR'))) {
                 foreach ($parent->getFacts(WT_EVENTS_DEAT) as $fact) {
                     if ($fact->getDate()->isOK() && WT_Date::Compare($birt_date, $fact->getDate()) <= 0 && WT_Date::Compare($fact->getDate(), $deat_date) <= 0) {
                         switch ($sosa) {
                             case 1:
                                 // Convert the event to a close relatives event.
                                 $rela_fact = clone $fact;
                                 $rela_fact->setTag('_' . $fact->getTag() . '_PARE');
                                 $facts[] = $rela_fact;
                                 break;
                             case 2:
                                 // Convert the event to a close relatives event
                                 $rela_fact = clone $fact;
                                 $rela_fact->setTag('_' . $fact->getTag() . '_GPA1');
                                 $facts[] = $rela_fact;
                                 break;
                             case 3:
                                 // Convert the event to a close relatives event
                                 $rela_fact = clone $fact;
                                 $rela_fact->setTag('_' . $fact->getTag() . '_GPA2');
                                 $facts[] = $rela_fact;
                                 break;
                         }
                     }
                 }
             }
         }
     }
     return $facts;
 }
コード例 #3
0
ファイル: clippings_ctrl.php プロジェクト: brambravo/webtrees
 function addAncestorsToCartFamilies(WT_Individual $person = null, $level = null)
 {
     if (!$person) {
         return;
     }
     if ($level > 0) {
         foreach ($person->getChildFamilies() as $family) {
             $this->addFamilyMembers($family);
             $this->addAncestorsToCartFamilies($family->getHusband(), $level - 1);
             $this->addAncestorsToCartFamilies($family->getWife(), $level - 1);
         }
     }
 }
コード例 #4
0
ファイル: Branches.php プロジェクト: brambravo/webtrees
 private function loadAncestors(WT_Individual $ancestor, $sosa)
 {
     if ($ancestor) {
         $this->ancestors[$sosa] = $ancestor;
         foreach ($ancestor->getChildFamilies() as $family) {
             foreach ($family->getSpouses() as $parent) {
                 $this->loadAncestors($parent, $sosa * 2 + ($parent->getSex() == 'F'));
             }
         }
     }
 }
コード例 #5
0
ファイル: Familybook.php プロジェクト: jacoline/webtrees
 /**
  * Prints pedigree of the person passed in
  *
  * @param WT_Individual $person
  * @param int           $count
  */
 function print_person_pedigree($person, $count)
 {
     global $WT_IMAGES, $bheight, $bwidth, $bhalfheight;
     if ($count >= $this->generations) {
         return;
     }
     //if (!$person) return;
     $genoffset = $this->generations;
     // handle pedigree n generations lines
     //-- calculate how tall the lines should be
     $lh = ($bhalfheight + 4) * pow(2, $genoffset - $count - 1);
     //
     //Prints empty table columns for children w/o parents up to the max generation
     //This allows vertical line spacing to be consistent
     if (count($person->getChildFamilies()) == 0) {
         echo '<table>';
         $this->printEmptyBox($bwidth, $bheight);
         //-- recursively get the father’s family
         $this->print_person_pedigree($person, $count + 1);
         echo '</td><td></tr>';
         $this->printEmptyBox($bwidth, $bheight);
         //-- recursively get the mother’s family
         $this->print_person_pedigree($person, $count + 1);
         echo '</td><td></tr></table>';
     }
     //Empty box section done, now for regular pedigree
     foreach ($person->getChildFamilies() as $family) {
         echo '<table><tr><td class="tdbot">';
         //
         //Determine line height for two or more spouces
         //And then adjust the vertical line for the root person only
         //
         $sfamilies = $person->getSpouseFamilies();
         $famcount = 0;
         if ($this->show_spouse) {
             // count number of spouses
             $famcount += count($sfamilies);
         }
         $savlh = $lh;
         // Save current line height
         if ($count == 1 && $genoffset <= $famcount) {
             $linefactor = 0;
             if ($genoffset > 2) {
                 // genoffset of 2 needs no adjustment
                 $tblheight = $bheight + 8;
                 if ($genoffset == 3) {
                     if ($famcount == 3) {
                         $linefactor = $tblheight / 2;
                     } else {
                         if ($famcount > 3) {
                             $linefactor = $tblheight;
                         }
                     }
                 }
                 if ($genoffset == 4) {
                     if ($famcount == 4) {
                         $linefactor = $tblheight;
                     } else {
                         if ($famcount > 4) {
                             $linefactor = ($famcount - $genoffset) * ($tblheight * 1.5);
                         }
                     }
                 }
                 if ($genoffset == 5) {
                     if ($famcount == 5) {
                         $linefactor = 0;
                     } else {
                         if ($famcount > 5) {
                             $linefactor = $tblheight * ($famcount - $genoffset);
                         }
                     }
                 }
             }
             $lh = ($famcount - 1) * ($bheight + 8) - $linefactor;
             if ($genoffset > 5) {
                 $lh = $savlh;
             }
         }
         echo '<img class="line3 pvline"  src="', $WT_IMAGES["vline"], '" height="', $lh - 1, '" alt=""></td>', '<td>', '<img class="line4" src="', $WT_IMAGES["hline"], '" height="3" alt=""></td>', '<td>';
         $lh = $savlh;
         // restore original line height
         //-- print the father box
         print_pedigree_person($family->getHusband());
         echo '</td>';
         if ($family->getHusband()) {
             echo '<td>';
             //-- recursively get the father’s family
             $this->print_person_pedigree($family->getHusband(), $count + 1);
             echo '</td>';
         } else {
             echo '<td>';
             if ($genoffset > $count) {
                 echo '<table>';
                 for ($i = 1; $i < pow(2, $genoffset - $count) / 2; $i++) {
                     $this->printEmptyBox($bwidth, $bheight);
                     echo '</tr>';
                 }
                 echo '</table>';
             }
         }
         echo '</tr><tr>', '<td class="tdtop"><img class="pvline" src="', $WT_IMAGES["vline"], '" height="', $lh + 1, '" alt=""></td>', '<td><img class="line4" src="', $WT_IMAGES["hline"], '" height="3" alt=""></td>', '<td>';
         //-- print the mother box
         print_pedigree_person($family->getWife());
         echo '</td>';
         if ($family->getWife()) {
             echo '<td>';
             //-- recursively print the mother’s family
             $this->print_person_pedigree($family->getWife(), $count + 1);
             echo '</td>';
         } else {
             echo '<td>';
             if ($count < $genoffset - 1) {
                 echo '<table>';
                 for ($i = 1; $i < pow(2, $genoffset - 1 - $count) / 2 + 1; $i++) {
                     $this->printEmptyBox($bwidth, $bheight);
                     echo '</tr>';
                     $this->printEmptyBox($bwidth, $bheight);
                     echo '</tr>';
                 }
                 echo '</table>';
             }
         }
         echo '</tr>', '</table>';
         break;
     }
 }