summaryrefslogtreecommitdiff
path: root/library/WT/Gedcom/Code/Pedi.php
blob: 783c59b4f1c18743df7fb69d37634d5dfbe11040 (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
<?php
// Functions and logic for GEDCOM "PEDI" codes
//
// webtrees: Web based Family History software
// Copyright (C) 2013 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 2 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, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// $Id$

if (!defined('WT_WEBTREES')) {
	header('HTTP/1.0 403 Forbidden');
	exit;
}

class WT_Gedcom_Code_Pedi {
	
	private static $TYPES=array('adopted', 'birth', 'foster', 'rada', 'sealing');

	// Translate a code, for an optional record
	public static function getValue($type, $record=null) {
		if ($record instanceof WT_Individual) {
			$sex=$record->getSex();
		} else {
			$sex='U';
		}

		switch ($type) {
		case 'birth':
			switch ($sex) {
			case 'U': return WT_I18N::translate_c('Pedigree',        'Birth');
			case 'M': return WT_I18N::translate_c('Male pedigree',   'Birth');
			case 'F': return WT_I18N::translate_c('Female pedigree', 'Birth');
			}
		case 'adopted':
			switch ($sex) {
			case 'U': return WT_I18N::translate_c('Pedigree',        'Adopted');
			case 'M': return WT_I18N::translate_c('Male pedigree',   'Adopted');
			case 'F': return WT_I18N::translate_c('Female pedigree', 'Adopted');
			}
		case 'foster':
			switch ($sex) {
			case 'U': return WT_I18N::translate_c('Pedigree',        'Foster');
			case 'M': return WT_I18N::translate_c('Male pedigree',   'Foster');
			case 'F': return WT_I18N::translate_c('Female pedigree', 'Foster');
			}
		case 'sealing':
			switch ($sex) {
			case 'U': return /* I18N: “sealing” is a ceremony in the Mormon church. */ WT_I18N::translate_c('Pedigree',        'Sealing');
			case 'M': return /* I18N: “sealing” is a ceremony in the Mormon church. */ WT_I18N::translate_c('Male pedigree',   'Sealing');
			case 'F': return /* I18N: “sealing” is a ceremony in the Mormon church. */ WT_I18N::translate_c('Female 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. */ WT_I18N::translate('Rada');
		default:
			return $type;
		}
	}

	// A list of all possible values for PEDI
	public static function getValues($record=null) {
		$values=array();
		foreach (self::$TYPES as $type) {
			$values[$type]=self::getValue($type, $record);
		}
		uasort($values, 'utf8_strcasecmp');
		return $values;
	}

	// A label for a parental family group
	public static function getChildFamilyLabel($pedi) {
		switch ($pedi) {
		case '':
		case 'birth':   return WT_I18N::translate('Family with parents');
		case 'adopted': return WT_I18N::translate('Family with adoptive parents');
		case 'foster':  return WT_I18N::translate('Family with foster parents');
		case 'sealing': return /* I18N: “sealing” is a Mormon ceremony. */ WT_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. */ WT_I18N::translate('Family with rada parents');
		default:        return WT_I18N::translate('Family with parents').' - '.$pedi;
		}
	}

	// Create GEDCOM for a new child-family pedigree
	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";
		}
	}
}