xref: /webtrees/app/Gedcom.php (revision 40c249dc3e911bfee29827d5c5d51237f07b710a)
10f471f91SGreg Roach<?php
23976b470SGreg Roach
30f471f91SGreg Roach/**
40f471f91SGreg Roach * webtrees: online genealogy
590949315SGreg Roach * Copyright (C) 2021 webtrees development team
60f471f91SGreg Roach * This program is free software: you can redistribute it and/or modify
70f471f91SGreg Roach * it under the terms of the GNU General Public License as published by
80f471f91SGreg Roach * the Free Software Foundation, either version 3 of the License, or
90f471f91SGreg Roach * (at your option) any later version.
100f471f91SGreg Roach * This program is distributed in the hope that it will be useful,
110f471f91SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
120f471f91SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
130f471f91SGreg Roach * GNU General Public License for more details.
140f471f91SGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
160f471f91SGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
200f471f91SGreg Roachnamespace Fisharebest\Webtrees;
210f471f91SGreg Roach
220f471f91SGreg Roach/**
230f471f91SGreg Roach * GEDCOM 5.5.1 specification
240f471f91SGreg Roach */
25c1010edaSGreg Roachclass Gedcom
26c1010edaSGreg Roach{
270f471f91SGreg Roach    // Use MSDOS style line endings, for maximum compatibility.
2816d6367aSGreg Roach    public const EOL = "\r\n";
290f471f91SGreg Roach
300f471f91SGreg Roach    // 255 less the EOL character.
3116d6367aSGreg Roach    public const LINE_LENGTH = 253;
328d0ebef0SGreg Roach
338d0ebef0SGreg Roach    // Gedcom tags which indicate the start of life.
3416d6367aSGreg Roach    public const BIRTH_EVENTS = ['BIRT', 'CHR', 'BAPM', 'ADOP'];
358d0ebef0SGreg Roach
368d0ebef0SGreg Roach    // Gedcom tags which indicate the end of life.
3716d6367aSGreg Roach    public const DEATH_EVENTS = ['DEAT', 'BURI', 'CREM'];
388d0ebef0SGreg Roach
398d0ebef0SGreg Roach    // Gedcom tags which indicate the start of a relationship.
4016d6367aSGreg Roach    public const MARRIAGE_EVENTS = ['MARR', '_NMR'];
418d0ebef0SGreg Roach
428d0ebef0SGreg Roach    // Gedcom tags which indicate the end of a relationship.
4316d6367aSGreg Roach    public const DIVORCE_EVENTS = ['DIV', 'ANUL', '_SEPR'];
448d0ebef0SGreg Roach
458d0ebef0SGreg Roach    // Regular expression to match a GEDCOM tag.
4616d6367aSGreg Roach    public const REGEX_TAG = '[_A-Z][_A-Z0-9]*';
478d0ebef0SGreg Roach
488d0ebef0SGreg Roach    // Regular expression to match a GEDCOM XREF.
49f81cefe9SGreg Roach    public const REGEX_XREF = '[A-Za-z0-9:_.-]{1,20}';
508d0ebef0SGreg Roach
518d0ebef0SGreg Roach    // UTF-8 encoded files may begin with an optional byte-order-mark (U+FEFF).
5216d6367aSGreg Roach    public const UTF8_BOM = "\xEF\xBB\xBF";
53ead61980SGreg Roach
54ead61980SGreg Roach    // Separates parts of a place name.
55ead61980SGreg Roach    public const PLACE_SEPARATOR = ', ';
56392561bbSGreg Roach
57392561bbSGreg Roach    // Regex to match a (badly formed) GEDCOM place separator.
5890949315SGreg Roach    public const PLACE_SEPARATOR_REGEX = '/ *,[, ]*/';
5990949315SGreg Roach
6090949315SGreg Roach    // LATI and LONG tags
6190949315SGreg Roach    public const LATITUDE_NORTH = 'N';
6290949315SGreg Roach    public const LATITUDE_SOUTH = 'S';
6390949315SGreg Roach    public const LONGITUDE_EAST = 'E';
6490949315SGreg Roach    public const LONGITUDE_WEST = 'W';
6571f696adSGreg Roach
6671f696adSGreg Roach    // Not all record types allow a CHAN event.
6771f696adSGreg Roach    public const RECORDS_WITH_CHAN = [
6871f696adSGreg Roach        Family::RECORD_TYPE,
6971f696adSGreg Roach        Individual::RECORD_TYPE,
7071f696adSGreg Roach        Media::RECORD_TYPE,
7171f696adSGreg Roach        Note::RECORD_TYPE,
7271f696adSGreg Roach        Repository::RECORD_TYPE,
7371f696adSGreg Roach        Source::RECORD_TYPE,
7471f696adSGreg Roach        Submitter::RECORD_TYPE,
7571f696adSGreg Roach    ];
76c8183f29SGreg Roach
77c8183f29SGreg Roach    // These preferences control multiple tag definitions
78c8183f29SGreg Roach    public const HIDDEN_TAGS = [
79c8183f29SGreg Roach        // Individual names
80c8183f29SGreg Roach        'NAME_NPFX' => ['INDI:NAME:NPFX', 'INDI:NAME:FONE:NPFX', 'INDI:NAME:ROMN:NPFX'],
81c8183f29SGreg Roach        'NAME_SPFX' => ['INDI:NAME:SPFX', 'INDI:NAME:FONE:SPFX', 'INDI:NAME:ROMN:SPFX'],
82c8183f29SGreg Roach        'NAME_NSFX' => ['INDI:NAME:NSFX', 'INDI:NAME:FONE:NSFX', 'INDI:NAME:ROMN:NSFX'],
83c8183f29SGreg Roach        'NAME_NICK' => ['INDI:NAME:NICK', 'INDI:NAME:FONE:NICK', 'INDI:NAME:ROMN:NICK'],
84c8183f29SGreg Roach        'NAME_FONE' => ['INDI:NAME:FONE'],
85c8183f29SGreg Roach        'NAME_ROMN' => ['INDI:NAME:ROMN'],
86c8183f29SGreg Roach        'NAME_NOTE' => ['INDI:NAME:NOTE'],
87c8183f29SGreg Roach        'NAME_SOUR' => ['INDI:NAME:SOUR'],
88c8183f29SGreg Roach        // Places
89c8183f29SGreg Roach        'PLAC_MAP'  => ['PLAC:MAP'],
90c8183f29SGreg Roach        'PLAC_FONE' => ['PLAC:FONE'],
91c8183f29SGreg Roach        'PLAC_ROMN' => ['PLAC:ROMN'],
92676cffa0SGreg Roach        'PLAC_FORM' => ['PLAC:FORM', 'HEAD:PLAC'],
93c8183f29SGreg Roach        'PLAC_NOTE' => ['PLAC:NOTE'],
94c8183f29SGreg Roach        // Addresses
95c8183f29SGreg Roach        'ADDR_FAX'  => ['FAX'],
96c8183f29SGreg Roach        'ADDR_PHON' => ['PHON'],
97c8183f29SGreg Roach        'ADDR_WWW'  => ['WWW'],
98c8183f29SGreg Roach        // Source citations
99c8183f29SGreg Roach        'SOUR_EVEN' => [':SOUR:EVEN'],
100c8183f29SGreg Roach        'SOUR_DATE' => [':SOUR:DATA:DATE'],
101c8183f29SGreg Roach        'SOUR_NOTE' => [':SOUR:NOTE'],
102c8183f29SGreg Roach        'SOUR_QUAY' => [':SOUR:QUAY'],
103c8183f29SGreg Roach        // Sources
104*40c249dcSGreg Roach        'SOUR_DATA' => ['SOUR:DATA:EVEN', 'SOUR:DATA:AGNC', 'SOUR:DATA:NOTE'],
105c8183f29SGreg Roach        // Individuals
106c8183f29SGreg Roach        'BIRT_FAMC' => ['INDI:BIRT:FAMC'],
107c8183f29SGreg Roach        'RELI'      => ['INDI:RELI'],
108c8183f29SGreg Roach        'BAPM'      => ['INDI:BAPM'],
109c8183f29SGreg Roach        'CHR'       => ['INDI:CHR', 'INDI:CHRA'],
110c8183f29SGreg Roach        'FCOM'      => ['INDI:FCOM', 'INDI:CONF'],
111c8183f29SGreg Roach        'ORDN'      => ['INDI:ORDN'],
112c8183f29SGreg Roach        'BARM'      => ['INDI:BARM', 'INDI:BASM'],
113c8183f29SGreg Roach        'ALIA'      => ['INDI:ALIA'],
114c8183f29SGreg Roach        'ASSO'      => ['INDI:ASSO'],
115c8183f29SGreg Roach        // Families
116c8183f29SGreg Roach        'ENGA'      => ['FAM:ENGA'],
117c8183f29SGreg Roach        'MARB'      => ['FAM:MARB'],
118c8183f29SGreg Roach        'MARC'      => ['FAM:MARC'],
119c8183f29SGreg Roach        'MARL'      => ['FAM:MARL'],
120c8183f29SGreg Roach        'MARS'      => ['FAM:MARS'],
121c8183f29SGreg Roach        'ANUL'      => ['FAM:ANUL'],
122c8183f29SGreg Roach        'DIVF'      => ['FAM:DIVF'],
123c8183f29SGreg Roach        'FAM_RESI'  => ['FAM:RESI'],
124c8183f29SGreg Roach        'FAM_CENS'  => ['FAM:CENS'],
125c8183f29SGreg Roach        // LDS church
126c8183f29SGreg Roach        'LDS'       => ['INDI:BAPL', 'INDI:CONL', 'INDI:ENDL', 'INDI:SLGC', 'FAM:SLGS', 'HEAD:SUBN'],
127c8183f29SGreg Roach        // Identifiers
128c8183f29SGreg Roach        'AFN'       => ['INDI:AFN'],
129c8183f29SGreg Roach        'IDNO'      => ['INDI:IDNO'],
130c8183f29SGreg Roach        'SSN'       => ['INDI:SSN'],
131c8183f29SGreg Roach        'RFN'       => ['RFN'],
132c8183f29SGreg Roach        'REFN'      => ['REFN'],
133c8183f29SGreg Roach        'RIN'       => ['RIN'],
134c8183f29SGreg Roach        // Submitters
135c8183f29SGreg Roach        'SUBM'      => ['INDI:SUBM', 'FAM:SUBM'],
136c8183f29SGreg Roach        'ANCI'      => ['INDI:ANCI', 'INDI:DESI'],
137c8183f29SGreg Roach    ];
1380f471f91SGreg Roach}
139