diff options
| author | Greg Roach <greg@subaqua.co.uk> | 2022-11-06 15:58:50 +0000 |
|---|---|---|
| committer | Greg Roach <greg@subaqua.co.uk> | 2022-11-06 15:59:12 +0000 |
| commit | f934075922fa819544d437a7c258b0c884f11178 (patch) | |
| tree | 3dd939e780e0c2fd0a613f0ebbf822935de59830 /app | |
| parent | 6f25e6714522c6dd70d5f7d6910917146de406d4 (diff) | |
| download | webtrees-f934075922fa819544d437a7c258b0c884f11178.tar.gz webtrees-f934075922fa819544d437a7c258b0c884f11178.tar.bz2 webtrees-f934075922fa819544d437a7c258b0c884f11178.zip | |
Fix:#4589 FAM:NCHI:* is only valid in GEDCOM 7
Diffstat (limited to 'app')
| -rw-r--r-- | app/CustomTags/Gedcom7.php | 3 | ||||
| -rw-r--r-- | app/Elements/CountOfChildrenFam.php | 36 | ||||
| -rw-r--r-- | app/Gedcom.php | 28 | ||||
| -rw-r--r-- | app/Http/RequestHandlers/SiteTagsAction.php | 4 | ||||
| -rw-r--r-- | app/Http/RequestHandlers/SiteTagsPage.php | 7 |
5 files changed, 74 insertions, 4 deletions
diff --git a/app/CustomTags/Gedcom7.php b/app/CustomTags/Gedcom7.php index 3e3faf8d48..e2f61efc9e 100644 --- a/app/CustomTags/Gedcom7.php +++ b/app/CustomTags/Gedcom7.php @@ -21,10 +21,12 @@ namespace Fisharebest\Webtrees\CustomTags; use Fisharebest\Webtrees\Contracts\CustomTagInterface; use Fisharebest\Webtrees\Contracts\ElementInterface; +use Fisharebest\Webtrees\Elements\CountOfChildren; use Fisharebest\Webtrees\Elements\Creation; use Fisharebest\Webtrees\Elements\CustomElement; use Fisharebest\Webtrees\Elements\DateValueExact; use Fisharebest\Webtrees\Elements\DateValueToday; +use Fisharebest\Webtrees\Elements\EventOrFactClassification; use Fisharebest\Webtrees\Elements\ExternalIdentifier; use Fisharebest\Webtrees\Elements\ExternalIdentifierType; use Fisharebest\Webtrees\Elements\FamilyFact; @@ -91,6 +93,7 @@ class Gedcom7 implements CustomTagInterface 'FAM:EXID' => new ExternalIdentifier(I18N::translate('External identifier')), 'FAM:EXID:TYPE' => new ExternalIdentifierType(I18N::translate('Type')), 'FAM:FACT' => new FamilyFact(I18N::translate('Fact')), + 'FAM:FACT:TYPE' => new EventOrFactClassification(I18N::translate('Type of fact')), 'FAM:REFN' => new UserReferenceNumber(I18N::translate('Reference number')), 'FAM:REFN:TYPE' => new UserReferenceType(I18N::translate('Type')), 'FAM:SNOTE' => new XrefSharedNote(I18N::translate('Shared note')), diff --git a/app/Elements/CountOfChildrenFam.php b/app/Elements/CountOfChildrenFam.php new file mode 100644 index 0000000000..545881dff7 --- /dev/null +++ b/app/Elements/CountOfChildrenFam.php @@ -0,0 +1,36 @@ +<?php + +/** + * webtrees: online genealogy + * Copyright (C) 2022 webtrees development team + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +declare(strict_types=1); + +namespace Fisharebest\Webtrees\Elements; + +use Fisharebest\Webtrees\Tree; + +/** + * COUNT_OF_CHILDREN := {Size=1:3} + * The known number of children of this individual from all marriages or, if + * subordinate to a family record, the reported number of children known to + * belong to this family, regardless of whether the associated children are + * represented in the corresponding structure. This is not necessarily the + * count of children listed in a family structure. + */ +class CountOfChildrenFam extends CountOfChildren +{ + // FAM:NCHI has no subtags, unlike INDI:NCHI + protected const SUBTAGS = []; +} diff --git a/app/Gedcom.php b/app/Gedcom.php index e4d13ea79e..47c07286a4 100644 --- a/app/Gedcom.php +++ b/app/Gedcom.php @@ -79,6 +79,7 @@ use Fisharebest\Webtrees\Elements\Coordinates; use Fisharebest\Webtrees\Elements\CopyrightFile; use Fisharebest\Webtrees\Elements\CopyrightSourceData; use Fisharebest\Webtrees\Elements\CountOfChildren; +use Fisharebest\Webtrees\Elements\CountOfChildrenFam; use Fisharebest\Webtrees\Elements\CountOfMarriages; use Fisharebest\Webtrees\Elements\Cremation; use Fisharebest\Webtrees\Elements\CustomElement; @@ -467,7 +468,7 @@ class Gedcom 'FAM:MARR:PLAC' => new PlaceName(I18N::translate('Place of marriage')), 'FAM:MARR:TYPE' => new MarriageType(I18N::translate('Type of marriage')), 'FAM:MARS' => new MarriageSettlement(I18N::translate('Marriage settlement')), - 'FAM:NCHI' => new CountOfChildren(I18N::translate('Number of children')), + 'FAM:NCHI' => new CountOfChildrenFam(I18N::translate('Number of children')), 'FAM:NOTE' => new NoteStructure(I18N::translate('Note')), 'FAM:OBJE' => new XrefMedia(I18N::translate('Media object')), 'FAM:REFN' => new UserReferenceNumber(I18N::translate('Reference number')), @@ -896,8 +897,6 @@ class Gedcom { return [ 'FAM:CHAN:_WT_USER' => new WebtreesUser(I18N::translate('Author of last change')), - 'FAM:FACT' => new FamilyFact(I18N::translate('Fact')), - 'FAM:FACT:TYPE' => new EventOrFactClassification(I18N::translate('Type of fact')), 'FAM:*:_ASSO' => new XrefAssociate(I18N::translate('Associate')), 'FAM:*:_ASSO:NOTE' => new NoteStructure(I18N::translate('Note on association')), 'FAM:*:_ASSO:RELA' => new RelationIsDescriptor(I18N::translate('Relationship')), @@ -1024,6 +1023,29 @@ class Gedcom 'INDI' => array_map(static fn (string $tag): array => [$tag, '0:M'], $custom_individual_tags), ]; + // GEDCOM 7 tags + if (Site::getPreference('CUSTOM_FAM_FACT') === '1') { + $subtags['FAM'][] = ['FACT', '0:M']; + } + if (Site::getPreference('CUSTOM_FAM_NCHI') === '1') { + $subtags['FAM:NCHI'] = [ + ['TYPE', '0:1:?'], + ['DATE', '0:1'], + ['PLAC', '0:1:?'], + ['ADDR', '0:1:?'], + ['EMAIL', '0:1:?'], + ['WWW', '0:1:?'], + ['PHON', '0:1:?'], + ['FAX', '0:1:?'], + ['CAUS', '0:1:?'], + ['AGNC', '0:1:?'], + ['RELI', '0:1:?'], + ['NOTE', '0:M'], + ['OBJE', '0:M'], + ['SOUR', '0:M'], + ['RESN', '0:1'], + ]; + } if (Site::getPreference('CUSTOM_TIME_TAGS') === '1') { $subtags['INDI:BIRT:DATE'][] = ['TIME', '0:1']; $subtags['INDI:DEAT:DATE'][] = ['TIME', '0:1']; diff --git a/app/Http/RequestHandlers/SiteTagsAction.php b/app/Http/RequestHandlers/SiteTagsAction.php index 59dc8c4ae3..63d1f944ff 100644 --- a/app/Http/RequestHandlers/SiteTagsAction.php +++ b/app/Http/RequestHandlers/SiteTagsAction.php @@ -53,11 +53,15 @@ class SiteTagsAction implements RequestHandlerInterface $custom_family_tags = Validator::parsedBody($request)->array('custom_family_tags'); $custom_individual_tags = Validator::parsedBody($request)->array('custom_individual_tags'); $custom_gedcom_l_tags = Validator::parsedBody($request)->boolean('custom_gedcom_l_tags', false); + $custom_fam_fact = Validator::parsedBody($request)->boolean('custom_fam_fact', false); + $custom_fam_nchi = Validator::parsedBody($request)->boolean('custom_fam_nchi', false); $custom_time_tags = Validator::parsedBody($request)->boolean('custom_time_tags', false); Site::setPreference('CUSTOM_FAMILY_TAGS', implode(',', $custom_family_tags)); Site::setPreference('CUSTOM_INDIVIDUAL_TAGS', implode(',', $custom_individual_tags)); Site::setPreference('CUSTOM_GEDCOM_L_TAGS', (string) $custom_gedcom_l_tags); + Site::setPreference('CUSTOM_FAM_FACT', (string) $custom_fam_fact); + Site::setPreference('CUSTOM_FAM_NCHI', (string) $custom_fam_nchi); Site::setPreference('CUSTOM_TIME_TAGS', (string) $custom_time_tags); FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success'); diff --git a/app/Http/RequestHandlers/SiteTagsPage.php b/app/Http/RequestHandlers/SiteTagsPage.php index ac509f355f..ed4cce3741 100644 --- a/app/Http/RequestHandlers/SiteTagsPage.php +++ b/app/Http/RequestHandlers/SiteTagsPage.php @@ -62,8 +62,11 @@ class SiteTagsPage implements RequestHandlerInterface ); $custom_gedcom_l_tags = (bool) Site::getPreference('CUSTOM_GEDCOM_L_TAGS'); - $custom_time_tags = (bool) Site::getPreference('CUSTOM_TIME_TAGS'); + // GEDCOM 7 extensions + $custom_fam_fact = (bool) Site::getPreference('CUSTOM_FAM_FACT'); + $custom_fam_nchi = (bool) Site::getPreference('CUSTOM_FAM_NCHI'); + $custom_time_tags = (bool) Site::getPreference('CUSTOM_TIME_TAGS'); return $this->viewResponse('admin/tags', [ 'all_family_tags' => $all_family_tags->sort()->all(), @@ -71,6 +74,8 @@ class SiteTagsPage implements RequestHandlerInterface 'custom_family_tags' => $custom_family_tags, 'custom_gedcom_l_tags' => $custom_gedcom_l_tags, 'custom_individual_tags' => $custom_individual_tags, + 'custom_fam_fact' => $custom_fam_fact, + 'custom_fam_nchi' => $custom_fam_nchi, 'custom_time_tags' => $custom_time_tags, 'element_factory' => Registry::elementFactory(), 'title' => I18N::translate('GEDCOM tags'), |
