diff options
| author | Greg Roach <fisharebest@gmail.com> | 2015-05-31 08:08:54 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2015-05-31 17:36:14 +0100 |
| commit | 0e62c4b8d0ec6901bfaffd1dc763db37489518a4 (patch) | |
| tree | a1949cbb3ba5e7cf7d5ab8b08a4f179857328625 /app/GedcomCode | |
| parent | 5bccd64ef5cfe5e079d2cd516f4a661881dbe46c (diff) | |
| download | webtrees-0e62c4b8d0ec6901bfaffd1dc763db37489518a4.tar.gz webtrees-0e62c4b8d0ec6901bfaffd1dc763db37489518a4.tar.bz2 webtrees-0e62c4b8d0ec6901bfaffd1dc763db37489518a4.zip | |
PSR-4
Diffstat (limited to 'app/GedcomCode')
| -rw-r--r-- | app/GedcomCode/GedcomCodeAdop.php | 93 | ||||
| -rw-r--r-- | app/GedcomCode/GedcomCodeName.php | 167 | ||||
| -rw-r--r-- | app/GedcomCode/GedcomCodePedi.php | 167 | ||||
| -rw-r--r-- | app/GedcomCode/GedcomCodeQuay.php | 69 | ||||
| -rw-r--r-- | app/GedcomCode/GedcomCodeRela.php | 277 | ||||
| -rw-r--r-- | app/GedcomCode/GedcomCodeStat.php | 134 | ||||
| -rw-r--r-- | app/GedcomCode/GedcomCodeTemp.php | 357 |
7 files changed, 1264 insertions, 0 deletions
diff --git a/app/GedcomCode/GedcomCodeAdop.php b/app/GedcomCode/GedcomCodeAdop.php new file mode 100644 index 0000000000..cf4a72d41a --- /dev/null +++ b/app/GedcomCode/GedcomCodeAdop.php @@ -0,0 +1,93 @@ +<?php +namespace Fisharebest\Webtrees\GedcomCode; + +/** + * webtrees: online genealogy + * Copyright (C) 2015 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 <http://www.gnu.org/licenses/>. + */ +use Fisharebest\Webtrees\GedcomRecord; +use Fisharebest\Webtrees\I18N; +use Fisharebest\Webtrees\Individual; + +/** + * Class GedcomCodeAdop - Functions and logic for GEDCOM "PEDI" codes + */ +class GedcomCodeAdop { + /** @var string[] A list of possible adoption codes */ + private static $TYPES = array('BOTH', 'HUSB', 'WIFE'); + + /** + * Translate a code, for an (optional) record + * + * @param string $type + * @param GedcomRecord|null $record + * + * @return string + */ + public static function getValue($type, GedcomRecord $record = null) { + if ($record instanceof Individual) { + $sex = $record->getSex(); + } else { + $sex = 'U'; + } + + switch ($type) { + case 'BOTH': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Adopted by both parents'); + case 'F': + return I18N::translateContext('FEMALE', 'Adopted by both parents'); + default: + return I18N::translate('Adopted by both parents'); + } + case 'HUSB': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Adopted by father'); + case 'F': + return I18N::translateContext('FEMALE', 'Adopted by father'); + default: + return I18N::translate('Adopted by father'); + } + case 'WIFE': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Adopted by mother'); + case 'F': + return I18N::translateContext('FEMALE', 'Adopted by mother'); + default: + return I18N::translate('Adopted by mother'); + } + default: + return $type; + } + } + + /** + * A list of all possible values for PEDI + * + * @param null GedcomRecord|null $record + * + * @return string[] + */ + public static function getValues(GedcomRecord $record = null) { + $values = array(); + foreach (self::$TYPES as $type) { + $values[$type] = self::getValue($type, $record); + } + + // Don't sort these. We want the order: both parents, father, mother + return $values; + } +} diff --git a/app/GedcomCode/GedcomCodeName.php b/app/GedcomCode/GedcomCodeName.php new file mode 100644 index 0000000000..3ae6c8b760 --- /dev/null +++ b/app/GedcomCode/GedcomCodeName.php @@ -0,0 +1,167 @@ +<?php +namespace Fisharebest\Webtrees\GedcomCode; + +/** + * webtrees: online genealogy + * Copyright (C) 2015 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 <http://www.gnu.org/licenses/>. + */ +use Fisharebest\Webtrees\GedcomRecord; +use Fisharebest\Webtrees\I18N; +use Fisharebest\Webtrees\Individual; + +/** + * Class GedcomCodeName - Functions and logic for GEDCOM "NAME" codes + */ +class GedcomCodeName { + /** @var string[] A list of possible types of name */ + private static $TYPES = array('adopted', 'aka', 'birth', 'change', 'estate', 'immigrant', 'maiden', 'married', 'religious'); + + /** + * Translate a code, for an (optional) record + * + * @param string $type + * @param GedcomRecord|null $record + * + * @return string + */ + public static function getValue($type, GedcomRecord $record = null) { + if ($record instanceof Individual) { + $sex = $record->getSex(); + } else { + $sex = 'U'; + } + + switch ($type) { + case 'adopted': + switch ($sex) { + case 'M': + /* I18N: The name given to a child by its adoptive parents */ + return I18N::translateContext('MALE', 'adopted name'); + case 'F': + /* I18N: The name given to a child by its adoptive parents */ + return I18N::translateContext('FEMALE', 'adopted name'); + default: + /* I18N: The name given to a child by its adoptive parents */ + return I18N::translate('adopted name'); + } + case 'aka': + switch ($sex) { + case 'M': + /* I18N: The name by which an individual is also known. e.g. a professional name or a stage name */ + return I18N::translateContext('MALE', 'also known as'); + case 'F': + /* I18N: The name by which an individual is also known. e.g. a professional name or a stage name */ + return I18N::translateContext('FEMALE', 'also known as'); + default: + /* I18N: The name by which an individual is also known. e.g. a professional name or a stage name */ + return I18N::translate('also known as'); + } + case 'birth': + switch ($sex) { + case 'M': + /* I18N: The name given to an individual at their birth */ + return I18N::translateContext('MALE', 'birth name'); + case 'F': + /* I18N: The name given to an individual at their birth */ + return I18N::translateContext('FEMALE', 'birth name'); + default: + /* I18N: The name given to an individual at their birth */ + return I18N::translate('birth name'); + } + case 'change': + switch ($sex) { + case 'M': + /* I18N: A name chosen by an individual, to replace their existing name (whether legal or otherwise) */ + return I18N::translateContext('MALE', 'change of name'); + case 'F': + /* I18N: A name chosen by an individual, to replace their existing name (whether legal or otherwise) */ + return I18N::translateContext('FEMALE', 'change of name'); + default: + /* I18N: A name chosen by an individual, to replace their existing name (whether legal or otherwise) */ + return I18N::translate('change of name'); + } + case 'estate': + switch ($sex) { + case 'M': + /* I18N: A name given to an individual, from the farm or estate on which they lived or worked */ + return I18N::translateContext('MALE', 'estate name'); + case 'F': + /* I18N: A name given to an individual, from the farm or estate on which they lived or worked */ + return I18N::translateContext('FEMALE', 'estate name'); + default: + /* I18N: A name given to an individual, from the farm or estate on which they lived or worked */ + return I18N::translate('estate name'); + } + case 'immigrant': + switch ($sex) { + case 'M': + /* I18N: A name taken on immigration - e.g. migrants to the USA frequently anglicized their names */ + return I18N::translateContext('MALE', 'immigration name'); + case 'F': + /* I18N: A name taken on immigration - e.g. migrants to the USA frequently anglicized their names */ + return I18N::translateContext('FEMALE', 'immigration name'); + default: + /* I18N: A name taken on immigration - e.g. migrants to the USA frequently anglicized their names */ + return I18N::translate('immigration name'); + } + case 'maiden': + // Only women have “maiden” names! + return + /* I18N: A woman’s name, before she marries (in cultures where women take their new husband’s name on marriage) */ + I18N::translate('maiden name'); + case 'married': + switch ($sex) { + case 'M': + /* I18N: A name taken on marriage - usually the wife takes the husband’s surname */ + return I18N::translateContext('MALE', 'married name'); + case 'F': + /* I18N: A name taken on marriage - usually the wife takes the husband’s surname */ + return I18N::translateContext('FEMALE', 'married name'); + default: + /* I18N: A name taken on marriage - usually the wife takes the husband’s surname */ + return I18N::translate('married name'); + } + case 'religious': + switch ($sex) { + case 'M': + /* I18N: A name taken when entering a religion or a religious order */ + return I18N::translateContext('MALE', 'religious name'); + case 'F': + /* I18N: A name taken when entering a religion or a religious order */ + return I18N::translateContext('FEMALE', 'religious name'); + default: + /* I18N: A name taken when entering a religion or a religious order */ + return I18N::translate('religious name'); + } + default: + return $type; + } + } + + /** + * A list of all possible values for NAME types + * + * @param GedcomRecord|null $record + * + * @return string[] + */ + public static function getValues(GedcomRecord $record = null) { + $values = array(); + foreach (self::$TYPES as $type) { + $values[$type] = self::getValue($type, $record); + } + uasort($values, '\Fisharebest\Webtrees\I18N::strcasecmp'); + + return $values; + } +} diff --git a/app/GedcomCode/GedcomCodePedi.php b/app/GedcomCode/GedcomCodePedi.php new file mode 100644 index 0000000000..71614fb354 --- /dev/null +++ b/app/GedcomCode/GedcomCodePedi.php @@ -0,0 +1,167 @@ +<?php +namespace Fisharebest\Webtrees\GedcomCode; + +/** + * webtrees: online genealogy + * Copyright (C) 2015 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 <http://www.gnu.org/licenses/>. + */ +use Fisharebest\Webtrees\GedcomRecord; +use Fisharebest\Webtrees\I18N; +use Fisharebest\Webtrees\Individual; + +/** + * Class GedcomCodePedi - Functions and logic for GEDCOM "PEDI" codes + */ +class GedcomCodePedi { + /** @var string[] Possible values for pedigree field */ + private static $TYPES = array('adopted', 'birth', 'foster', 'rada', 'sealing'); + + /** + * Translate a code, for an optional record + * + * @param string $type + * @param GedcomRecord|null $record + * + * @return string + */ + public static function getValue($type, GedcomRecord $record = null) { + if ($record instanceof Individual) { + $sex = $record->getSex(); + } else { + $sex = 'U'; + } + + switch ($type) { + case 'birth': + switch ($sex) { + case 'M': + return I18N::translateContext('Male pedigree', 'Birth'); + case 'F': + return I18N::translateContext('Female pedigree', 'Birth'); + default: + return I18N::translateContext('Pedigree', 'Birth'); + } + case 'adopted': + switch ($sex) { + case 'M': + return I18N::translateContext('Male pedigree', 'Adopted'); + case 'F': + return I18N::translateContext('Female pedigree', 'Adopted'); + default: + return I18N::translateContext('Pedigree', 'Adopted'); + } + case 'foster': + switch ($sex) { + case 'M': + return I18N::translateContext('Male pedigree', 'Foster'); + case 'F': + return I18N::translateContext('Female pedigree', 'Foster'); + default: + return I18N::translateContext('Pedigree', 'Foster'); + } + case 'sealing': + switch ($sex) { + case 'M': + return + /* I18N: “sealing” is a ceremony in the Mormon church. */ + I18N::translateContext('Male pedigree', 'Sealing'); + case 'F': + return + /* I18N: “sealing” is a ceremony in the Mormon church. */ + I18N::translateContext('Female pedigree', 'Sealing'); + default: + return + /* I18N: “sealing” is a ceremony in the Mormon church. */ + I18N::translateContext('Pedigree', 'Sealing'); + } + case 'rada': + // Not standard GEDCOM - a webtrees extension + // This is an arabic word which does not exist in other languages. + // So, it will not have any inflected forms. + return + /* I18N: This is an Arabic word, pronounced “ra DAH”. It is child-to-parent pedigree, established by wet-nursing. */ + I18N::translate('Rada'); + default: + return $type; + } + } + + /** + * A list of all possible values for PEDI + * + * @param GedcomRecord|null $record + * + * @return string[] + */ + public static function getValues(GedcomRecord $record = null) { + $values = array(); + foreach (self::$TYPES as $type) { + $values[$type] = self::getValue($type, $record); + } + uasort($values, '\Fisharebest\Webtrees\I18N::strcasecmp'); + + return $values; + } + + /** + * A label for a parental family group + * + * @param string $pedi + * + * @return string + */ + public static function getChildFamilyLabel($pedi) { + switch ($pedi) { + case '': + case 'birth': + return I18N::translate('Family with parents'); + case 'adopted': + return I18N::translate('Family with adoptive parents'); + case 'foster': + return I18N::translate('Family with foster parents'); + case 'sealing': + return + /* I18N: “sealing” is a Mormon ceremony. */ + I18N::translate('Family with sealing parents'); + case 'rada': + return + /* I18N: “rada” is an Arabic word, pronounced “ra DAH”. It is child-to-parent pedigree, established by wet-nursing. */ + I18N::translate('Family with rada parents'); + default: + return I18N::translate('Family with parents') . ' - ' . $pedi; + } + } + + /** + * Create GEDCOM for a new child-family pedigree + * + * @param $pedi + * @param $xref + * + * @return string + */ + public static function createNewFamcPedi($pedi, $xref) { + switch ($pedi) { + case '': + return "1 FAMC @$xref@"; + case 'adopted': + return "1 FAMC @$xref@\n2 PEDI $pedi\n1 ADOP\n2 FAMC @$xref@\n3 ADOP BOTH"; + case 'sealing': + return "1 FAMC @$xref@\n2 PEDI $pedi\n1 SLGC\n2 FAMC @$xref@"; + case 'foster': + return "1 FAMC @$xref@\n2 PEDI $pedi\n1 EVEN\n2 TYPE $pedi"; + default: + return "1 FAMC @$xref@\n2 PEDI $pedi"; + } + } +} diff --git a/app/GedcomCode/GedcomCodeQuay.php b/app/GedcomCode/GedcomCodeQuay.php new file mode 100644 index 0000000000..3b71b7b6e5 --- /dev/null +++ b/app/GedcomCode/GedcomCodeQuay.php @@ -0,0 +1,69 @@ +<?php +namespace Fisharebest\Webtrees\GedcomCode; + +/** + * webtrees: online genealogy + * Copyright (C) 2015 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 <http://www.gnu.org/licenses/>. + */ +use Fisharebest\Webtrees\I18N; + +/** + * Class GedcomCodeQuay - Functions and logic for GEDCOM "QUAY" codes + */ +class GedcomCodeQuay { + private static $TYPES = array('3', '2', '1', '0'); + + /** + * Translate a code, for an optional record + * + * @param string $type + * + * @return string + */ + public static function getValue($type) { + switch ($type) { + case '3': + return + /* I18N: Quality of source information - GEDCOM tag “QUAY 3” */ + I18N::translate('primary evidence'); + case '2': + return + /* I18N: Quality of source information - GEDCOM tag “QUAY 2” */ + I18N::translate('secondary evidence'); + case '1': + return + /* I18N: Quality of source information - GEDCOM tag “QUAY 1” */ + I18N::translate('questionable evidence'); + case '0': + return + /* I18N: Quality of source information - GEDCOM tag “QUAY 0” */ + I18N::translate('unreliable evidence'); + default: + return $type; + } + } + + /** + * A list of all possible values for QUAY + * + * @return string[] + */ + public static function getValues() { + $values = array(); + foreach (self::$TYPES as $type) { + $values[$type] = self::getValue($type); + } + + return $values; + } +} diff --git a/app/GedcomCode/GedcomCodeRela.php b/app/GedcomCode/GedcomCodeRela.php new file mode 100644 index 0000000000..0b2ffa76f9 --- /dev/null +++ b/app/GedcomCode/GedcomCodeRela.php @@ -0,0 +1,277 @@ +<?php +namespace Fisharebest\Webtrees\GedcomCode; + +/** + * webtrees: online genealogy + * Copyright (C) 2015 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 <http://www.gnu.org/licenses/>. + */ +use Fisharebest\Webtrees\GedcomRecord; +use Fisharebest\Webtrees\I18N; +use Fisharebest\Webtrees\Individual; + +/** + * Class GedcomCodeRela - Functions and logic for GEDCOM "RELA" codes + */ +class GedcomCodeRela { + /** @var string[] List of possible values for the RELA tag */ + private static $TYPES = array( + 'attendant', 'attending', 'best_man', 'bridesmaid', 'buyer', + 'circumciser', 'civil_registrar', 'employee', 'employer', 'foster_child', + 'foster_father', 'foster_mother', 'friend', 'godfather', 'godmother', + 'godparent', 'godson', 'goddaughter', 'godchild', 'guardian', + 'informant', 'lodger', 'nanny', 'nurse', 'owner', + 'priest', 'rabbi', 'registry_officer', 'seller', 'servant', + 'slave', 'ward', 'witness', + ); + + /** + * Translate a code, for an (optional) record. + * We need the record to translate the sex (godfather/godmother) but + * we won’t have this when adding data for new individuals. + * + * @param string $type + * @param GedcomRecord|null $record + * + * @return string + */ + public static function getValue($type, GedcomRecord $record = null) { + if ($record instanceof Individual) { + $sex = $record->getSex(); + } else { + $sex = 'U'; + } + + switch ($type) { + case 'attendant': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Attendant'); + case 'F': + return I18N::translateContext('FEMALE', 'Attendant'); + default: + return I18N::translate('Attendant'); + } + case 'attending': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Attending'); + case 'F': + return I18N::translateContext('FEMALE', 'Attending'); + default: + return I18N::translate('Attending'); + } + case 'best_man': + // always male + return I18N::translate('Best man'); + case 'bridesmaid': + // always female + return I18N::translate('Bridesmaid'); + case 'buyer': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Buyer'); + case 'F': + return I18N::translateContext('FEMALE', 'Buyer'); + default: + return I18N::translate('Buyer'); + } + case 'circumciser': + // always male + return I18N::translate('Circumciser'); + case 'civil_registrar': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Civil registrar'); + case 'F': + return I18N::translateContext('FEMALE', 'Civil registrar'); + default: + return I18N::translate('Civil registrar'); + } + case 'employee': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Employee'); + case 'F': + return I18N::translateContext('FEMALE', 'Employee'); + default: + return I18N::translate('Employee'); + } + case 'employer': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Employer'); + case 'F': + return I18N::translateContext('FEMALE', 'Employer'); + default: + return I18N::translate('Employer'); + } + case 'foster_child': + // no sex implied + return I18N::translate('Foster child'); + case 'foster_father': + // always male + return I18N::translate('Foster father'); + case 'foster_mother': + // always female + return I18N::translate('Foster mother'); + case 'friend': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Friend'); + case 'F': + return I18N::translateContext('FEMALE', 'Friend'); + default: + return I18N::translate('Friend'); + } + case 'godfather': + // always male + return I18N::translate('Godfather'); + case 'godmother': + // always female + return I18N::translate('Godmother'); + case 'godparent': + // no sex implied + return I18N::translate('Godparent'); + case 'godson': + // always male + return I18N::translate('Godson'); + case 'goddaughter': + // always female + return I18N::translate('Goddaughter'); + case 'godchild': + // no sex implied + return I18N::translate('Godchild'); + case 'guardian': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Guardian'); + case 'F': + return I18N::translateContext('FEMALE', 'Guardian'); + default: + return I18N::translate('Guardian'); + } + case 'informant': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Informant'); + case 'F': + return I18N::translateContext('FEMALE', 'Informant'); + default: + return I18N::translate('Informant'); + } + case 'lodger': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Lodger'); + case 'F': + return I18N::translateContext('FEMALE', 'Lodger'); + default: + return I18N::translate('Lodger'); + } + case 'nanny': + // no sex implied + return I18N::translate('Nanny'); + case 'nurse': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Nurse'); + case 'F': + return I18N::translateContext('FEMALE', 'Nurse'); + default: + return I18N::translate('Nurse'); + } + case 'owner': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Owner'); + case 'F': + return I18N::translateContext('FEMALE', 'Owner'); + default: + return I18N::translate('Owner'); + } + case 'priest': + // no sex implied + return I18N::translate('Priest'); + case 'rabbi': + // always male + return I18N::translate('Rabbi'); + case 'registry_officer': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Registry officer'); + case 'F': + return I18N::translateContext('FEMALE', 'Registry officer'); + default: + return I18N::translate('Registry officer'); + } + case 'seller': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Seller'); + case 'F': + return I18N::translateContext('FEMALE', 'Seller'); + default: + return I18N::translate('Seller'); + } + case 'servant': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Servant'); + case 'F': + return I18N::translateContext('FEMALE', 'Servant'); + default: + return I18N::translate('Servant'); + } + case 'slave': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Slave'); + case 'F': + return I18N::translateContext('FEMALE', 'Slave'); + default: + return I18N::translate('Slave'); + } + case 'ward': + switch ($sex) { + case 'M': + return I18N::translateContext('MALE', 'Ward'); + case 'F': + return I18N::translateContext('FEMALE', 'Ward'); + default: + return I18N::translate('Ward'); + } + case 'witness': + // Do we need separate male/female translations for this? + return I18N::translate('Witness'); + default: + return $type; + } + } + + /** + * A list of all possible values for RELA + * + * @param GedcomRecord|null $record + * + * @return string[] + */ + public static function getValues(GedcomRecord $record = null) { + $values = array(); + foreach (self::$TYPES as $type) { + $values[$type] = self::getValue($type, $record); + } + uasort($values, '\Fisharebest\Webtrees\I18N::strcasecmp'); + + return $values; + } +} diff --git a/app/GedcomCode/GedcomCodeStat.php b/app/GedcomCode/GedcomCodeStat.php new file mode 100644 index 0000000000..888ea34943 --- /dev/null +++ b/app/GedcomCode/GedcomCodeStat.php @@ -0,0 +1,134 @@ +<?php +namespace Fisharebest\Webtrees\GedcomCode; + +/** + * webtrees: online genealogy + * Copyright (C) 2015 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 <http://www.gnu.org/licenses/>. + */ +use Fisharebest\Webtrees\I18N; + +/** + * Class GedcomCodeStat - Functions and logic for GEDCOM "STAT" codes + */ +class GedcomCodeStat { + /** + * Get a list of status codes that can be used on a given LDS tag + * + * @param string $tag + * + * @return string[] + */ + public static function statusCodes($tag) { + switch ($tag) { + case 'BAPL': + case 'CONL': + // LDS_BAPTISM_DATE_STATUS + return array('CHILD', 'COMPLETED', 'EXCLUDED', 'INFANT', 'PRE-1970', 'STILLBORN', 'SUBMITTED', 'UNCLEARED'); + case 'ENDL': + // LDS_ENDOWMENT_DATE_STATUS + return array('CHILD', 'COMPLETED', 'EXCLUDED', 'INFANT', 'PRE-1970', 'STILLBORN', 'SUBMITTED', 'UNCLEARED'); + case 'SLGC': + // LDS_CHILD_SEALING_DATE_STATUS + return array('BIC', 'COMPLETED', 'EXCLUDED', 'PRE-1970', 'STILLBORN', 'SUBMITTED', 'UNCLEARED'); + case 'SLGS': + // LDS_SPOUSE_SEALING_DATE_STATUS + return array('CANCELED', 'COMPLETED', 'DNS', 'DNS/CAN', 'EXCLUDED', 'PRE-1970', 'SUBMITTED', 'UNCLEARED'); + default: + throw new \InvalidArgumentException('Internal error - bad argument to GedcomCodeStat::statusCodes("' . $tag . '")'); + } + } + + /** + * Get the localized name for a status code + * + * @param string $status_code + * + * @return string + */ + public static function statusName($status_code) { + switch ($status_code) { + case 'BIC': + return + /* I18N: LDS sealing status; see http://en.wikipedia.org/wiki/Sealing_(Latter_Day_Saints) */ + I18N::translate('Born in the covenant'); + case 'CANCELED': + return + /* I18N: LDS sealing status; see http://en.wikipedia.org/wiki/Sealing_(Latter_Day_Saints) */ + I18N::translate('Sealing cancelled (divorce)'); + case 'CHILD': + return + /* I18N: LDS sealing status; see http://en.wikipedia.org/wiki/Sealing_(Latter_Day_Saints) */ + I18N::translate('Died as a child: exempt'); + case 'CLEARED': + // This status appears in PhpGedView, but not in the GEDCOM 5.5.1 specification. + return + /* I18N: LDS sealing status; see http://en.wikipedia.org/wiki/Sealing_(Latter_Day_Saints) */ + I18N::translate('Cleared but not yet completed'); + case 'COMPLETED': + return + /* I18N: LDS sealing status; see http://en.wikipedia.org/wiki/Sealing_(Latter_Day_Saints) */ + I18N::translate('Completed; date unknown'); + case 'DNS': + return + /* I18N: LDS sealing status; see http://en.wikipedia.org/wiki/Sealing_(Latter_Day_Saints) */ + I18N::translate('Do not seal: unauthorized'); + case 'DNS/CAN': + return + /* I18N: LDS sealing status; see http://en.wikipedia.org/wiki/Sealing_(Latter_Day_Saints) */ + I18N::translate('Do not seal, previous sealing cancelled'); + case 'EXCLUDED': + return + /* I18N: LDS sealing status; see http://en.wikipedia.org/wiki/Sealing_(Latter_Day_Saints) */ + I18N::translate('Excluded from this submission'); + case 'INFANT': + return + /* I18N: LDS sealing status; see http://en.wikipedia.org/wiki/Sealing_(Latter_Day_Saints) */ + I18N::translate('Died as an infant: exempt'); + case 'PRE-1970': + return + /* I18N: LDS sealing status; see http://en.wikipedia.org/wiki/Sealing_(Latter_Day_Saints) */ + I18N::translate('Completed before 1970; date not available'); + case 'STILLBORN': + return + /* I18N: LDS sealing status; see http://en.wikipedia.org/wiki/Sealing_(Latter_Day_Saints) */ + I18N::translate('Stillborn: exempt'); + case 'SUBMITTED': + return + /* I18N: LDS sealing status; see http://en.wikipedia.org/wiki/Sealing_(Latter_Day_Saints) */ + I18N::translate('Submitted but not yet cleared'); + case 'UNCLEARED': + return + /* I18N: LDS sealing status; see http://en.wikipedia.org/wiki/Sealing_(Latter_Day_Saints) */ + I18N::translate('Uncleared: insufficient data'); + default: + return $status_code; + } + } + + /** + * A sorted list of all status names, for a given GEDCOM tag + * + * @param string $tag + * + * @return string[] + */ + public static function statusNames($tag) { + $status_names = array(); + foreach (self::statusCodes($tag) as $status_code) { + $status_names[$status_code] = self::statusName($status_code); + } + uasort($status_names, '\Fisharebest\Webtrees\I18N::strcasecmp'); + + return $status_names; + } +} diff --git a/app/GedcomCode/GedcomCodeTemp.php b/app/GedcomCode/GedcomCodeTemp.php new file mode 100644 index 0000000000..9588d0125f --- /dev/null +++ b/app/GedcomCode/GedcomCodeTemp.php @@ -0,0 +1,357 @@ +<?php +namespace Fisharebest\Webtrees\GedcomCode; + +/** + * webtrees: online genealogy + * Copyright (C) 2015 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 <http://www.gnu.org/licenses/>. + */ +use Fisharebest\Webtrees\I18N; + +/** + * Class GedcomCodeTemp - Functions and logic for GEDCOM "TEMP" codes + */ +class GedcomCodeTemp { + /** + * A list of GEDCOM tags that require a TEMP subtag + * + * @param string $tag + * + * @return bool + */ + public static function isTagLDS($tag) { + return $tag === 'BAPL' || $tag === 'CONL' || $tag === 'ENDL' || $tag === 'SLGC' || $tag === 'SLGS'; + } + + /** + * A list of all temple codes, from the GEDCOM 5.5.1 specification + * + * Note that this list is out-of-date. We could add recently built + * temples, but what codes would we use? + * + * @link http://en.wikipedia.org/wiki/List_of_temples_of_The_Church_of_Jesus_Christ_of_Latter-day_Saints + * + * @return string[] + */ + public static function templeCodes() { + return array( + 'ABA', 'ACCRA', 'ADELA', 'ALBER', 'ALBUQ', 'ANCHO', 'ARIZO', 'ASUNC', + 'ATLAN', 'BAIRE', 'BILLI', 'BIRMI', 'BISMA', 'BOGOT', 'BOISE', 'BOSTO', + 'BOUNT', 'BRISB', 'BROUG', 'CAMPI', 'CARAC', 'CHICA', 'CIUJU', 'COCHA', + 'COLJU', 'COLSC', 'COLUM', 'COPEN', 'CRIVE', 'DALLA', 'DENVE', 'DETRO', + 'EDMON', 'EHOUS', 'FRANK', 'FREIB', 'FRESN', 'FUKUO', 'GUADA', 'GUATE', + 'GUAYA', 'HAGUE', 'HALIF', 'HARTF', 'HAWAI', 'HELSI', 'HERMO', 'HKONG', + 'HOUST', 'IFALL', 'JOHAN', 'JRIVE', 'KIEV', 'KONA', 'LANGE', 'LIMA', + 'LOGAN', 'LONDO', 'LOUIS', 'LUBBO', 'LVEGA', 'MADRI', 'MANIL', 'MANTI', + 'MEDFO', 'MELBO', 'MEMPH', 'MERID', 'MEXIC', 'MNTVD', 'MONTE', 'MONTI', + 'MONTR', 'MTIMP', 'NASHV', 'NAUV2', 'NAUVO', 'NBEAC', 'NUKUA', 'NYORK', + 'NZEAL', 'OAKLA', 'OAXAC', 'OGDEN', 'OKLAH', 'ORLAN', 'PALEG', 'PALMY', + 'PAPEE', 'PERTH', 'POFFI', 'PORTL', 'PREST', 'PROVO', 'RALEI', 'RECIF', + 'REDLA', 'REGIN', 'RENO', 'SACRA', 'SAMOA', 'SANTI', 'SANTO', 'SDIEG', + 'SDOMI', 'SEATT', 'SEOUL', 'SGEOR', 'SJOSE', 'SLAKE', 'SLOUI', 'SNOWF', + 'SPAUL', 'SPMIN', 'SPOKA', 'STOCK', 'SUVA', 'SWISS', 'SYDNE', 'TAIPE', + 'TAMPI', 'TGUTI', 'TOKYO', 'TORNO', 'VERAC', 'VERNA', 'VILLA', 'WASHI', + 'WINTE', + ); + } + + /** + * Get the localized name for a temple code + * + * @param string $temple_code + * + * @return string + */ + public static function templeName($temple_code) { + switch ($temple_code) { + case 'ABA': + return I18N::translate('Aba, Nigeria'); + case 'ACCRA': + return I18N::translate('Accra, Ghana'); + case 'ADELA': + return I18N::translate('Adelaide, Australia'); + case 'ALBER': + return I18N::translate('Cardston, Alberta, Canada'); + case 'ALBUQ': + return I18N::translate('Albuquerque, New Mexico'); + case 'ANCHO': + return I18N::translate('Anchorage, Alaska'); + case 'ARIZO': + return I18N::translate('Mesa, Arizona'); + case 'ASUNC': + return I18N::translate('Asuncion, Paraguay'); + case 'ATLAN': + return I18N::translate('Atlanta, Georgia'); + case 'BAIRE': + return I18N::translate('Buenos Aires, Argentina'); + case 'BILLI': + return I18N::translate('Billings, Montana'); + case 'BIRMI': + return I18N::translate('Birmingham, Alabama'); + case 'BISMA': + return I18N::translate('Bismarck, North Dakota'); + case 'BOGOT': + return I18N::translate('Bogota, Colombia'); + case 'BOISE': + return I18N::translate('Boise, Idaho'); + case 'BOSTO': + return I18N::translate('Boston, Massachusetts'); + case 'BOUNT': + return I18N::translate('Bountiful, Utah'); + case 'BRISB': + return I18N::translate('Brisbane, Australia'); + case 'BROUG': + return I18N::translate('Baton Rouge, Louisiana'); + case 'CAMPI': + return I18N::translate('Campinas, Brazil'); + case 'CARAC': + return I18N::translate('Caracas, Venezuela'); + case 'CHICA': + return I18N::translate('Chicago, Illinois'); + case 'CIUJU': + return I18N::translate('Ciudad Juarez, Mexico'); + case 'COCHA': + return I18N::translate('Cochabamba, Bolivia'); + case 'COLJU': + return I18N::translate('Colonia Juarez, Mexico'); + case 'COLSC': + return I18N::translate('Columbia, South Carolina'); + case 'COLUM': + return I18N::translate('Columbus, Ohio'); + case 'COPEN': + return I18N::translate('Copenhagen, Denmark'); + case 'CRIVE': + return I18N::translate('Columbia River, Washington'); + case 'DALLA': + return I18N::translate('Dallas, Texas'); + case 'DENVE': + return I18N::translate('Denver, Colorado'); + case 'DETRO': + return I18N::translate('Detroit, Michigan'); + case 'EDMON': + return I18N::translate('Edmonton, Alberta, Canada'); + case 'EHOUS': + return + /* I18N: http://en.wikipedia.org/wiki/Endowment_house */ + I18N::translate('Endowment House'); + case 'FRANK': + return I18N::translate('Frankfurt am Main, Germany'); + case 'FREIB': + return I18N::translate('Freiburg, Germany'); + case 'FRESN': + return I18N::translate('Fresno, California'); + case 'FUKUO': + return I18N::translate('Fukuoka, Japan'); + case 'GUADA': + return I18N::translate('Guadalajara, Mexico'); + case 'GUATE': + return I18N::translate('Guatemala City, Guatemala'); + case 'GUAYA': + return I18N::translate('Guayaquil, Ecuador'); + case 'HAGUE': + return I18N::translate('The Hague, Netherlands'); + case 'HALIF': + return I18N::translate('Halifax, Nova Scotia, Canada'); + case 'HARTF': + return I18N::translate('Hartford, Connecticut'); + case 'HAWAI': + return I18N::translate('Laie, Hawaii'); + case 'HELSI': + return I18N::translate('Helsinki, Finland'); + case 'HERMO': + return I18N::translate('Hermosillo, Mexico'); + case 'HKONG': + return I18N::translate('Hong Kong'); + case 'HOUST': + return I18N::translate('Houston, Texas'); + case 'IFALL': + return I18N::translate('Idaho Falls, Idaho'); + case 'JOHAN': + return I18N::translate('Johannesburg, South Africa'); + case 'JRIVE': + return I18N::translate('Jordan River, Utah'); + case 'KIEV': + return I18N::translate('Kiev, Ukraine'); + case 'KONA': + return I18N::translate('Kona, Hawaii'); + case 'LANGE': + return I18N::translate('Los Angeles, California'); + case 'LIMA': + return I18N::translate('Lima, Peru'); + case 'LOGAN': + return I18N::translate('Logan, Utah'); + case 'LONDO': + return I18N::translate('London, England'); + case 'LOUIS': + return I18N::translate('Louisville, Kentucky'); + case 'LUBBO': + return I18N::translate('Lubbock, Texas'); + case 'LVEGA': + return I18N::translate('Las Vegas, Nevada'); + case 'MADRI': + return I18N::translate('Madrid, Spain'); + case 'MANIL': + return I18N::translate('Manila, Philippines'); + case 'MANTI': + return I18N::translate('Manti, Utah'); + case 'MEDFO': + return I18N::translate('Medford, Oregon'); + case 'MELBO': + return I18N::translate('Melbourne, Australia'); + case 'MEMPH': + return I18N::translate('Memphis, Tennessee'); + case 'MERID': + return I18N::translate('Merida, Mexico'); + case 'MEXIC': + return I18N::translate('Mexico City, Mexico'); + case 'MNTVD': + return I18N::translate('Montevideo, Uruguay'); + case 'MONTE': + return I18N::translate('Monterrey, Mexico'); + case 'MONTI': + return I18N::translate('Monticello, Utah'); + case 'MONTR': + return I18N::translate('Montreal, Quebec, Canada'); + case 'MTIMP': + return I18N::translate('Mount Timpanogos, Utah'); + case 'NASHV': + return I18N::translate('Nashville, Tennessee'); + case 'NAUV2': + return I18N::translate('Nauvoo, Illinois (new)'); + case 'NAUVO': + return I18N::translate('Nauvoo, Illinois (original)'); + case 'NBEAC': + return I18N::translate('Newport Beach, California'); + case 'NUKUA': + return I18N::translate('Nuku’Alofa, Tonga'); + case 'NYORK': + return I18N::translate('New York, New York'); + case 'NZEAL': + return I18N::translate('Hamilton, New Zealand'); + case 'OAKLA': + return I18N::translate('Oakland, California'); + case 'OAXAC': + return I18N::translate('Oaxaca, Mexico'); + case 'OGDEN': + return I18N::translate('Ogden, Utah'); + case 'OKLAH': + return I18N::translate('Oklahoma City, Oklahoma'); + case 'ORLAN': + return I18N::translate('Orlando, Florida'); + case 'PALEG': + return I18N::translate('Porto Alegre, Brazil'); + case 'PALMY': + return I18N::translate('Palmyra, New York'); + case 'PAPEE': + return I18N::translate('Papeete, Tahiti'); + case 'PERTH': + return I18N::translate('Perth, Australia'); + case 'POFFI': + return + /* I18N: http://en.wikipedia.org/wiki/President_of_the_Church */ + I18N::translate('President’s Office'); + case 'PORTL': + return I18N::translate('Portland, Oregon'); + case 'PREST': + return I18N::translate('Preston, England'); + case 'PROVO': + return I18N::translate('Provo, Utah'); + case 'RALEI': + return I18N::translate('Raleigh, North Carolina'); + case 'RECIF': + return I18N::translate('Recife, Brazil'); + case 'REDLA': + return I18N::translate('Redlands, California'); + case 'REGIN': + return I18N::translate('Regina, Saskatchewan, Canada'); + case 'RENO': + return I18N::translate('Reno, Nevada'); + case 'SACRA': + return I18N::translate('Sacramento, California'); + case 'SAMOA': + return I18N::translate('Apia, Samoa'); + case 'SANTI': + return I18N::translate('Santiago, Chile'); + case 'SANTO': + return I18N::translate('San Antonio, Texas'); + case 'SDIEG': + return I18N::translate('San Diego, California'); + case 'SDOMI': + return I18N::translate('Santo Domingo, Dominican Republic'); + case 'SEATT': + return I18N::translate('Seattle, Washington'); + case 'SEOUL': + return I18N::translate('Seoul, Korea'); + case 'SGEOR': + return I18N::translate('St. George, Utah'); + case 'SJOSE': + return I18N::translate('San Jose, Costa Rica'); + case 'SLAKE': + return I18N::translate('Salt Lake City, Utah'); + case 'SLOUI': + return I18N::translate('St. Louis, Missouri'); + case 'SNOWF': + return I18N::translate('Snowflake, Arizona'); + case 'SPAUL': + return I18N::translate('Sao Paulo, Brazil'); + case 'SPMIN': + return I18N::translate('St. Paul, Minnesota'); + case 'SPOKA': + return I18N::translate('Spokane, Washington'); + case 'STOCK': + return I18N::translate('Stockholm, Sweden'); + case 'SUVA': + return I18N::translate('Suva, Fiji'); + case 'SWISS': + return I18N::translate('Bern, Switzerland'); + case 'SYDNE': + return I18N::translate('Sydney, Australia'); + case 'TAIPE': + return I18N::translate('Taipei, Taiwan'); + case 'TAMPI': + return I18N::translate('Tampico, Mexico'); + case 'TGUTI': + return I18N::translate('Tuxtla Gutierrez, Mexico'); + case 'TOKYO': + return I18N::translate('Tokyo, Japan'); + case 'TORNO': + return I18N::translate('Toronto, Ontario, Canada'); + case 'VERAC': + return I18N::translate('Veracruz, Mexico'); + case 'VERNA': + return I18N::translate('Vernal, Utah'); + case 'VILLA': + return I18N::translate('Villa Hermosa, Mexico'); + case 'WASHI': + return I18N::translate('Washington, DC'); + case 'WINTE': + return I18N::translate('Winter Quarters, Nebraska'); + default: + return $temple_code; + } + } + + /** + * A sorted list of all temple names + * + * @return string[] + */ + public static function templeNames() { + $temple_names = array(); + foreach (self::templeCodes() as $temple_code) { + $temple_names[$temple_code] = self::templeName($temple_code); + } + uasort($temple_names, '\Fisharebest\Webtrees\I18N::strcasecmp'); + + return $temple_names; + } +} |
