summaryrefslogtreecommitdiff
path: root/app/Functions/Functions.php
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2020-05-10 12:01:34 +0100
committerGreg Roach <greg@subaqua.co.uk>2020-05-10 12:14:42 +0100
commit71c7dbe976700ed2ddb484eb335d535a03fa104f (patch)
tree617cd76e5267a570c3c5c7a8ef374d251017c11d /app/Functions/Functions.php
parent2d65026fd8942de28fc1d119744d98cf3f9ba0fa (diff)
downloadwebtrees-71c7dbe976700ed2ddb484eb335d535a03fa104f.tar.gz
webtrees-71c7dbe976700ed2ddb484eb335d535a03fa104f.tar.bz2
webtrees-71c7dbe976700ed2ddb484eb335d535a03fa104f.zip
Fix: #3222, Fix: #567 - include fiance in relationship names
Diffstat (limited to 'app/Functions/Functions.php')
-rw-r--r--app/Functions/Functions.php72
1 files changed, 42 insertions, 30 deletions
diff --git a/app/Functions/Functions.php b/app/Functions/Functions.php
index 03f180ed60..66c8e53b99 100644
--- a/app/Functions/Functions.php
+++ b/app/Functions/Functions.php
@@ -21,6 +21,7 @@ namespace Fisharebest\Webtrees\Functions;
use Exception;
use Fisharebest\Webtrees\Auth;
+use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
@@ -618,39 +619,46 @@ class Functions
case 'par':
return I18N::translate('parent');
case 'hus':
- if ($person1 && $person2) {
+ if ($person1 instanceof Individual && $person2 instanceof Individual) {
+ // We had the linking family earlier, but lost it. Find it again.
foreach ($person1->spouseFamilies() as $family) {
if ($person2 === $family->spouse($person1)) {
- if ($family->facts(['MARR'], false, Auth::PRIV_HIDE)->isNotEmpty()) {
- if ($family->facts(Gedcom::DIVORCE_EVENTS, false, Auth::PRIV_HIDE)->isNotEmpty()) {
- return I18N::translate('ex-husband');
- }
+ $event = $family->facts(['ANUL', 'DIV', 'ENGA', 'MARR'], true, Auth::PRIV_HIDE, true)->last();
- return I18N::translate('husband');
- }
-
- if ($family->facts(Gedcom::DIVORCE_EVENTS, false, Auth::PRIV_HIDE)->isNotEmpty()) {
- return I18N::translateContext('MALE', 'ex-partner');
+ if ($event instanceof Fact) {
+ switch ($event->getTag()) {
+ case 'ANUL':
+ case 'DIV':
+ return I18N::translate('ex-husband');
+ case 'MARR':
+ return I18N::translate('husband');
+ case 'ENGA':
+ return I18N::translate('fiancé');
+ }
}
}
}
}
return I18N::translateContext('MALE', 'partner');
+
case 'wif':
- if ($person1 && $person2) {
+ if ($person1 instanceof Individual && $person2 instanceof Individual) {
+ // We had the linking family earlier, but lost it. Find it again.
foreach ($person1->spouseFamilies() as $family) {
if ($person2 === $family->spouse($person1)) {
- if ($family->facts(['MARR'], false, Auth::PRIV_HIDE)->isNotEmpty()) {
- if ($family->facts(Gedcom::DIVORCE_EVENTS, false, Auth::PRIV_HIDE)->isNotEmpty()) {
- return I18N::translate('ex-wife');
- }
+ $event = $family->facts(['ANUL', 'DIV', 'ENGA', 'MARR'], true, Auth::PRIV_HIDE, true)->last();
- return I18N::translate('wife');
- }
-
- if ($family->facts(Gedcom::DIVORCE_EVENTS, false, Auth::PRIV_HIDE)->isNotEmpty()) {
- return I18N::translateContext('FEMALE', 'ex-partner');
+ if ($event instanceof Fact) {
+ switch ($event->getTag()) {
+ case 'ANUL':
+ case 'DIV':
+ return I18N::translate('ex-wife');
+ case 'MARR':
+ return I18N::translate('wife');
+ case 'ENGA':
+ return I18N::translate('fiancée');
+ }
}
}
}
@@ -658,25 +666,29 @@ class Functions
return I18N::translateContext('FEMALE', 'partner');
case 'spo':
- if ($person1 && $person2) {
+ if ($person1 instanceof Individual && $person2 instanceof Individual) {
+ // We had the linking family earlier, but lost it. Find it again.
foreach ($person1->spouseFamilies() as $family) {
if ($person2 === $family->spouse($person1)) {
- if ($family->facts(['MARR'], false, Auth::PRIV_HIDE)->isNotEmpty()) {
- if ($family->facts(Gedcom::DIVORCE_EVENTS, false, Auth::PRIV_HIDE)->isNotEmpty()) {
- return I18N::translate('ex-spouse');
- }
+ $event = $family->facts(['ANUL', 'DIV', 'ENGA', 'MARR'], true, Auth::PRIV_HIDE, true)->last();
- return I18N::translate('spouse');
- }
-
- if ($family->facts(Gedcom::DIVORCE_EVENTS, false, Auth::PRIV_HIDE)->isNotEmpty()) {
- return I18N::translate('ex-partner');
+ if ($event instanceof Fact) {
+ switch ($event->getTag()) {
+ case 'ANUL':
+ case 'DIV':
+ return I18N::translate('ex-spouse');
+ case 'MARR':
+ return I18N::translate('spouse');
+ case 'ENGA':
+ return I18N::translate('fiancé(e)');
+ }
}
}
}
}
return I18N::translate('partner');
+
case 'son':
return I18N::translate('son');
case 'dau':