diff options
| author | Greg Roach <greg@subaqua.co.uk> | 2021-02-03 14:22:57 +0000 |
|---|---|---|
| committer | Greg Roach <greg@subaqua.co.uk> | 2021-02-03 14:36:30 +0000 |
| commit | e7e5b0150ad5d9683e615828caa3422931d9e9e1 (patch) | |
| tree | a8618cbcd34b419833c204ab1d3c7dc7f06a790a /app | |
| parent | c2ed51d13a57743094c11c8fe84befd9d4f158cd (diff) | |
| download | webtrees-e7e5b0150ad5d9683e615828caa3422931d9e9e1.tar.gz webtrees-e7e5b0150ad5d9683e615828caa3422931d9e9e1.tar.bz2 webtrees-e7e5b0150ad5d9683e615828caa3422931d9e9e1.zip | |
Fix: editing header record
Diffstat (limited to 'app')
| -rw-r--r-- | app/Elements/FamilyRecord.php | 30 | ||||
| -rw-r--r-- | app/Elements/HeaderRecord.php | 41 | ||||
| -rw-r--r-- | app/Elements/IndividualRecord.php | 32 | ||||
| -rw-r--r-- | app/Elements/LanguageId.php | 9 | ||||
| -rw-r--r-- | app/Factories/ElementFactory.php | 10 | ||||
| -rw-r--r-- | app/GedcomRecord.php | 2 | ||||
| -rw-r--r-- | app/Http/RequestHandlers/EditRecordAction.php | 8 |
7 files changed, 126 insertions, 6 deletions
diff --git a/app/Elements/FamilyRecord.php b/app/Elements/FamilyRecord.php new file mode 100644 index 0000000000..a3c085843c --- /dev/null +++ b/app/Elements/FamilyRecord.php @@ -0,0 +1,30 @@ +<?php + +/** + * webtrees: online genealogy + * Copyright (C) 2021 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; + +/** + * A level 0 family record + */ +class FamilyRecord extends AbstractElement +{ + protected const SUBTAGS = [ + 'MARR' => '0:1', + ]; +} diff --git a/app/Elements/HeaderRecord.php b/app/Elements/HeaderRecord.php new file mode 100644 index 0000000000..324d402ad4 --- /dev/null +++ b/app/Elements/HeaderRecord.php @@ -0,0 +1,41 @@ +<?php + +/** + * webtrees: online genealogy + * Copyright (C) 2021 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; + +/** + * A level 0 header record + */ +class HeaderRecord extends AbstractElement +{ + protected const SUBTAGS = [ + 'SOUR' => '1:1', + 'DEST' => '0:1', + 'DATE' => '0:1', + 'SUBM' => '1:1', + 'SUBN' => '0:1', + 'FILE' => '0:1', + 'COPR' => '0:1', + 'GEDC' => '0:1', + 'CHAR' => '0:1', + 'LANG' => '0:1', + 'PLAC' => '0:1', + 'NOTE' => '0:1', + ]; +} diff --git a/app/Elements/IndividualRecord.php b/app/Elements/IndividualRecord.php new file mode 100644 index 0000000000..988212b755 --- /dev/null +++ b/app/Elements/IndividualRecord.php @@ -0,0 +1,32 @@ +<?php + +/** + * webtrees: online genealogy + * Copyright (C) 2021 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; + +/** + * A level 0 individual record + */ +class IndividualRecord extends AbstractElement +{ + protected const SUBTAGS = [ + 'SEX' => '1:1', + 'BIRT' => '0:1', + 'DEAT' => '0:1', + ]; +} diff --git a/app/Elements/LanguageId.php b/app/Elements/LanguageId.php index de931e31cd..d8565b8d2f 100644 --- a/app/Elements/LanguageId.php +++ b/app/Elements/LanguageId.php @@ -91,6 +91,8 @@ use Fisharebest\Localization\Locale\LocaleVi; use Fisharebest\Localization\Locale\LocaleYi; use Fisharebest\Localization\Locale\LocaleYue; +use Fisharebest\Webtrees\I18N; + use function preg_replace_callback; /** @@ -123,7 +125,7 @@ class LanguageId extends AbstractElement */ public function values(): array { - return [ + $values = [ '' => '', 'Afrikaans' => (new LocaleAf())->endonym(), 'Albanian' => (new LocaleSq())->endonym(), @@ -212,5 +214,10 @@ class LanguageId extends AbstractElement //'Wendic' => (new LocaleWen())->endonym(), 'Yiddish' => (new LocaleYi())->endonym(), ]; + + uasort($values, [I18N::class, 'strcasecmp']); + + return $values; + } } diff --git a/app/Factories/ElementFactory.php b/app/Factories/ElementFactory.php index 0f42b0511f..11ae45a4ae 100644 --- a/app/Factories/ElementFactory.php +++ b/app/Factories/ElementFactory.php @@ -77,6 +77,7 @@ use Fisharebest\Webtrees\Elements\EventDescriptor; use Fisharebest\Webtrees\Elements\EventOrFactClassification; use Fisharebest\Webtrees\Elements\EventsRecorded; use Fisharebest\Webtrees\Elements\EventTypeCitedFrom; +use Fisharebest\Webtrees\Elements\FamilyRecord; use Fisharebest\Webtrees\Elements\FileName; use Fisharebest\Webtrees\Elements\FirstCommunion; use Fisharebest\Webtrees\Elements\Form; @@ -84,7 +85,9 @@ use Fisharebest\Webtrees\Elements\Gedcom; use Fisharebest\Webtrees\Elements\GenerationsOfAncestors; use Fisharebest\Webtrees\Elements\GenerationsOfDescendants; use Fisharebest\Webtrees\Elements\Graduation; +use Fisharebest\Webtrees\Elements\HeaderRecord; use Fisharebest\Webtrees\Elements\Immigration; +use Fisharebest\Webtrees\Elements\IndividualRecord; use Fisharebest\Webtrees\Elements\LanguageId; use Fisharebest\Webtrees\Elements\LdsBaptism; use Fisharebest\Webtrees\Elements\LdsBaptismDateStatus; @@ -256,7 +259,7 @@ class ElementFactory implements ElementFactoryInterface if ($this->elements === null) { // Custom tags are indicated with *** $this->elements = [ - 'FAM' => new EmptyElement(I18N::translate('Family')), + 'FAM' => new FamilyRecord(I18N::translate('Family')), 'FAM:*:ADDR' => new AddressLine(I18N::translate('Address')), 'FAM:*:ADDR:ADR1' => new AddressLine1(I18N::translate('Address line 1')), 'FAM:*:ADDR:ADR2' => new AddressLine2(I18N::translate('Address line 2')), @@ -356,7 +359,7 @@ class ElementFactory implements ElementFactoryInterface 'FAM:SUBM' => new XrefSubmitter(I18N::translate('Submitter')), 'FAM:WIFE' => new XrefIndividual(I18N::translate('Wife')), 'FAM:_UID' => new PafUid(I18N::translate('Unique identifier')), // *** - 'HEAD' => new EmptyElement(I18N::translate('Header')), + 'HEAD' => new HeaderRecord(I18N::translate('Header')), 'HEAD:CHAR' => new CharacterSet(I18N::translate('Character set')), 'HEAD:CHAR:VERS' => new VersionNumber(I18N::translate('Version')), 'HEAD:COPR' => new CopyrightFile(I18N::translate('Copyright')), @@ -367,6 +370,7 @@ class ElementFactory implements ElementFactoryInterface 'HEAD:GEDC' => new Gedcom(I18N::translate('GEDCOM file')), 'HEAD:GEDC:FORM' => new Form(I18N::translate('Format')), 'HEAD:GEDC:VERS' => new VersionNumber(I18N::translate('Version')), + 'HEAD:LANG' => new LanguageId(I18N::translate('Language')), 'HEAD:NOTE' => new ContentDescription(I18N::translate('Note')), 'HEAD:PLAC' => new EmptyElement(I18N::translate('Place'), ['FORM' => '1:1']), 'HEAD:PLAC:FORM' => new PlaceHierarchy(I18N::translate('Format')), @@ -391,7 +395,7 @@ class ElementFactory implements ElementFactoryInterface 'HEAD:SOUR:VERS' => new VersionNumber(I18N::translate('Version')), 'HEAD:SUBM' => new XrefSubmitter(I18N::translate('Submitter')), 'HEAD:SUBN' => new XrefSubmission(I18N::translate('Submission')), - 'INDI' => new EmptyElement(I18N::translate('Individual')), + 'INDI' => new IndividualRecord(I18N::translate('Individual')), 'INDI:*:ADDR' => new AddressLine(I18N::translate('Address')), 'INDI:*:ADDR:ADR1' => new AddressLine1(I18N::translate('Address line 1')), 'INDI:*:ADDR:ADR2' => new AddressLine2(I18N::translate('Address line 2')), diff --git a/app/GedcomRecord.php b/app/GedcomRecord.php index 4c62e78ede..0051ac5c05 100644 --- a/app/GedcomRecord.php +++ b/app/GedcomRecord.php @@ -1363,7 +1363,7 @@ class GedcomRecord * * @return string */ - public function insertMissingLevels(string $tag, string $gedcom): string + protected function insertMissingLevels(string $tag, string $gedcom): string { $next_level = substr_count($tag, ':') + 1; $factory = Registry::elementFactory(); diff --git a/app/Http/RequestHandlers/EditRecordAction.php b/app/Http/RequestHandlers/EditRecordAction.php index 69658e871a..adfe4e945a 100644 --- a/app/Http/RequestHandlers/EditRecordAction.php +++ b/app/Http/RequestHandlers/EditRecordAction.php @@ -20,6 +20,7 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fisharebest\Webtrees\Auth; +use Fisharebest\Webtrees\Header; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\GedcomEditService; use Fisharebest\Webtrees\Services\ModuleService; @@ -77,7 +78,12 @@ class EditRecordAction implements RequestHandlerInterface $tags = $params['tags']; $values = $params['values']; - $gedcom = '0 @' . $record->xref() . '@ ' . $record->tag() . "\n"; + if ($record->tag() === Header::RECORD_TYPE) { + $gedcom = '0 ' . $record->tag() . "\n"; + } else { + $gedcom = '0 @' . $record->xref() . '@ ' . $record->tag() . "\n"; + } + $gedcom .= $this->gedcom_edit_service->editLinesToGedcom($record::RECORD_TYPE, $levels, $tags, $values); $record->updateRecord($gedcom, !$keep_chan); |
