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; }