summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2015-07-09 21:15:24 +0100
committerGreg Roach <fisharebest@gmail.com>2015-07-09 21:15:24 +0100
commit3b5d3a3eab6f7f0281010ddb713e7e6d1092edd6 (patch)
tree63a747f646cf9567e3de7f969e993dc832c98559 /app
parent9152e6f4a92fd869ef51e0e6d1d55eb974c26232 (diff)
downloadwebtrees-3b5d3a3eab6f7f0281010ddb713e7e6d1092edd6.tar.gz
webtrees-3b5d3a3eab6f7f0281010ddb713e7e6d1092edd6.tar.bz2
webtrees-3b5d3a3eab6f7f0281010ddb713e7e6d1092edd6.zip
Fix #439 - ASSO/RELA of other individuals
Diffstat (limited to 'app')
-rw-r--r--app/Functions/FunctionsPrint.php69
-rw-r--r--app/Functions/FunctionsPrintFacts.php72
-rw-r--r--app/Module/IndividualFactsTabModule.php14
3 files changed, 71 insertions, 84 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() . '&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;
- }
-
- /**
* 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() . '&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;
+ }
+
+ /**
* 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');
}