private static function associate_facts(WT_Individual $person) { $facts = array(); $associates = array_merge($person->linkedIndividuals('ASSO'), $person->linkedIndividuals('_ASSO'), $person->linkedFamilies('ASSO'), $person->linkedFamilies('_ASSO')); foreach ($associates as $associate) { foreach ($associate->getFacts() as $fact) { $arec = $fact->getAttribute('_ASSO'); if (!$arec) { $arec = $fact->getAttribute('ASSO'); } if ($arec) { // Extract the important details from the fact $factrec = '1 ' . $fact->getTag(); if (preg_match('/\\n2 DATE .*/', $fact->getGedcom(), $match)) { $factrec .= $match[0]; } if (preg_match('/\\n2 PLAC .*/', $fact->getGedcom(), $match)) { $factrec .= $match[0]; } if ($associate instanceof WT_Family) { foreach ($associate->getSpouses() as $spouse) { $factrec .= "\n2 _ASSO @" . $spouse->getXref() . '@'; } } else { $factrec .= "\n2 _ASSO @" . $associate->getXref() . '@'; // CHR/BAPM events are commonly used. Generate the reverse relationship if (preg_match('/^(?:BAPM|CHR)$/', $fact->getTag()) && preg_match('/2 _?ASSO @(' . $person->getXref() . ')@\\n3 RELA god(?:parent|mother|father)/', $fact->getGedcom())) { switch ($associate->getSex()) { case 'M': $factrec .= "\n3 RELA godson"; break; case 'F': $factrec .= "\n3 RELA goddaughter"; break; case 'U': $factrec .= "\n3 RELA godchild"; break; } } } $facts[] = new WT_Fact($factrec, $associate, 'asso'); } } } return $facts; }