function getSpouseFamilyLabel(WT_Family $family) { $spouse = $family->getSpouse($this); if ($spouse) { return WT_I18N::translate('Family with %s', $spouse->getFullName()); } else { return $family->getFullName(); } }
/** * 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>'; }
/** * Draw a person in the tree * * @param WT_Individual $person The Person object to draw the box for * @param int $gen The number of generations up or down to print * @param int $state Whether we are going up or down the tree, -1 for descendents +1 for ancestors * @param WT_Family $pfamily * @param string $order first (1), last(2), unique(0), or empty. Required for drawing lines between boxes * @param boolean $isRoot * * @return string * * Notes : "spouse" means explicitely married partners. Thus, the word "partner" * (for "life partner") here fits much better than "spouse" or "mate" * to translate properly the modern french meaning of "conjoint" */ private function drawPerson(WT_Individual $person, $gen, $state, WT_Family $pfamily = null, $order = null, $isRoot = false) { global $TEXT_DIRECTION; if ($gen < 0) { return ''; } if (!empty($pfamily)) { $partner = $pfamily->getSpouse($person); } else { $partner = $person->getCurrentSpouse(); } if ($isRoot) { $html = '<table id="tvTreeBorder" class="tv_tree"><tbody><tr><td id="tv_tree_topleft"></td><td id="tv_tree_top"></td><td id="tv_tree_topright"></td></tr><tr><td id="tv_tree_left"></td><td>'; } else { $html = ''; } /* height 1% : this hack enable the div auto-dimensioning in td for FF & Chrome */ $html .= '<table class="tv_tree"' . ($isRoot ? ' id="tv_tree"' : '') . ' style="height: 1%"><tbody><tr>'; if ($state <= 0) { // draw children $html .= $this->drawChildren($person->getSpouseFamilies(), $gen); } else { // draw the parent’s lines $html .= $this->drawVerticalLine($order) . $this->drawHorizontalLine(); } /* draw the person. Do NOT add person or family id as an id, since a same person could appear more than once in the tree !!! */ // Fixing the width for td to the box initial width when the person is the root person fix a rare bug that happen when a person without child and without known parents is the root person : an unwanted white rectangle appear at the right of the person’s boxes, otherwise. $html .= '<td' . ($isRoot ? ' style="width:1px"' : '') . '><div class="tv_box' . ($isRoot ? ' rootPerson' : '') . '" dir="' . $TEXT_DIRECTION . '" style="text-align: ' . ($TEXT_DIRECTION == "rtl" ? "right" : "left") . '; direction: ' . $TEXT_DIRECTION . '" abbr="' . $person->getXref() . '" onclick="' . $this->name . 'Handler.expandBox(this, event);">'; $html .= $this->drawPersonName($person); $fop = array(); // $fop is fathers of partners if (!is_null($partner)) { $dashed = ''; foreach ($person->getSpouseFamilies() as $family) { $spouse = $family->getSpouse($person); if ($spouse) { if ($spouse === $partner || $this->all_partners === 'true') { $spouse_parents = $spouse->getPrimaryChildFamily(); if ($spouse_parents && $spouse_parents->getHusband()) { $fop[] = array($spouse_parents->getHusband(), $spouse_parents); } $html .= $this->drawPersonName($spouse, $dashed); if ($this->all_partners !== 'true') { break; // we can stop here the foreach loop } $dashed = 'dashed'; } } } } $html .= '</div></td>'; $primaryChildFamily = $person->getPrimaryChildFamily(); if (!empty($primaryChildFamily)) { $parent = $primaryChildFamily->getHusband(); if (empty($parent)) { $parent = $primaryChildFamily->getWife(); } } if (!empty($parent) || count($fop) || $state < 0) { $html .= $this->drawHorizontalLine(); } /* draw the parents */ if ($state >= 0 && (!empty($parent) || count($fop))) { $unique = empty($parent) || count($fop) == 0; $html .= '<td align="left"><table class="tv_tree"><tbody>'; if (!empty($parent)) { $u = $unique ? 'c' : 't'; $html .= '<tr><td ' . ($gen == 0 ? ' abbr="p' . $primaryChildFamily->getXref() . '@' . $u . '"' : '') . '>'; $html .= $this->drawPerson($parent, $gen - 1, 1, $primaryChildFamily, $u); $html .= '</td></tr>'; } if (count($fop)) { $n = 0; $nb = count($fop); foreach ($fop as $p) { $n++; $u = $unique ? 'c' : ($n == $nb || empty($p[1]) ? 'b' : 'h'); $html .= '<tr><td ' . ($gen == 0 ? ' abbr="p' . $p[1]->getXref() . '@' . $u . '"' : '') . '>' . $this->drawPerson($p[0], $gen - 1, 1, $p[1], $u) . '</td></tr>'; } } $html .= '</tbody></table></td>'; } if ($state < 0) { $html .= $this->drawVerticalLine($order); } $html .= '</tr></tbody></table>'; if ($isRoot) { $html .= '</td><td id="tv_tree_right"></td></tr><tr><td id="tv_tree_bottomleft"></td><td id="tv_tree_bottom"></td><td id="tv_tree_bottomright"></td></tr></tbody></table>'; } return $html; }