本文整理汇总了PHP中Fisharebest\Webtrees\Functions\Functions::getAssociateRelationshipName方法的典型用法代码示例。如果您正苦于以下问题:PHP Functions::getAssociateRelationshipName方法的具体用法?PHP Functions::getAssociateRelationshipName怎么用?PHP Functions::getAssociateRelationshipName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Functions\Functions
的用法示例。
在下文中一共展示了Functions::getAssociateRelationshipName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formatAssociateRelationship
/**
* Print the associations from the associated individuals in $event to the individuals in $record
*
* @param Fact $event
*
* @return string
*/
private static function formatAssociateRelationship(Fact $event)
{
$parent = $event->getParent();
// To whom is this record an assocate?
if ($parent instanceof Individual) {
// On an individual page, we just show links to the person
$associates = array($parent);
} elseif ($parent instanceof Family) {
// On a family page, we show links to both spouses
$associates = $parent->getSpouses();
} else {
// On other pages, it does not make sense to show associates
return '';
}
preg_match_all('/^1 ASSO @(' . WT_REGEX_XREF . ')@((\\n[2-9].*)*)/', $event->getGedcom(), $amatches1, PREG_SET_ORDER);
preg_match_all('/\\n2 _?ASSO @(' . WT_REGEX_XREF . ')@((\\n[3-9].*)*)/', $event->getGedcom(), $amatches2, PREG_SET_ORDER);
$html = '';
// For each ASSO record
foreach (array_merge($amatches1, $amatches2) as $amatch) {
$person = Individual::getInstance($amatch[1], $event->getParent()->getTree());
if ($person && $person->canShowName()) {
// Is there a "RELA" tag
if (preg_match('/\\n[23] RELA (.+)/', $amatch[2], $rmatch)) {
// Use the supplied relationship as a label
$label = GedcomCodeRela::getValue($rmatch[1], $person);
} else {
// Use a default label
$label = GedcomTag::getLabel('ASSO', $person);
}
$values = array('<a href="' . $person->getHtmlUrl() . '">' . $person->getFullName() . '</a>');
foreach ($associates as $associate) {
$relationship_name = Functions::getAssociateRelationshipName($associate, $person);
if (!$relationship_name) {
$relationship_name = GedcomTag::getLabel('RELA');
}
if ($parent instanceof Family) {
// For family ASSO records (e.g. MARR), identify the spouse with a sex icon
$relationship_name .= $associate->getSexImage();
}
$values[] = '<a href="relationship.php?pid1=' . $associate->getXref() . '&pid2=' . $person->getXref() . '&ged=' . $associate->getTree()->getNameUrl() . '" rel="nofollow">' . $relationship_name . '</a>';
}
$value = implode(' — ', $values);
// Use same markup as GedcomTag::getLabelValue()
$asso = I18N::translate('<span class="label">%1$s:</span> <span class="field" dir="auto">%2$s</span>', $label, $value);
} elseif (!$person && Auth::isEditor($event->getParent()->getTree())) {
$asso = GedcomTag::getLabelValue('ASSO', '<span class="error">' . $amatch[1] . '</span>');
} else {
$asso = '';
}
$html .= '<div class="fact_ASSO">' . $asso . '</div>';
}
return $html;
}