/** * print a family descendancy * * @param WT_Individual $person * @param WT_Family $family * @param int $depth the descendancy depth to show * * @return void */ function print_family_descendancy(WT_Individual $person, WT_Family $family, $depth) { global $WT_IMAGES, $Dindent, $personcount; // print marriage info echo '<li>'; echo '<img src="', $WT_IMAGES['spacer'], '" height="2" width="', $Dindent + 4, '" alt="">'; echo '<span class="details1" style="white-space:nowrap;">'; echo "<a href=\"#\" onclick=\"expand_layer('" . $family->getXref() . $personcount . "'); return false;\" class=\"top\"><i id=\"" . $family->getXref() . $personcount . "_img\" class=\"icon-minus\" title=\"" . WT_I18N::translate('View family') . "\"></i></a>"; if ($family->canShow()) { foreach ($family->getFacts(WT_EVENTS_MARR) as $fact) { echo ' <a href="', $family->getHtmlUrl(), '" class="details1">', $fact->summary(), '</a>'; } } echo '</span>'; // print spouse $spouse = $family->getSpouse($person); echo '<ul style="list-style:none; display:block;" id="' . $family->getXref() . $personcount . '">'; echo '<li>'; echo '<table border="0" cellpadding="0" cellspacing="0"><tr><td>'; print_pedigree_person($spouse, 1, 0, $personcount); echo '</td>'; // check if spouse has parents and add an arrow echo '<td> </td>'; echo '<td>'; if ($spouse) { foreach ($spouse->getChildFamilies() as $cfamily) { foreach ($cfamily->getSpouses() as $parent) { print_url_arrow($parent->getXref() . $personcount . $person->getXref(), '?rootid=' . $parent->getXref() . '&generations=' . $this->generations . '&chart_style=' . $this->chart_style . '&show_full=' . $this->show_full . '&box_width=' . $this->box_width . '&ged=' . WT_GEDURL, WT_I18N::translate('Start at parents'), 2); $personcount++; // only show the arrow for one of the parents break; } } } if ($this->show_full) { echo '<br><br> '; } echo '</td></tr>'; // children $children = $family->getChildren(); echo '<tr><td colspan="3" class="details1" > '; if ($children) { echo WT_Gedcom_Tag::getLabel('NCHI') . ': ' . count($children); } else { // Distinguish between no children (NCHI 0) and no recorded // children (no CHIL records) if (strpos($family->getGedcom(), '\\n1 NCHI 0')) { echo WT_Gedcom_Tag::getLabel('NCHI') . ': ' . count($children); } else { echo WT_I18N::translate('No children'); } } echo '</td></tr></table>'; echo '</li>'; if ($depth > 1) { foreach ($children as $child) { $personcount++; $this->print_child_descendancy($child, $depth - 1); } } echo '</ul>'; echo '</li>'; }
/** * print the children table for a family * * @param WT_Family $family family * @param string $childid child ID * @param int $sosa child sosa number * @param string $label indi label (descendancy booklet) * @param int $personcount */ function print_family_children(WT_Family $family, $childid = '', $sosa = 0, $label = '', $personcount = 1) { global $bheight, $pbheight, $cbheight, $show_cousins, $WT_IMAGES, $TEXT_DIRECTION; $children = $family->getChildren(); $numchil = count($children); echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\"><tr>"; if ($sosa > 0) { echo "<td></td>"; } echo "<td><span class=\"subheaders\">"; if ($numchil == 0) { echo WT_I18N::translate('No children'); } else { echo WT_I18N::plural('%s child', '%s children', $numchil, $numchil); } echo '</span>'; if ($sosa == 0 && WT_USER_CAN_EDIT) { echo '<br>'; echo "<a href=\"#\" onclick=\"return add_child_to_family('", $family->getXref(), "', 'U');\">" . WT_I18N::translate('Add a child to this family') . "</a>"; echo ' <a class="icon-sex_m_15x15" href="#" onclick="return add_child_to_family(\'', $family->getXref(), '\', \'M\');" title="', WT_I18N::translate('son'), '"></a>'; echo ' <a class="icon-sex_f_15x15" href="#" onclick="return add_child_to_family(\'', $family->getXref(), '\', \'F\');" title="', WT_I18N::translate('daughter'), '"></a>'; echo '<br><br>'; } echo '</td>'; if ($sosa > 0) { echo '<td></td><td></td>'; } echo '</tr>'; $nchi = 1; if ($children) { foreach ($children as $child) { echo '<tr>'; if ($sosa != 0) { if ($child->getXref() == $childid) { print_sosa_number($sosa, $childid); } elseif (empty($label)) { print_sosa_number(""); } else { print_sosa_number($label . $nchi++ . "."); } } if ($child->isNew()) { echo '<td valign="middle" class="new">'; } elseif ($child->isOld()) { echo '<td valign="middle" class="old">'; } else { echo '<td valign="middle">'; } print_pedigree_person($child, 1, 8, $personcount++); echo "</td>"; if ($sosa != 0) { // loop for all families where current child is a spouse $famids = $child->getSpouseFamilies(); $maxfam = count($famids) - 1; for ($f = 0; $f <= $maxfam; $f++) { $famid_child = $famids[$f]->getXref(); // multiple marriages if ($f > 0) { echo "</tr><tr><td> </td>"; echo "<td valign=\"top\""; if ($TEXT_DIRECTION == "rtl") { echo " align=\"left\">"; } else { echo " align=\"right\">"; } //if ($f==$maxfam) echo "<img height=\"50%\""; //else echo "<img height=\"100%\""; //find out how many cousins there are to establish vertical line on second families $fchildren = $famids[$f]->getChildren(); $kids = count($fchildren); $Pheader = $cbheight * $kids - $bheight; $PBadj = 6; // default if ($show_cousins > 0) { if ($cbheight * $kids > $bheight) { $PBadj = $Pheader / 2 + $kids * 4.5; } } if ($PBadj < 0) { $PBadj = 0; } if ($f == $maxfam) { echo "<img height=\"" . ($bheight / 2 + $PBadj) . "px\""; } else { echo "<img height=\"" . $pbheight . "px\""; } echo " width=\"3\" src=\"" . $WT_IMAGES["vline"] . "\" alt=\"\">"; echo "</td>"; } echo "<td class=\"details1\" valign=\"middle\" align=\"center\">"; $spouse = $famids[$f]->getSpouse($child); $marr = $famids[$f]->getFirstFact('MARR'); $div = $famids[$f]->getFirstFact('DIV'); if ($marr) { // marriage date echo $marr->getDate()->minDate()->format('%Y'); // divorce date if ($div) { echo '–', $div->getDate()->minDate()->format('%Y'); } } echo "<br><img width=\"100%\" class=\"line5\" height=\"3\" src=\"" . $WT_IMAGES["hline"] . "\" alt=\"\">"; echo "</td>"; // spouse information echo "<td style=\"vertical-align: center;"; if (!empty($divrec)) { echo " filter:alpha(opacity=40);opacity:0.4;\">"; } else { echo "\">"; } print_pedigree_person($spouse, 1, 9, $personcount++); echo "</td>"; // cousins if ($show_cousins) { print_cousins($famid_child, $personcount++); } } } echo "</tr>"; } } elseif ($sosa < 1) { // message 'no children' except for sosa if (preg_match('/\\n1 NCHI (\\d+)/', $family->getGedcom(), $match) && $match[1] == 0) { echo '<tr><td><i class="icon-childless"></i> ' . WT_I18N::translate('This family remained childless') . '</td></tr>'; } } else { echo "<tr>"; print_sosa_number($sosa, $child); echo "<td valign=\"top\">"; print_pedigree_person(WT_Individual::getInstance($childid), 1, 0, $personcount); echo "</td></tr>"; } echo "</table><br>"; }
private static function child_facts(WT_Individual $person, WT_Family $family, $option, $relation) { global $controller, $SHOW_RELATIVES_EVENTS; $facts = array(); // Only include events between birth and death $birt_date = $controller->record->getEstimatedBirthDate(); $deat_date = $controller->record->getEstimatedDeathDate(); // Deal with recursion. switch ($option) { case '_CHIL': // Add grandchildren foreach ($family->getChildren() as $child) { foreach ($child->getSpouseFamilies() as $cfamily) { switch ($child->getSex()) { case 'M': foreach (self::child_facts($person, $cfamily, '_GCHI', 'son') as $fact) { $facts[] = $fact; } break; case 'F': foreach (self::child_facts($person, $cfamily, '_GCHI', 'dau') as $fact) { $facts[] = $fact; } break; case 'U': foreach (self::child_facts($person, $cfamily, '_GCHI', 'chi') as $fact) { $facts[] = $fact; } break; } } } break; } // For each child in the family foreach ($family->getChildren() as $child) { if ($child->getXref() == $person->getXref()) { // We are not our own sibling! continue; } // add child’s birth if (strpos($SHOW_RELATIVES_EVENTS, '_BIRT' . str_replace('_HSIB', '_SIBL', $option)) !== false) { foreach ($child->getFacts(WT_EVENTS_BIRT) as $fact) { $sgdate = $fact->getDate(); // Always show _BIRT_CHIL, even if the dates are not known if ($option == '_CHIL' || $sgdate->isOK() && WT_Date::Compare($birt_date, $sgdate) <= 0 && WT_Date::Compare($sgdate, $deat_date) <= 0) { if ($option == '_GCHI' && $relation == 'dau') { // Convert the event to a close relatives event. $rela_fact = clone $fact; $rela_fact->setTag('_' . $fact->getTag() . '_GCH1'); $facts[] = $rela_fact; } elseif ($option == '_GCHI' && $relation == 'son') { // Convert the event to a close relatives event. $rela_fact = clone $fact; $rela_fact->setTag('_' . $fact->getTag() . '_GCH2'); $facts[] = $rela_fact; } else { // Convert the event to a close relatives event. $rela_fact = clone $fact; $rela_fact->setTag('_' . $fact->getTag() . $option); $facts[] = $rela_fact; } } } } // add child’s death if (strpos($SHOW_RELATIVES_EVENTS, '_DEAT' . str_replace('_HSIB', '_SIBL', $option)) !== false) { foreach ($child->getFacts(WT_EVENTS_DEAT) as $fact) { $sgdate = $fact->getDate(); $srec = $fact->getGedcom(); if ($sgdate->isOK() && WT_Date::Compare($birt_date, $sgdate) <= 0 && WT_Date::Compare($sgdate, $deat_date) <= 0) { if ($option == '_GCHI' && $relation == 'dau') { // Convert the event to a close relatives event. $rela_fact = clone $fact; $rela_fact->setTag('_' . $fact->getTag() . '_GCH1'); $facts[] = $rela_fact; } elseif ($option == '_GCHI' && $relation == 'son') { // Convert the event to a close relatives event. $rela_fact = clone $fact; $rela_fact->setTag('_' . $fact->getTag() . '_GCH2'); $facts[] = $rela_fact; } else { // Convert the event to a close relatives event. $rela_fact = clone $fact; $rela_fact->setTag('_' . $fact->getTag() . $option); $facts[] = $rela_fact; } } } } // add child’s marriage if (strstr($SHOW_RELATIVES_EVENTS, '_MARR' . str_replace('_HSIB', '_SIBL', $option))) { foreach ($child->getSpouseFamilies() as $sfamily) { foreach ($sfamily->getFacts(WT_EVENTS_MARR) as $fact) { $sgdate = $fact->getDate(); if ($sgdate->isOK() && WT_Date::Compare($birt_date, $sgdate) <= 0 && WT_Date::Compare($sgdate, $deat_date) <= 0) { if ($option == '_GCHI' && $relation == 'dau') { // Convert the event to a close relatives event. $rela_fact = clone $fact; $rela_fact->setTag('_' . $fact->getTag() . '_GCH1'); $facts[] = $rela_fact; } elseif ($option == '_GCHI' && $relation == 'son') { // Convert the event to a close relatives event. $rela_fact = clone $fact; $rela_fact->setTag('_' . $fact->getTag() . '_GCH2'); $facts[] = $rela_fact; } else { // Convert the event to a close relatives event. $rela_fact = clone $fact; $rela_fact->setTag('_' . $fact->getTag() . $option); $facts[] = $rela_fact; } } } } } } return $facts; }
function addFamilyDescendancy(WT_Family $family = null, $level = PHP_INT_MAX) { if (!$family) { return; } foreach ($family->getSpouses() as $spouse) { $this->addClipping($spouse); } foreach ($family->getChildren() as $child) { $this->addClipping($child); foreach ($child->getSpouseFamilies() as $child_family) { $this->addClipping($child_family); if ($level > 0) { $this->addFamilyDescendancy($child_family, $level - 1); // recurse on the childs family } } } }
function printFamily(WT_Family $family, $type, $label) { global $controller; global $personcount; // TODO: use a unique id instead? global $SHOW_PRIVATE_RELATIONSHIPS; if ($SHOW_PRIVATE_RELATIONSHIPS) { $access_level = WT_PRIV_HIDE; } else { $access_level = WT_USER_ACCESS_LEVEL; } ?> <table> <tr> <td> <i class="icon-cfamily"></i> </td> <td> <span class="subheaders"> <?php echo $label; ?> </span> - <a href="<?php echo $family->getHtmlUrl(); ?> "><?php echo WT_I18N::translate('View family'); ?> </a> </td> </tr> </table> <table class="facts_table"> <?php ///// HUSB ///// $found = false; foreach ($family->getFacts('HUSB', false, $access_level) as $fact) { $found |= !$fact->isOld(); $person = $fact->getTarget(); if ($person instanceof WT_Individual) { if ($fact->isNew()) { $class = 'facts_label new'; } elseif ($fact->isOld()) { $class = 'facts_label old'; } else { $class = 'facts_label'; } ?> <tr> <td class="<?php echo $class; ?> "> <?php echo get_close_relationship_name($controller->record, $person); ?> </td> <td class="<?php echo $controller->getPersonStyle($person); ?> "> <?php print_pedigree_person($person, 2, 0, $personcount++); ?> </td> </tr> <?php } } if (!$found && $family->canEdit()) { ?> <tr> <td class="facts_label"> </td> <td class="facts_value"><a href="#" onclick="return add_spouse_to_family('<?php echo $family->getXref(); ?> ', 'HUSB');"><?php echo WT_I18N::translate('Add a husband to this family'); ?> </a></td> </tr> <?php } ///// WIFE ///// $found = false; foreach ($family->getFacts('WIFE', false, $access_level) as $fact) { $person = $fact->getTarget(); if ($person instanceof WT_Individual) { $found |= !$fact->isOld(); if ($fact->isNew()) { $class = 'facts_label new'; } elseif ($fact->isOld()) { $class = 'facts_label old'; } else { $class = 'facts_label'; } ?> <tr> <td class="<?php echo $class; ?> "> <?php echo get_close_relationship_name($controller->record, $person); ?> </td> <td class="<?php echo $controller->getPersonStyle($person); ?> "> <?php print_pedigree_person($person, 2, 0, $personcount++); ?> </td> </tr> <?php } } if (!$found && $family->canEdit()) { ?> <tr> <td class="facts_label"> </td> <td class="facts_value"><a href="#" onclick="return add_spouse_to_family('<?php echo $family->getXref(); ?> ', 'WIFE');"><?php echo WT_I18N::translate('Add a wife to this family'); ?> </a></td> </tr> <?php } ///// MARR ///// $found = false; $prev = new WT_Date(''); foreach ($family->getFacts(WT_EVENTS_MARR) as $fact) { $found |= !$fact->isOld(); if ($fact->isNew()) { $class = ' new'; } elseif ($fact->isOld()) { $class = ' old'; } else { $class = ''; } ?> <tr> <td class="facts_label"> </td> <td class="facts_value<?php echo $class; ?> "> <?php echo WT_Gedcom_Tag::getLabelValue($fact->getTag(), $fact->getDate()->Display(false) . ' — ' . $fact->getPlace()->getFullName()); ?> </td> </tr> <?php if (!$prev->isOK() && $fact->getDate()->isOK()) { $prev = $fact->getDate(); } } if (!$found && $family->canShow() && $family->canEdit()) { // Add a new marriage ?> <tr> <td class="facts_label"> </td> <td class="facts_value"> <a href="#" onclick="return add_new_record('<?php echo $family->getXref(); ?> ', 'MARR');"> <?php echo WT_I18N::translate('Add marriage details'); ?> </a> </td> </tr> <?php } ///// CHIL ///// $child_number = 0; foreach ($family->getFacts('CHIL', false, $access_level) as $fact) { $person = $fact->getTarget(); if ($person instanceof WT_Individual) { if ($fact->isNew()) { $child_number++; $class = 'facts_label new'; } elseif ($fact->isOld()) { $class = 'facts_label old'; } else { $child_number++; $class = 'facts_label'; } $next = new WT_Date(''); foreach ($person->getFacts(WT_EVENTS_BIRT) as $bfact) { if ($bfact->getDate()->isOK()) { $next = $bfact->getDate(); break; } } ?> <tr> <td class="<?php echo $class; ?> "> <?php echo self::ageDifference($prev, $next, $child_number); ?> <?php echo get_close_relationship_name($controller->record, $person); ?> </td> <td class="<?php echo $controller->getPersonStyle($person); ?> "> <?php print_pedigree_person($person, 2, 0, $personcount++); ?> </td> </tr> <?php $prev = $next; } } // Re-order children / add a new child if ($family->canEdit()) { if ($type == 'FAMS') { $child_u = WT_I18N::translate('Add a new son or daughter'); $child_m = WT_I18N::translate('son'); $child_f = WT_I18N::translate('daughter'); } else { $child_u = WT_I18N::translate('Add a new brother or sister'); $child_m = WT_I18N::translate('brother'); $child_f = WT_I18N::translate('sister'); } ?> <tr> <td class="facts_label"> <?php if (count($family->getChildren()) > 1) { ?> <a href="#" onclick="reorder_children('<?php echo $family->getXref(); ?> ');tabswitch(5);"><i class="icon-media-shuffle"></i> <?php echo WT_I18N::translate('Re-order children'); ?> </a> <?php } ?> </td> <td class="facts_value"> <a href="#" onclick="return add_child_to_family('<?php echo $family->getXref(); ?> ');"><?php echo $child_u; ?> </a> <span style='white-space:nowrap;'> <a href="#" class="icon-sex_m_15x15" onclick="return add_child_to_family('<?php echo $family->getXref(); ?> ','M');"></a> <a href="#" class="icon-sex_f_15x15" onclick="return add_child_to_family('<?php echo $family->getXref(); ?> ','F');"></a> </span> </td> </tr> <?php } echo '</table>'; return; }
public function loadChildren(WT_Family $family, $generations) { $out = ''; if ($family->canShow()) { $children = $family->getChildren(); if ($children) { foreach ($children as $child) { $out .= $this->getPersonLi($child, $generations - 1); } } else { $out .= '<li class="sb_desc_none">' . WT_I18N::translate('No children') . '</li>'; } } if ($out) { return '<ul>' . $out . '</ul>'; } else { return ''; } }