本文整理汇总了PHP中Fisharebest\Webtrees\Family::getSpouse方法的典型用法代码示例。如果您正苦于以下问题:PHP Family::getSpouse方法的具体用法?PHP Family::getSpouse怎么用?PHP Family::getSpouse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Family
的用法示例。
在下文中一共展示了Family::getSpouse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSpouseFamilyLabel
/**
* Get the description for the family.
*
* For example, "XXX's family with new wife".
*
* @param Family $family
* @param Individual $individual
*
* @return string
*/
public function getSpouseFamilyLabel(Family $family, Individual $individual)
{
$spouse = $family->getSpouse($individual);
if ($spouse) {
return I18N::translate('Family with %s', $spouse->getFullName());
} else {
return $family->getFullName();
}
}
示例2: getStepFamilyLabel
/**
* Create a label for a step family
*
* @param Family $step_family
*
* @return string
*/
public function getStepFamilyLabel(Family $step_family)
{
foreach ($this->getChildFamilies() as $family) {
if ($family !== $step_family) {
// Must be a step-family
foreach ($family->getSpouses() as $parent) {
foreach ($step_family->getSpouses() as $step_parent) {
if ($parent === $step_parent) {
// One common parent - must be a step family
if ($parent->getSex() == 'M') {
// Father’s family with someone else
if ($step_family->getSpouse($step_parent)) {
return I18N::translate('Father’s family with %s', $step_family->getSpouse($step_parent)->getFullName());
} else {
return I18N::translate('Father’s family with an unknown individual');
}
} else {
// Mother’s family with someone else
if ($step_family->getSpouse($step_parent)) {
return I18N::translate('Mother’s family with %s', $step_family->getSpouse($step_parent)->getFullName());
} else {
return I18N::translate('Mother’s family with an unknown individual');
}
}
}
}
}
}
}
// Perahps same parents - but a different family record?
return I18N::translate('Family with parents');
}
示例3: getFamilyLi
/**
* Format a family in a list.
*
* @param Family $family
* @param Individual $person
* @param int $generations
*
* @return string
*/
public function getFamilyLi(Family $family, Individual $person, $generations = 0)
{
$spouse = $family->getSpouse($person);
if ($spouse) {
$spouse_name = $spouse->getSexImage() . $spouse->getFullName();
$spouse_link = '<a class="icon-button_indi" href="' . $spouse->getHtmlUrl() . '"></a>';
} else {
$spouse_name = '';
$spouse_link = '';
}
$marryear = $family->getMarriageYear();
$marr = $marryear ? '<i class="icon-rings"></i>' . $marryear : '';
return '<li class="sb_desc_indi_li">' . '<a class="sb_desc_indi" href="#"><i class="plusminus icon-minus"></i>' . $spouse_name . $marr . '</a>' . $spouse_link . '<a href="' . $family->getHtmlUrl() . '" class="icon-button_family"></a>' . '<div>' . $this->loadChildren($family, $generations) . '</div>' . '</li>';
}
示例4: drawPerson
/**
* Draw a person in the tree
*
* @param 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 Family $pfamily
* @param string $order first (1), last(2), unique(0), or empty. Required for drawing lines between boxes
* @param bool $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(Individual $person, $gen, $state, Family $pfamily = null, $order = null, $isRoot = false)
{
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="' . I18N::direction() . '" style="text-align: ' . (I18N::direction() === 'rtl' ? 'right' : 'left') . '; direction: ' . I18N::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);
} elseif ($spouse_parents && $spouse_parents->getWife()) {
$fop[] = array($spouse_parents->getWife(), $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>';
}
//.........这里部分代码省略.........
示例5: 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>';
}