summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2021-06-06 14:59:05 +0100
committerGreg Roach <greg@subaqua.co.uk>2021-06-12 13:26:01 +0100
commitc8183f294aedbaa1f62c070929381961858fb914 (patch)
treecb6c1fc031077a003a4ee2db2cf7e4e5797881e2 /app
parent8a07c98e2c323f7fe8deb3ac46485d8082b4b795 (diff)
downloadwebtrees-c8183f294aedbaa1f62c070929381961858fb914.tar.gz
webtrees-c8183f294aedbaa1f62c070929381961858fb914.tar.bz2
webtrees-c8183f294aedbaa1f62c070929381961858fb914.zip
Configure GEDCOM tags
Diffstat (limited to 'app')
-rw-r--r--app/Factories/ElementFactory.php4
-rw-r--r--app/Gedcom.php61
-rw-r--r--app/GedcomRecord.php30
-rw-r--r--app/Http/RequestHandlers/SiteTagsAction.php57
-rw-r--r--app/Http/RequestHandlers/SiteTagsPage.php50
-rw-r--r--app/Http/Routes/WebRoutes.php4
-rw-r--r--app/Module/CustomTagsWebtrees.php2
-rw-r--r--app/Services/GedcomEditService.php2
-rw-r--r--app/Site.php2
9 files changed, 206 insertions, 6 deletions
diff --git a/app/Factories/ElementFactory.php b/app/Factories/ElementFactory.php
index 5a6177e011..b23377a876 100644
--- a/app/Factories/ElementFactory.php
+++ b/app/Factories/ElementFactory.php
@@ -317,7 +317,7 @@ class ElementFactory implements ElementFactoryInterface
'FAM:*:WIFE:AGE' => new AgeAtEvent(I18N::translate('Wife’s age')),
'FAM:*:WWW' => new AddressWebPage(I18N::translate('URL')),
'FAM:ANUL' => new Annulment(I18N::translate('Annulment')),
- 'FAM:CENS' => new Census(I18N::translate('Census')),
+ 'FAM:CENS' => new Census(I18N::translate('Family census')),
'FAM:CHAN' => new Change(I18N::translate('Last change')),
'FAM:CHAN:DATE' => new ChangeDate(I18N::translate('Date of last change')),
'FAM:CHAN:DATE:TIME' => new TimeValue(I18N::translate('Time')),
@@ -345,7 +345,7 @@ class ElementFactory implements ElementFactoryInterface
'FAM:OBJE' => new XrefMedia(I18N::translate('Media object')),
'FAM:REFN' => new UserReferenceNumber(I18N::translate('Reference number')),
'FAM:REFN:TYPE' => new UserReferenceType(I18N::translate('Type')),
- 'FAM:RESI' => new Residence(I18N::translate('Residence')),
+ 'FAM:RESI' => new Residence(I18N::translate('Family residence')),
'FAM:RESN' => new RestrictionNotice(I18N::translate('Restriction')),
'FAM:RIN' => new AutomatedRecordId(I18N::translate('Record ID number')),
'FAM:SLGS' => new LdsSpouseSealing(I18N::translate('LDS spouse sealing')),
diff --git a/app/Gedcom.php b/app/Gedcom.php
index aac0569ffa..531a4c79dd 100644
--- a/app/Gedcom.php
+++ b/app/Gedcom.php
@@ -73,4 +73,65 @@ class Gedcom
Source::RECORD_TYPE,
Submitter::RECORD_TYPE,
];
+
+ // These preferences control multiple tag definitions
+ public const HIDDEN_TAGS = [
+ // Individual names
+ 'NAME_NPFX' => ['INDI:NAME:NPFX', 'INDI:NAME:FONE:NPFX', 'INDI:NAME:ROMN:NPFX'],
+ 'NAME_SPFX' => ['INDI:NAME:SPFX', 'INDI:NAME:FONE:SPFX', 'INDI:NAME:ROMN:SPFX'],
+ 'NAME_NSFX' => ['INDI:NAME:NSFX', 'INDI:NAME:FONE:NSFX', 'INDI:NAME:ROMN:NSFX'],
+ 'NAME_NICK' => ['INDI:NAME:NICK', 'INDI:NAME:FONE:NICK', 'INDI:NAME:ROMN:NICK'],
+ 'NAME_FONE' => ['INDI:NAME:FONE'],
+ 'NAME_ROMN' => ['INDI:NAME:ROMN'],
+ 'NAME_NOTE' => ['INDI:NAME:NOTE'],
+ 'NAME_SOUR' => ['INDI:NAME:SOUR'],
+ // Places
+ 'PLAC_MAP' => ['PLAC:MAP'],
+ 'PLAC_FONE' => ['PLAC:FONE'],
+ 'PLAC_ROMN' => ['PLAC:ROMN'],
+ 'PLAC_NOTE' => ['PLAC:NOTE'],
+ // Addresses
+ 'ADDR_FAX' => ['FAX'],
+ 'ADDR_PHON' => ['PHON'],
+ 'ADDR_WWW' => ['WWW'],
+ // Source citations
+ 'SOUR_EVEN' => [':SOUR:EVEN'],
+ 'SOUR_DATE' => [':SOUR:DATA:DATE'],
+ 'SOUR_NOTE' => [':SOUR:NOTE'],
+ 'SOUR_QUAY' => [':SOUR:QUAY'],
+ // Sources
+ 'SOUR_DATA' => ['SOUR:DATA'],
+ // Individuals
+ 'BIRT_FAMC' => ['INDI:BIRT:FAMC'],
+ 'RELI' => ['INDI:RELI'],
+ 'BAPM' => ['INDI:BAPM'],
+ 'CHR' => ['INDI:CHR', 'INDI:CHRA'],
+ 'FCOM' => ['INDI:FCOM', 'INDI:CONF'],
+ 'ORDN' => ['INDI:ORDN'],
+ 'BARM' => ['INDI:BARM', 'INDI:BASM'],
+ 'ALIA' => ['INDI:ALIA'],
+ 'ASSO' => ['INDI:ASSO'],
+ // Families
+ 'ENGA' => ['FAM:ENGA'],
+ 'MARB' => ['FAM:MARB'],
+ 'MARC' => ['FAM:MARC'],
+ 'MARL' => ['FAM:MARL'],
+ 'MARS' => ['FAM:MARS'],
+ 'ANUL' => ['FAM:ANUL'],
+ 'DIVF' => ['FAM:DIVF'],
+ 'FAM_RESI' => ['FAM:RESI'],
+ 'FAM_CENS' => ['FAM:CENS'],
+ // LDS church
+ 'LDS' => ['INDI:BAPL', 'INDI:CONL', 'INDI:ENDL', 'INDI:SLGC', 'FAM:SLGS', 'HEAD:SUBN'],
+ // Identifiers
+ 'AFN' => ['INDI:AFN'],
+ 'IDNO' => ['INDI:IDNO'],
+ 'SSN' => ['INDI:SSN'],
+ 'RFN' => ['RFN'],
+ 'REFN' => ['REFN'],
+ 'RIN' => ['RIN'],
+ // Submitters
+ 'SUBM' => ['INDI:SUBM', 'FAM:SUBM'],
+ 'ANCI' => ['INDI:ANCI', 'INDI:DESI'],
+ ];
}
diff --git a/app/GedcomRecord.php b/app/GedcomRecord.php
index 996d5bf108..75bf6a76d0 100644
--- a/app/GedcomRecord.php
+++ b/app/GedcomRecord.php
@@ -34,10 +34,13 @@ use Illuminate\Support\Collection;
use function addcslashes;
use function app;
use function array_combine;
+use function array_filter;
use function array_keys;
use function array_map;
+use function array_merge;
use function array_search;
use function array_shift;
+use function array_values;
use function assert;
use function count;
use function date;
@@ -62,6 +65,7 @@ use function strtoupper;
use function substr_count;
use function trim;
+use const ARRAY_FILTER_USE_KEY;
use const PHP_INT_MAX;
use const PREG_SET_ORDER;
use const STR_PAD_LEFT;
@@ -1382,6 +1386,10 @@ class GedcomRecord
$return = array_shift($parts);
foreach ($subtags as $subtag => $occurrences) {
+ if ($this->isHiddenTag($tag . ':' . $subtag)) {
+ continue;
+ }
+
[$min, $max] = explode(':', $occurrences);
$min = (int) $min;
@@ -1426,4 +1434,26 @@ class GedcomRecord
return $return;
}
+
+ /**
+ * List of tags to exclude when creating new data.
+ *
+ * @param string $tag
+ *
+ * @return bool
+ */
+ private function isHiddenTag(string $tag): bool
+ {
+ $preferences = array_filter(Gedcom::HIDDEN_TAGS, fn (string $x): bool => (bool) Site::getPreference('HIDE_' . $x), ARRAY_FILTER_USE_KEY);
+ $preferences = array_values($preferences);
+ $hidden_tags = array_merge(...$preferences);
+
+ foreach ($hidden_tags as $hidden_tag) {
+ if (str_contains($tag, $hidden_tag)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
}
diff --git a/app/Http/RequestHandlers/SiteTagsAction.php b/app/Http/RequestHandlers/SiteTagsAction.php
new file mode 100644
index 0000000000..7d71f32917
--- /dev/null
+++ b/app/Http/RequestHandlers/SiteTagsAction.php
@@ -0,0 +1,57 @@
+<?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\Http\RequestHandlers;
+
+use Fisharebest\Webtrees\FlashMessages;
+use Fisharebest\Webtrees\Gedcom;
+use Fisharebest\Webtrees\I18N;
+use Fisharebest\Webtrees\Site;
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
+use Psr\Http\Server\RequestHandlerInterface;
+
+use function array_keys;
+use function redirect;
+use function route;
+
+/**
+ * Edit the tree preferences.
+ */
+class SiteTagsAction implements RequestHandlerInterface
+{
+ /**
+ * @param ServerRequestInterface $request
+ *
+ * @return ResponseInterface
+ */
+ public function handle(ServerRequestInterface $request): ResponseInterface
+ {
+ $params = (array) $request->getParsedBody();
+
+ foreach (array_keys(Gedcom::HIDDEN_TAGS) as $setting) {
+ $value = (bool) ($params['HIDE_' . $setting] ?? false);
+ Site::setPreference('HIDE_' . $setting, (string) $value);
+ }
+
+ FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
+
+ return redirect(route(ControlPanel::class));
+ }
+}
diff --git a/app/Http/RequestHandlers/SiteTagsPage.php b/app/Http/RequestHandlers/SiteTagsPage.php
new file mode 100644
index 0000000000..fb6e7a936d
--- /dev/null
+++ b/app/Http/RequestHandlers/SiteTagsPage.php
@@ -0,0 +1,50 @@
+<?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\Http\RequestHandlers;
+
+use Fisharebest\Webtrees\Http\ViewResponseTrait;
+use Fisharebest\Webtrees\I18N;
+use Fisharebest\Webtrees\Registry;
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
+use Psr\Http\Server\RequestHandlerInterface;
+
+/**
+ * Edit the tree preferences.
+ */
+class SiteTagsPage implements RequestHandlerInterface
+{
+ use ViewResponseTrait;
+
+ /**
+ * @param ServerRequestInterface $request
+ *
+ * @return ResponseInterface
+ */
+ public function handle(ServerRequestInterface $request): ResponseInterface
+ {
+ $this->layout = 'layouts/administration';
+
+ return $this->viewResponse('admin/tags', [
+ 'element_factory' => Registry::elementFactory(),
+ 'title' => I18N::translate('GEDCOM tags'),
+ ]);
+ }
+}
diff --git a/app/Http/Routes/WebRoutes.php b/app/Http/Routes/WebRoutes.php
index dca3d1acf5..3e2f2039db 100644
--- a/app/Http/Routes/WebRoutes.php
+++ b/app/Http/Routes/WebRoutes.php
@@ -295,6 +295,8 @@ use Fisharebest\Webtrees\Http\RequestHandlers\TreePreferencesAction;
use Fisharebest\Webtrees\Http\RequestHandlers\TreePreferencesPage;
use Fisharebest\Webtrees\Http\RequestHandlers\TreePrivacyAction;
use Fisharebest\Webtrees\Http\RequestHandlers\TreePrivacyPage;
+use Fisharebest\Webtrees\Http\RequestHandlers\SiteTagsAction;
+use Fisharebest\Webtrees\Http\RequestHandlers\SiteTagsPage;
use Fisharebest\Webtrees\Http\RequestHandlers\UnconnectedAction;
use Fisharebest\Webtrees\Http\RequestHandlers\UnconnectedPage;
use Fisharebest\Webtrees\Http\RequestHandlers\UpgradeWizardConfirm;
@@ -433,6 +435,8 @@ class WebRoutes
$router->post(SitePreferencesAction::class, '/site-preferences');
$router->get(SiteRegistrationPage::class, '/site-registration');
$router->post(SiteRegistrationAction::class, '/site-registration');
+ $router->get(SiteTagsPage::class, '/tags');
+ $router->post(SiteTagsAction::class, '/tags');
$router->get(TreePageDefaultEdit::class, '/trees/default-blocks');
$router->post(TreePageDefaultUpdate::class, '/trees/default-blocks');
$router->get(MergeTreesPage::class, '/trees/merge');
diff --git a/app/Module/CustomTagsWebtrees.php b/app/Module/CustomTagsWebtrees.php
index a98122fe4f..426b1ff551 100644
--- a/app/Module/CustomTagsWebtrees.php
+++ b/app/Module/CustomTagsWebtrees.php
@@ -51,8 +51,6 @@ class CustomTagsWebtrees extends AbstractModule implements ModuleConfigInterface
{
return [
'FAM:CHAN:_WT_USER' => new WebtreesUser(I18N::translate('Author of last change')),
- 'FAM:_ASSO' => new XrefAssociate(I18N::translate('Associate')),
- 'FAM:_ASSO:RELA' => new RelationIsDescriptor(I18N::translate('Relationship')),
'FAM:*:_ASSO' => new XrefAssociate(I18N::translate('Associate')),
'FAM:*:_ASSO:NOTE' => new NoteStructure(I18N::translate('Note')),
'FAM:*:_ASSO:RELA' => new RelationIsDescriptor(I18N::translate('Relationship')),
diff --git a/app/Services/GedcomEditService.php b/app/Services/GedcomEditService.php
index 52bfcbe700..b5ada6d275 100644
--- a/app/Services/GedcomEditService.php
+++ b/app/Services/GedcomEditService.php
@@ -207,7 +207,7 @@ class GedcomEditService
*
* @return string The updated gedcom record
*/
- public function handleUpdates(string $newged, $levelOverride = 'no'): string
+ public function handleUpdates(string $newged, string $levelOverride = 'no'): string
{
if ($levelOverride === 'no') {
$levelAdjust = 0;
diff --git a/app/Site.php b/app/Site.php
index a41c9c4eeb..43a5c9bc44 100644
--- a/app/Site.php
+++ b/app/Site.php
@@ -68,7 +68,6 @@ class Site
'HIDE_NAME_NSFX' => '1',
'HIDE_NAME_ROMN' => '1',
'HIDE_NAME_SOUR' => '1',
- 'HIDE_NAME_SPFX' => '1',
'HIDE_ORDN' => '1',
'HIDE_PLAC_FONE' => '1',
'HIDE_PLAC_MAP' => '1',
@@ -77,6 +76,7 @@ class Site
'HIDE_REFN' => '1',
'HIDE_RFN' => '1',
'HIDE_RIN' => '1',
+ 'HIDE_SOUR_DATA' => '1',
'HIDE_SOUR_DATE' => '1',
'HIDE_SOUR_EVEN' => '1',
'HIDE_SOUR_NOTE' => '1',