/** * 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>"; }
/** * print the children table for a family * * @param string $famid family gedcom ID * @param string $childid optional child ID * @param int $sosa optional child sosa number * @param string $label optional indi label (descendancy booklet) */ function print_family_children($famid, $childid = "", $sosa = 0, $label = "", $personcount = "1") { global $pgv_lang, $factarray, $pbwidth, $pbheight, $view, $show_famlink, $show_cousins; global $PGV_IMAGE_DIR, $PGV_IMAGES, $show_changes, $pgv_changes, $GEDCOM, $SHOW_ID_NUMBERS, $TEXT_DIRECTION; $family = Family::getInstance($famid); $children = $family->getChildrenIds(); print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\"><tr>"; if ($sosa > 0) { print "<td></td>"; } print "<td><span class=\"subheaders\">" . $pgv_lang["children"] . "</span></td>"; if ($sosa > 0) { print "<td></td><td></td>"; } print "</tr>\n"; $newchildren = array(); $oldchildren = array(); if (PGV_USER_CAN_EDIT) { if (isset($_REQUEST['show_changes']) && $_REQUEST['show_changes'] == 'yes' && isset($pgv_changes[$famid . "_" . $GEDCOM])) { $newrec = find_updated_record($famid); $ct = preg_match_all("/1 CHIL @(.*)@/", $newrec, $match, PREG_SET_ORDER); if ($ct > 0) { $oldchil = array(); for ($i = 0; $i < $ct; $i++) { if (!in_array($match[$i][1], $children)) { $newchildren[] = $match[$i][1]; } else { $oldchil[] = $match[$i][1]; } } foreach ($children as $indexval => $chil) { if (!in_array($chil, $oldchil)) { $oldchildren[] = $chil; } } //-- if there are no old or new children then the children were reordered if (count($newchildren) == 0 && count($oldchildren) == 0) { $children = array(); for ($i = 0; $i < $ct; $i++) { $children[] = $match[$i][1]; } } } } } $nchi = 1; if (count($children) > 0 || count($newchildren) > 0 || count($oldchildren) > 0) { foreach ($children as $indexval => $chil) { if (!in_array($chil, $oldchildren)) { print "<tr>\n"; if ($sosa != 0) { if ($chil == $childid) { print_sosa_number($sosa, $childid); } else { if (empty($label)) { print_sosa_number(""); } else { print_sosa_number($label . $nchi++ . "."); } } } print "<td valign=\"middle\" >"; print_pedigree_person($chil, 1, $show_famlink, 8, $personcount); $personcount++; print "</td>"; if ($sosa != 0) { // loop for all families where current child is a spouse $famids = find_sfamily_ids($chil); $maxfam = count($famids) - 1; for ($f = 0; $f <= $maxfam; $f++) { $famid = $famids[$f]; if (!$famid) { continue; } $parents = find_parents($famid); if (!$parents) { continue; } if ($parents["HUSB"] == $chil) { $spouse = $parents["WIFE"]; } else { $spouse = $parents["HUSB"]; } // multiple marriages if ($f > 0) { print "</tr>\n<tr><td> </td>"; print "<td valign=\"top\""; if ($TEXT_DIRECTION == "rtl") { print " align=\"left\">"; } else { print " align=\"right\">"; } //if ($f==$maxfam) print "<img height=\"50%\""; //else print "<img height=\"100%\""; if ($f == $maxfam) { print "<img height=\"" . ($pbheight / 2 - 3) . "px\""; } else { print "<img height=\"" . $pbheight . "px\""; } print " width=\"3\" src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["vline"]["other"] . "\" alt=\"\" />"; print "</td>"; } print "<td class=\"details1\" valign=\"middle\" align=\"center\">"; $divrec = ""; if (showFact("MARR", $famid)) { // marriage date $famrec = find_family_record($famid); $ct = preg_match("/2 DATE.*(\\d\\d\\d\\d)/", get_sub_record(1, "1 MARR", $famrec), $match); if ($ct > 0) { print "<span class=\"date\">" . trim($match[1]) . "</span>"; } // divorce date $divrec = get_sub_record(1, "1 DIV", $famrec); $ct = preg_match("/2 DATE.*(\\d\\d\\d\\d)/", $divrec, $match); if ($ct > 0) { print "-<span class=\"date\">" . trim($match[1]) . "</span>"; } } print "<br /><img width=\"100%\" height=\"3\" src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["hline"]["other"] . "\" alt=\"\" />"; // family link if ($famid) { print "<br />"; print "<a class=\"details1\" href=\"family.php?famid={$famid}\">"; if ($SHOW_ID_NUMBERS) { print getLRM() . " ({$famid}) " . getLRM(); } print "</a>"; } print "</td>\n"; // spouse information print "<td style=\"vertical-align: center;"; if (!empty($divrec) and $view != "preview") { print " filter:alpha(opacity=40);-moz-opacity:0.4\">"; } else { print "\">"; } print_pedigree_person($spouse, 1, $show_famlink, 9, $personcount); $personcount++; print "</td>\n"; // cousins if ($show_cousins) { print_cousins($famid, $personcount); $personcount++; } } } print "</tr>\n"; } } foreach ($newchildren as $indexval => $chil) { print "<tr >"; print "<td valign=\"top\" class=\"facts_valueblue\" style=\"width: " . $pbwidth . "px; height: " . $pbheight . "px;\">\n"; print_pedigree_person($chil, 1, $show_famlink, 0, $personcount); $personcount++; print "</td></tr>\n"; } foreach ($oldchildren as $indexval => $chil) { print "<tr >"; print "<td valign=\"top\" class=\"facts_valuered\" style=\"width: " . $pbwidth . "px; height: " . $pbheight . "px;\">\n"; print_pedigree_person($chil, 1, $show_famlink, 0, $personcount); $personcount++; print "</td></tr>\n"; } // message 'no children' except for sosa } else { if ($sosa < 1) { print "<tr><td></td><td valign=\"top\" >"; $nchi = ""; if (isset($pgv_changes[$famid . "_" . $GEDCOM])) { $famrec = find_updated_record($famid); } else { $famrec = find_family_record($famid); } $ct = preg_match("/1 NCHI (\\w+)/", $famrec, $match); if ($ct > 0) { $nchi = $match[1]; } else { $famrec = find_family_record($famid); $ct = preg_match("/1 NCHI (\\w+)/", $famrec, $match); if ($ct > 0) { $nchi = $match[1]; } } if ($nchi == "0") { print "<img src=\"images/small/childless.gif\" alt=\"" . $pgv_lang["childless_family"] . "\" title=\"" . $pgv_lang["childless_family"] . "\" /> " . $pgv_lang["childless_family"]; } else { print $pgv_lang["no_children"]; } print "</td></tr>"; } else { print "<tr>\n"; print_sosa_number($sosa, $childid); print "<td valign=\"top\">"; print_pedigree_person($childid, 1, $show_famlink, 0, $personcount); $personcount++; print "</td></tr>\n"; } } print "</table><br />"; if ($view != "preview" && $sosa == 0 && PGV_USER_CAN_EDIT) { print_help_link("add_child_help", "qm", "add_child_to_family"); print "<a href=\"javascript:;\" onclick=\"return addnewchild('{$famid}','');\">" . $pgv_lang["add_child_to_family"] . "</a>"; print "<span style='white-space:nowrap;'>"; print " <a href=\"javascript:;\" onclick=\"return addnewchild('{$famid}','M');\">[" . Person::sexImage('M', 'small', $pgv_lang['son']) . "]</a>"; print " <a href=\"javascript:;\" onclick=\"return addnewchild('{$famid}','F');\">[" . Person::sexImage('F', 'small', $pgv_lang['daughter']) . "]</a>"; print "</span>"; } }