Test Failed
Branch master (4a3c5b)
by Greg
12:31
created
edit_interface.php 1 patch
Switch Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -288,40 +288,40 @@  discard block
 block discarded – undo
288 288
 
289 289
 	$level1type = $edit_fact->getTag();
290 290
 	switch ($record::RECORD_TYPE) {
291
-	case 'REPO':
292
-		// REPO:NAME facts may take a NOTE (but the REPO record may not).
293
-		if ($level1type === 'NAME') {
294
-			FunctionsEdit::printAddLayer('NOTE');
295
-			FunctionsEdit::printAddLayer('SHARED_NOTE');
296
-		}
297
-		break;
298
-	case 'FAM':
299
-	case 'INDI':
300
-		// FAM and INDI records have real facts. They can take NOTE/SOUR/OBJE/etc.
301
-		if ($level1type !== 'SEX' && $level1type !== 'NOTE' && $level1type !== 'ALIA') {
302
-			if ($level1type !== 'SOUR') {
303
-				FunctionsEdit::printAddLayer('SOUR');
304
-			}
305
-			if ($level1type !== 'OBJE') {
306
-				FunctionsEdit::printAddLayer('OBJE');
307
-			}
308
-			FunctionsEdit::printAddLayer('NOTE');
309
-			FunctionsEdit::printAddLayer('SHARED_NOTE', 2, $level1type);
310
-			if ($level1type !== 'ASSO' && $level1type !== 'NOTE' && $level1type !== 'SOUR') {
311
-				FunctionsEdit::printAddLayer('ASSO');
312
-			}
313
-			// allow to add godfather and godmother for CHR fact or best man and bridesmaid  for MARR fact in one window
314
-			if (in_array($level1type, Config::twoAssociates())) {
315
-				FunctionsEdit::printAddLayer('ASSO2');
291
+		case 'REPO':
292
+			// REPO:NAME facts may take a NOTE (but the REPO record may not).
293
+			if ($level1type === 'NAME') {
294
+				FunctionsEdit::printAddLayer('NOTE');
295
+				FunctionsEdit::printAddLayer('SHARED_NOTE');
316 296
 			}
317
-			if ($level1type !== 'SOUR') {
318
-				FunctionsEdit::printAddLayer('RESN');
297
+			break;
298
+		case 'FAM':
299
+		case 'INDI':
300
+			// FAM and INDI records have real facts. They can take NOTE/SOUR/OBJE/etc.
301
+			if ($level1type !== 'SEX' && $level1type !== 'NOTE' && $level1type !== 'ALIA') {
302
+				if ($level1type !== 'SOUR') {
303
+					FunctionsEdit::printAddLayer('SOUR');
304
+				}
305
+				if ($level1type !== 'OBJE') {
306
+					FunctionsEdit::printAddLayer('OBJE');
307
+				}
308
+				FunctionsEdit::printAddLayer('NOTE');
309
+				FunctionsEdit::printAddLayer('SHARED_NOTE', 2, $level1type);
310
+				if ($level1type !== 'ASSO' && $level1type !== 'NOTE' && $level1type !== 'SOUR') {
311
+					FunctionsEdit::printAddLayer('ASSO');
312
+				}
313
+				// allow to add godfather and godmother for CHR fact or best man and bridesmaid  for MARR fact in one window
314
+				if (in_array($level1type, Config::twoAssociates())) {
315
+					FunctionsEdit::printAddLayer('ASSO2');
316
+				}
317
+				if ($level1type !== 'SOUR') {
318
+					FunctionsEdit::printAddLayer('RESN');
319
+				}
319 320
 			}
320
-		}
321
-		break;
322
-	default:
323
-		// Other types of record do not have these lower-level records
324
-		break;
321
+			break;
322
+		default:
323
+			// Other types of record do not have these lower-level records
324
+			break;
325 325
 	}
326 326
 
327 327
 	?>
@@ -2120,15 +2120,15 @@  discard block
 block discarded – undo
2120 2120
 							<b>
2121 2121
 								<?php
2122 2122
 								switch ($father->getSex()) {
2123
-								case 'M':
2124
-									echo I18N::translate('husband');
2125
-									break;
2126
-								case 'F':
2127
-									echo I18N::translate('wife');
2128
-									break;
2129
-								default:
2130
-									echo I18N::translate('spouse');
2131
-									break;
2123
+									case 'M':
2124
+										echo I18N::translate('husband');
2125
+										break;
2126
+									case 'F':
2127
+										echo I18N::translate('wife');
2128
+										break;
2129
+									default:
2130
+										echo I18N::translate('spouse');
2131
+										break;
2132 2132
 								}
2133 2133
 								?>
2134 2134
 							</b>
@@ -2159,15 +2159,15 @@  discard block
 block discarded – undo
2159 2159
 							<b>
2160 2160
 								<?php
2161 2161
 								switch ($mother->getSex()) {
2162
-								case 'M':
2163
-									echo I18N::translate('husband');
2164
-									break;
2165
-								case 'F':
2166
-									echo I18N::translate('wife');
2167
-									break;
2168
-								default:
2169
-									echo I18N::translate('spouse');
2170
-									break;
2162
+									case 'M':
2163
+										echo I18N::translate('husband');
2164
+										break;
2165
+									case 'F':
2166
+										echo I18N::translate('wife');
2167
+										break;
2168
+									default:
2169
+										echo I18N::translate('spouse');
2170
+										break;
2171 2171
 								}
2172 2172
 								?>
2173 2173
 							</b>
@@ -2200,15 +2200,15 @@  discard block
 block discarded – undo
2200 2200
 							<b>
2201 2201
 								<?php
2202 2202
 								switch ($child->getSex()) {
2203
-								case 'M':
2204
-									echo I18N::translate('son');
2205
-									break;
2206
-								case 'F':
2207
-									echo I18N::translate('daughter');
2208
-									break;
2209
-								default:
2210
-									echo I18N::translate('child');
2211
-									break;
2203
+									case 'M':
2204
+										echo I18N::translate('son');
2205
+										break;
2206
+									case 'F':
2207
+										echo I18N::translate('daughter');
2208
+										break;
2209
+									default:
2210
+										echo I18N::translate('child');
2211
+										break;
2212 2212
 								}
2213 2213
 								?>
2214 2214
 							</b>
@@ -2886,35 +2886,35 @@  discard block
 block discarded – undo
2886 2886
 		}
2887 2887
 
2888 2888
 		switch ($nextaction) {
2889
-		case 'add_child_to_family_action':
2890
-			$name_fields = array_merge($name_fields, $surname_tradition->newChildNames($father_name, $mother_name, $gender));
2891
-			break;
2892
-		case 'add_child_to_individual_action':
2893
-			if ($person->getSex() === 'F') {
2894
-				$name_fields = array_merge($name_fields, $surname_tradition->newChildNames('', $indi_name, $gender));
2895
-			} else {
2896
-				$name_fields = array_merge($name_fields, $surname_tradition->newChildNames($indi_name, '', $gender));
2897
-			}
2898
-			break;
2899
-		case 'add_parent_to_individual_action':
2900
-			$name_fields = array_merge($name_fields, $surname_tradition->newParentNames($indi_name, $gender));
2901
-			break;
2902
-		case 'add_spouse_to_family_action':
2903
-			if ($father) {
2904
-				$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($father_name, $gender));
2905
-			} else {
2906
-				$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($mother_name, $gender));
2907
-			}
2908
-			break;
2909
-		case 'add_spouse_to_individual_action':
2910
-			$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($indi_name, $gender));
2911
-			break;
2912
-		case 'add_unlinked_indi_action':
2913
-		case 'update':
2914
-			if ($surname_tradition->hasSurnames()) {
2915
-				$name_fields['NAME'] = '//';
2916
-			}
2917
-			break;
2889
+			case 'add_child_to_family_action':
2890
+				$name_fields = array_merge($name_fields, $surname_tradition->newChildNames($father_name, $mother_name, $gender));
2891
+				break;
2892
+			case 'add_child_to_individual_action':
2893
+				if ($person->getSex() === 'F') {
2894
+					$name_fields = array_merge($name_fields, $surname_tradition->newChildNames('', $indi_name, $gender));
2895
+				} else {
2896
+					$name_fields = array_merge($name_fields, $surname_tradition->newChildNames($indi_name, '', $gender));
2897
+				}
2898
+				break;
2899
+			case 'add_parent_to_individual_action':
2900
+				$name_fields = array_merge($name_fields, $surname_tradition->newParentNames($indi_name, $gender));
2901
+				break;
2902
+			case 'add_spouse_to_family_action':
2903
+				if ($father) {
2904
+					$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($father_name, $gender));
2905
+				} else {
2906
+					$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($mother_name, $gender));
2907
+				}
2908
+				break;
2909
+			case 'add_spouse_to_individual_action':
2910
+				$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($indi_name, $gender));
2911
+				break;
2912
+			case 'add_unlinked_indi_action':
2913
+			case 'update':
2914
+				if ($surname_tradition->hasSurnames()) {
2915
+					$name_fields['NAME'] = '//';
2916
+				}
2917
+				break;
2918 2918
 		}
2919 2919
 	}
2920 2920
 
@@ -2934,11 +2934,11 @@  discard block
 block discarded – undo
2934 2934
 	echo '<table class="table wt-facts-table">';
2935 2935
 
2936 2936
 	switch ($nextaction) {
2937
-	case 'add_child_to_family_action':
2938
-	case 'add_child_to_individual_action':
2939
-		// When adding a new child, specify the pedigree
2940
-		echo FunctionsEdit::addSimpleTag('0 PEDI');
2941
-		break;
2937
+		case 'add_child_to_family_action':
2938
+		case 'add_child_to_individual_action':
2939
+			// When adding a new child, specify the pedigree
2940
+			echo FunctionsEdit::addSimpleTag('0 PEDI');
2941
+			break;
2942 2942
 	}
2943 2943
 	// First - standard name fields
2944 2944
 	foreach ($name_fields as $tag => $value) {
Please login to merge, or discard this patch.
autocomplete.php 1 patch
Switch Indentation   +448 added lines, -448 removed lines patch added patch discarded remove patch
@@ -29,505 +29,505 @@
 block discarded – undo
29 29
 
30 30
 
31 31
 switch ($type) {
32
-case 'ASSO': // Associates of an individuals, whose name contains the search terms
33
-	header('Content-Type: text/plain; charset=UTF-8');
34
-
35
-	$data = [];
36
-	// Fetch all data, regardless of privacy
37
-	$rows = Database::prepare(
38
-		"SELECT 'INDI' AS type, i_id AS xref, i_gedcom AS gedcom, n_full" .
39
-		" FROM `##individuals`" .
40
-		" JOIN `##name` ON i_id = n_id AND i_file = n_file" .
41
-		" WHERE (n_full LIKE CONCAT('%', REPLACE(:term_1, ' ', '%'), '%') OR n_surn LIKE CONCAT('%', REPLACE(:term_2, ' ', '%'), '%')) AND i_file = :tree_id" .
42
-		" ORDER BY n_full COLLATE :collate"
43
-	)->execute([
44
-		'term_1'  => $term,
45
-		'term_2'  => $term,
46
-		'tree_id' => $WT_TREE->getTreeId(),
47
-		'collate' => I18N::collation(),
48
-	])->fetchAll();
49
-
50
-	// Filter for privacy and whether they could be alive at the right time
51
-	$event_date = Filter::get('extra');
52
-	$date       = new Date($event_date);
53
-	$event_jd   = $date->julianDay();
54
-	foreach ($rows as $row) {
55
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
56
-		if ($person->canShow()) {
57
-			if ($event_jd) {
58
-				// Exclude individuals who were born after the event.
59
-				$person_birth_jd = $person->getEstimatedBirthDate()->minimumJulianDay();
60
-				if ($person_birth_jd && $person_birth_jd > $event_jd) {
61
-					continue;
32
+	case 'ASSO': // Associates of an individuals, whose name contains the search terms
33
+		header('Content-Type: text/plain; charset=UTF-8');
34
+
35
+		$data = [];
36
+		// Fetch all data, regardless of privacy
37
+		$rows = Database::prepare(
38
+			"SELECT 'INDI' AS type, i_id AS xref, i_gedcom AS gedcom, n_full" .
39
+			" FROM `##individuals`" .
40
+			" JOIN `##name` ON i_id = n_id AND i_file = n_file" .
41
+			" WHERE (n_full LIKE CONCAT('%', REPLACE(:term_1, ' ', '%'), '%') OR n_surn LIKE CONCAT('%', REPLACE(:term_2, ' ', '%'), '%')) AND i_file = :tree_id" .
42
+			" ORDER BY n_full COLLATE :collate"
43
+		)->execute([
44
+			'term_1'  => $term,
45
+			'term_2'  => $term,
46
+			'tree_id' => $WT_TREE->getTreeId(),
47
+			'collate' => I18N::collation(),
48
+		])->fetchAll();
49
+
50
+		// Filter for privacy and whether they could be alive at the right time
51
+		$event_date = Filter::get('extra');
52
+		$date       = new Date($event_date);
53
+		$event_jd   = $date->julianDay();
54
+		foreach ($rows as $row) {
55
+			$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
56
+			if ($person->canShow()) {
57
+				if ($event_jd) {
58
+					// Exclude individuals who were born after the event.
59
+					$person_birth_jd = $person->getEstimatedBirthDate()->minimumJulianDay();
60
+					if ($person_birth_jd && $person_birth_jd > $event_jd) {
61
+						continue;
62
+					}
63
+					// Exclude individuals who died before the event.
64
+					$person_death_jd = $person->getEstimatedDeathDate()->maximumJulianDay();
65
+					if ($person_death_jd && $person_death_jd < $event_jd) {
66
+						continue;
67
+					}
62 68
 				}
63
-				// Exclude individuals who died before the event.
64
-				$person_death_jd = $person->getEstimatedDeathDate()->maximumJulianDay();
65
-				if ($person_death_jd && $person_death_jd < $event_jd) {
66
-					continue;
69
+				// Add the age (if we have it) or the lifespan (if we do not).
70
+				$label = $person->getFullName();
71
+				if ($event_jd && $person->getBirthDate()->isOK()) {
72
+					$label .= ', <span class="age">(' . I18N::translate('Age') . ' ' . Date::getAge($person->getBirthDate(), $date, 0) . ')</span>';
73
+				} else {
74
+					$label .= ', <i>' . $person->getLifeSpan() . '</i>';
67 75
 				}
76
+				$data[$row->xref] = ['value' => $row->xref, 'label' => $label];
68 77
 			}
69
-			// Add the age (if we have it) or the lifespan (if we do not).
70
-			$label = $person->getFullName();
71
-			if ($event_jd && $person->getBirthDate()->isOK()) {
72
-				$label .= ', <span class="age">(' . I18N::translate('Age') . ' ' . Date::getAge($person->getBirthDate(), $date, 0) . ')</span>';
73
-			} else {
74
-				$label .= ', <i>' . $person->getLifeSpan() . '</i>';
75
-			}
76
-			$data[$row->xref] = ['value' => $row->xref, 'label' => $label];
77 78
 		}
78
-	}
79
-	echo json_encode($data);
79
+		echo json_encode($data);
80 80
 
81
-	return;
81
+		return;
82 82
 
83
-case 'CEME': // Cemetery fields, that contain the search term
84
-	header('Content-Type: text/plain; charset=UTF-8');
83
+	case 'CEME': // Cemetery fields, that contain the search term
84
+		header('Content-Type: text/plain; charset=UTF-8');
85 85
 
86
-	$data = [];
87
-	// Fetch all data, regardless of privacy
88
-	$rows = Database::prepare(
89
-		"SELECT SQL_CACHE i_id AS xref, i_gedcom AS gedcom" .
90
-		" FROM `##individuals`" .
91
-		" WHERE i_gedcom LIKE '%\n2 CEME %' AND i_file = :tree_id" .
92
-		" ORDER BY SUBSTRING_INDEX(i_gedcom, '\n2 CEME ', -1) COLLATE :collation"
93
-	)->execute([
94
-		'tree_id'   => $WT_TREE->getTreeId(),
95
-		'collation' => I18N::collation(),
96
-	])->fetchAll();
97
-	// Filter for privacy
98
-	foreach ($rows as $row) {
99
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
100
-		if (preg_match('/\n2 CEME (.*' . preg_quote($term, '/') . '.*)/i', $person->getGedcom(), $match)) {
101
-			if (!in_array($match[1], $data)) {
102
-				$data[] = $match[1];
86
+		$data = [];
87
+		// Fetch all data, regardless of privacy
88
+		$rows = Database::prepare(
89
+			"SELECT SQL_CACHE i_id AS xref, i_gedcom AS gedcom" .
90
+			" FROM `##individuals`" .
91
+			" WHERE i_gedcom LIKE '%\n2 CEME %' AND i_file = :tree_id" .
92
+			" ORDER BY SUBSTRING_INDEX(i_gedcom, '\n2 CEME ', -1) COLLATE :collation"
93
+		)->execute([
94
+			'tree_id'   => $WT_TREE->getTreeId(),
95
+			'collation' => I18N::collation(),
96
+		])->fetchAll();
97
+		// Filter for privacy
98
+		foreach ($rows as $row) {
99
+			$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
100
+			if (preg_match('/\n2 CEME (.*' . preg_quote($term, '/') . '.*)/i', $person->getGedcom(), $match)) {
101
+				if (!in_array($match[1], $data)) {
102
+					$data[] = $match[1];
103
+				}
103 104
 			}
104 105
 		}
105
-	}
106
-	echo json_encode($data);
107
-
108
-	return;
109
-
110
-case 'FAM': // Families, whose name contains the search terms
111
-	header('Content-Type: text/plain; charset=UTF-8');
112
-
113
-	$data = [];
114
-	// Fetch all data, regardless of privacy
115
-	$rows = get_FAM_rows($WT_TREE, $term);
116
-	// Filter for privacy
117
-	foreach ($rows as $row) {
118
-		$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
119
-		if ($family->canShowName()) {
120
-			$marriage_year = $family->getMarriageYear();
121
-			if ($marriage_year) {
122
-				$data[] = ['value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>'];
123
-			} else {
124
-				$data[] = ['value' => $family->getXref(), 'label' => $family->getFullName()];
106
+		echo json_encode($data);
107
+
108
+		return;
109
+
110
+	case 'FAM': // Families, whose name contains the search terms
111
+		header('Content-Type: text/plain; charset=UTF-8');
112
+
113
+		$data = [];
114
+		// Fetch all data, regardless of privacy
115
+		$rows = get_FAM_rows($WT_TREE, $term);
116
+		// Filter for privacy
117
+		foreach ($rows as $row) {
118
+			$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
119
+			if ($family->canShowName()) {
120
+				$marriage_year = $family->getMarriageYear();
121
+				if ($marriage_year) {
122
+					$data[] = ['value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>'];
123
+				} else {
124
+					$data[] = ['value' => $family->getXref(), 'label' => $family->getFullName()];
125
+				}
125 126
 			}
126 127
 		}
127
-	}
128
-	echo json_encode($data);
129
-
130
-	return;
131
-
132
-case 'GIVN': // Given names, that start with the search term
133
-	header('Content-Type: text/plain; charset=UTF-8');
134
-
135
-	// Do not filter by privacy. Given names on their own do not identify individuals.
136
-	echo json_encode(
137
-		Database::prepare(
138
-			"SELECT SQL_CACHE DISTINCT n_givn" .
139
-			" FROM `##name`" .
140
-			" WHERE n_givn LIKE CONCAT(:term, '%') AND n_file = :tree_id" .
141
-			" ORDER BY n_givn COLLATE :collation"
128
+		echo json_encode($data);
129
+
130
+		return;
131
+
132
+	case 'GIVN': // Given names, that start with the search term
133
+		header('Content-Type: text/plain; charset=UTF-8');
134
+
135
+		// Do not filter by privacy. Given names on their own do not identify individuals.
136
+		echo json_encode(
137
+			Database::prepare(
138
+				"SELECT SQL_CACHE DISTINCT n_givn" .
139
+				" FROM `##name`" .
140
+				" WHERE n_givn LIKE CONCAT(:term, '%') AND n_file = :tree_id" .
141
+				" ORDER BY n_givn COLLATE :collation"
142
+			)->execute([
143
+				'term'      => $term,
144
+				'tree_id'   => $WT_TREE->getTreeId(),
145
+				'collation' => I18N::collation(),
146
+			])->fetchOneColumn()
147
+		);
148
+
149
+		return;
150
+
151
+	case 'INDI': // Individuals, whose name contains the search terms
152
+		header('Content-Type: text/plain; charset=UTF-8');
153
+
154
+		$data = [];
155
+		// Fetch all data, regardless of privacy
156
+		$rows = Database::prepare(
157
+			"SELECT i_id AS xref, i_gedcom AS gedcom, n_full" .
158
+			" FROM `##individuals`" .
159
+			" JOIN `##name` ON i_id = n_id AND i_file = n_file" .
160
+			" WHERE (n_full LIKE CONCAT('%', REPLACE(:term_1, ' ', '%'), '%') OR n_surn LIKE CONCAT('%', REPLACE(:term_2, ' ', '%'), '%')) AND i_file = :tree_id" .
161
+			" ORDER BY n_full COLLATE :collation"
142 162
 		)->execute([
143
-			'term'      => $term,
163
+			'term_1'    => $term,
164
+			'term_2'    => $term,
144 165
 			'tree_id'   => $WT_TREE->getTreeId(),
145 166
 			'collation' => I18N::collation(),
146
-		])->fetchOneColumn()
147
-	);
167
+		])->fetchAll();
168
+		// Filter for privacy
169
+		foreach ($rows as $row) {
170
+			$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
171
+			if ($person->canShowName()) {
172
+				$data[] = ['value' => $row->xref, 'label' => str_replace(['@N.N.', '@P.N.'], [I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')], $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>'];
173
+			}
174
+		}
175
+		echo json_encode($data);
148 176
 
149
-	return;
177
+		return;
150 178
 
151
-case 'INDI': // Individuals, whose name contains the search terms
152
-	header('Content-Type: text/plain; charset=UTF-8');
179
+	case 'NOTE': // Notes which contain the search terms
180
+		header('Content-Type: text/plain; charset=UTF-8');
153 181
 
154
-	$data = [];
155
-	// Fetch all data, regardless of privacy
156
-	$rows = Database::prepare(
157
-		"SELECT i_id AS xref, i_gedcom AS gedcom, n_full" .
158
-		" FROM `##individuals`" .
159
-		" JOIN `##name` ON i_id = n_id AND i_file = n_file" .
160
-		" WHERE (n_full LIKE CONCAT('%', REPLACE(:term_1, ' ', '%'), '%') OR n_surn LIKE CONCAT('%', REPLACE(:term_2, ' ', '%'), '%')) AND i_file = :tree_id" .
161
-		" ORDER BY n_full COLLATE :collation"
162
-	)->execute([
163
-		'term_1'    => $term,
164
-		'term_2'    => $term,
165
-		'tree_id'   => $WT_TREE->getTreeId(),
166
-		'collation' => I18N::collation(),
167
-	])->fetchAll();
168
-	// Filter for privacy
169
-	foreach ($rows as $row) {
170
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
171
-		if ($person->canShowName()) {
172
-			$data[] = ['value' => $row->xref, 'label' => str_replace(['@N.N.', '@P.N.'], [I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')], $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>'];
173
-		}
174
-	}
175
-	echo json_encode($data);
176
-
177
-	return;
178
-
179
-case 'NOTE': // Notes which contain the search terms
180
-	header('Content-Type: text/plain; charset=UTF-8');
181
-
182
-	$data = [];
183
-	// Fetch all data, regardless of privacy
184
-	$rows = get_NOTE_rows($WT_TREE, $term);
185
-	// Filter for privacy
186
-	foreach ($rows as $row) {
187
-		$note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom);
188
-		if ($note->canShowName()) {
189
-			$data[] = ['value' => $note->getXref(), 'label' => $note->getFullName()];
190
-		}
191
-	}
192
-	echo json_encode($data);
193
-
194
-	return;
195
-
196
-case 'OBJE':
197
-	header('Content-Type: text/plain; charset=UTF-8');
198
-
199
-	$data = [];
200
-	// Fetch all data, regardless of privacy
201
-	$rows = get_OBJE_rows($WT_TREE, $term);
202
-	// Filter for privacy
203
-	foreach ($rows as $row) {
204
-		$media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
205
-		if ($media->canShowName()) {
206
-			$data[] = ['value' => $row->xref, 'label' => '<img src="' . $media->imageUrl(25, 25, 'crop') . '" width="25" height="25"> ' . $media->getFullName()];
207
-		}
208
-	}
209
-	echo json_encode($data);
210
-
211
-	return;
212
-
213
-case 'PLAC': // Place names (with hierarchy), that include the search term
214
-	header('Content-Type: text/plain; charset=UTF-8');
215
-
216
-	// Do not filter by privacy. Place names on their own do not identify individuals.
217
-	$data = [];
218
-	foreach (Place::findPlaces($term, $WT_TREE) as $place) {
219
-		$data[] = $place->getGedcomName();
220
-	}
221
-	if (!$data && $WT_TREE->getPreference('GEONAMES_ACCOUNT')) {
222
-		// No place found? Use an external gazetteer
223
-		$url =
224
-			"http://api.geonames.org/searchJSON" .
225
-			"?name_startsWith=" . urlencode($term) .
226
-			"&lang=" . WT_LOCALE .
227
-			"&fcode=CMTY&fcode=ADM4&fcode=PPL&fcode=PPLA&fcode=PPLC" .
228
-			"&style=full" .
229
-			"&username=" . $WT_TREE->getPreference('GEONAMES_ACCOUNT');
230
-		// try to use curl when file_get_contents not allowed
231
-		if (ini_get('allow_url_fopen')) {
232
-			$json = file_get_contents($url);
233
-		} elseif (function_exists('curl_init')) {
234
-			$ch = curl_init();
235
-			curl_setopt($ch, CURLOPT_URL, $url);
236
-			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
237
-			$json = curl_exec($ch);
238
-			curl_close($ch);
239
-		} else {
240
-			return $data;
241
-		}
242
-		$places = json_decode($json, true);
243
-		if (isset($places['geonames']) && is_array($places['geonames'])) {
244
-			foreach ($places['geonames'] as $k => $place) {
245
-				$data[] = $place['name'] . ', ' . $place['adminName2'] . ', ' . $place['adminName1'] . ', ' . $place['countryName'];
182
+		$data = [];
183
+		// Fetch all data, regardless of privacy
184
+		$rows = get_NOTE_rows($WT_TREE, $term);
185
+		// Filter for privacy
186
+		foreach ($rows as $row) {
187
+			$note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom);
188
+			if ($note->canShowName()) {
189
+				$data[] = ['value' => $note->getXref(), 'label' => $note->getFullName()];
246 190
 			}
247 191
 		}
248
-	}
249
-	echo json_encode($data);
192
+		echo json_encode($data);
250 193
 
251
-	return;
194
+		return;
252 195
 
253
-case 'PLAC2': // Place names (without hierarchy), that include the search term
254
-	header('Content-Type: text/plain; charset=UTF-8');
196
+	case 'OBJE':
197
+		header('Content-Type: text/plain; charset=UTF-8');
255 198
 
256
-	// Do not filter by privacy. Place names on their own do not identify individuals.
257
-	echo json_encode(
258
-		Database::prepare(
259
-			"SELECT SQL_CACHE p_place" .
260
-			" FROM `##places`" .
261
-			" WHERE p_place LIKE CONCAT('%', :term, '%') AND p_file = :tree_id" .
262
-			" ORDER BY p_place COLLATE :collation"
263
-		)->execute([
264
-			'term'      => $term,
265
-			'tree_id'   => $WT_TREE->getTreeId(),
266
-			'collation' => I18N::collation(),
267
-		])->fetchOneColumn()
268
-	);
269
-
270
-	return;
271
-
272
-case 'REPO': // Repositories, that include the search terms
273
-	header('Content-Type: text/plain; charset=UTF-8');
274
-
275
-	$data = [];
276
-	// Fetch all data, regardless of privacy
277
-	$rows = get_REPO_rows($WT_TREE, $term);
278
-	// Filter for privacy
279
-	foreach ($rows as $row) {
280
-		$record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
281
-		if ($record->canShowName()) {
282
-			foreach ($record->getFacts('NAME') as $fact) {
283
-				$data[] = ['value' => $record->getXref(), 'label' => $fact->getValue()];
284
-			}
285
-		}
286
-	}
287
-	echo json_encode($data);
288
-
289
-	return;
290
-
291
-case 'REPO_NAME': // Repository names, that include the search terms
292
-	header('Content-Type: text/plain; charset=UTF-8');
293
-
294
-	$data = [];
295
-	// Fetch all data, regardless of privacy
296
-	$rows = get_REPO_rows($WT_TREE, $term);
297
-	// Filter for privacy
298
-	foreach ($rows as $row) {
299
-		$record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
300
-		if ($record->canShowName()) {
301
-			$data[] = strip_tags($record->getFullName());
302
-		}
303
-	}
304
-	echo json_encode($data);
305
-
306
-	return;
307
-
308
-case 'SOUR': // Sources, that include the search terms
309
-	header('Content-Type: text/plain; charset=UTF-8');
310
-
311
-	$data = [];
312
-	// Fetch all data, regardless of privacy
313
-	$rows = get_SOUR_rows($WT_TREE, $term);
314
-	// Filter for privacy
315
-	foreach ($rows as $row) {
316
-		$record = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
317
-		if ($record->canShowName()) {
318
-			foreach ($record->getFacts('TITL') as $fact) {
319
-				$data[] = ['value' => $record->getXref(), 'label' => $fact->getValue()];
199
+		$data = [];
200
+		// Fetch all data, regardless of privacy
201
+		$rows = get_OBJE_rows($WT_TREE, $term);
202
+		// Filter for privacy
203
+		foreach ($rows as $row) {
204
+			$media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
205
+			if ($media->canShowName()) {
206
+				$data[] = ['value' => $row->xref, 'label' => '<img src="' . $media->imageUrl(25, 25, 'crop') . '" width="25" height="25"> ' . $media->getFullName()];
320 207
 			}
321 208
 		}
322
-	}
323
-	echo json_encode($data);
209
+		echo json_encode($data);
324 210
 
325
-	return;
211
+		return;
326 212
 
327
-case 'PAGE': // Citation details, for a given source, that contain the search term
328
-	header('Content-Type: text/plain; charset=UTF-8');
213
+	case 'PLAC': // Place names (with hierarchy), that include the search term
214
+		header('Content-Type: text/plain; charset=UTF-8');
329 215
 
330
-	$data = [];
331
-	$sid  = Filter::get('extra', WT_REGEX_XREF);
332
-	// Fetch all data, regardless of privacy
333
-	$rows = Database::prepare(
334
-		"SELECT SQL_CACHE i_id AS xref, i_gedcom AS gedcom" .
335
-		" FROM `##individuals`" .
336
-		" WHERE i_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND i_file = :tree_id"
337
-	)->execute([
338
-		'xref'    => $sid,
339
-		'term'    => $term,
340
-		'tree_id' => $WT_TREE->getTreeId(),
341
-	])->fetchAll();
342
-	// Filter for privacy
343
-	foreach ($rows as $row) {
344
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
345
-		if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) {
346
-			$data[] = $match[1];
216
+		// Do not filter by privacy. Place names on their own do not identify individuals.
217
+		$data = [];
218
+		foreach (Place::findPlaces($term, $WT_TREE) as $place) {
219
+			$data[] = $place->getGedcomName();
347 220
 		}
348
-		if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) {
349
-			$data[] = $match[1];
221
+		if (!$data && $WT_TREE->getPreference('GEONAMES_ACCOUNT')) {
222
+			// No place found? Use an external gazetteer
223
+			$url =
224
+				"http://api.geonames.org/searchJSON" .
225
+				"?name_startsWith=" . urlencode($term) .
226
+				"&lang=" . WT_LOCALE .
227
+				"&fcode=CMTY&fcode=ADM4&fcode=PPL&fcode=PPLA&fcode=PPLC" .
228
+				"&style=full" .
229
+				"&username=" . $WT_TREE->getPreference('GEONAMES_ACCOUNT');
230
+			// try to use curl when file_get_contents not allowed
231
+			if (ini_get('allow_url_fopen')) {
232
+				$json = file_get_contents($url);
233
+			} elseif (function_exists('curl_init')) {
234
+				$ch = curl_init();
235
+				curl_setopt($ch, CURLOPT_URL, $url);
236
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
237
+				$json = curl_exec($ch);
238
+				curl_close($ch);
239
+			} else {
240
+				return $data;
241
+			}
242
+			$places = json_decode($json, true);
243
+			if (isset($places['geonames']) && is_array($places['geonames'])) {
244
+				foreach ($places['geonames'] as $k => $place) {
245
+					$data[] = $place['name'] . ', ' . $place['adminName2'] . ', ' . $place['adminName1'] . ', ' . $place['countryName'];
246
+				}
247
+			}
350 248
 		}
351
-	}
352
-	// Fetch all data, regardless of privacy
353
-	$rows = Database::prepare(
354
-		"SELECT SQL_CACHE f_id AS xref, f_gedcom AS gedcom" .
355
-		" FROM `##families`" .
356
-		" WHERE f_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND f_file = :tree_id"
357
-	)->execute([
358
-		'xref'    => $sid,
359
-		'term'    => $term,
360
-		'tree_id' => $WT_TREE->getTreeId(),
361
-	])->fetchAll();
362
-	// Filter for privacy
363
-	foreach ($rows as $row) {
364
-		$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
365
-		if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) {
366
-			$data[] = $match[1];
249
+		echo json_encode($data);
250
+
251
+		return;
252
+
253
+	case 'PLAC2': // Place names (without hierarchy), that include the search term
254
+		header('Content-Type: text/plain; charset=UTF-8');
255
+
256
+		// Do not filter by privacy. Place names on their own do not identify individuals.
257
+		echo json_encode(
258
+			Database::prepare(
259
+				"SELECT SQL_CACHE p_place" .
260
+				" FROM `##places`" .
261
+				" WHERE p_place LIKE CONCAT('%', :term, '%') AND p_file = :tree_id" .
262
+				" ORDER BY p_place COLLATE :collation"
263
+			)->execute([
264
+				'term'      => $term,
265
+				'tree_id'   => $WT_TREE->getTreeId(),
266
+				'collation' => I18N::collation(),
267
+			])->fetchOneColumn()
268
+		);
269
+
270
+		return;
271
+
272
+	case 'REPO': // Repositories, that include the search terms
273
+		header('Content-Type: text/plain; charset=UTF-8');
274
+
275
+		$data = [];
276
+		// Fetch all data, regardless of privacy
277
+		$rows = get_REPO_rows($WT_TREE, $term);
278
+		// Filter for privacy
279
+		foreach ($rows as $row) {
280
+			$record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
281
+			if ($record->canShowName()) {
282
+				foreach ($record->getFacts('NAME') as $fact) {
283
+					$data[] = ['value' => $record->getXref(), 'label' => $fact->getValue()];
284
+				}
285
+			}
367 286
 		}
368
-		if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) {
369
-			$data[] = $match[1];
287
+		echo json_encode($data);
288
+
289
+		return;
290
+
291
+	case 'REPO_NAME': // Repository names, that include the search terms
292
+		header('Content-Type: text/plain; charset=UTF-8');
293
+
294
+		$data = [];
295
+		// Fetch all data, regardless of privacy
296
+		$rows = get_REPO_rows($WT_TREE, $term);
297
+		// Filter for privacy
298
+		foreach ($rows as $row) {
299
+			$record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
300
+			if ($record->canShowName()) {
301
+				$data[] = strip_tags($record->getFullName());
302
+			}
370 303
 		}
371
-	}
372
-	// array_unique() converts the keys from integer to string, which breaks
373
-	// the JSON encoding - so need to call array_values() to convert them
374
-	// back into integers.
375
-	$data = array_values(array_unique($data));
376
-	echo json_encode($data);
377
-
378
-	return;
379
-
380
-case 'SOUR_TITL': // Source titles, that include the search terms
381
-	header('Content-Type: text/plain; charset=UTF-8');
382
-
383
-	$data = [];
384
-	// Fetch all data, regardless of privacy
385
-	$rows = Database::prepare(
386
-		"SELECT s_id AS xref, s_gedcom AS gedcom, s_name" .
387
-		" FROM `##sources`" .
388
-		" WHERE s_name LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND s_file = :tree_id" .
389
-		" ORDER BY s_name COLLATE :collation"
390
-	)->execute([
391
-		'term'      => $term,
392
-		'tree_id'   => $WT_TREE->getTreeId(),
393
-		'collation' => I18N::collation(),
394
-	])->fetchAll();
395
-	// Filter for privacy
396
-	foreach ($rows as $row) {
397
-		$source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
398
-		if ($source->canShowName()) {
399
-			$data[] = $row->s_name;
304
+		echo json_encode($data);
305
+
306
+		return;
307
+
308
+	case 'SOUR': // Sources, that include the search terms
309
+		header('Content-Type: text/plain; charset=UTF-8');
310
+
311
+		$data = [];
312
+		// Fetch all data, regardless of privacy
313
+		$rows = get_SOUR_rows($WT_TREE, $term);
314
+		// Filter for privacy
315
+		foreach ($rows as $row) {
316
+			$record = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
317
+			if ($record->canShowName()) {
318
+				foreach ($record->getFacts('TITL') as $fact) {
319
+					$data[] = ['value' => $record->getXref(), 'label' => $fact->getValue()];
320
+				}
321
+			}
400 322
 		}
401
-	}
402
-	echo json_encode($data);
323
+		echo json_encode($data);
403 324
 
404
-	return;
325
+		return;
405 326
 
406
-case 'SURN': // Surnames, that start with the search term
407
-	header('Content-Type: text/plain; charset=UTF-8');
327
+	case 'PAGE': // Citation details, for a given source, that contain the search term
328
+		header('Content-Type: text/plain; charset=UTF-8');
408 329
 
409
-	// Do not filter by privacy. Surnames on their own do not identify individuals.
410
-	echo json_encode(
411
-		Database::prepare(
412
-			"SELECT SQL_CACHE DISTINCT n_surname" .
413
-			" FROM `##name`" .
414
-			" WHERE n_surname LIKE CONCAT(:term, '%') AND n_file = :tree_id" .
415
-			" ORDER BY n_surname COLLATE :collation"
330
+		$data = [];
331
+		$sid  = Filter::get('extra', WT_REGEX_XREF);
332
+		// Fetch all data, regardless of privacy
333
+		$rows = Database::prepare(
334
+			"SELECT SQL_CACHE i_id AS xref, i_gedcom AS gedcom" .
335
+			" FROM `##individuals`" .
336
+			" WHERE i_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND i_file = :tree_id"
337
+		)->execute([
338
+			'xref'    => $sid,
339
+			'term'    => $term,
340
+			'tree_id' => $WT_TREE->getTreeId(),
341
+		])->fetchAll();
342
+		// Filter for privacy
343
+		foreach ($rows as $row) {
344
+			$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
345
+			if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) {
346
+				$data[] = $match[1];
347
+			}
348
+			if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) {
349
+				$data[] = $match[1];
350
+			}
351
+		}
352
+		// Fetch all data, regardless of privacy
353
+		$rows = Database::prepare(
354
+			"SELECT SQL_CACHE f_id AS xref, f_gedcom AS gedcom" .
355
+			" FROM `##families`" .
356
+			" WHERE f_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND f_file = :tree_id"
357
+		)->execute([
358
+			'xref'    => $sid,
359
+			'term'    => $term,
360
+			'tree_id' => $WT_TREE->getTreeId(),
361
+		])->fetchAll();
362
+		// Filter for privacy
363
+		foreach ($rows as $row) {
364
+			$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
365
+			if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) {
366
+				$data[] = $match[1];
367
+			}
368
+			if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) {
369
+				$data[] = $match[1];
370
+			}
371
+		}
372
+		// array_unique() converts the keys from integer to string, which breaks
373
+		// the JSON encoding - so need to call array_values() to convert them
374
+		// back into integers.
375
+		$data = array_values(array_unique($data));
376
+		echo json_encode($data);
377
+
378
+		return;
379
+
380
+	case 'SOUR_TITL': // Source titles, that include the search terms
381
+		header('Content-Type: text/plain; charset=UTF-8');
382
+
383
+		$data = [];
384
+		// Fetch all data, regardless of privacy
385
+		$rows = Database::prepare(
386
+			"SELECT s_id AS xref, s_gedcom AS gedcom, s_name" .
387
+			" FROM `##sources`" .
388
+			" WHERE s_name LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND s_file = :tree_id" .
389
+			" ORDER BY s_name COLLATE :collation"
416 390
 		)->execute([
417 391
 			'term'      => $term,
418 392
 			'tree_id'   => $WT_TREE->getTreeId(),
419 393
 			'collation' => I18N::collation(),
420
-		])->fetchOneColumn()
421
-	);
422
-
423
-	return;
424
-
425
-case 'IFSRO':
426
-	header('Content-Type: text/plain; charset=UTF-8');
427
-
428
-	$data = [];
429
-	// Fetch all data, regardless of privacy
430
-	$rows = get_INDI_rows($WT_TREE, $term);
431
-	// Filter for privacy
432
-	foreach ($rows as $row) {
433
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
434
-		if ($person->canShowName()) {
435
-			$data[] = ['value' => $person->getXref(), 'label' => str_replace(['@N.N.', '@P.N.'], [I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')], $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>'];
394
+		])->fetchAll();
395
+		// Filter for privacy
396
+		foreach ($rows as $row) {
397
+			$source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
398
+			if ($source->canShowName()) {
399
+				$data[] = $row->s_name;
400
+			}
436 401
 		}
437
-	}
438
-	// Fetch all data, regardless of privacy
439
-	$rows = get_SOUR_rows($WT_TREE, $term);
440
-	// Filter for privacy
441
-	foreach ($rows as $row) {
442
-		$source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
443
-		if ($source->canShowName()) {
444
-			$data[] = ['value' => $source->getXref(), 'label' => $source->getFullName()];
402
+		echo json_encode($data);
403
+
404
+		return;
405
+
406
+	case 'SURN': // Surnames, that start with the search term
407
+		header('Content-Type: text/plain; charset=UTF-8');
408
+
409
+		// Do not filter by privacy. Surnames on their own do not identify individuals.
410
+		echo json_encode(
411
+			Database::prepare(
412
+				"SELECT SQL_CACHE DISTINCT n_surname" .
413
+				" FROM `##name`" .
414
+				" WHERE n_surname LIKE CONCAT(:term, '%') AND n_file = :tree_id" .
415
+				" ORDER BY n_surname COLLATE :collation"
416
+			)->execute([
417
+				'term'      => $term,
418
+				'tree_id'   => $WT_TREE->getTreeId(),
419
+				'collation' => I18N::collation(),
420
+			])->fetchOneColumn()
421
+		);
422
+
423
+		return;
424
+
425
+	case 'IFSRO':
426
+		header('Content-Type: text/plain; charset=UTF-8');
427
+
428
+		$data = [];
429
+		// Fetch all data, regardless of privacy
430
+		$rows = get_INDI_rows($WT_TREE, $term);
431
+		// Filter for privacy
432
+		foreach ($rows as $row) {
433
+			$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
434
+			if ($person->canShowName()) {
435
+				$data[] = ['value' => $person->getXref(), 'label' => str_replace(['@N.N.', '@P.N.'], [I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')], $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>'];
436
+			}
437
+		}
438
+		// Fetch all data, regardless of privacy
439
+		$rows = get_SOUR_rows($WT_TREE, $term);
440
+		// Filter for privacy
441
+		foreach ($rows as $row) {
442
+			$source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
443
+			if ($source->canShowName()) {
444
+				$data[] = ['value' => $source->getXref(), 'label' => $source->getFullName()];
445
+			}
445 446
 		}
446
-	}
447
-	// Fetch all data, regardless of privacy
448
-	$rows = get_REPO_rows($WT_TREE, $term);
449
-	// Filter for privacy
450
-	foreach ($rows as $row) {
451
-		$repository = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
452
-		if ($repository->canShowName()) {
453
-			$data[] = ['value' => $repository->getXref(), 'label' => $repository->getFullName()];
447
+		// Fetch all data, regardless of privacy
448
+		$rows = get_REPO_rows($WT_TREE, $term);
449
+		// Filter for privacy
450
+		foreach ($rows as $row) {
451
+			$repository = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
452
+			if ($repository->canShowName()) {
453
+				$data[] = ['value' => $repository->getXref(), 'label' => $repository->getFullName()];
454
+			}
454 455
 		}
455
-	}
456
-	// Fetch all data, regardless of privacy
457
-	$rows = get_OBJE_rows($WT_TREE, $term);
458
-	// Filter for privacy
459
-	foreach ($rows as $row) {
460
-		$media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
461
-		if ($media->canShowName()) {
462
-			$data[] = ['value' => $media->getXref(), 'label' => '<img src="' . $media->imageUrl(25, 25, 'crop') . '" width="25" height="25"> ' . $media->getFullName()];
456
+		// Fetch all data, regardless of privacy
457
+		$rows = get_OBJE_rows($WT_TREE, $term);
458
+		// Filter for privacy
459
+		foreach ($rows as $row) {
460
+			$media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
461
+			if ($media->canShowName()) {
462
+				$data[] = ['value' => $media->getXref(), 'label' => '<img src="' . $media->imageUrl(25, 25, 'crop') . '" width="25" height="25"> ' . $media->getFullName()];
463
+			}
463 464
 		}
464
-	}
465
-	// Fetch all data, regardless of privacy
466
-	$rows = get_FAM_rows($WT_TREE, $term);
467
-	// Filter for privacy
468
-	foreach ($rows as $row) {
469
-		$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
470
-		if ($family->canShowName()) {
471
-			$marriage_year = $family->getMarriageYear();
472
-			if ($marriage_year) {
473
-				$data[] = ['value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>'];
474
-			} else {
475
-				$data[] = ['value' => $family->getXref(), 'label' => $family->getFullName()];
465
+		// Fetch all data, regardless of privacy
466
+		$rows = get_FAM_rows($WT_TREE, $term);
467
+		// Filter for privacy
468
+		foreach ($rows as $row) {
469
+			$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
470
+			if ($family->canShowName()) {
471
+				$marriage_year = $family->getMarriageYear();
472
+				if ($marriage_year) {
473
+					$data[] = ['value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>'];
474
+				} else {
475
+					$data[] = ['value' => $family->getXref(), 'label' => $family->getFullName()];
476
+				}
476 477
 			}
477 478
 		}
478
-	}
479
-	// Fetch all data, regardless of privacy
480
-	$rows = get_NOTE_rows($WT_TREE, $term);
481
-	// Filter for privacy
482
-	foreach ($rows as $row) {
483
-		$note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom);
484
-		if ($note->canShowName()) {
485
-			$data[] = ['value' => $note->getXref(), 'label' => $note->getFullName()];
479
+		// Fetch all data, regardless of privacy
480
+		$rows = get_NOTE_rows($WT_TREE, $term);
481
+		// Filter for privacy
482
+		foreach ($rows as $row) {
483
+			$note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom);
484
+			if ($note->canShowName()) {
485
+				$data[] = ['value' => $note->getXref(), 'label' => $note->getFullName()];
486
+			}
486 487
 		}
487
-	}
488
-	echo json_encode($data);
489
-
490
-	return;
491
-
492
-case 'IFS':
493
-	header('Content-Type: text/plain; charset=UTF-8');
494
-
495
-	$data = [];
496
-	// Fetch all data, regardless of privacy
497
-	$rows = get_INDI_rows($WT_TREE, $term);
498
-	// Filter for privacy
499
-	foreach ($rows as $row) {
500
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
501
-		if ($person->canShowName()) {
502
-			$data[] = ['value' => $person->getXref(), 'label' => str_replace(['@N.N.', '@P.N.'], [I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')], $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>'];
488
+		echo json_encode($data);
489
+
490
+		return;
491
+
492
+	case 'IFS':
493
+		header('Content-Type: text/plain; charset=UTF-8');
494
+
495
+		$data = [];
496
+		// Fetch all data, regardless of privacy
497
+		$rows = get_INDI_rows($WT_TREE, $term);
498
+		// Filter for privacy
499
+		foreach ($rows as $row) {
500
+			$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
501
+			if ($person->canShowName()) {
502
+				$data[] = ['value' => $person->getXref(), 'label' => str_replace(['@N.N.', '@P.N.'], [I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')], $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>'];
503
+			}
503 504
 		}
504
-	}
505
-	// Fetch all data, regardless of privacy
506
-	$rows = get_SOUR_rows($WT_TREE, $term);
507
-	// Filter for privacy
508
-	foreach ($rows as $row) {
509
-		$source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
510
-		if ($source->canShowName()) {
511
-			$data[] = ['value' => $source->getXref(), 'label' => $source->getFullName()];
505
+		// Fetch all data, regardless of privacy
506
+		$rows = get_SOUR_rows($WT_TREE, $term);
507
+		// Filter for privacy
508
+		foreach ($rows as $row) {
509
+			$source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
510
+			if ($source->canShowName()) {
511
+				$data[] = ['value' => $source->getXref(), 'label' => $source->getFullName()];
512
+			}
512 513
 		}
513
-	}
514
-	// Fetch all data, regardless of privacy
515
-	$rows = get_FAM_rows($WT_TREE, $term);
516
-	// Filter for privacy
517
-	foreach ($rows as $row) {
518
-		$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
519
-		if ($family->canShowName()) {
520
-			$marriage_year = $family->getMarriageYear();
521
-			if ($marriage_year) {
522
-				$data[] = ['value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>'];
523
-			} else {
524
-				$data[] = ['value' => $family->getXref(), 'label' => $family->getFullName()];
514
+		// Fetch all data, regardless of privacy
515
+		$rows = get_FAM_rows($WT_TREE, $term);
516
+		// Filter for privacy
517
+		foreach ($rows as $row) {
518
+			$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
519
+			if ($family->canShowName()) {
520
+				$marriage_year = $family->getMarriageYear();
521
+				if ($marriage_year) {
522
+					$data[] = ['value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>'];
523
+				} else {
524
+					$data[] = ['value' => $family->getXref(), 'label' => $family->getFullName()];
525
+				}
525 526
 			}
526 527
 		}
527
-	}
528
-	echo json_encode($data);
528
+		echo json_encode($data);
529 529
 
530
-	return;
530
+		return;
531 531
 }
532 532
 
533 533
 /**
Please login to merge, or discard this patch.