当前位置: 首页>>代码示例>>PHP>>正文


PHP Functions::getAssociateRelationshipName方法代码示例

本文整理汇总了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() . '&amp;pid2=' . $person->getXref() . '&amp;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;
 }
开发者ID:jflash,项目名称:webtrees,代码行数:60,代码来源:FunctionsPrintFacts.php


注:本文中的Fisharebest\Webtrees\Functions\Functions::getAssociateRelationshipName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。