diff options
| -rw-r--r-- | app/Functions/FunctionsPrint.php | 69 | ||||
| -rw-r--r-- | app/Functions/FunctionsPrintFacts.php | 72 | ||||
| -rw-r--r-- | app/Module/IndividualFactsTabModule.php | 14 | ||||
| -rw-r--r-- | expand_view.php | 37 |
4 files changed, 88 insertions, 104 deletions
diff --git a/app/Functions/FunctionsPrint.php b/app/Functions/FunctionsPrint.php index f6332d3958..f2220ada13 100644 --- a/app/Functions/FunctionsPrint.php +++ b/app/Functions/FunctionsPrint.php @@ -15,13 +15,11 @@ */ namespace Fisharebest\Webtrees\Functions; -use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Controller\SearchController; use Fisharebest\Webtrees\Date; use Fisharebest\Webtrees\Fact; use Fisharebest\Webtrees\Family; use Fisharebest\Webtrees\Filter; -use Fisharebest\Webtrees\GedcomCode\GedcomCodeRela; use Fisharebest\Webtrees\GedcomCode\GedcomCodeStat; use Fisharebest\Webtrees\GedcomCode\GedcomCodeTemp; use Fisharebest\Webtrees\GedcomRecord; @@ -240,73 +238,6 @@ class FunctionsPrint { } /** - * Print the associations from the associated individuals in $event to the individuals in $record - * - * @param Fact $event - * - * @return string - */ - public 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; - } - - /** * Format age of parents in HTML * * @param Individual $person child diff --git a/app/Functions/FunctionsPrintFacts.php b/app/Functions/FunctionsPrintFacts.php index ae92ab894a..edb4c6d679 100644 --- a/app/Functions/FunctionsPrintFacts.php +++ b/app/Functions/FunctionsPrintFacts.php @@ -22,6 +22,7 @@ use Fisharebest\Webtrees\Family; use Fisharebest\Webtrees\Filter; use Fisharebest\Webtrees\GedcomCode\GedcomCodeAdop; use Fisharebest\Webtrees\GedcomCode\GedcomCodeQuay; +use Fisharebest\Webtrees\GedcomCode\GedcomCodeRela; use Fisharebest\Webtrees\GedcomRecord; use Fisharebest\Webtrees\GedcomTag; use Fisharebest\Webtrees\I18N; @@ -353,7 +354,9 @@ class FunctionsPrintFacts { } // Print the associates of this fact/event - echo FunctionsPrint::formatAssociateRelationship($fact); + if ($fact->getFactId() !== 'asso') { + echo self::formatAssociateRelationship($fact); + } // Print any other "2 XXXX" attributes, in the order in which they appear. preg_match_all('/\n2 (' . WT_REGEX_TAG . ') (.+)/', $fact->getGedcom(), $matches, PREG_SET_ORDER); @@ -480,6 +483,73 @@ class FunctionsPrintFacts { } /** + * 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; + } + + /** * print a repository record * * find and print repository information attached to a source diff --git a/app/Module/IndividualFactsTabModule.php b/app/Module/IndividualFactsTabModule.php index 6e9a7a541c..2d04b55757 100644 --- a/app/Module/IndividualFactsTabModule.php +++ b/app/Module/IndividualFactsTabModule.php @@ -514,20 +514,6 @@ class IndividualFactsTabModule extends AbstractModule implements ModuleTabInterf } } 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; - default: - $factrec .= "\n3 RELA godchild"; - break; - } - } } $facts[] = new Fact($factrec, $associate, 'asso'); } diff --git a/expand_view.php b/expand_view.php index e7d5b3c4de..e6e1b9171b 100644 --- a/expand_view.php +++ b/expand_view.php @@ -44,38 +44,35 @@ Functions::sortFacts($facts); foreach ($facts as $fact) { switch ($fact->getTag()) { - case 'SEX': - case 'FAMS': + case 'ADDR': + case 'ALIA': + case 'ASSO': + case 'CHAN': + case 'CHIL': + case 'EMAIL': case 'FAMC': + case 'FAMS': + case 'HUSB': case 'NAME': - case 'TITL': case 'NOTE': - case 'SOUR': - case 'SSN': case 'OBJE': - case 'HUSB': - case 'WIFE': - case 'CHIL': - case 'ALIA': - case 'ADDR': case 'PHON': + case 'RESI': + case 'RESN': + case 'SEX': + case 'SOUR': + case 'SSN': case 'SUBM': - case '_EMAIL': - case 'CHAN': + case 'TITL': case 'URL': - case 'EMAIL': + case 'WIFE': case 'WWW': - case 'RESI': - case 'RESN': - case '_UID': + case '_EMAIL': case '_TODO': + case '_UID': case '_WT_OBJE_SORT': // Do not show these break; - case 'ASSO': - // Associates - echo FunctionsPrint::formatAssociateRelationship($fact); - break; default: // Simple version of FunctionsPrintFacts::print_fact() echo $fact->summary(); |
