summaryrefslogtreecommitdiff
path: root/app/GedcomCode/GedcomCodeStat.php
blob: 2be312830f065f2ecd0b6192a6efc560e718be34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
 * 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/>.
 */
namespace Fisharebest\Webtrees\GedcomCode;

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;
	}
}