本文整理汇总了PHP中Fisharebest\Webtrees\Family::getChildren方法的典型用法代码示例。如果您正苦于以下问题:PHP Family::getChildren方法的具体用法?PHP Family::getChildren怎么用?PHP Family::getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Family
的用法示例。
在下文中一共展示了Family::getChildren方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: censusNavigatorFamily
/**
* Create a family on the census navigator.
*
* @param CensusInterface $census
* @param Family $family
* @param Individual $head
*
* @return string
*/
public static function censusNavigatorFamily(CensusInterface $census, Family $family, Individual $head)
{
$headImg2 = '<i class="icon-button_head" title="' . I18N::translate('Head of household') . '"></i>';
foreach ($family->getSpouses() as $spouse) {
$menu = new Menu(Functions::getCloseRelationshipName($head, $spouse));
foreach ($spouse->getChildFamilies() as $grandparents) {
foreach ($grandparents->getSpouses() as $grandparent) {
$submenu = new Menu(Functions::getCloseRelationshipName($head, $grandparent) . ' - ' . $grandparent->getFullName(), '#', '', array('onclick' => 'return appendCensusRow("' . Filter::escapeJs(self::censusTableRow($census, $grandparent, $head)) . '");'));
$submenu->addClass('submenuitem', '');
$menu->addSubmenu($submenu);
$menu->addClass('', 'submenu');
}
}
?>
<tr>
<td class="optionbox">
<?php
echo $menu->getMenu();
?>
</td>
<td class="facts_value nowrap">
<a href="#" onclick="return appendCensusRow('<?php
echo Filter::escapeJs(self::censusTableRow($census, $spouse, $head));
?>
');">
<?php
echo $spouse->getFullName();
?>
</a>
</td>
<td class="facts_value">
<?php
if ($head !== $spouse) {
?>
<a href="edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=<?php
echo $spouse->getXref();
?>
&gedcom=<?php
echo $spouse->getTree()->getNameUrl();
?>
&census=<?php
echo get_class($census);
?>
">
<?php
echo $headImg2;
?>
</a>
<?php
}
?>
</td>
</tr>
<?php
}
foreach ($family->getChildren() as $child) {
$menu = new Menu(Functions::getCloseRelationshipName($head, $child));
foreach ($child->getSpouseFamilies() as $spouse_family) {
foreach ($spouse_family->getSpouses() as $spouse_family_spouse) {
if ($spouse_family_spouse != $child) {
$submenu = new Menu(Functions::getCloseRelationshipName($head, $spouse_family_spouse) . ' - ' . $spouse_family_spouse->getFullName(), '#', '', array('onclick' => 'return appendCensusRow("' . Filter::escapeJs(self::censusTableRow($census, $spouse_family_spouse, $head)) . '");'));
$submenu->addClass('submenuitem', '');
$menu->addSubmenu($submenu);
$menu->addClass('', 'submenu');
}
}
foreach ($spouse_family->getChildren() as $spouse_family_child) {
$submenu = new Menu(Functions::getCloseRelationshipName($head, $spouse_family_child) . ' - ' . $spouse_family_child->getFullName(), '#', '', array('onclick' => 'return appendCensusRow("' . Filter::escapeJs(self::censusTableRow($census, $spouse_family_child, $head)) . '");'));
$submenu->addClass('submenuitem', '');
$menu->addSubmenu($submenu);
$menu->addClass('', 'submenu');
}
}
?>
<tr>
<td class="optionbox">
<?php
echo $menu->getMenu();
?>
</td>
<td class="facts_value">
<a href="#" onclick="return appendCensusRow('<?php
echo Filter::escapeJs(self::censusTableRow($census, $child, $head));
?>
');">
<?php
echo $child->getFullName();
?>
</a>
</td>
<td class="facts_value">
//.........这里部分代码省略.........
示例2: print_navigator_family
/**
* Display family members with clickable links
*
* @param Family $family
* @param Individual $individual
*/
function print_navigator_family(Family $family, Individual $individual)
{
foreach ($family->getSpouses() as $spouse) {
?>
<tr class="fact_value">
<td class="facts_value">
<a href="edit_interface.php?action=addmedia_links&noteid=newnote&pid=<?php
echo $spouse->getXref();
?>
&gedcom=<?php
echo $spouse->getTree()->getNameUrl();
?>
">
<i class="headimg vmiddle icon-button_head"></i>
</a>
</td>
<td class="facts_value" >
<a href="#" onclick="opener.insertRowToTable('<?php
echo $spouse->getXref();
?>
', '<?php
echo Filter::escapeJs($spouse->getFullName());
?>
', '', '', '', '', '', '', '', '');">
<?php
echo $spouse === $individual ? '<b>' : '';
?>
<?php
echo $spouse->getFullName();
?>
<?php
echo $spouse->getLifeSpan();
?>
<?php
echo $spouse === $individual ? '</b>' : '';
?>
</a>
</td>
<tr>
<?php
}
foreach ($family->getChildren() as $child) {
?>
<tr>
<td class="facts_value" >
<a href="edit_interface.php?action=addmedia_links&noteid=newnote&pid=<?php
echo $child->getXref();
?>
&gedcom=<?php
echo $child->getTree()->getNameUrl();
?>
">
<i class="headimg vmiddle icon-button_head"></i>
</a>
</td>
<td class="facts_value">
<a href="#" onclick="opener.insertRowToTable('<?php
echo $child->getXref();
?>
', '<?php
echo Filter::escapeJs($child->getFullName());
?>
', '', '', '', '', '', '', '', '');">
<?php
echo $child === $individual ? '<b>' : '';
?>
<?php
echo $child->getFullName();
?>
<?php
echo $child->getLifeSpan();
?>
<?php
echo $child === $individual ? '</b>' : '';
?>
</a>
</td>
</tr>
<?php
}
}
示例3: childFacts
/**
* Get the events of children and grandchildren.
*
* @param Individual $person
* @param Family $family
* @param string $option
* @param string $relation
*
* @return Fact[]
*/
private static function childFacts(Individual $person, Family $family, $option, $relation)
{
global $controller;
$SHOW_RELATIVES_EVENTS = $person->getTree()->getPreference('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::childFacts($person, $cfamily, '_GCHI', 'son') as $fact) {
$facts[] = $fact;
}
break;
case 'F':
foreach (self::childFacts($person, $cfamily, '_GCHI', 'dau') as $fact) {
$facts[] = $fact;
}
break;
default:
foreach (self::childFacts($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() && Date::compare($birt_date, $sgdate) <= 0 && 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();
if ($sgdate->isOK() && Date::compare($birt_date, $sgdate) <= 0 && 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;
}
}
}
}
//.........这里部分代码省略.........
示例4: printFamilyChildren
/**
* print the children table for a family
*
* @param Family $family family
* @param string $childid child ID
* @param int $sosa child sosa number
* @param string $label indi label (descendancy booklet)
* @param int $show_cousins display cousins on chart
* @param int $show_full large or small box
*/
public static function printFamilyChildren(Family $family, $childid = '', $sosa = 0, $label = '', $show_cousins = 0, $show_full = 1)
{
if ($show_full) {
$bheight = Theme::theme()->parameter('chart-box-y');
} else {
$bheight = Theme::theme()->parameter('compact-chart-box-y');
}
$pbheight = $bheight + 14;
$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 I18N::translate('No children');
} else {
echo I18N::plural('%s child', '%s children', $numchil, $numchil);
}
echo '</span>';
if ($sosa == 0 && Auth::isEditor($family->getTree())) {
echo '<br>';
echo "<a href=\"#\" onclick=\"return add_child_to_family('", $family->getXref(), "', 'U');\">" . 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="', I18N::translate('son'), '"></a>';
echo ' <a class="icon-sex_f_15x15" href="#" onclick="return add_child_to_family(\'', $family->getXref(), '\', \'F\');" title="', 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) {
self::printSosaNumber($sosa, $childid);
} elseif (empty($label)) {
self::printSosaNumber("");
} else {
self::printSosaNumber($label . $nchi++ . ".");
}
}
if ($child->isPendingAddtion()) {
echo '<td valign="middle" class="new">';
} elseif ($child->isPendingDeletion()) {
echo '<td valign="middle" class="old">';
} else {
echo '<td valign="middle">';
}
FunctionsPrint::printPedigreePerson($child, $show_full);
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 (I18N::direction() === 'rtl') {
echo ' align="left">';
} else {
echo ' align="right">';
}
//find out how many cousins there are to establish vertical line on second families
$fchildren = $famids[$f]->getChildren();
$kids = count($fchildren);
$Pheader = ($bheight - 1) * $kids;
$PBadj = 6;
// default
if ($show_cousins > 0) {
if ($kids) {
$PBadj = max(0, $Pheader / 2 + $kids * 4.5);
}
}
if ($f == $maxfam) {
echo "<img height=\"" . ($bheight / 2 + $PBadj) . "px\"";
} else {
echo "<img height=\"" . $pbheight . "px\"";
}
echo " width=\"3\" src=\"" . Theme::theme()->parameter('image-vline') . "\" alt=\"\">";
echo "</td>";
}
echo "<td class=\"details1\" valign=\"middle\" align=\"center\">";
//.........这里部分代码省略.........
示例5: drawFamily
/**
* Format a family.
*
* @param Family $family
* @param string $title
*/
private function drawFamily(Family $family, $title)
{
global $controller;
?>
<tr>
<td class="center" colspan="2">
<a class="famnav_title" href="<?php
echo $family->getHtmlUrl();
?>
">
<?php
echo $title;
?>
</a>
</td>
</tr>
<?php
foreach ($family->getSpouses() as $spouse) {
$menu = new Menu(Functions::getCloseRelationshipName($controller->record, $spouse));
$menu->addClass('', 'submenu flyout');
$menu->addSubmenu(new Menu($this->getParents($spouse)));
?>
<tr>
<td class="facts_label">
<?php
echo $menu->getMenu();
?>
</td>
<td class="center <?php
echo $controller->getPersonStyle($spouse);
?>
nam">
<a class="famnav_link" href="<?php
echo $spouse->getHtmlUrl();
?>
">
<?php
echo $spouse->getFullName();
?>
</a>
<div class="font9">
<?php
echo $spouse->getLifeSpan();
?>
</div>
</td>
</tr>
<?php
}
foreach ($family->getChildren() as $child) {
$menu = new Menu(Functions::getCloseRelationshipName($controller->record, $child));
$menu->addClass('', 'submenu flyout');
$menu->addSubmenu(new Menu($this->getFamily($child)));
?>
<tr>
<td class="facts_label">
<?php
echo $menu->getMenu();
?>
</td>
<td class="center <?php
echo $controller->getPersonStyle($child);
?>
nam">
<a class="famnav_link" href="<?php
echo $child->getHtmlUrl();
?>
">
<?php
echo $child->getFullName();
?>
</a>
<div class="font9">
<?php
echo $child->getLifeSpan();
?>
</div>
</td>
</tr>
<?php
}
}
示例6: printFamily
//.........这里部分代码省略.........
</td>
</tr>
<?php
}
///// CHIL /////
$child_number = 0;
foreach ($family->getFacts('CHIL', false, $access_level) as $fact) {
$person = $fact->getTarget();
if ($person instanceof Individual) {
if ($fact->isPendingAddition()) {
$child_number++;
$class = 'facts_label new';
} elseif ($fact->isPendingDeletion()) {
$class = 'facts_label old';
} else {
$child_number++;
$class = 'facts_label';
}
$next = new Date('');
foreach ($person->getFacts(WT_EVENTS_BIRT, true) 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 Functions::getCloseRelationshipName($controller->record, $person);
?>
</td>
<td class="<?php
echo $controller->getPersonStyle($person);
?>
">
<?php
echo Theme::theme()->individualBoxLarge($person);
?>
</td>
</tr>
<?php
$prev = $next;
}
}
// Re-order children / add a new child
if ($family->canEdit()) {
if ($type == 'FAMS') {
$add_child_text = I18N::translate('Add a son or daughter');
} else {
$add_child_text = I18N::translate('Add a brother or sister');
}
?>
<tr class="noprint">
<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 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 $add_child_text;
?>
</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;
}
示例7: addFamilyDescendancy
/**
* Recursive function to traverse the tree
*
* @param Family|null $family
* @param int $level
*/
public function addFamilyDescendancy(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
}
}
}
}
示例8: loadChildren
/**
* Display descendants.
*
* @param Family $family
* @param int $generations
*
* @return string
*/
public function loadChildren(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">' . I18N::translate('No children') . '</li>';
}
}
if ($out) {
return '<ul>' . $out . '</ul>';
} else {
return '';
}
}
示例9: printFamilyDescendancy
/**
* print a family descendancy
*
* @param Individual $person
* @param Family $family
* @param int $depth the descendancy depth to show
*/
private function printFamilyDescendancy(Individual $person, Family $family, $depth)
{
$uid = Uuid::uuid4();
// create a unique ID
// print marriage info
echo '<li>';
echo '<img src="', Theme::theme()->parameter('image-spacer'), '" height="2" width="', Theme::theme()->parameter('chart-descendancy-indent') + 4, '">';
echo '<span class="details1">';
echo "<a href=\"#\" onclick=\"expand_layer('" . $uid . "'); return false;\" class=\"top\"><i id=\"" . $uid . "_img\" class=\"icon-minus\" title=\"" . I18N::translate('View this 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 id="' . $uid . '" class="generation">';
echo '<li>';
echo '<table><tr><td>';
FunctionsPrint::printPedigreePerson($spouse, $this->showFull());
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) {
FunctionsCharts::printUrlArrow('?rootid=' . $parent->getXref() . '&generations=' . $this->generations . '&chart_style=' . $this->chart_style . '&show_full=' . $this->showFull() . '&ged=' . $parent->getTree()->getNameUrl(), I18N::translate('Start at parents'), 2);
// only show the arrow for one of the parents
break;
}
}
}
if ($this->showFull()) {
echo '<br><br> ';
}
echo '</td></tr>';
// children
$children = $family->getChildren();
echo '<tr><td colspan="3" class="details1" > ';
if ($children) {
echo GedcomTag::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 GedcomTag::getLabel('NCHI') . ': ' . count($children);
} else {
echo I18N::translate('No children');
}
}
echo '</td></tr></table>';
echo '</li>';
if ($depth > 1) {
foreach ($children as $child) {
$this->printChildDescendancy($child, $depth - 1);
}
}
echo '</ul>';
echo '</li>';
}