Completed
Push — 1.7 ( 6ce0c4...f4ab0d )
by Greg
09:24
created
edit_interface.php 3 patches
Indentation   +1778 added lines, -1778 removed lines patch added patch discarded remove patch
@@ -34,25 +34,25 @@  discard block
 block discarded – undo
34 34
 
35 35
 $controller = new SimpleController;
36 36
 $controller
37
-	->restrictAccess(Auth::isEditor($WT_TREE))
38
-	->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
39
-	->addInlineJavascript('autocomplete();')
40
-	->addInlineJavascript('var locale_date_format="' . preg_replace('/[^DMY]/', '', str_replace(array('j', 'F'), array('D', 'M'), I18N::dateFormat())) . '";');
37
+    ->restrictAccess(Auth::isEditor($WT_TREE))
38
+    ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
39
+    ->addInlineJavascript('autocomplete();')
40
+    ->addInlineJavascript('var locale_date_format="' . preg_replace('/[^DMY]/', '', str_replace(array('j', 'F'), array('D', 'M'), I18N::dateFormat())) . '";');
41 41
 
42 42
 switch ($action) {
43 43
 ////////////////////////////////////////////////////////////////////////////////
44 44
 case 'editraw':
45
-	$xref = Filter::get('xref', WT_REGEX_XREF);
45
+    $xref = Filter::get('xref', WT_REGEX_XREF);
46 46
 
47
-	$record = GedcomRecord::getInstance($xref, $WT_TREE);
48
-	check_record_access($record);
47
+    $record = GedcomRecord::getInstance($xref, $WT_TREE);
48
+    check_record_access($record);
49 49
 
50
-	$controller
51
-		->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM'))
52
-		->pageHeader()
53
-		->addInlineJavascript('jQuery("#raw-gedcom-list").sortable({opacity: 0.7, cursor: "move", axis: "y"});');
50
+    $controller
51
+        ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM'))
52
+        ->pageHeader()
53
+        ->addInlineJavascript('jQuery("#raw-gedcom-list").sortable({opacity: 0.7, cursor: "move", axis: "y"});');
54 54
 
55
-	?>
55
+    ?>
56 56
 	<div id="edit_interface-page">
57 57
 		<h2>
58 58
 			<?php echo $controller->getPageTitle(); ?>
@@ -91,78 +91,78 @@  discard block
 block discarded – undo
91 91
 		</form>
92 92
 	</div>
93 93
 	<?php
94
-	break;
94
+    break;
95 95
 
96 96
 ////////////////////////////////////////////////////////////////////////////////
97 97
 case 'updateraw':
98
-	$xref      = Filter::post('xref', WT_REGEX_XREF);
99
-	$facts     = Filter::postArray('fact');
100
-	$fact_ids  = Filter::postArray('fact_id');
98
+    $xref      = Filter::post('xref', WT_REGEX_XREF);
99
+    $facts     = Filter::postArray('fact');
100
+    $fact_ids  = Filter::postArray('fact_id');
101 101
 
102
-	if (!Filter::checkCsrf()) {
103
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editraw&xref=' . $xref);
102
+    if (!Filter::checkCsrf()) {
103
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editraw&xref=' . $xref);
104 104
 
105
-		return;
106
-	}
105
+        return;
106
+    }
107 107
 
108
-	$record = GedcomRecord::getInstance($xref, $WT_TREE);
109
-	check_record_access($record);
108
+    $record = GedcomRecord::getInstance($xref, $WT_TREE);
109
+    check_record_access($record);
110 110
 
111
-	$controller
112
-		->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM'))
113
-		->pageHeader();
111
+    $controller
112
+        ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM'))
113
+        ->pageHeader();
114 114
 
115
-	$gedcom = '0 @' . $record->getXref() . '@ ' . $record::RECORD_TYPE;
115
+    $gedcom = '0 @' . $record->getXref() . '@ ' . $record::RECORD_TYPE;
116 116
 
117
-	// Retain any private facts
118
-	foreach ($record->getFacts(null, false, Auth::PRIV_HIDE) as $fact) {
119
-		if (!in_array($fact->getFactId(), $fact_ids) && !$fact->isPendingDeletion()) {
120
-			$gedcom .= "\n" . $fact->getGedcom();
121
-		}
122
-	}
123
-	// Append the new facts
124
-	foreach ($facts as $fact) {
125
-		$gedcom .= "\n" . $fact;
126
-	}
117
+    // Retain any private facts
118
+    foreach ($record->getFacts(null, false, Auth::PRIV_HIDE) as $fact) {
119
+        if (!in_array($fact->getFactId(), $fact_ids) && !$fact->isPendingDeletion()) {
120
+            $gedcom .= "\n" . $fact->getGedcom();
121
+        }
122
+    }
123
+    // Append the new facts
124
+    foreach ($facts as $fact) {
125
+        $gedcom .= "\n" . $fact;
126
+    }
127 127
 
128
-	// Cleanup the client’s bad editing?
129
-	$gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom); // Empty lines
130
-	$gedcom = trim($gedcom); // Leading/trailing spaces
128
+    // Cleanup the client’s bad editing?
129
+    $gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom); // Empty lines
130
+    $gedcom = trim($gedcom); // Leading/trailing spaces
131 131
 
132
-	$record->updateRecord($gedcom, false);
132
+    $record->updateRecord($gedcom, false);
133 133
 
134
-	$controller->addInlineJavascript('closePopupAndReloadParent();');
135
-	break;
134
+    $controller->addInlineJavascript('closePopupAndReloadParent();');
135
+    break;
136 136
 
137 137
 ////////////////////////////////////////////////////////////////////////////////
138 138
 case 'editrawfact':
139
-	$xref    = Filter::get('xref', WT_REGEX_XREF);
140
-	$fact_id = Filter::get('fact_id');
141
-
142
-	$record = GedcomRecord::getInstance($xref, $WT_TREE);
143
-	check_record_access($record);
144
-
145
-	// Find the fact to edit
146
-	$edit_fact = null;
147
-	foreach ($record->getFacts() as $fact) {
148
-		if ($fact->getFactId() === $fact_id && $fact->canEdit()) {
149
-			$edit_fact = $fact;
150
-			break;
151
-		}
152
-	}
153
-	if (!$edit_fact) {
154
-		$controller
155
-			->pageHeader()
156
-			->addInlineJavascript('closePopupAndReloadParent();');
157
-
158
-		return;
159
-	}
160
-
161
-	$controller
162
-		->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM'))
163
-		->pageHeader();
164
-
165
-	?>
139
+    $xref    = Filter::get('xref', WT_REGEX_XREF);
140
+    $fact_id = Filter::get('fact_id');
141
+
142
+    $record = GedcomRecord::getInstance($xref, $WT_TREE);
143
+    check_record_access($record);
144
+
145
+    // Find the fact to edit
146
+    $edit_fact = null;
147
+    foreach ($record->getFacts() as $fact) {
148
+        if ($fact->getFactId() === $fact_id && $fact->canEdit()) {
149
+            $edit_fact = $fact;
150
+            break;
151
+        }
152
+    }
153
+    if (!$edit_fact) {
154
+        $controller
155
+            ->pageHeader()
156
+            ->addInlineJavascript('closePopupAndReloadParent();');
157
+
158
+        return;
159
+    }
160
+
161
+    $controller
162
+        ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM'))
163
+        ->pageHeader();
164
+
165
+    ?>
166 166
 	<div id="edit_interface-page">
167 167
 		<h2>
168 168
 			<?php echo $controller->getPageTitle(); ?>
@@ -186,140 +186,140 @@  discard block
 block discarded – undo
186 186
 		</form>
187 187
 	</div>
188 188
 	<?php
189
-	break;
189
+    break;
190 190
 
191 191
 ////////////////////////////////////////////////////////////////////////////////
192 192
 case 'updaterawfact':
193
-	$xref      = Filter::post('xref', WT_REGEX_XREF);
194
-	$fact_id   = Filter::post('fact_id');
195
-	$gedcom    = Filter::post('gedcom');
196
-	$keep_chan = Filter::postBool('keep_chan');
193
+    $xref      = Filter::post('xref', WT_REGEX_XREF);
194
+    $fact_id   = Filter::post('fact_id');
195
+    $gedcom    = Filter::post('gedcom');
196
+    $keep_chan = Filter::postBool('keep_chan');
197 197
 
198
-	if (!Filter::checkCsrf()) {
199
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editrawfact&xref=' . $xref . '&fact_id=' . $fact_id);
198
+    if (!Filter::checkCsrf()) {
199
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editrawfact&xref=' . $xref . '&fact_id=' . $fact_id);
200 200
 
201
-		return;
202
-	}
201
+        return;
202
+    }
203 203
 
204
-	$record = GedcomRecord::getInstance($xref, $WT_TREE);
205
-	check_record_access($record);
204
+    $record = GedcomRecord::getInstance($xref, $WT_TREE);
205
+    check_record_access($record);
206 206
 
207
-	// Find the fact to edit
208
-	$edit_fact = null;
209
-	foreach ($record->getFacts() as $fact) {
210
-		if ($fact->getFactId() === $fact_id && $fact->canEdit()) {
211
-			$edit_fact = $fact;
212
-			break;
213
-		}
214
-	}
215
-	if (!$edit_fact) {
216
-		$controller
217
-			->pageHeader()
218
-			->addInlineJavascript('closePopupAndReloadParent();');
207
+    // Find the fact to edit
208
+    $edit_fact = null;
209
+    foreach ($record->getFacts() as $fact) {
210
+        if ($fact->getFactId() === $fact_id && $fact->canEdit()) {
211
+            $edit_fact = $fact;
212
+            break;
213
+        }
214
+    }
215
+    if (!$edit_fact) {
216
+        $controller
217
+            ->pageHeader()
218
+            ->addInlineJavascript('closePopupAndReloadParent();');
219 219
 
220
-		return;
221
-	}
220
+        return;
221
+    }
222 222
 
223
-	$controller
224
-		->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM'))
225
-		->pageHeader();
223
+    $controller
224
+        ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM'))
225
+        ->pageHeader();
226 226
 
227
-	// Cleanup the client’s bad editing?
228
-	$gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom); // Empty lines
229
-	$gedcom = trim($gedcom); // Leading/trailing spaces
227
+    // Cleanup the client’s bad editing?
228
+    $gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom); // Empty lines
229
+    $gedcom = trim($gedcom); // Leading/trailing spaces
230 230
 
231
-	$record->updateFact($fact_id, $gedcom, !$keep_chan);
231
+    $record->updateFact($fact_id, $gedcom, !$keep_chan);
232 232
 
233
-	$controller->addInlineJavascript('closePopupAndReloadParent();');
234
-	break;
233
+    $controller->addInlineJavascript('closePopupAndReloadParent();');
234
+    break;
235 235
 
236 236
 ////////////////////////////////////////////////////////////////////////////////
237 237
 case 'edit':
238
-	$xref    = Filter::get('xref', WT_REGEX_XREF);
239
-	$fact_id = Filter::get('fact_id');
240
-
241
-	$record = GedcomRecord::getInstance($xref, $WT_TREE);
242
-	check_record_access($record);
243
-
244
-	// Find the fact to edit
245
-	$edit_fact = null;
246
-	foreach ($record->getFacts() as $fact) {
247
-		if ($fact->getFactId() === $fact_id && $fact->canEdit()) {
248
-			$edit_fact = $fact;
249
-			break;
250
-		}
251
-	}
252
-	if (!$edit_fact) {
253
-		$controller
254
-			->pageHeader()
255
-			->addInlineJavascript('closePopupAndReloadParent();');
256
-
257
-		return;
258
-	}
259
-
260
-	$controller
261
-		->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit'))
262
-		->pageHeader();
263
-
264
-	echo '<div id="edit_interface-page">';
265
-	echo '<h2>', $controller->getPageTitle(), '</h2>';
266
-	FunctionsPrint::initializeCalendarPopup();
267
-	echo '<form name="editform" method="post" action="edit_interface.php" enctype="multipart/form-data">';
268
-	echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">';
269
-	echo '<input type="hidden" name="action" value="update">';
270
-	echo '<input type="hidden" name="fact_id" value="', $fact_id, '">';
271
-	echo '<input type="hidden" name="xref" value="', $xref, '">';
272
-	echo '<input type="hidden" name="prev_action" value="edit">';
273
-	echo Filter::getCsrf();
274
-	echo '<table class="facts_table">';
275
-	FunctionsEdit::createEditForm($edit_fact);
276
-	echo keep_chan($record);
277
-	echo '</table>';
278
-
279
-	$level1type = $edit_fact->getTag();
280
-	switch ($record::RECORD_TYPE) {
281
-	case 'REPO':
282
-		// REPO:NAME facts may take a NOTE (but the REPO record may not).
283
-		if ($level1type === 'NAME') {
284
-			FunctionsEdit::printAddLayer('NOTE');
285
-			FunctionsEdit::printAddLayer('SHARED_NOTE');
286
-		}
287
-		break;
288
-	case 'FAM':
289
-	case 'INDI':
290
-		// FAM and INDI records have real facts. They can take NOTE/SOUR/OBJE/etc.
291
-		if ($level1type !== 'SEX' && $level1type !== 'NOTE' && $level1type !== 'ALIA') {
292
-			if ($level1type !== 'SOUR') {
293
-				FunctionsEdit::printAddLayer('SOUR');
294
-			}
295
-			if ($level1type !== 'OBJE') {
296
-				FunctionsEdit::printAddLayer('OBJE');
297
-			}
298
-			FunctionsEdit::printAddLayer('NOTE');
299
-			FunctionsEdit::printAddLayer('SHARED_NOTE', 2, $level1type);
300
-			if ($level1type !== 'ASSO' && $level1type !== 'NOTE' && $level1type !== 'SOUR') {
301
-				FunctionsEdit::printAddLayer('ASSO');
302
-			}
303
-			// allow to add godfather and godmother for CHR fact or best man and bridesmaid  for MARR fact in one window
304
-			if (in_array($level1type, Config::twoAssociates())) {
305
-				FunctionsEdit::printAddLayer('ASSO2');
306
-			}
307
-			if ($level1type !== 'SOUR') {
308
-				FunctionsEdit::printAddLayer('RESN');
309
-			}
310
-		}
311
-		break;
312
-	default:
313
-		// Other types of record do not have these lower-level records
314
-		break;
315
-	}
316
-	if (Auth::isAdmin() || $WT_TREE->getPreference('SHOW_GEDCOM_RECORD')) {
317
-		echo
318
-			'<br><br><a href="edit_interface.php?action=editrawfact&amp;xref=', $xref, '&amp;fact_id=', $fact_id, '&amp;ged=', $WT_TREE->getNameUrl(), '">',
319
-			I18N::translate('Edit the raw GEDCOM'),
320
-			'</a>';
321
-	}
322
-	?>
238
+    $xref    = Filter::get('xref', WT_REGEX_XREF);
239
+    $fact_id = Filter::get('fact_id');
240
+
241
+    $record = GedcomRecord::getInstance($xref, $WT_TREE);
242
+    check_record_access($record);
243
+
244
+    // Find the fact to edit
245
+    $edit_fact = null;
246
+    foreach ($record->getFacts() as $fact) {
247
+        if ($fact->getFactId() === $fact_id && $fact->canEdit()) {
248
+            $edit_fact = $fact;
249
+            break;
250
+        }
251
+    }
252
+    if (!$edit_fact) {
253
+        $controller
254
+            ->pageHeader()
255
+            ->addInlineJavascript('closePopupAndReloadParent();');
256
+
257
+        return;
258
+    }
259
+
260
+    $controller
261
+        ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit'))
262
+        ->pageHeader();
263
+
264
+    echo '<div id="edit_interface-page">';
265
+    echo '<h2>', $controller->getPageTitle(), '</h2>';
266
+    FunctionsPrint::initializeCalendarPopup();
267
+    echo '<form name="editform" method="post" action="edit_interface.php" enctype="multipart/form-data">';
268
+    echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">';
269
+    echo '<input type="hidden" name="action" value="update">';
270
+    echo '<input type="hidden" name="fact_id" value="', $fact_id, '">';
271
+    echo '<input type="hidden" name="xref" value="', $xref, '">';
272
+    echo '<input type="hidden" name="prev_action" value="edit">';
273
+    echo Filter::getCsrf();
274
+    echo '<table class="facts_table">';
275
+    FunctionsEdit::createEditForm($edit_fact);
276
+    echo keep_chan($record);
277
+    echo '</table>';
278
+
279
+    $level1type = $edit_fact->getTag();
280
+    switch ($record::RECORD_TYPE) {
281
+    case 'REPO':
282
+        // REPO:NAME facts may take a NOTE (but the REPO record may not).
283
+        if ($level1type === 'NAME') {
284
+            FunctionsEdit::printAddLayer('NOTE');
285
+            FunctionsEdit::printAddLayer('SHARED_NOTE');
286
+        }
287
+        break;
288
+    case 'FAM':
289
+    case 'INDI':
290
+        // FAM and INDI records have real facts. They can take NOTE/SOUR/OBJE/etc.
291
+        if ($level1type !== 'SEX' && $level1type !== 'NOTE' && $level1type !== 'ALIA') {
292
+            if ($level1type !== 'SOUR') {
293
+                FunctionsEdit::printAddLayer('SOUR');
294
+            }
295
+            if ($level1type !== 'OBJE') {
296
+                FunctionsEdit::printAddLayer('OBJE');
297
+            }
298
+            FunctionsEdit::printAddLayer('NOTE');
299
+            FunctionsEdit::printAddLayer('SHARED_NOTE', 2, $level1type);
300
+            if ($level1type !== 'ASSO' && $level1type !== 'NOTE' && $level1type !== 'SOUR') {
301
+                FunctionsEdit::printAddLayer('ASSO');
302
+            }
303
+            // allow to add godfather and godmother for CHR fact or best man and bridesmaid  for MARR fact in one window
304
+            if (in_array($level1type, Config::twoAssociates())) {
305
+                FunctionsEdit::printAddLayer('ASSO2');
306
+            }
307
+            if ($level1type !== 'SOUR') {
308
+                FunctionsEdit::printAddLayer('RESN');
309
+            }
310
+        }
311
+        break;
312
+    default:
313
+        // Other types of record do not have these lower-level records
314
+        break;
315
+    }
316
+    if (Auth::isAdmin() || $WT_TREE->getPreference('SHOW_GEDCOM_RECORD')) {
317
+        echo
318
+            '<br><br><a href="edit_interface.php?action=editrawfact&amp;xref=', $xref, '&amp;fact_id=', $fact_id, '&amp;ged=', $WT_TREE->getNameUrl(), '">',
319
+            I18N::translate('Edit the raw GEDCOM'),
320
+            '</a>';
321
+    }
322
+    ?>
323 323
 		<p id="save-cancel">
324 324
 			<input type="submit" class="save" value="<?php echo I18N::translate('save'); ?>">
325 325
 			<input type="button" class="cancel" value="<?php echo I18N::translate('close'); ?>" onclick="window.close();">
@@ -327,60 +327,60 @@  discard block
 block discarded – undo
327 327
 	</form>
328 328
 	</div>
329 329
 	<?php
330
-	break;
330
+    break;
331 331
 
332 332
 ////////////////////////////////////////////////////////////////////////////////
333 333
 case 'add':
334
-	$xref = Filter::get('xref', WT_REGEX_XREF);
335
-	$fact = Filter::get('fact', WT_REGEX_TAG);
336
-
337
-	$record = GedcomRecord::getInstance($xref, $WT_TREE);
338
-	check_record_access($record);
339
-
340
-	$controller
341
-		->setPageTitle($record->getFullName() . ' - ' . GedcomTag::getLabel($fact, $record))
342
-		->pageHeader();
343
-
344
-	$level0type = $record::RECORD_TYPE;
345
-
346
-	echo '<div id="edit_interface-page">';
347
-	echo '<h2>', $controller->getPageTitle(), '</h2>';
348
-
349
-	FunctionsPrint::initializeCalendarPopup();
350
-	echo '<form name="addform" method="post" action="edit_interface.php" enctype="multipart/form-data">';
351
-	echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">';
352
-	echo '<input type="hidden" name="action" value="update">';
353
-	echo '<input type="hidden" name="xref" value="', $xref, '">';
354
-	echo '<input type="hidden" name="prev_action" value="add">';
355
-	echo '<input type="hidden" name="fact_type" value="' . $fact . '">';
356
-	echo Filter::getCsrf();
357
-	echo '<table class="facts_table">';
358
-
359
-	FunctionsEdit::createAddForm($fact);
360
-
361
-	echo keep_chan($record);
362
-	echo '</table>';
363
-
364
-	// Genealogical facts (e.g. for INDI and FAM records) can have 2 SOUR/NOTE/OBJE/ASSO/RESN ...
365
-	if ($level0type === 'INDI' || $level0type === 'FAM') {
366
-		// ... but not facts which are simply links to other records
367
-		if ($fact !== 'OBJE' && $fact !== 'NOTE' && $fact !== 'SHARED_NOTE' && $fact !== 'REPO' && $fact !== 'SOUR' && $fact !== 'ASSO' && $fact !== 'ALIA') {
368
-			FunctionsEdit::printAddLayer('SOUR');
369
-			FunctionsEdit::printAddLayer('OBJE');
370
-			// Don’t add notes to notes!
371
-			if ($fact !== 'NOTE') {
372
-				FunctionsEdit::printAddLayer('NOTE');
373
-				FunctionsEdit::printAddLayer('SHARED_NOTE', 2, $fact);
374
-			}
375
-			FunctionsEdit::printAddLayer('ASSO');
376
-			// allow to add godfather and godmother for CHR fact or best man and bridesmaid  for MARR fact in one window
377
-			if (in_array($fact, Config::twoAssociates())) {
378
-				FunctionsEdit::printAddLayer('ASSO2');
379
-			}
380
-			FunctionsEdit::printAddLayer('RESN');
381
-		}
382
-	}
383
-	?>
334
+    $xref = Filter::get('xref', WT_REGEX_XREF);
335
+    $fact = Filter::get('fact', WT_REGEX_TAG);
336
+
337
+    $record = GedcomRecord::getInstance($xref, $WT_TREE);
338
+    check_record_access($record);
339
+
340
+    $controller
341
+        ->setPageTitle($record->getFullName() . ' - ' . GedcomTag::getLabel($fact, $record))
342
+        ->pageHeader();
343
+
344
+    $level0type = $record::RECORD_TYPE;
345
+
346
+    echo '<div id="edit_interface-page">';
347
+    echo '<h2>', $controller->getPageTitle(), '</h2>';
348
+
349
+    FunctionsPrint::initializeCalendarPopup();
350
+    echo '<form name="addform" method="post" action="edit_interface.php" enctype="multipart/form-data">';
351
+    echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">';
352
+    echo '<input type="hidden" name="action" value="update">';
353
+    echo '<input type="hidden" name="xref" value="', $xref, '">';
354
+    echo '<input type="hidden" name="prev_action" value="add">';
355
+    echo '<input type="hidden" name="fact_type" value="' . $fact . '">';
356
+    echo Filter::getCsrf();
357
+    echo '<table class="facts_table">';
358
+
359
+    FunctionsEdit::createAddForm($fact);
360
+
361
+    echo keep_chan($record);
362
+    echo '</table>';
363
+
364
+    // Genealogical facts (e.g. for INDI and FAM records) can have 2 SOUR/NOTE/OBJE/ASSO/RESN ...
365
+    if ($level0type === 'INDI' || $level0type === 'FAM') {
366
+        // ... but not facts which are simply links to other records
367
+        if ($fact !== 'OBJE' && $fact !== 'NOTE' && $fact !== 'SHARED_NOTE' && $fact !== 'REPO' && $fact !== 'SOUR' && $fact !== 'ASSO' && $fact !== 'ALIA') {
368
+            FunctionsEdit::printAddLayer('SOUR');
369
+            FunctionsEdit::printAddLayer('OBJE');
370
+            // Don’t add notes to notes!
371
+            if ($fact !== 'NOTE') {
372
+                FunctionsEdit::printAddLayer('NOTE');
373
+                FunctionsEdit::printAddLayer('SHARED_NOTE', 2, $fact);
374
+            }
375
+            FunctionsEdit::printAddLayer('ASSO');
376
+            // allow to add godfather and godmother for CHR fact or best man and bridesmaid  for MARR fact in one window
377
+            if (in_array($fact, Config::twoAssociates())) {
378
+                FunctionsEdit::printAddLayer('ASSO2');
379
+            }
380
+            FunctionsEdit::printAddLayer('RESN');
381
+        }
382
+    }
383
+    ?>
384 384
 		<p id="save-cancel">
385 385
 			<input type="submit" class="save" value="<?php echo I18N::translate('save'); ?>">
386 386
 			<input type="button" class="cancel" value="<?php echo I18N::translate('close'); ?>" onclick="window.close();">
@@ -388,582 +388,582 @@  discard block
 block discarded – undo
388 388
 	</form>
389 389
 	</div>
390 390
 	<?php
391
-	break;
391
+    break;
392 392
 
393 393
 ////////////////////////////////////////////////////////////////////////////////
394 394
 case 'update':
395
-	// Update a fact
396
-	$xref      = Filter::post('xref', WT_REGEX_XREF);
397
-	$fact_id   = Filter::post('fact_id');
398
-	$keep_chan = Filter::postBool('keep_chan');
399
-
400
-	if (!Filter::checkCsrf()) {
401
-		$prev_action = Filter::post('prev_action', 'add|edit|addname|editname');
402
-		$fact_type   = Filter::post('fact_type', WT_REGEX_TAG);
403
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=' . $prev_action . '&xref=' . $xref . '&fact_id=' . $fact_id . '&fact=' . $fact_type);
404
-
405
-		return;
406
-	}
407
-
408
-	$record = GedcomRecord::getInstance($xref, $WT_TREE);
409
-	check_record_access($record);
410
-
411
-	// Arrays for each GEDCOM line
412
-	$glevels = Filter::postArray('glevels', '[0-9]');
413
-	$tag     = Filter::postArray('tag', WT_REGEX_TAG);
414
-	$text    = Filter::postArray('text');
415
-	$islink  = Filter::postArray('islink', '[01]');
416
-
417
-	$controller
418
-		->setPageTitle(I18N::translate('Edit'))
419
-		->pageHeader();
420
-
421
-	// If the fact has a DATE or PLAC, then delete any value of Y
422
-	if ($text[0] === 'Y') {
423
-		for ($n = 1; $n < count($tag); ++$n) {
424
-			if ($glevels[$n] == 2 && ($tag[$n] === 'DATE' || $tag[$n] === 'PLAC') && $text[$n]) {
425
-				$text[0] = '';
426
-				break;
427
-			}
428
-		}
429
-	}
430
-
431
-	$newged = '';
432
-	if (!empty($_POST['NAME'])) {
433
-		$newged .= "\n1 NAME " . $_POST['NAME'];
434
-		$name_facts = array('TYPE', 'NPFX', 'GIVN', 'NICK', 'SPFX', 'SURN', 'NSFX');
435
-		foreach ($name_facts as $name_fact) {
436
-			if (!empty($_POST[$name_fact])) {
437
-				$newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact];
438
-			}
439
-		}
440
-	}
441
-
442
-	if (isset($_POST['NOTE'])) {
443
-		$NOTE = $_POST['NOTE'];
444
-	}
445
-	if (!empty($NOTE)) {
446
-		$tempnote = preg_split('/\r?\n/', trim($NOTE) . "\n"); // make sure only one line ending on the end
447
-		$title[]  = '0 @' . $xref . '@ NOTE ' . array_shift($tempnote);
448
-		foreach ($tempnote as &$line) {
449
-			$line = trim('1 CONT ' . $line, ' ');
450
-		}
451
-	}
452
-
453
-	$newged = FunctionsEdit::handleUpdates($newged);
454
-
455
-	// Add new names after existing names
456
-	if (!empty($_POST['NAME'])) {
457
-		preg_match_all('/[_0-9A-Z]+/', $WT_TREE->getPreference('ADVANCED_NAME_FACTS'), $match);
458
-		$name_facts = array_unique(array_merge(array('_MARNM'), $match[0]));
459
-		foreach ($name_facts as $name_fact) {
460
-			if (!empty($_POST[$name_fact])) {
461
-				$newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact];
462
-			}
463
-		}
464
-	}
465
-
466
-	$newged = substr($newged, 1); // Remove leading newline
467
-	$record->updateFact($fact_id, $newged, !$keep_chan);
468
-
469
-	// For the GEDFact_assistant module
470
-	$pid_array = Filter::post('pid_array');
471
-	if ($pid_array) {
472
-		foreach (explode(',', $pid_array) as $pid) {
473
-			if ($pid !== $xref) {
474
-				$indi = Individual::getInstance($pid, $WT_TREE);
475
-				if ($indi && $indi->canEdit()) {
476
-					$indi->updateFact($fact_id, $newged, !$keep_chan);
477
-				}
478
-			}
479
-		}
480
-	}
481
-
482
-	$controller->addInlineJavascript('closePopupAndReloadParent();');
483
-	break;
395
+    // Update a fact
396
+    $xref      = Filter::post('xref', WT_REGEX_XREF);
397
+    $fact_id   = Filter::post('fact_id');
398
+    $keep_chan = Filter::postBool('keep_chan');
399
+
400
+    if (!Filter::checkCsrf()) {
401
+        $prev_action = Filter::post('prev_action', 'add|edit|addname|editname');
402
+        $fact_type   = Filter::post('fact_type', WT_REGEX_TAG);
403
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=' . $prev_action . '&xref=' . $xref . '&fact_id=' . $fact_id . '&fact=' . $fact_type);
404
+
405
+        return;
406
+    }
407
+
408
+    $record = GedcomRecord::getInstance($xref, $WT_TREE);
409
+    check_record_access($record);
410
+
411
+    // Arrays for each GEDCOM line
412
+    $glevels = Filter::postArray('glevels', '[0-9]');
413
+    $tag     = Filter::postArray('tag', WT_REGEX_TAG);
414
+    $text    = Filter::postArray('text');
415
+    $islink  = Filter::postArray('islink', '[01]');
416
+
417
+    $controller
418
+        ->setPageTitle(I18N::translate('Edit'))
419
+        ->pageHeader();
420
+
421
+    // If the fact has a DATE or PLAC, then delete any value of Y
422
+    if ($text[0] === 'Y') {
423
+        for ($n = 1; $n < count($tag); ++$n) {
424
+            if ($glevels[$n] == 2 && ($tag[$n] === 'DATE' || $tag[$n] === 'PLAC') && $text[$n]) {
425
+                $text[0] = '';
426
+                break;
427
+            }
428
+        }
429
+    }
430
+
431
+    $newged = '';
432
+    if (!empty($_POST['NAME'])) {
433
+        $newged .= "\n1 NAME " . $_POST['NAME'];
434
+        $name_facts = array('TYPE', 'NPFX', 'GIVN', 'NICK', 'SPFX', 'SURN', 'NSFX');
435
+        foreach ($name_facts as $name_fact) {
436
+            if (!empty($_POST[$name_fact])) {
437
+                $newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact];
438
+            }
439
+        }
440
+    }
441
+
442
+    if (isset($_POST['NOTE'])) {
443
+        $NOTE = $_POST['NOTE'];
444
+    }
445
+    if (!empty($NOTE)) {
446
+        $tempnote = preg_split('/\r?\n/', trim($NOTE) . "\n"); // make sure only one line ending on the end
447
+        $title[]  = '0 @' . $xref . '@ NOTE ' . array_shift($tempnote);
448
+        foreach ($tempnote as &$line) {
449
+            $line = trim('1 CONT ' . $line, ' ');
450
+        }
451
+    }
452
+
453
+    $newged = FunctionsEdit::handleUpdates($newged);
454
+
455
+    // Add new names after existing names
456
+    if (!empty($_POST['NAME'])) {
457
+        preg_match_all('/[_0-9A-Z]+/', $WT_TREE->getPreference('ADVANCED_NAME_FACTS'), $match);
458
+        $name_facts = array_unique(array_merge(array('_MARNM'), $match[0]));
459
+        foreach ($name_facts as $name_fact) {
460
+            if (!empty($_POST[$name_fact])) {
461
+                $newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact];
462
+            }
463
+        }
464
+    }
465
+
466
+    $newged = substr($newged, 1); // Remove leading newline
467
+    $record->updateFact($fact_id, $newged, !$keep_chan);
468
+
469
+    // For the GEDFact_assistant module
470
+    $pid_array = Filter::post('pid_array');
471
+    if ($pid_array) {
472
+        foreach (explode(',', $pid_array) as $pid) {
473
+            if ($pid !== $xref) {
474
+                $indi = Individual::getInstance($pid, $WT_TREE);
475
+                if ($indi && $indi->canEdit()) {
476
+                    $indi->updateFact($fact_id, $newged, !$keep_chan);
477
+                }
478
+            }
479
+        }
480
+    }
481
+
482
+    $controller->addInlineJavascript('closePopupAndReloadParent();');
483
+    break;
484 484
 
485 485
 ////////////////////////////////////////////////////////////////////////////////
486 486
 // Add a child to an existing family
487 487
 ////////////////////////////////////////////////////////////////////////////////
488 488
 case 'add_child_to_family':
489
-	$xref   = Filter::get('xref', WT_REGEX_XREF);
490
-	$gender = Filter::get('gender', '[MFU]', 'U');
489
+    $xref   = Filter::get('xref', WT_REGEX_XREF);
490
+    $gender = Filter::get('gender', '[MFU]', 'U');
491 491
 
492
-	$family = Family::getInstance($xref, $WT_TREE);
493
-	check_record_access($family);
492
+    $family = Family::getInstance($xref, $WT_TREE);
493
+    check_record_access($family);
494 494
 
495
-	$controller
496
-		->setPageTitle($family->getFullName() . ' - ' . I18N::translate('Add a child'))
497
-		->pageHeader();
495
+    $controller
496
+        ->setPageTitle($family->getFullName() . ' - ' . I18N::translate('Add a child'))
497
+        ->pageHeader();
498 498
 
499
-	print_indi_form('add_child_to_family_action', null, $family, null, 'CHIL', $gender);
500
-	break;
499
+    print_indi_form('add_child_to_family_action', null, $family, null, 'CHIL', $gender);
500
+    break;
501 501
 
502 502
 case 'add_child_to_family_action':
503
-	$xref      = Filter::post('xref', WT_REGEX_XREF);
504
-	$PEDI      = Filter::post('PEDI');
505
-	$keep_chan = Filter::postBool('keep_chan');
506
-	$glevels   = Filter::postArray('glevels', '[0-9]');
507
-	$tag       = Filter::postArray('tag', WT_REGEX_TAG);
508
-	$text      = Filter::postArray('text');
509
-	$islink    = Filter::postArray('islink', '[01]');
510
-
511
-	if (!Filter::checkCsrf()) {
512
-		$gender = Filter::get('gender', '[MFU]', 'U');
513
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_child_to_family&xref=' . $xref . '&gender=' . $gender);
514
-
515
-		return;
516
-	}
517
-
518
-	$family = Family::getInstance($xref, $WT_TREE);
519
-	check_record_access($family);
520
-
521
-	$controller->pageHeader();
522
-
523
-	FunctionsEdit::splitSource();
524
-	$gedrec = '0 @REF@ INDI';
525
-	$gedrec .= FunctionsEdit::addNewName();
526
-	$gedrec .= FunctionsEdit::addNewSex();
527
-	if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
528
-		foreach ($matches[1] as $match) {
529
-			$gedrec .= FunctionsEdit::addNewFact($match);
530
-		}
531
-	}
532
-	$gedrec .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $xref);
533
-	if (Filter::postBool('SOUR_INDI')) {
534
-		$gedrec = FunctionsEdit::handleUpdates($gedrec);
535
-	} else {
536
-		$gedrec = FunctionsEdit::updateRest($gedrec);
537
-	}
538
-
539
-	// Create the new child
540
-	$new_child = $family->getTree()->createRecord($gedrec);
541
-
542
-	// Insert new child at the right place
543
-	$done = false;
544
-	foreach ($family->getFacts('CHIL') as $fact) {
545
-		$old_child = $fact->getTarget();
546
-		if ($old_child && Date::compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate()) < 0) {
547
-			// Insert before this child
548
-			$family->updateFact($fact->getFactId(), '1 CHIL @' . $new_child->getXref() . "@\n" . $fact->getGedcom(), !$keep_chan);
549
-			$done = true;
550
-			break;
551
-		}
552
-	}
553
-	if (!$done) {
554
-		// Append child at end
555
-		$family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan);
556
-	}
557
-
558
-	if (Filter::post('goto') === 'new') {
559
-		$controller->addInlineJavascript('closePopupAndReloadParent("' . $new_child->getRawUrl() . '");');
560
-	} else {
561
-		$controller->addInlineJavascript('closePopupAndReloadParent();');
562
-	}
563
-	break;
503
+    $xref      = Filter::post('xref', WT_REGEX_XREF);
504
+    $PEDI      = Filter::post('PEDI');
505
+    $keep_chan = Filter::postBool('keep_chan');
506
+    $glevels   = Filter::postArray('glevels', '[0-9]');
507
+    $tag       = Filter::postArray('tag', WT_REGEX_TAG);
508
+    $text      = Filter::postArray('text');
509
+    $islink    = Filter::postArray('islink', '[01]');
510
+
511
+    if (!Filter::checkCsrf()) {
512
+        $gender = Filter::get('gender', '[MFU]', 'U');
513
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_child_to_family&xref=' . $xref . '&gender=' . $gender);
514
+
515
+        return;
516
+    }
517
+
518
+    $family = Family::getInstance($xref, $WT_TREE);
519
+    check_record_access($family);
520
+
521
+    $controller->pageHeader();
522
+
523
+    FunctionsEdit::splitSource();
524
+    $gedrec = '0 @REF@ INDI';
525
+    $gedrec .= FunctionsEdit::addNewName();
526
+    $gedrec .= FunctionsEdit::addNewSex();
527
+    if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
528
+        foreach ($matches[1] as $match) {
529
+            $gedrec .= FunctionsEdit::addNewFact($match);
530
+        }
531
+    }
532
+    $gedrec .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $xref);
533
+    if (Filter::postBool('SOUR_INDI')) {
534
+        $gedrec = FunctionsEdit::handleUpdates($gedrec);
535
+    } else {
536
+        $gedrec = FunctionsEdit::updateRest($gedrec);
537
+    }
538
+
539
+    // Create the new child
540
+    $new_child = $family->getTree()->createRecord($gedrec);
541
+
542
+    // Insert new child at the right place
543
+    $done = false;
544
+    foreach ($family->getFacts('CHIL') as $fact) {
545
+        $old_child = $fact->getTarget();
546
+        if ($old_child && Date::compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate()) < 0) {
547
+            // Insert before this child
548
+            $family->updateFact($fact->getFactId(), '1 CHIL @' . $new_child->getXref() . "@\n" . $fact->getGedcom(), !$keep_chan);
549
+            $done = true;
550
+            break;
551
+        }
552
+    }
553
+    if (!$done) {
554
+        // Append child at end
555
+        $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan);
556
+    }
557
+
558
+    if (Filter::post('goto') === 'new') {
559
+        $controller->addInlineJavascript('closePopupAndReloadParent("' . $new_child->getRawUrl() . '");');
560
+    } else {
561
+        $controller->addInlineJavascript('closePopupAndReloadParent();');
562
+    }
563
+    break;
564 564
 
565 565
 ////////////////////////////////////////////////////////////////////////////////
566 566
 // Add a child to an existing individual (creating a one-parent family)
567 567
 ////////////////////////////////////////////////////////////////////////////////
568 568
 case 'add_child_to_individual':
569
-	$xref = Filter::get('xref', WT_REGEX_XREF);
569
+    $xref = Filter::get('xref', WT_REGEX_XREF);
570 570
 
571
-	$person = Individual::getInstance($xref, $WT_TREE);
572
-	check_record_access($person);
571
+    $person = Individual::getInstance($xref, $WT_TREE);
572
+    check_record_access($person);
573 573
 
574
-	$controller
575
-		->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a child to create a one-parent family'))
576
-		->pageHeader();
574
+    $controller
575
+        ->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a child to create a one-parent family'))
576
+        ->pageHeader();
577 577
 
578
-	print_indi_form('add_child_to_individual_action', $person, null, null, 'CHIL', $person->getSex());
579
-	break;
578
+    print_indi_form('add_child_to_individual_action', $person, null, null, 'CHIL', $person->getSex());
579
+    break;
580 580
 
581 581
 case 'add_child_to_individual_action':
582
-	$xref    = Filter::post('xref', WT_REGEX_XREF);
583
-	$PEDI    = Filter::post('PEDI');
584
-	$glevels = Filter::postArray('glevels', '[0-9]');
585
-	$tag     = Filter::postArray('tag', WT_REGEX_TAG);
586
-	$text    = Filter::postArray('text');
587
-	$islink  = Filter::postArray('islink', '[01]');
588
-
589
-	if (!Filter::checkCsrf()) {
590
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_child_to_individual&xref=' . $xref);
591
-
592
-		return;
593
-	}
594
-
595
-	$person = Individual::getInstance($xref, $WT_TREE);
596
-	check_record_access($person);
597
-
598
-	$controller->pageHeader();
599
-
600
-	// Create a family
601
-	if ($person->getSex() === 'F') {
602
-		$gedcom = "0 @NEW@ FAM\n1 WIFE @" . $person->getXref() . '@';
603
-	} else {
604
-		$gedcom = "0 @NEW@ FAM\n1 HUSB @" . $person->getXref() . '@';
605
-	}
606
-	$family = $person->getTree()->createRecord($gedcom);
607
-
608
-	// Link the parent to the family
609
-	$person->createFact('1 FAMS @' . $family->getXref() . '@', true);
610
-
611
-	// Create a child
612
-	FunctionsEdit::splitSource(); // separate SOUR record from the rest
613
-
614
-	$gedcom = '0 @NEW@ INDI';
615
-	$gedcom .= FunctionsEdit::addNewName();
616
-	$gedcom .= FunctionsEdit::addNewSex();
617
-	$gedcom .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $family->getXref());
618
-	if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
619
-		foreach ($matches[1] as $match) {
620
-			$gedcom .= FunctionsEdit::addNewFact($match);
621
-		}
622
-	}
623
-	if (Filter::postBool('SOUR_INDI')) {
624
-		$gedcom = FunctionsEdit::handleUpdates($gedcom);
625
-	} else {
626
-		$gedcom = FunctionsEdit::updateRest($gedcom);
627
-	}
628
-
629
-	$child = $person->getTree()->createRecord($gedcom);
630
-
631
-	// Link the family to the child
632
-	$family->createFact('1 CHIL @' . $child->getXref() . '@', true);
633
-
634
-	if (Filter::post('goto') === 'new') {
635
-		$controller->addInlineJavascript('closePopupAndReloadParent("' . $child->getRawUrl() . '");');
636
-	} else {
637
-		$controller->addInlineJavascript('closePopupAndReloadParent();');
638
-	}
639
-	break;
582
+    $xref    = Filter::post('xref', WT_REGEX_XREF);
583
+    $PEDI    = Filter::post('PEDI');
584
+    $glevels = Filter::postArray('glevels', '[0-9]');
585
+    $tag     = Filter::postArray('tag', WT_REGEX_TAG);
586
+    $text    = Filter::postArray('text');
587
+    $islink  = Filter::postArray('islink', '[01]');
588
+
589
+    if (!Filter::checkCsrf()) {
590
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_child_to_individual&xref=' . $xref);
591
+
592
+        return;
593
+    }
594
+
595
+    $person = Individual::getInstance($xref, $WT_TREE);
596
+    check_record_access($person);
597
+
598
+    $controller->pageHeader();
599
+
600
+    // Create a family
601
+    if ($person->getSex() === 'F') {
602
+        $gedcom = "0 @NEW@ FAM\n1 WIFE @" . $person->getXref() . '@';
603
+    } else {
604
+        $gedcom = "0 @NEW@ FAM\n1 HUSB @" . $person->getXref() . '@';
605
+    }
606
+    $family = $person->getTree()->createRecord($gedcom);
607
+
608
+    // Link the parent to the family
609
+    $person->createFact('1 FAMS @' . $family->getXref() . '@', true);
610
+
611
+    // Create a child
612
+    FunctionsEdit::splitSource(); // separate SOUR record from the rest
613
+
614
+    $gedcom = '0 @NEW@ INDI';
615
+    $gedcom .= FunctionsEdit::addNewName();
616
+    $gedcom .= FunctionsEdit::addNewSex();
617
+    $gedcom .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $family->getXref());
618
+    if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
619
+        foreach ($matches[1] as $match) {
620
+            $gedcom .= FunctionsEdit::addNewFact($match);
621
+        }
622
+    }
623
+    if (Filter::postBool('SOUR_INDI')) {
624
+        $gedcom = FunctionsEdit::handleUpdates($gedcom);
625
+    } else {
626
+        $gedcom = FunctionsEdit::updateRest($gedcom);
627
+    }
628
+
629
+    $child = $person->getTree()->createRecord($gedcom);
630
+
631
+    // Link the family to the child
632
+    $family->createFact('1 CHIL @' . $child->getXref() . '@', true);
633
+
634
+    if (Filter::post('goto') === 'new') {
635
+        $controller->addInlineJavascript('closePopupAndReloadParent("' . $child->getRawUrl() . '");');
636
+    } else {
637
+        $controller->addInlineJavascript('closePopupAndReloadParent();');
638
+    }
639
+    break;
640 640
 
641 641
 ////////////////////////////////////////////////////////////////////////////////
642 642
 // Add a new parent to an existing individual (creating a one-parent family)
643 643
 ////////////////////////////////////////////////////////////////////////////////
644 644
 case 'add_parent_to_individual':
645
-	$xref   = Filter::get('xref', WT_REGEX_XREF);
646
-	$gender = Filter::get('gender', '[MF]', 'U');
647
-
648
-	$individual = Individual::getInstance($xref, $WT_TREE);
649
-	check_record_access($individual);
650
-
651
-	if ($gender === 'F') {
652
-		$controller->setPageTitle(I18N::translate('Add a mother'));
653
-		$famtag = 'WIFE';
654
-	} else {
655
-		$controller->setPageTitle(I18N::translate('Add a father'));
656
-		$famtag = 'HUSB';
657
-	}
658
-	$controller->pageHeader();
659
-
660
-	print_indi_form('add_parent_to_individual_action', $individual, null, null, $famtag, $gender);
661
-	break;
662
-
663
-case 'add_parent_to_individual_action':
664
-	$xref    = Filter::post('xref', WT_REGEX_XREF);
665
-	$PEDI    = Filter::post('PEDI');
666
-	$glevels = Filter::postArray('glevels', '[0-9]');
667
-	$tag     = Filter::postArray('tag', WT_REGEX_TAG);
668
-	$text    = Filter::postArray('text');
669
-	$islink  = Filter::postArray('islink', '[01]');
670
-
671
-	if (!Filter::checkCsrf()) {
672
-		$gender = Filter::get('gender', '[MFU]', 'U');
673
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_parent_to_individual&xref=' . $xref . '&gender=' . $gender);
674
-
675
-		return;
676
-	}
677
-
678
-	$person = Individual::getInstance($xref, $WT_TREE);
679
-	check_record_access($person);
680
-
681
-	$controller->pageHeader();
645
+    $xref   = Filter::get('xref', WT_REGEX_XREF);
646
+    $gender = Filter::get('gender', '[MF]', 'U');
682 647
 
683
-	// Create a new family
684
-	$gedcom = "0 @NEW@ FAM\n1 CHIL @" . $person->getXref() . '@';
685
-	$family = $person->getTree()->createRecord($gedcom);
648
+    $individual = Individual::getInstance($xref, $WT_TREE);
649
+    check_record_access($individual);
686 650
 
687
-	// Link the child to the family
688
-	$person->createFact('1 FAMC @' . $family->getXref() . '@', true);
651
+    if ($gender === 'F') {
652
+        $controller->setPageTitle(I18N::translate('Add a mother'));
653
+        $famtag = 'WIFE';
654
+    } else {
655
+        $controller->setPageTitle(I18N::translate('Add a father'));
656
+        $famtag = 'HUSB';
657
+    }
658
+    $controller->pageHeader();
689 659
 
690
-	// Create a child
691
-	FunctionsEdit::splitSource(); // separate SOUR record from the rest
660
+    print_indi_form('add_parent_to_individual_action', $individual, null, null, $famtag, $gender);
661
+    break;
692 662
 
693
-	$gedcom = '0 @NEW@ INDI';
694
-	$gedcom .= FunctionsEdit::addNewName();
695
-	$gedcom .= FunctionsEdit::addNewSex();
696
-	if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
697
-		foreach ($matches[1] as $match) {
698
-			$gedcom .= FunctionsEdit::addNewFact($match);
699
-		}
700
-	}
701
-	if (Filter::postBool('SOUR_INDI')) {
702
-		$gedcom = FunctionsEdit::handleUpdates($gedcom);
703
-	} else {
704
-		$gedcom = FunctionsEdit::updateRest($gedcom);
705
-	}
706
-	$gedcom .= "\n1 FAMS @" . $family->getXref() . '@';
707
-
708
-	$parent = $person->getTree()->createRecord($gedcom);
709
-
710
-	// Link the family to the child
711
-	if ($parent->getSex() === 'F') {
712
-		$family->createFact('1 WIFE @' . $parent->getXref() . '@', true);
713
-	} else {
714
-		$family->createFact('1 HUSB @' . $parent->getXref() . '@', true);
715
-	}
716
-
717
-	if (Filter::post('goto') === 'new') {
718
-		$controller->addInlineJavascript('closePopupAndReloadParent("' . $parent->getRawUrl() . '");');
719
-	} else {
720
-		$controller->addInlineJavascript('closePopupAndReloadParent();');
721
-	}
722
-	break;
663
+case 'add_parent_to_individual_action':
664
+    $xref    = Filter::post('xref', WT_REGEX_XREF);
665
+    $PEDI    = Filter::post('PEDI');
666
+    $glevels = Filter::postArray('glevels', '[0-9]');
667
+    $tag     = Filter::postArray('tag', WT_REGEX_TAG);
668
+    $text    = Filter::postArray('text');
669
+    $islink  = Filter::postArray('islink', '[01]');
670
+
671
+    if (!Filter::checkCsrf()) {
672
+        $gender = Filter::get('gender', '[MFU]', 'U');
673
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_parent_to_individual&xref=' . $xref . '&gender=' . $gender);
674
+
675
+        return;
676
+    }
677
+
678
+    $person = Individual::getInstance($xref, $WT_TREE);
679
+    check_record_access($person);
680
+
681
+    $controller->pageHeader();
682
+
683
+    // Create a new family
684
+    $gedcom = "0 @NEW@ FAM\n1 CHIL @" . $person->getXref() . '@';
685
+    $family = $person->getTree()->createRecord($gedcom);
686
+
687
+    // Link the child to the family
688
+    $person->createFact('1 FAMC @' . $family->getXref() . '@', true);
689
+
690
+    // Create a child
691
+    FunctionsEdit::splitSource(); // separate SOUR record from the rest
692
+
693
+    $gedcom = '0 @NEW@ INDI';
694
+    $gedcom .= FunctionsEdit::addNewName();
695
+    $gedcom .= FunctionsEdit::addNewSex();
696
+    if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
697
+        foreach ($matches[1] as $match) {
698
+            $gedcom .= FunctionsEdit::addNewFact($match);
699
+        }
700
+    }
701
+    if (Filter::postBool('SOUR_INDI')) {
702
+        $gedcom = FunctionsEdit::handleUpdates($gedcom);
703
+    } else {
704
+        $gedcom = FunctionsEdit::updateRest($gedcom);
705
+    }
706
+    $gedcom .= "\n1 FAMS @" . $family->getXref() . '@';
707
+
708
+    $parent = $person->getTree()->createRecord($gedcom);
709
+
710
+    // Link the family to the child
711
+    if ($parent->getSex() === 'F') {
712
+        $family->createFact('1 WIFE @' . $parent->getXref() . '@', true);
713
+    } else {
714
+        $family->createFact('1 HUSB @' . $parent->getXref() . '@', true);
715
+    }
716
+
717
+    if (Filter::post('goto') === 'new') {
718
+        $controller->addInlineJavascript('closePopupAndReloadParent("' . $parent->getRawUrl() . '");');
719
+    } else {
720
+        $controller->addInlineJavascript('closePopupAndReloadParent();');
721
+    }
722
+    break;
723 723
 
724 724
 ////////////////////////////////////////////////////////////////////////////////
725 725
 // Add a new, unlinked individual
726 726
 ////////////////////////////////////////////////////////////////////////////////
727 727
 case 'add_unlinked_indi':
728
-	$controller
729
-		->restrictAccess(Auth::isManager($WT_TREE))
730
-		->setPageTitle(I18N::translate('Create an individual'))
731
-		->pageHeader();
728
+    $controller
729
+        ->restrictAccess(Auth::isManager($WT_TREE))
730
+        ->setPageTitle(I18N::translate('Create an individual'))
731
+        ->pageHeader();
732 732
 
733
-	print_indi_form('add_unlinked_indi_action', null, null, null, null, null);
734
-	break;
733
+    print_indi_form('add_unlinked_indi_action', null, null, null, null, null);
734
+    break;
735 735
 
736 736
 case 'add_unlinked_indi_action':
737
-	$glevels = Filter::postArray('glevels', '[0-9]');
738
-	$tag     = Filter::postArray('tag', WT_REGEX_TAG);
739
-	$text    = Filter::postArray('text');
740
-	$islink  = Filter::postArray('islink', '[01]');
741
-
742
-	if (!Filter::checkCsrf()) {
743
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_unlinked_indi');
744
-
745
-		return;
746
-	}
747
-
748
-	$controller
749
-		->restrictAccess(Auth::isManager($WT_TREE))
750
-		->pageHeader();
751
-
752
-	FunctionsEdit::splitSource();
753
-	$gedrec = '0 @REF@ INDI';
754
-	$gedrec .= FunctionsEdit::addNewName();
755
-	$gedrec .= FunctionsEdit::addNewSex();
756
-	if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
757
-		foreach ($matches[1] as $match) {
758
-			$gedrec .= FunctionsEdit::addNewFact($match);
759
-		}
760
-	}
761
-	if (Filter::postBool('SOUR_INDI')) {
762
-		$gedrec = FunctionsEdit::handleUpdates($gedrec);
763
-	} else {
764
-		$gedrec = FunctionsEdit::updateRest($gedrec);
765
-	}
766
-
767
-	$new_indi = $WT_TREE->createRecord($gedrec);
768
-
769
-	if (Filter::post('goto') === 'new') {
770
-		$controller->addInlineJavascript('closePopupAndReloadParent("' . $new_indi->getRawUrl() . '");');
771
-	} else {
772
-		$controller->addInlineJavascript('closePopupAndReloadParent();');
773
-	}
774
-	break;
737
+    $glevels = Filter::postArray('glevels', '[0-9]');
738
+    $tag     = Filter::postArray('tag', WT_REGEX_TAG);
739
+    $text    = Filter::postArray('text');
740
+    $islink  = Filter::postArray('islink', '[01]');
741
+
742
+    if (!Filter::checkCsrf()) {
743
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_unlinked_indi');
744
+
745
+        return;
746
+    }
747
+
748
+    $controller
749
+        ->restrictAccess(Auth::isManager($WT_TREE))
750
+        ->pageHeader();
751
+
752
+    FunctionsEdit::splitSource();
753
+    $gedrec = '0 @REF@ INDI';
754
+    $gedrec .= FunctionsEdit::addNewName();
755
+    $gedrec .= FunctionsEdit::addNewSex();
756
+    if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
757
+        foreach ($matches[1] as $match) {
758
+            $gedrec .= FunctionsEdit::addNewFact($match);
759
+        }
760
+    }
761
+    if (Filter::postBool('SOUR_INDI')) {
762
+        $gedrec = FunctionsEdit::handleUpdates($gedrec);
763
+    } else {
764
+        $gedrec = FunctionsEdit::updateRest($gedrec);
765
+    }
766
+
767
+    $new_indi = $WT_TREE->createRecord($gedrec);
768
+
769
+    if (Filter::post('goto') === 'new') {
770
+        $controller->addInlineJavascript('closePopupAndReloadParent("' . $new_indi->getRawUrl() . '");');
771
+    } else {
772
+        $controller->addInlineJavascript('closePopupAndReloadParent();');
773
+    }
774
+    break;
775 775
 
776 776
 ////////////////////////////////////////////////////////////////////////////////
777 777
 // Add a spouse to an existing individual (creating a new family)
778 778
 ////////////////////////////////////////////////////////////////////////////////
779 779
 case 'add_spouse_to_individual':
780
-	$famtag = Filter::get('famtag', 'HUSB|WIFE');
781
-	$xref   = Filter::get('xref', WT_REGEX_XREF);
782
-
783
-	$individual = Individual::getInstance($xref, $WT_TREE);
784
-	check_record_access($individual);
785
-
786
-	if ($famtag === 'WIFE') {
787
-		$controller->setPageTitle(I18N::translate('Add a wife'));
788
-		$sex = 'F';
789
-	} else {
790
-		$controller->setPageTitle(I18N::translate('Add a husband'));
791
-		$sex = 'M';
792
-	}
793
-	$controller->pageHeader();
794
-
795
-	print_indi_form('add_spouse_to_individual_action', $individual, null, null, $famtag, $sex);
796
-	break;
780
+    $famtag = Filter::get('famtag', 'HUSB|WIFE');
781
+    $xref   = Filter::get('xref', WT_REGEX_XREF);
797 782
 
798
-case 'add_spouse_to_individual_action':
799
-	$xref    = Filter::post('xref'); // Add a spouse to this individual
800
-	$sex     = Filter::post('SEX', '[MFU]', 'U');
801
-	$glevels = Filter::postArray('glevels', '[0-9]');
802
-	$tag     = Filter::postArray('tag', WT_REGEX_TAG);
803
-	$text    = Filter::postArray('text');
804
-	$islink  = Filter::postArray('islink', '[01]');
805
-
806
-	if (!Filter::checkCsrf()) {
807
-		$famtag = Filter::get('famtag', 'HUSB|WIFE');
808
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_spouse_to_individual&xref=' . $xref . '&famtag=' . $famtag);
809
-
810
-		return;
811
-	}
783
+    $individual = Individual::getInstance($xref, $WT_TREE);
784
+    check_record_access($individual);
812 785
 
813
-	$person = Individual::getInstance($xref, $WT_TREE);
814
-	check_record_access($person);
786
+    if ($famtag === 'WIFE') {
787
+        $controller->setPageTitle(I18N::translate('Add a wife'));
788
+        $sex = 'F';
789
+    } else {
790
+        $controller->setPageTitle(I18N::translate('Add a husband'));
791
+        $sex = 'M';
792
+    }
793
+    $controller->pageHeader();
815 794
 
816
-	$controller
817
-		->setPageTitle(I18N::translate('Add a spouse'))
818
-		->pageHeader();
795
+    print_indi_form('add_spouse_to_individual_action', $individual, null, null, $famtag, $sex);
796
+    break;
819 797
 
820
-	FunctionsEdit::splitSource();
821
-	$indi_gedcom = '0 @REF@ INDI';
822
-	$indi_gedcom .= FunctionsEdit::addNewName();
823
-	$indi_gedcom .= FunctionsEdit::addNewSex();
824
-	if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
825
-		foreach ($matches[1] as $match) {
826
-			$indi_gedcom .= FunctionsEdit::addNewFact($match);
827
-		}
828
-	}
829
-	if (Filter::postBool('SOUR_INDI')) {
830
-		$indi_gedcom = FunctionsEdit::handleUpdates($indi_gedcom);
831
-	} else {
832
-		$indi_gedcom = FunctionsEdit::updateRest($indi_gedcom);
833
-	}
834
-
835
-	$fam_gedcom = '';
836
-	if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) {
837
-		foreach ($matches[1] as $match) {
838
-			$fam_gedcom .= FunctionsEdit::addNewFact($match);
839
-		}
840
-	}
841
-	if (Filter::postBool('SOUR_FAM')) {
842
-		$fam_gedcom = FunctionsEdit::handleUpdates($fam_gedcom);
843
-	} else {
844
-		$fam_gedcom = FunctionsEdit::updateRest($fam_gedcom);
845
-	}
846
-
847
-	// Create the new spouse
848
-	$spouse = $person->getTree()->createRecord($indi_gedcom);
849
-	// Create a new family
850
-	if ($sex === 'F') {
851
-		$family = $spouse->getTree()->createRecord("0 @NEW@ FAM\n1 WIFE @" . $spouse->getXref() . "@\n1 HUSB @" . $person->getXref() . '@' . $fam_gedcom);
852
-	} else {
853
-		$family = $spouse->getTree()->createRecord("0 @NEW@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@' . $fam_gedcom);
854
-	}
855
-	// Link the spouses to the family
856
-	$spouse->createFact('1 FAMS @' . $family->getXref() . '@', true);
857
-	$person->createFact('1 FAMS @' . $family->getXref() . '@', true);
858
-
859
-	if (Filter::post('goto') === 'new') {
860
-		$controller->addInlineJavascript('closePopupAndReloadParent("' . $spouse->getRawUrl() . '");');
861
-	} else {
862
-		$controller->addInlineJavascript('closePopupAndReloadParent();');
863
-	}
864
-	break;
798
+case 'add_spouse_to_individual_action':
799
+    $xref    = Filter::post('xref'); // Add a spouse to this individual
800
+    $sex     = Filter::post('SEX', '[MFU]', 'U');
801
+    $glevels = Filter::postArray('glevels', '[0-9]');
802
+    $tag     = Filter::postArray('tag', WT_REGEX_TAG);
803
+    $text    = Filter::postArray('text');
804
+    $islink  = Filter::postArray('islink', '[01]');
805
+
806
+    if (!Filter::checkCsrf()) {
807
+        $famtag = Filter::get('famtag', 'HUSB|WIFE');
808
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_spouse_to_individual&xref=' . $xref . '&famtag=' . $famtag);
809
+
810
+        return;
811
+    }
812
+
813
+    $person = Individual::getInstance($xref, $WT_TREE);
814
+    check_record_access($person);
815
+
816
+    $controller
817
+        ->setPageTitle(I18N::translate('Add a spouse'))
818
+        ->pageHeader();
819
+
820
+    FunctionsEdit::splitSource();
821
+    $indi_gedcom = '0 @REF@ INDI';
822
+    $indi_gedcom .= FunctionsEdit::addNewName();
823
+    $indi_gedcom .= FunctionsEdit::addNewSex();
824
+    if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
825
+        foreach ($matches[1] as $match) {
826
+            $indi_gedcom .= FunctionsEdit::addNewFact($match);
827
+        }
828
+    }
829
+    if (Filter::postBool('SOUR_INDI')) {
830
+        $indi_gedcom = FunctionsEdit::handleUpdates($indi_gedcom);
831
+    } else {
832
+        $indi_gedcom = FunctionsEdit::updateRest($indi_gedcom);
833
+    }
834
+
835
+    $fam_gedcom = '';
836
+    if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) {
837
+        foreach ($matches[1] as $match) {
838
+            $fam_gedcom .= FunctionsEdit::addNewFact($match);
839
+        }
840
+    }
841
+    if (Filter::postBool('SOUR_FAM')) {
842
+        $fam_gedcom = FunctionsEdit::handleUpdates($fam_gedcom);
843
+    } else {
844
+        $fam_gedcom = FunctionsEdit::updateRest($fam_gedcom);
845
+    }
846
+
847
+    // Create the new spouse
848
+    $spouse = $person->getTree()->createRecord($indi_gedcom);
849
+    // Create a new family
850
+    if ($sex === 'F') {
851
+        $family = $spouse->getTree()->createRecord("0 @NEW@ FAM\n1 WIFE @" . $spouse->getXref() . "@\n1 HUSB @" . $person->getXref() . '@' . $fam_gedcom);
852
+    } else {
853
+        $family = $spouse->getTree()->createRecord("0 @NEW@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@' . $fam_gedcom);
854
+    }
855
+    // Link the spouses to the family
856
+    $spouse->createFact('1 FAMS @' . $family->getXref() . '@', true);
857
+    $person->createFact('1 FAMS @' . $family->getXref() . '@', true);
858
+
859
+    if (Filter::post('goto') === 'new') {
860
+        $controller->addInlineJavascript('closePopupAndReloadParent("' . $spouse->getRawUrl() . '");');
861
+    } else {
862
+        $controller->addInlineJavascript('closePopupAndReloadParent();');
863
+    }
864
+    break;
865 865
 
866 866
 ////////////////////////////////////////////////////////////////////////////////
867 867
 // Add a spouse to an existing family
868 868
 ////////////////////////////////////////////////////////////////////////////////
869 869
 case 'add_spouse_to_family':
870
-	$xref   = Filter::get('xref', WT_REGEX_XREF);
871
-	$famtag = Filter::get('famtag', 'HUSB|WIFE');
872
-
873
-	$family = Family::getInstance($xref, $WT_TREE);
874
-	check_record_access($family);
875
-
876
-	if ($famtag === 'WIFE') {
877
-		$controller->setPageTitle(I18N::translate('Add a wife'));
878
-		$sex = 'F';
879
-	} else {
880
-		$controller->setPageTitle(I18N::translate('Add a husband'));
881
-		$sex = 'M';
882
-	}
883
-	$controller->pageHeader();
870
+    $xref   = Filter::get('xref', WT_REGEX_XREF);
871
+    $famtag = Filter::get('famtag', 'HUSB|WIFE');
884 872
 
885
-	print_indi_form('add_spouse_to_family_action', null, $family, null, $famtag, $sex);
886
-	break;
873
+    $family = Family::getInstance($xref, $WT_TREE);
874
+    check_record_access($family);
887 875
 
888
-case 'add_spouse_to_family_action':
889
-	$xref    = Filter::post('xref', WT_REGEX_XREF);
890
-	$glevels = Filter::postArray('glevels', '[0-9]');
891
-	$tag     = Filter::postArray('tag', WT_REGEX_TAG);
892
-	$text    = Filter::postArray('text');
893
-	$islink  = Filter::postArray('islink', '[01]');
876
+    if ($famtag === 'WIFE') {
877
+        $controller->setPageTitle(I18N::translate('Add a wife'));
878
+        $sex = 'F';
879
+    } else {
880
+        $controller->setPageTitle(I18N::translate('Add a husband'));
881
+        $sex = 'M';
882
+    }
883
+    $controller->pageHeader();
894 884
 
895
-	$family  = Family::getInstance($xref, $WT_TREE);
896
-	check_record_access($family);
897
-
898
-	if (!Filter::checkCsrf()) {
899
-		$famtag = Filter::get('famtag', 'HUSB|WIFE');
900
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_spouse_to_family&xref=' . $xref . '&famtag=' . $famtag);
901
-
902
-		return;
903
-	}
904
-
905
-	$controller->pageHeader();
906
-
907
-	// Create the new spouse
908
-	FunctionsEdit::splitSource(); // separate SOUR record from the rest
909
-
910
-	$gedrec = '0 @REF@ INDI';
911
-	$gedrec .= FunctionsEdit::addNewName();
912
-	$gedrec .= FunctionsEdit::addNewSex();
913
-	if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
914
-		foreach ($matches[1] as $match) {
915
-			$gedrec .= FunctionsEdit::addNewFact($match);
916
-		}
917
-	}
918
-
919
-	if (Filter::postBool('SOUR_INDI')) {
920
-		$gedrec = FunctionsEdit::handleUpdates($gedrec);
921
-	} else {
922
-		$gedrec = FunctionsEdit::updateRest($gedrec);
923
-	}
924
-	$gedrec .= "\n1 FAMS @" . $family->getXref() . '@';
925
-	$spouse = $family->getTree()->createRecord($gedrec);
926
-
927
-	// Update the existing family - add marriage, etc
928
-	if ($family->getFirstFact('HUSB')) {
929
-		$family->createFact('1 WIFE @' . $spouse->getXref() . '@', true);
930
-	} else {
931
-		$family->createFact('1 HUSB @' . $spouse->getXref() . '@', true);
932
-	}
933
-	$famrec = '';
934
-	if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) {
935
-		foreach ($matches[1] as $match) {
936
-			$famrec .= FunctionsEdit::addNewFact($match);
937
-		}
938
-	}
939
-	if (Filter::postBool('SOUR_FAM')) {
940
-		$famrec = FunctionsEdit::handleUpdates($famrec);
941
-	} else {
942
-		$famrec = FunctionsEdit::updateRest($famrec);
943
-	}
944
-	$family->createFact(trim($famrec), true); // trim leading \n
885
+    print_indi_form('add_spouse_to_family_action', null, $family, null, $famtag, $sex);
886
+    break;
945 887
 
946
-	if (Filter::post('goto') === 'new') {
947
-		$controller->addInlineJavascript('closePopupAndReloadParent("' . $spouse->getRawUrl() . '");');
948
-	} else {
949
-		$controller->addInlineJavascript('closePopupAndReloadParent();');
950
-	}
951
-	break;
888
+case 'add_spouse_to_family_action':
889
+    $xref    = Filter::post('xref', WT_REGEX_XREF);
890
+    $glevels = Filter::postArray('glevels', '[0-9]');
891
+    $tag     = Filter::postArray('tag', WT_REGEX_TAG);
892
+    $text    = Filter::postArray('text');
893
+    $islink  = Filter::postArray('islink', '[01]');
894
+
895
+    $family  = Family::getInstance($xref, $WT_TREE);
896
+    check_record_access($family);
897
+
898
+    if (!Filter::checkCsrf()) {
899
+        $famtag = Filter::get('famtag', 'HUSB|WIFE');
900
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_spouse_to_family&xref=' . $xref . '&famtag=' . $famtag);
901
+
902
+        return;
903
+    }
904
+
905
+    $controller->pageHeader();
906
+
907
+    // Create the new spouse
908
+    FunctionsEdit::splitSource(); // separate SOUR record from the rest
909
+
910
+    $gedrec = '0 @REF@ INDI';
911
+    $gedrec .= FunctionsEdit::addNewName();
912
+    $gedrec .= FunctionsEdit::addNewSex();
913
+    if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
914
+        foreach ($matches[1] as $match) {
915
+            $gedrec .= FunctionsEdit::addNewFact($match);
916
+        }
917
+    }
918
+
919
+    if (Filter::postBool('SOUR_INDI')) {
920
+        $gedrec = FunctionsEdit::handleUpdates($gedrec);
921
+    } else {
922
+        $gedrec = FunctionsEdit::updateRest($gedrec);
923
+    }
924
+    $gedrec .= "\n1 FAMS @" . $family->getXref() . '@';
925
+    $spouse = $family->getTree()->createRecord($gedrec);
926
+
927
+    // Update the existing family - add marriage, etc
928
+    if ($family->getFirstFact('HUSB')) {
929
+        $family->createFact('1 WIFE @' . $spouse->getXref() . '@', true);
930
+    } else {
931
+        $family->createFact('1 HUSB @' . $spouse->getXref() . '@', true);
932
+    }
933
+    $famrec = '';
934
+    if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) {
935
+        foreach ($matches[1] as $match) {
936
+            $famrec .= FunctionsEdit::addNewFact($match);
937
+        }
938
+    }
939
+    if (Filter::postBool('SOUR_FAM')) {
940
+        $famrec = FunctionsEdit::handleUpdates($famrec);
941
+    } else {
942
+        $famrec = FunctionsEdit::updateRest($famrec);
943
+    }
944
+    $family->createFact(trim($famrec), true); // trim leading \n
945
+
946
+    if (Filter::post('goto') === 'new') {
947
+        $controller->addInlineJavascript('closePopupAndReloadParent("' . $spouse->getRawUrl() . '");');
948
+    } else {
949
+        $controller->addInlineJavascript('closePopupAndReloadParent();');
950
+    }
951
+    break;
952 952
 
953 953
 ////////////////////////////////////////////////////////////////////////////////
954 954
 // Link an individual to an existing family, as a child
955 955
 ////////////////////////////////////////////////////////////////////////////////
956 956
 case 'addfamlink':
957
-	$xref = Filter::get('xref', WT_REGEX_XREF);
957
+    $xref = Filter::get('xref', WT_REGEX_XREF);
958 958
 
959
-	$person = Individual::getInstance($xref, $WT_TREE);
960
-	check_record_access($person);
959
+    $person = Individual::getInstance($xref, $WT_TREE);
960
+    check_record_access($person);
961 961
 
962
-	$controller
963
-		->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Link this individual to an existing family as a child'))
964
-		->pageHeader();
962
+    $controller
963
+        ->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Link this individual to an existing family as a child'))
964
+        ->pageHeader();
965 965
 
966
-	?>
966
+    ?>
967 967
 	<div id="edit_interface-page">
968 968
 		<h2><?php echo $controller->getPageTitle(); ?></h2>
969 969
 		<form method="post" name="addchildform" action="edit_interface.php">
@@ -1001,77 +1001,77 @@  discard block
 block discarded – undo
1001 1001
 		</form>
1002 1002
 	</div>
1003 1003
 	<?php
1004
-	break;
1004
+    break;
1005 1005
 
1006 1006
 case 'linkfamaction':
1007
-	$xref   = Filter::post('xref', WT_REGEX_XREF);
1008
-	$famid  = Filter::post('famid', WT_REGEX_XREF);
1009
-	$PEDI   = Filter::post('PEDI');
1010
-
1011
-	if (!Filter::checkCsrf()) {
1012
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addfamlink&xref=' . $xref);
1013
-
1014
-		return;
1015
-	}
1016
-
1017
-	$person = Individual::getInstance($xref, $WT_TREE);
1018
-	$family = Family::getInstance($famid, $WT_TREE);
1019
-	check_record_access($person);
1020
-	check_record_access($family);
1021
-
1022
-	$controller
1023
-		->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Link this individual to an existing family as a child'))
1024
-		->pageHeader();
1025
-
1026
-	// Replace any existing child->family link (we may be changing the PEDI);
1027
-	$fact_id = null;
1028
-	foreach ($person->getFacts('FAMC') as $fact) {
1029
-		if ($family === $fact->getTarget()) {
1030
-			$fact_id = $fact->getFactId();
1031
-			break;
1032
-		}
1033
-	}
1034
-
1035
-	$gedcom = GedcomCodePedi::createNewFamcPedi($PEDI, $famid);
1036
-	$person->updateFact($fact_id, $gedcom, true);
1037
-
1038
-	// Only set the family->child link if it does not already exist
1039
-	$edit_fact = null;
1040
-	foreach ($family->getFacts('CHIL') as $fact) {
1041
-		if ($person === $fact->getTarget()) {
1042
-			$edit_fact = $fact;
1043
-			break;
1044
-		}
1045
-	}
1046
-	if (!$edit_fact) {
1047
-		$family->createFact('1 CHIL @' . $person->getXref() . '@', true);
1048
-	}
1049
-
1050
-	$controller->addInlineJavascript('closePopupAndReloadParent();');
1051
-	break;
1007
+    $xref   = Filter::post('xref', WT_REGEX_XREF);
1008
+    $famid  = Filter::post('famid', WT_REGEX_XREF);
1009
+    $PEDI   = Filter::post('PEDI');
1010
+
1011
+    if (!Filter::checkCsrf()) {
1012
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addfamlink&xref=' . $xref);
1013
+
1014
+        return;
1015
+    }
1016
+
1017
+    $person = Individual::getInstance($xref, $WT_TREE);
1018
+    $family = Family::getInstance($famid, $WT_TREE);
1019
+    check_record_access($person);
1020
+    check_record_access($family);
1021
+
1022
+    $controller
1023
+        ->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Link this individual to an existing family as a child'))
1024
+        ->pageHeader();
1025
+
1026
+    // Replace any existing child->family link (we may be changing the PEDI);
1027
+    $fact_id = null;
1028
+    foreach ($person->getFacts('FAMC') as $fact) {
1029
+        if ($family === $fact->getTarget()) {
1030
+            $fact_id = $fact->getFactId();
1031
+            break;
1032
+        }
1033
+    }
1034
+
1035
+    $gedcom = GedcomCodePedi::createNewFamcPedi($PEDI, $famid);
1036
+    $person->updateFact($fact_id, $gedcom, true);
1037
+
1038
+    // Only set the family->child link if it does not already exist
1039
+    $edit_fact = null;
1040
+    foreach ($family->getFacts('CHIL') as $fact) {
1041
+        if ($person === $fact->getTarget()) {
1042
+            $edit_fact = $fact;
1043
+            break;
1044
+        }
1045
+    }
1046
+    if (!$edit_fact) {
1047
+        $family->createFact('1 CHIL @' . $person->getXref() . '@', true);
1048
+    }
1049
+
1050
+    $controller->addInlineJavascript('closePopupAndReloadParent();');
1051
+    break;
1052 1052
 
1053 1053
 ////////////////////////////////////////////////////////////////////////////////
1054 1054
 // Link and individual to an existing individual as a spouse
1055 1055
 ////////////////////////////////////////////////////////////////////////////////
1056 1056
 case 'linkspouse':
1057
-	$famtag = Filter::get('famtag', 'HUSB|WIFE');
1058
-	$xref   = Filter::get('xref', WT_REGEX_XREF);
1059
-
1060
-	$person = Individual::getInstance($xref, $WT_TREE);
1061
-	check_record_access($person);
1062
-
1063
-	if ($person->getSex() === 'F') {
1064
-		$controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual'));
1065
-		$label = I18N::translate('Husband');
1066
-	} else {
1067
-		$controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual'));
1068
-		$label = I18N::translate('Wife');
1069
-	}
1057
+    $famtag = Filter::get('famtag', 'HUSB|WIFE');
1058
+    $xref   = Filter::get('xref', WT_REGEX_XREF);
1070 1059
 
1071
-	$controller->pageHeader();
1072
-	FunctionsPrint::initializeCalendarPopup();
1060
+    $person = Individual::getInstance($xref, $WT_TREE);
1061
+    check_record_access($person);
1073 1062
 
1074
-	?>
1063
+    if ($person->getSex() === 'F') {
1064
+        $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual'));
1065
+        $label = I18N::translate('Husband');
1066
+    } else {
1067
+        $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual'));
1068
+        $label = I18N::translate('Wife');
1069
+    }
1070
+
1071
+    $controller->pageHeader();
1072
+    FunctionsPrint::initializeCalendarPopup();
1073
+
1074
+    ?>
1075 1075
 	<div id="edit_interface-page">
1076 1076
 		<h2><?php echo $controller->getPageTitle(); ?></h2>
1077 1077
 		<form method="post" name="addchildform" action="edit_interface.php">
@@ -1109,74 +1109,74 @@  discard block
 block discarded – undo
1109 1109
 		</form>
1110 1110
 	</div>
1111 1111
 	<?php
1112
-	break;
1112
+    break;
1113 1113
 
1114 1114
 case 'linkspouseaction':
1115
-	$xref    = Filter::post('xref', WT_REGEX_XREF);
1116
-	$spid    = Filter::post('spid', WT_REGEX_XREF);
1117
-	$famtag  = Filter::post('famtag', 'HUSB|WIFE');
1118
-	$glevels = Filter::postArray('glevels', '[0-9]');
1119
-	$tag     = Filter::postArray('tag', WT_REGEX_TAG);
1120
-	$text    = Filter::postArray('text');
1121
-	$islink  = Filter::postArray('islink', '[01]');
1122
-
1123
-	if (!Filter::checkCsrf()) {
1124
-		$famtag = Filter::get('famtag', 'HUSB|WIFE');
1125
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=linkspouse&xref=' . $xref . '&famtag=' . $famtag);
1126
-
1127
-		return;
1128
-	}
1129
-
1130
-	$person  = Individual::getInstance($xref, $WT_TREE);
1131
-	$spouse  = Individual::getInstance($spid, $WT_TREE);
1132
-	check_record_access($person);
1133
-	check_record_access($spouse);
1134
-
1135
-	if ($person->getSex() === 'F') {
1136
-		$controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual'));
1137
-	} else {
1138
-		$controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual'));
1139
-	}
1140
-	$controller->pageHeader();
1141
-
1142
-	if ($person->getSex() === 'M') {
1143
-		$gedcom = "0 @new@ FAM\n1 HUSB @" . $person->getXref() . "@\n1 WIFE @" . $spouse->getXref() . '@';
1144
-	} else {
1145
-		$gedcom = "0 @new@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@';
1146
-	}
1147
-	FunctionsEdit::splitSource();
1148
-	$gedcom .= FunctionsEdit::addNewFact('MARR');
1149
-
1150
-	if (Filter::postBool('SOUR_FAM') || count($tagSOUR) > 0) {
1151
-		// before adding 2 SOUR it needs to add 1 MARR Y first
1152
-		if (FunctionsEdit::addNewFact('MARR') === '') {
1153
-			$gedcom .= "\n1 MARR Y";
1154
-		}
1155
-		$gedcom = FunctionsEdit::handleUpdates($gedcom);
1156
-	} else {
1157
-		// before adding level 2 facts it needs to add 1 MARR Y first
1158
-		if (FunctionsEdit::addNewFact('MARR') === '') {
1159
-			$gedcom .= "\n1 MARR Y";
1160
-		}
1161
-		$gedcom = FunctionsEdit::updateRest($gedcom);
1162
-	}
1163
-
1164
-	$family = $person->getTree()->createRecord($gedcom);
1165
-	$person->createFact('1 FAMS @' . $family->getXref() . '@', true);
1166
-	$spouse->createFact('1 FAMS @' . $family->getXref() . '@', true);
1167
-
1168
-	$controller->addInlineJavascript('closePopupAndReloadParent();');
1169
-	break;
1115
+    $xref    = Filter::post('xref', WT_REGEX_XREF);
1116
+    $spid    = Filter::post('spid', WT_REGEX_XREF);
1117
+    $famtag  = Filter::post('famtag', 'HUSB|WIFE');
1118
+    $glevels = Filter::postArray('glevels', '[0-9]');
1119
+    $tag     = Filter::postArray('tag', WT_REGEX_TAG);
1120
+    $text    = Filter::postArray('text');
1121
+    $islink  = Filter::postArray('islink', '[01]');
1122
+
1123
+    if (!Filter::checkCsrf()) {
1124
+        $famtag = Filter::get('famtag', 'HUSB|WIFE');
1125
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=linkspouse&xref=' . $xref . '&famtag=' . $famtag);
1126
+
1127
+        return;
1128
+    }
1129
+
1130
+    $person  = Individual::getInstance($xref, $WT_TREE);
1131
+    $spouse  = Individual::getInstance($spid, $WT_TREE);
1132
+    check_record_access($person);
1133
+    check_record_access($spouse);
1134
+
1135
+    if ($person->getSex() === 'F') {
1136
+        $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual'));
1137
+    } else {
1138
+        $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual'));
1139
+    }
1140
+    $controller->pageHeader();
1141
+
1142
+    if ($person->getSex() === 'M') {
1143
+        $gedcom = "0 @new@ FAM\n1 HUSB @" . $person->getXref() . "@\n1 WIFE @" . $spouse->getXref() . '@';
1144
+    } else {
1145
+        $gedcom = "0 @new@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@';
1146
+    }
1147
+    FunctionsEdit::splitSource();
1148
+    $gedcom .= FunctionsEdit::addNewFact('MARR');
1149
+
1150
+    if (Filter::postBool('SOUR_FAM') || count($tagSOUR) > 0) {
1151
+        // before adding 2 SOUR it needs to add 1 MARR Y first
1152
+        if (FunctionsEdit::addNewFact('MARR') === '') {
1153
+            $gedcom .= "\n1 MARR Y";
1154
+        }
1155
+        $gedcom = FunctionsEdit::handleUpdates($gedcom);
1156
+    } else {
1157
+        // before adding level 2 facts it needs to add 1 MARR Y first
1158
+        if (FunctionsEdit::addNewFact('MARR') === '') {
1159
+            $gedcom .= "\n1 MARR Y";
1160
+        }
1161
+        $gedcom = FunctionsEdit::updateRest($gedcom);
1162
+    }
1163
+
1164
+    $family = $person->getTree()->createRecord($gedcom);
1165
+    $person->createFact('1 FAMS @' . $family->getXref() . '@', true);
1166
+    $spouse->createFact('1 FAMS @' . $family->getXref() . '@', true);
1167
+
1168
+    $controller->addInlineJavascript('closePopupAndReloadParent();');
1169
+    break;
1170 1170
 
1171 1171
 ////////////////////////////////////////////////////////////////////////////////
1172 1172
 // Create a new source record
1173 1173
 ////////////////////////////////////////////////////////////////////////////////
1174 1174
 case 'addnewsource':
1175
-	$controller
1176
-		->setPageTitle(I18N::translate('Create a source'))
1177
-		->pageHeader();
1175
+    $controller
1176
+        ->setPageTitle(I18N::translate('Create a source'))
1177
+        ->pageHeader();
1178 1178
 
1179
-	?>
1179
+    ?>
1180 1180
 	<script>
1181 1181
 		function check_form(frm) {
1182 1182
 			if (frm.TITL.value=="") {
@@ -1225,24 +1225,24 @@  discard block
 block discarded – undo
1225 1225
 					<td class="descriptionbox wrap width25"><?php echo I18N::translate('Select events'), FunctionsPrint::helpLink('edit_SOUR_EVEN'); ?></td>
1226 1226
 					<td class="optionbox wrap"><select name="EVEN[]" multiple="multiple" size="5">
1227 1227
 						<?php
1228
-						$parts = explode(',', $WT_TREE->getPreference('INDI_FACTS_ADD'));
1229
-						foreach ($parts as $key) {
1230
-							?><option value="<?php echo $key; ?>"><?php echo GedcomTag::getLabel($key); ?></option>
1228
+                        $parts = explode(',', $WT_TREE->getPreference('INDI_FACTS_ADD'));
1229
+                        foreach ($parts as $key) {
1230
+                            ?><option value="<?php echo $key; ?>"><?php echo GedcomTag::getLabel($key); ?></option>
1231 1231
 						<?php
1232
-						}
1233
-						$parts = explode(',', $WT_TREE->getPreference('FAM_FACTS_ADD'));
1234
-						foreach ($parts as $key) {
1235
-							?><option value="<?php echo $key; ?>"><?php echo GedcomTag::getLabel($key); ?></option>
1232
+                        }
1233
+                        $parts = explode(',', $WT_TREE->getPreference('FAM_FACTS_ADD'));
1234
+                        foreach ($parts as $key) {
1235
+                            ?><option value="<?php echo $key; ?>"><?php echo GedcomTag::getLabel($key); ?></option>
1236 1236
 						<?php
1237
-						}
1238
-						?>
1237
+                        }
1238
+                        ?>
1239 1239
 					</select></td>
1240 1240
 				</tr>
1241 1241
 				<?php
1242
-				FunctionsEdit::addSimpleTag('0 DATE', 'EVEN');
1243
-				FunctionsEdit::addSimpleTag('0 PLAC', 'EVEN');
1244
-				FunctionsEdit::addSimpleTag('0 AGNC');
1245
-				?>
1242
+                FunctionsEdit::addSimpleTag('0 DATE', 'EVEN');
1243
+                FunctionsEdit::addSimpleTag('0 PLAC', 'EVEN');
1244
+                FunctionsEdit::addSimpleTag('0 AGNC');
1245
+                ?>
1246 1246
 				</table>
1247 1247
 			</div>
1248 1248
 			<p id="save-cancel">
@@ -1252,83 +1252,83 @@  discard block
 block discarded – undo
1252 1252
 		</form>
1253 1253
 	</div>
1254 1254
 	<?php
1255
-	break;
1255
+    break;
1256 1256
 
1257 1257
 case 'addsourceaction':
1258
-	$controller
1259
-		->setPageTitle(I18N::translate('Create a source'))
1260
-		->pageHeader();
1261
-
1262
-	if (!Filter::checkCsrf()) {
1263
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewsource');
1264
-
1265
-		return;
1266
-	}
1267
-
1268
-	$newgedrec = '0 @XREF@ SOUR';
1269
-	$ABBR      = Filter::post('ABBR');
1270
-	if ($ABBR) {
1271
-		$newgedrec .= "\n1 ABBR " . $ABBR;
1272
-	}
1273
-	$TITL = Filter::post('TITL');
1274
-	if ($TITL) {
1275
-		$newgedrec .= "\n1 TITL " . $TITL;
1276
-		$_HEB = Filter::post('_HEB');
1277
-		if ($_HEB) {
1278
-			$newgedrec .= "\n2 _HEB " . $_HEB;
1279
-		}
1280
-		$ROMN = Filter::post('ROMN');
1281
-		if ($ROMN) {
1282
-			$newgedrec .= "\n2 ROMN " . $ROMN;
1283
-		}
1284
-	}
1285
-	$AUTH = Filter::post('AUTH');
1286
-	if ($AUTH) {
1287
-		$newgedrec .= "\n1 AUTH " . $AUTH;
1288
-	}
1289
-	$PUBL = Filter::post('PUBL');
1290
-	if ($PUBL) {
1291
-		$newgedrec .= "\n1 PUBL " . preg_replace('/\r?\n/', "\n2 CONT ", $PUBL);
1292
-	}
1293
-	$REPO = Filter::post('REPO', WT_REGEX_XREF);
1294
-	if ($REPO) {
1295
-		$newgedrec .= "\n1 REPO @" . $REPO . '@';
1296
-		$CALN = Filter::post('CALN');
1297
-		if ($CALN) {
1298
-			$newgedrec .= "\n2 CALN " . $CALN;
1299
-		}
1300
-	}
1301
-	$EVEN = Filter::postArray('EVEN', WT_REGEX_TAG);
1302
-	if ($EVEN) {
1303
-		$newgedrec .= "\n1 DATA";
1304
-		$newgedrec .= "\n2 EVEN " . implode(',', $EVEN);
1305
-		$EVEN_DATE = Filter::post('EVEN_DATE');
1306
-		if ($EVEN_DATE) {
1307
-			$newgedrec .= "\n3 EVEN_DATE " . $EVEN_DATE;
1308
-		}
1309
-		$EVEN_PLAC = Filter::post('EVEN_PLAC');
1310
-		if ($EVEN_PLAC) {
1311
-			$newgedrec .= "\n3 EVEN_PLAC " . $EVEN_PLAC;
1312
-		}
1313
-		$AGNC = Filter::post('AGNC');
1314
-		if ($AGNC) {
1315
-			$newgedrec .= "\n2 AGNC " . $AGNC;
1316
-		}
1317
-	}
1318
-
1319
-	$record = $WT_TREE->createRecord($newgedrec);
1320
-	$controller->addInlineJavascript('openerpasteid("' . $record->getXref() . '");');
1321
-	break;
1258
+    $controller
1259
+        ->setPageTitle(I18N::translate('Create a source'))
1260
+        ->pageHeader();
1261
+
1262
+    if (!Filter::checkCsrf()) {
1263
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewsource');
1264
+
1265
+        return;
1266
+    }
1267
+
1268
+    $newgedrec = '0 @XREF@ SOUR';
1269
+    $ABBR      = Filter::post('ABBR');
1270
+    if ($ABBR) {
1271
+        $newgedrec .= "\n1 ABBR " . $ABBR;
1272
+    }
1273
+    $TITL = Filter::post('TITL');
1274
+    if ($TITL) {
1275
+        $newgedrec .= "\n1 TITL " . $TITL;
1276
+        $_HEB = Filter::post('_HEB');
1277
+        if ($_HEB) {
1278
+            $newgedrec .= "\n2 _HEB " . $_HEB;
1279
+        }
1280
+        $ROMN = Filter::post('ROMN');
1281
+        if ($ROMN) {
1282
+            $newgedrec .= "\n2 ROMN " . $ROMN;
1283
+        }
1284
+    }
1285
+    $AUTH = Filter::post('AUTH');
1286
+    if ($AUTH) {
1287
+        $newgedrec .= "\n1 AUTH " . $AUTH;
1288
+    }
1289
+    $PUBL = Filter::post('PUBL');
1290
+    if ($PUBL) {
1291
+        $newgedrec .= "\n1 PUBL " . preg_replace('/\r?\n/', "\n2 CONT ", $PUBL);
1292
+    }
1293
+    $REPO = Filter::post('REPO', WT_REGEX_XREF);
1294
+    if ($REPO) {
1295
+        $newgedrec .= "\n1 REPO @" . $REPO . '@';
1296
+        $CALN = Filter::post('CALN');
1297
+        if ($CALN) {
1298
+            $newgedrec .= "\n2 CALN " . $CALN;
1299
+        }
1300
+    }
1301
+    $EVEN = Filter::postArray('EVEN', WT_REGEX_TAG);
1302
+    if ($EVEN) {
1303
+        $newgedrec .= "\n1 DATA";
1304
+        $newgedrec .= "\n2 EVEN " . implode(',', $EVEN);
1305
+        $EVEN_DATE = Filter::post('EVEN_DATE');
1306
+        if ($EVEN_DATE) {
1307
+            $newgedrec .= "\n3 EVEN_DATE " . $EVEN_DATE;
1308
+        }
1309
+        $EVEN_PLAC = Filter::post('EVEN_PLAC');
1310
+        if ($EVEN_PLAC) {
1311
+            $newgedrec .= "\n3 EVEN_PLAC " . $EVEN_PLAC;
1312
+        }
1313
+        $AGNC = Filter::post('AGNC');
1314
+        if ($AGNC) {
1315
+            $newgedrec .= "\n2 AGNC " . $AGNC;
1316
+        }
1317
+    }
1318
+
1319
+    $record = $WT_TREE->createRecord($newgedrec);
1320
+    $controller->addInlineJavascript('openerpasteid("' . $record->getXref() . '");');
1321
+    break;
1322 1322
 
1323 1323
 ////////////////////////////////////////////////////////////////////////////////
1324 1324
 // Create a new note record
1325 1325
 ////////////////////////////////////////////////////////////////////////////////
1326 1326
 case 'addnewnote':
1327
-	$controller
1328
-		->setPageTitle(I18N::translate('Create a shared note'))
1329
-		->pageHeader();
1327
+    $controller
1328
+        ->setPageTitle(I18N::translate('Create a shared note'))
1329
+        ->pageHeader();
1330 1330
 
1331
-	?>
1331
+    ?>
1332 1332
 	<div id="edit_interface-page">
1333 1333
 		<h2><?php echo $controller->getPageTitle(); ?></h2>
1334 1334
 
@@ -1338,18 +1338,18 @@  discard block
 block discarded – undo
1338 1338
 			<input type="hidden" name="noteid" value="newnote">
1339 1339
 			<?php echo Filter::getCsrf(); ?>
1340 1340
 			<?php
1341
-			echo '<table class="facts_table">';
1342
-			echo '<tr>';
1343
-			echo '<td class="descriptionbox nowrap">';
1344
-			echo I18N::translate('Shared note');
1345
-			echo '</td>';
1346
-			echo '<td class="optionbox wrap"><textarea name="NOTE" id="NOTE" rows="15" cols="87"></textarea>';
1347
-			echo FunctionsPrint::printSpecialCharacterLink('NOTE');
1348
-			echo '</td>';
1349
-			echo '</tr>';
1350
-			echo keep_chan();
1351
-			echo '</table>';
1352
-			?>
1341
+            echo '<table class="facts_table">';
1342
+            echo '<tr>';
1343
+            echo '<td class="descriptionbox nowrap">';
1344
+            echo I18N::translate('Shared note');
1345
+            echo '</td>';
1346
+            echo '<td class="optionbox wrap"><textarea name="NOTE" id="NOTE" rows="15" cols="87"></textarea>';
1347
+            echo FunctionsPrint::printSpecialCharacterLink('NOTE');
1348
+            echo '</td>';
1349
+            echo '</tr>';
1350
+            echo keep_chan();
1351
+            echo '</table>';
1352
+            ?>
1353 1353
 			<p id="save-cancel">
1354 1354
 				<input type="submit" class="save" value="<?php echo I18N::translate('save'); ?>">
1355 1355
 				<input type="button" class="cancel" value="<?php echo I18N::translate('close'); ?>" onclick="window.close();">
@@ -1357,47 +1357,47 @@  discard block
 block discarded – undo
1357 1357
 		</form>
1358 1358
 	</div>
1359 1359
 	<?php
1360
-	break;
1360
+    break;
1361 1361
 
1362 1362
 case 'addnoteaction':
1363
-	$controller
1364
-		->setPageTitle(I18N::translate('Create a shared note'))
1365
-		->pageHeader();
1363
+    $controller
1364
+        ->setPageTitle(I18N::translate('Create a shared note'))
1365
+        ->pageHeader();
1366 1366
 
1367
-	if (!Filter::checkCsrf()) {
1368
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewnote');
1367
+    if (!Filter::checkCsrf()) {
1368
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewnote');
1369 1369
 
1370
-		return;
1371
-	}
1370
+        return;
1371
+    }
1372 1372
 
1373
-	$gedrec = '0 @XREF@ NOTE ' . preg_replace("/\r?\n/", "\n1 CONT ", Filter::post('NOTE'));
1373
+    $gedrec = '0 @XREF@ NOTE ' . preg_replace("/\r?\n/", "\n1 CONT ", Filter::post('NOTE'));
1374 1374
 
1375
-	$record = $WT_TREE->createRecord($gedrec);
1376
-	$controller->addInlineJavascript('openerpasteid("' . $record->getXref() . '");');
1377
-	break;
1375
+    $record = $WT_TREE->createRecord($gedrec);
1376
+    $controller->addInlineJavascript('openerpasteid("' . $record->getXref() . '");');
1377
+    break;
1378 1378
 
1379 1379
 ////////////////////////////////////////////////////////////////////////////////
1380 1380
 case 'addnewnote_assisted':
1381
-	require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/census/census-edit.php';
1382
-	break;
1381
+    require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/census/census-edit.php';
1382
+    break;
1383 1383
 
1384 1384
 ////////////////////////////////////////////////////////////////////////////////
1385 1385
 case 'addnoteaction_assisted':
1386
-	require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/census/census-save.php';
1387
-	break;
1386
+    require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/census/census-save.php';
1387
+    break;
1388 1388
 
1389 1389
 ////////////////////////////////////////////////////////////////////////////////
1390 1390
 case 'addmedia_links':
1391
-	$pid = Filter::get('pid', WT_REGEX_XREF);
1391
+    $pid = Filter::get('pid', WT_REGEX_XREF);
1392 1392
 
1393
-	$person = Individual::getInstance($pid, $WT_TREE);
1394
-	check_record_access($person);
1393
+    $person = Individual::getInstance($pid, $WT_TREE);
1394
+    check_record_access($person);
1395 1395
 
1396
-	$controller
1397
-		->setPageTitle(I18N::translate('Family navigator') . ' — ' . $person->getFullName())
1398
-		->pageHeader();
1396
+    $controller
1397
+        ->setPageTitle(I18N::translate('Family navigator') . ' — ' . $person->getFullName())
1398
+        ->pageHeader();
1399 1399
 
1400
-	?>
1400
+    ?>
1401 1401
 	<div id="edit_interface-page">
1402 1402
 		<h2><?php echo $controller->getPageTitle(); ?></h2>
1403 1403
 		<form method="post" action="edit_interface.php?xref=<?php echo $person->getXref(); ?>" onsubmit="findindi()">
@@ -1409,22 +1409,22 @@  discard block
 block discarded – undo
1409 1409
 		</form>
1410 1410
 	</div>
1411 1411
 	<?php
1412
-	break;
1412
+    break;
1413 1413
 
1414 1414
 ////////////////////////////////////////////////////////////////////////////////
1415 1415
 // Edit a note record
1416 1416
 ////////////////////////////////////////////////////////////////////////////////
1417 1417
 case 'editnote':
1418
-	$xref = Filter::get('xref', WT_REGEX_XREF);
1418
+    $xref = Filter::get('xref', WT_REGEX_XREF);
1419 1419
 
1420
-	$note = Note::getInstance($xref, $WT_TREE);
1421
-	check_record_access($note);
1420
+    $note = Note::getInstance($xref, $WT_TREE);
1421
+    check_record_access($note);
1422 1422
 
1423
-	$controller
1424
-		->setPageTitle(I18N::translate('Edit the shared note'))
1425
-		->pageHeader();
1423
+    $controller
1424
+        ->setPageTitle(I18N::translate('Edit the shared note'))
1425
+        ->pageHeader();
1426 1426
 
1427
-	?>
1427
+    ?>
1428 1428
 	<div id="edit_interface-page">
1429 1429
 		<h2><?php echo $controller->getPageTitle(); ?></h2>
1430 1430
 		<form method="post" action="edit_interface.php">
@@ -1450,53 +1450,53 @@  discard block
 block discarded – undo
1450 1450
 		</form>
1451 1451
 	</div>
1452 1452
 	<?php
1453
-	break;
1453
+    break;
1454 1454
 
1455 1455
 case 'editnoteaction':
1456
-	$xref      = Filter::post('xref', WT_REGEX_XREF);
1457
-	$keep_chan = Filter::postBool('keep_chan');
1458
-	$note      = Filter::post('NOTE');
1456
+    $xref      = Filter::post('xref', WT_REGEX_XREF);
1457
+    $keep_chan = Filter::postBool('keep_chan');
1458
+    $note      = Filter::post('NOTE');
1459 1459
 
1460
-	if (!Filter::checkCsrf()) {
1461
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editnote&xref=' . $xref);
1460
+    if (!Filter::checkCsrf()) {
1461
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editnote&xref=' . $xref);
1462 1462
 
1463
-		return;
1464
-	}
1463
+        return;
1464
+    }
1465 1465
 
1466
-	$record = Note::getInstance($xref, $WT_TREE);
1467
-	check_record_access($record);
1466
+    $record = Note::getInstance($xref, $WT_TREE);
1467
+    check_record_access($record);
1468 1468
 
1469
-	$controller
1470
-		->setPageTitle(I18N::translate('Edit the shared note'))
1471
-		->pageHeader();
1469
+    $controller
1470
+        ->setPageTitle(I18N::translate('Edit the shared note'))
1471
+        ->pageHeader();
1472 1472
 
1473
-	// We have user-supplied data in a replacement string - escape it against backreferences
1474
-	$note = str_replace(array('\\', '$'), array('\\\\', '\\$'), $note);
1473
+    // We have user-supplied data in a replacement string - escape it against backreferences
1474
+    $note = str_replace(array('\\', '$'), array('\\\\', '\\$'), $note);
1475 1475
 
1476
-	$gedrec = preg_replace(
1477
-		'/^0 @' . $record->getXref() . '@ NOTE.*(\n1 CONT.*)*/',
1478
-		'0 @' . $record->getXref() . '@ NOTE ' . preg_replace("/\r?\n/", "\n1 CONT ", $note),
1479
-		$record->getGedcom()
1480
-	);
1476
+    $gedrec = preg_replace(
1477
+        '/^0 @' . $record->getXref() . '@ NOTE.*(\n1 CONT.*)*/',
1478
+        '0 @' . $record->getXref() . '@ NOTE ' . preg_replace("/\r?\n/", "\n1 CONT ", $note),
1479
+        $record->getGedcom()
1480
+    );
1481 1481
 
1482
-	$record->updateRecord($gedrec, !$keep_chan);
1482
+    $record->updateRecord($gedrec, !$keep_chan);
1483 1483
 
1484
-	$controller->addInlineJavascript('closePopupAndReloadParent();');
1485
-	break;
1484
+    $controller->addInlineJavascript('closePopupAndReloadParent();');
1485
+    break;
1486 1486
 
1487 1487
 ////////////////////////////////////////////////////////////////////////////////
1488 1488
 // Create a new repository
1489 1489
 ////////////////////////////////////////////////////////////////////////////////
1490 1490
 case 'addnewrepository':
1491
-	$controller
1492
-		->setPageTitle(I18N::translate('Create a repository'))
1493
-		->pageHeader();
1491
+    $controller
1492
+        ->setPageTitle(I18N::translate('Create a repository'))
1493
+        ->pageHeader();
1494 1494
 
1495
-	echo '<div id="edit_interface-page">';
1496
-	echo '<h2>', $controller->getPageTitle(), '</h2>';
1495
+    echo '<div id="edit_interface-page">';
1496
+    echo '<h2>', $controller->getPageTitle(), '</h2>';
1497 1497
 
1498
-	echo '<script>';
1499
-	?>
1498
+    echo '<script>';
1499
+    ?>
1500 1500
 		function check_form(frm) {
1501 1501
 			if (frm.NAME.value=="") {
1502 1502
 				alert('<?php echo I18N::translate('You must provide a repository name.'); ?>');
@@ -1506,8 +1506,8 @@  discard block
 block discarded – undo
1506 1506
 			return true;
1507 1507
 		}
1508 1508
 	<?php
1509
-	echo '</script>';
1510
-	?>
1509
+    echo '</script>';
1510
+    ?>
1511 1511
 	<form method="post" action="edit_interface.php" onsubmit="return check_form(this);">
1512 1512
 		<input type="hidden" name="ged" value="<?php echo $WT_TREE->getNameHtml(); ?>">
1513 1513
 		<input type="hidden" name="action" value="addrepoaction">
@@ -1541,116 +1541,116 @@  discard block
 block discarded – undo
1541 1541
 	</form>
1542 1542
 	</div>
1543 1543
 	<?php
1544
-	break;
1544
+    break;
1545 1545
 
1546 1546
 case 'addrepoaction':
1547 1547
 
1548
-	if (!Filter::checkCsrf()) {
1549
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewrepository');
1550
-
1551
-		return;
1552
-	}
1553
-
1554
-	$controller
1555
-		->setPageTitle(I18N::translate('Create a repository'))
1556
-		->pageHeader();
1557
-
1558
-	$gedrec    = '0 @XREF@ REPO';
1559
-	$REPO_NAME = Filter::post('REPO_NAME');
1560
-	if ($REPO_NAME) {
1561
-		$gedrec .= "\n1 NAME " . $REPO_NAME;
1562
-		$_HEB = Filter::post('_HEB');
1563
-		if ($_HEB) {
1564
-			$gedrec .= "\n2 _HEB " . $_HEB;
1565
-		}
1566
-		$ROMN = Filter::post('ROMN');
1567
-		if ($ROMN) {
1568
-			$gedrec .= "\n2 ROMN " . $ROMN;
1569
-		}
1570
-	}
1571
-	$ADDR = Filter::post('ADDR');
1572
-	if ($ADDR) {
1573
-		$gedrec .= "\n1 ADDR " . preg_replace('/\r?\n/', "\n2 CONT ", $ADDR);
1574
-	}
1575
-	$PHON = Filter::post('PHON');
1576
-	if ($PHON) {
1577
-		$gedrec .= "\n1 PHON " . $PHON;
1578
-	}
1579
-	$FAX = Filter::post('FAX');
1580
-	if ($FAX) {
1581
-		$gedrec .= "\n1 FAX " . $FAX;
1582
-	}
1583
-	$EMAIL = Filter::post('EMAIL');
1584
-	if ($EMAIL) {
1585
-		$gedrec .= "\n1 EMAIL " . $EMAIL;
1586
-	}
1587
-	$WWW = Filter::post('WWW');
1588
-	if ($WWW) {
1589
-		$gedrec .= "\n1 WWW " . $WWW;
1590
-	}
1591
-
1592
-	$record = $WT_TREE->createRecord($gedrec);
1593
-	$controller->addInlineJavascript('openerpasteid("' . $record->getXref() . '");');
1594
-	break;
1548
+    if (!Filter::checkCsrf()) {
1549
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewrepository');
1550
+
1551
+        return;
1552
+    }
1553
+
1554
+    $controller
1555
+        ->setPageTitle(I18N::translate('Create a repository'))
1556
+        ->pageHeader();
1557
+
1558
+    $gedrec    = '0 @XREF@ REPO';
1559
+    $REPO_NAME = Filter::post('REPO_NAME');
1560
+    if ($REPO_NAME) {
1561
+        $gedrec .= "\n1 NAME " . $REPO_NAME;
1562
+        $_HEB = Filter::post('_HEB');
1563
+        if ($_HEB) {
1564
+            $gedrec .= "\n2 _HEB " . $_HEB;
1565
+        }
1566
+        $ROMN = Filter::post('ROMN');
1567
+        if ($ROMN) {
1568
+            $gedrec .= "\n2 ROMN " . $ROMN;
1569
+        }
1570
+    }
1571
+    $ADDR = Filter::post('ADDR');
1572
+    if ($ADDR) {
1573
+        $gedrec .= "\n1 ADDR " . preg_replace('/\r?\n/', "\n2 CONT ", $ADDR);
1574
+    }
1575
+    $PHON = Filter::post('PHON');
1576
+    if ($PHON) {
1577
+        $gedrec .= "\n1 PHON " . $PHON;
1578
+    }
1579
+    $FAX = Filter::post('FAX');
1580
+    if ($FAX) {
1581
+        $gedrec .= "\n1 FAX " . $FAX;
1582
+    }
1583
+    $EMAIL = Filter::post('EMAIL');
1584
+    if ($EMAIL) {
1585
+        $gedrec .= "\n1 EMAIL " . $EMAIL;
1586
+    }
1587
+    $WWW = Filter::post('WWW');
1588
+    if ($WWW) {
1589
+        $gedrec .= "\n1 WWW " . $WWW;
1590
+    }
1591
+
1592
+    $record = $WT_TREE->createRecord($gedrec);
1593
+    $controller->addInlineJavascript('openerpasteid("' . $record->getXref() . '");');
1594
+    break;
1595 1595
 
1596 1596
 ////////////////////////////////////////////////////////////////////////////////
1597 1597
 case 'editname':
1598
-	$xref    = Filter::get('xref', WT_REGEX_XREF);
1599
-	$fact_id = Filter::get('fact_id');
1598
+    $xref    = Filter::get('xref', WT_REGEX_XREF);
1599
+    $fact_id = Filter::get('fact_id');
1600 1600
 
1601
-	$person = Individual::getInstance($xref, $WT_TREE);
1602
-	check_record_access($person);
1601
+    $person = Individual::getInstance($xref, $WT_TREE);
1602
+    check_record_access($person);
1603 1603
 
1604
-	// Find the fact to edit
1605
-	$name_fact = null;
1606
-	foreach ($person->getFacts() as $fact) {
1607
-		if ($fact->getFactId() === $fact_id && $fact->canEdit()) {
1608
-			$name_fact = $fact;
1609
-		}
1610
-	}
1611
-	if (!$name_fact) {
1612
-		$controller
1613
-			->pageHeader()
1614
-			->addInlineJavascript('closePopupAndReloadParent();');
1604
+    // Find the fact to edit
1605
+    $name_fact = null;
1606
+    foreach ($person->getFacts() as $fact) {
1607
+        if ($fact->getFactId() === $fact_id && $fact->canEdit()) {
1608
+            $name_fact = $fact;
1609
+        }
1610
+    }
1611
+    if (!$name_fact) {
1612
+        $controller
1613
+            ->pageHeader()
1614
+            ->addInlineJavascript('closePopupAndReloadParent();');
1615 1615
 
1616
-		return;
1617
-	}
1616
+        return;
1617
+    }
1618 1618
 
1619
-	$controller
1620
-		->setPageTitle(I18N::translate('Edit the name'))
1621
-		->pageHeader();
1619
+    $controller
1620
+        ->setPageTitle(I18N::translate('Edit the name'))
1621
+        ->pageHeader();
1622 1622
 
1623
-	print_indi_form('update', $person, null, $name_fact, '', $person->getSex());
1623
+    print_indi_form('update', $person, null, $name_fact, '', $person->getSex());
1624 1624
 
1625
-	break;
1625
+    break;
1626 1626
 
1627 1627
 ////////////////////////////////////////////////////////////////////////////////
1628 1628
 case 'addname':
1629
-	$xref = Filter::get('xref', WT_REGEX_XREF);
1629
+    $xref = Filter::get('xref', WT_REGEX_XREF);
1630 1630
 
1631
-	$person = Individual::getInstance($xref, $WT_TREE);
1632
-	check_record_access($person);
1631
+    $person = Individual::getInstance($xref, $WT_TREE);
1632
+    check_record_access($person);
1633 1633
 
1634
-	$controller
1635
-		->setPageTitle(I18N::translate('Add a name'))
1636
-		->pageHeader();
1634
+    $controller
1635
+        ->setPageTitle(I18N::translate('Add a name'))
1636
+        ->pageHeader();
1637 1637
 
1638
-	print_indi_form('update', $person, null, null, '', $person->getSex());
1639
-	break;
1638
+    print_indi_form('update', $person, null, null, '', $person->getSex());
1639
+    break;
1640 1640
 
1641 1641
 ////////////////////////////////////////////////////////////////////////////////
1642 1642
 // Change the order of media objects
1643 1643
 ////////////////////////////////////////////////////////////////////////////////
1644 1644
 case 'reorder_media':
1645
-	$xref = Filter::get('xref', WT_REGEX_XREF);
1645
+    $xref = Filter::get('xref', WT_REGEX_XREF);
1646 1646
 
1647
-	$person = Individual::getInstance($xref, $WT_TREE);
1648
-	check_record_access($person);
1647
+    $person = Individual::getInstance($xref, $WT_TREE);
1648
+    check_record_access($person);
1649 1649
 
1650
-	$controller
1651
-		->setPageTitle(I18N::translate('Re-order media'))
1652
-		->pageHeader()
1653
-		->addInlineJavascript('
1650
+    $controller
1651
+        ->setPageTitle(I18N::translate('Re-order media'))
1652
+        ->pageHeader()
1653
+        ->addInlineJavascript('
1654 1654
 			jQuery("#reorder_media_list").sortable({forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"});
1655 1655
 
1656 1656
 			//-- update the order numbers after drag-n-drop sorting is complete
@@ -1663,37 +1663,37 @@  discard block
 block discarded – undo
1663 1663
 				});
1664 1664
 		');
1665 1665
 
1666
-	// Get the current sort order
1667
-	$sort_obje = array();
1668
-	foreach ($person->getFacts('_WT_OBJE_SORT') as $fact) {
1669
-		$media = $fact->getTarget();
1670
-		if ($media && $media->canShow()) {
1671
-			$sort_obje[] = $media;
1672
-		}
1673
-	}
1674
-
1675
-	// Add other media objects from the individual and any spouse-families
1676
-	$record_list = array($person);
1677
-	foreach ($person->getSpouseFamilies() as $family) {
1678
-		$record_list[] = $family;
1679
-	}
1680
-	foreach ($record_list as $record) {
1681
-		if ($record->canShow()) {
1682
-			foreach ($record->getFacts() as $fact) {
1683
-				if (!$fact->isPendingDeletion()) {
1684
-					preg_match_all('/(?:^1|\n\d) OBJE @(' . WT_REGEX_XREF . ')@/', $fact->getGedcom(), $matches);
1685
-					foreach ($matches[1] as $match) {
1686
-						$media = Media::getInstance($match, $WT_TREE);
1687
-						if (!in_array($media, $sort_obje)) {
1688
-							$sort_obje[] = $media;
1689
-						}
1690
-					}
1691
-				}
1692
-			}
1693
-		}
1694
-	}
1695
-
1696
-	?>
1666
+    // Get the current sort order
1667
+    $sort_obje = array();
1668
+    foreach ($person->getFacts('_WT_OBJE_SORT') as $fact) {
1669
+        $media = $fact->getTarget();
1670
+        if ($media && $media->canShow()) {
1671
+            $sort_obje[] = $media;
1672
+        }
1673
+    }
1674
+
1675
+    // Add other media objects from the individual and any spouse-families
1676
+    $record_list = array($person);
1677
+    foreach ($person->getSpouseFamilies() as $family) {
1678
+        $record_list[] = $family;
1679
+    }
1680
+    foreach ($record_list as $record) {
1681
+        if ($record->canShow()) {
1682
+            foreach ($record->getFacts() as $fact) {
1683
+                if (!$fact->isPendingDeletion()) {
1684
+                    preg_match_all('/(?:^1|\n\d) OBJE @(' . WT_REGEX_XREF . ')@/', $fact->getGedcom(), $matches);
1685
+                    foreach ($matches[1] as $match) {
1686
+                        $media = Media::getInstance($match, $WT_TREE);
1687
+                        if (!in_array($media, $sort_obje)) {
1688
+                            $sort_obje[] = $media;
1689
+                        }
1690
+                    }
1691
+                }
1692
+            }
1693
+        }
1694
+    }
1695
+
1696
+    ?>
1697 1697
 	<div id="edit_interface-page">
1698 1698
 		<h2><?php echo I18N::translate('Re-order media'); ?></h2>
1699 1699
 		<form name="reorder_form" method="post" action="edit_interface.php">
@@ -1725,61 +1725,61 @@  discard block
 block discarded – undo
1725 1725
 		</form>
1726 1726
 	</div>
1727 1727
 	<?php
1728
-	break;
1728
+    break;
1729 1729
 
1730 1730
 case 'reorder_media_update':
1731
-	$xref   = Filter::post('xref', WT_REGEX_XREF);
1732
-	$order1 = Filter::post('order1');
1731
+    $xref   = Filter::post('xref', WT_REGEX_XREF);
1732
+    $order1 = Filter::post('order1');
1733 1733
 
1734
-	if (!Filter::checkCsrf()) {
1735
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_media_&xref=' . $xref);
1734
+    if (!Filter::checkCsrf()) {
1735
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_media_&xref=' . $xref);
1736 1736
 
1737
-		return;
1738
-	}
1737
+        return;
1738
+    }
1739 1739
 
1740
-	$person = Individual::getInstance($xref, $WT_TREE);
1741
-	check_record_access($person);
1740
+    $person = Individual::getInstance($xref, $WT_TREE);
1741
+    check_record_access($person);
1742 1742
 
1743
-	$controller
1744
-		->setPageTitle(I18N::translate('Re-order media'))
1745
-		->pageHeader();
1743
+    $controller
1744
+        ->setPageTitle(I18N::translate('Re-order media'))
1745
+        ->pageHeader();
1746 1746
 
1747
-	// Delete any existing _WT_OBJE_SORT records
1748
-	$facts = array('0 @' . $person->getXref() . '@ INDI');
1749
-	foreach ($person->getFacts() as $fact) {
1750
-		if ($fact->getTag() !== '_WT_OBJE_SORT') {
1751
-			$facts[] = $fact->getGedcom();
1752
-		}
1753
-	}
1754
-	if (is_array($order1)) {
1755
-		// Add new _WT_OBJE_SORT records
1756
-		foreach ($order1 as $xref => $n) {
1757
-			$facts[] = '1 _WT_OBJE_SORT @' . $xref . '@';
1758
-		}
1759
-	}
1747
+    // Delete any existing _WT_OBJE_SORT records
1748
+    $facts = array('0 @' . $person->getXref() . '@ INDI');
1749
+    foreach ($person->getFacts() as $fact) {
1750
+        if ($fact->getTag() !== '_WT_OBJE_SORT') {
1751
+            $facts[] = $fact->getGedcom();
1752
+        }
1753
+    }
1754
+    if (is_array($order1)) {
1755
+        // Add new _WT_OBJE_SORT records
1756
+        foreach ($order1 as $xref => $n) {
1757
+            $facts[] = '1 _WT_OBJE_SORT @' . $xref . '@';
1758
+        }
1759
+    }
1760 1760
 
1761
-	$person->updateRecord(implode("\n", $facts), false);
1761
+    $person->updateRecord(implode("\n", $facts), false);
1762 1762
 
1763
-	$controller->addInlineJavascript('closePopupAndReloadParent();');
1764
-	break;
1763
+    $controller->addInlineJavascript('closePopupAndReloadParent();');
1764
+    break;
1765 1765
 
1766 1766
 ////////////////////////////////////////////////////////////////////////////////
1767 1767
 // Change the order of children within a family record
1768 1768
 ////////////////////////////////////////////////////////////////////////////////
1769 1769
 case 'reorder_children':
1770
-	$xref   = Filter::post('xref', WT_REGEX_XREF, Filter::get('xref', WT_REGEX_XREF));
1771
-	$option = Filter::post('option');
1770
+    $xref   = Filter::post('xref', WT_REGEX_XREF, Filter::get('xref', WT_REGEX_XREF));
1771
+    $option = Filter::post('option');
1772 1772
 
1773
-	$family = Family::getInstance($xref, $WT_TREE);
1774
-	check_record_access($family);
1773
+    $family = Family::getInstance($xref, $WT_TREE);
1774
+    check_record_access($family);
1775 1775
 
1776
-	$controller
1777
-		->addInlineJavascript('jQuery("#reorder_list").sortable({forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"});')
1778
-		->addInlineJavascript('jQuery("#reorder_list").bind("sortupdate", function(event, ui) { jQuery("#"+jQuery(this).attr("id")+" input").each( function (index, value) { value.value = index+1; }); });')
1779
-		->setPageTitle(I18N::translate('Re-order children'))
1780
-		->pageHeader();
1776
+    $controller
1777
+        ->addInlineJavascript('jQuery("#reorder_list").sortable({forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"});')
1778
+        ->addInlineJavascript('jQuery("#reorder_list").bind("sortupdate", function(event, ui) { jQuery("#"+jQuery(this).attr("id")+" input").each( function (index, value) { value.value = index+1; }); });')
1779
+        ->setPageTitle(I18N::translate('Re-order children'))
1780
+        ->pageHeader();
1781 1781
 
1782
-	?>
1782
+    ?>
1783 1783
 	<div id="edit_interface-page">
1784 1784
 		<h2><?php echo $controller->getPageTitle(); ?></h2>
1785 1785
 		<form name="reorder_form" method="post" action="edit_interface.php">
@@ -1790,37 +1790,37 @@  discard block
 block discarded – undo
1790 1790
 			<?php echo Filter::getCsrf(); ?>
1791 1791
 			<ul id="reorder_list">
1792 1792
 				<?php
1793
-				// reorder children in modified families
1794
-				$ids = array();
1795
-				foreach ($family->getChildren() as $child) {
1796
-					$ids[] = $child->getXref();
1797
-				}
1798
-				$children = array();
1799
-				foreach ($family->getChildren() as $k => $child) {
1800
-					$bdate = $child->getEstimatedBirthDate();
1801
-					if ($bdate->isOK()) {
1802
-						$sortkey = $bdate->julianDay();
1803
-					} else {
1804
-						$sortkey = 1e8; // birth date missing => sort last
1805
-					}
1806
-					$children[$child->getXref()] = $sortkey;
1807
-				}
1808
-				if ($option === 'bybirth') {
1809
-					asort($children);
1810
-				}
1811
-				$i = 0;
1812
-				foreach ($children as $id => $child) {
1813
-					echo '<li style="cursor:move; margin-bottom:2px; position:relative;"';
1814
-					if (!in_array($id, $ids)) {
1815
-						echo ' class="facts_value new"';
1816
-					}
1817
-					echo ' id="li_', $id, '">';
1818
-					echo Theme::theme()->individualBoxLarge(Individual::getInstance($id, $WT_TREE));
1819
-					echo '<input type="hidden" name="order[', $id, ']" value="', $i, '">';
1820
-					echo '</li>';
1821
-					$i++;
1822
-				}
1823
-			?>
1793
+                // reorder children in modified families
1794
+                $ids = array();
1795
+                foreach ($family->getChildren() as $child) {
1796
+                    $ids[] = $child->getXref();
1797
+                }
1798
+                $children = array();
1799
+                foreach ($family->getChildren() as $k => $child) {
1800
+                    $bdate = $child->getEstimatedBirthDate();
1801
+                    if ($bdate->isOK()) {
1802
+                        $sortkey = $bdate->julianDay();
1803
+                    } else {
1804
+                        $sortkey = 1e8; // birth date missing => sort last
1805
+                    }
1806
+                    $children[$child->getXref()] = $sortkey;
1807
+                }
1808
+                if ($option === 'bybirth') {
1809
+                    asort($children);
1810
+                }
1811
+                $i = 0;
1812
+                foreach ($children as $id => $child) {
1813
+                    echo '<li style="cursor:move; margin-bottom:2px; position:relative;"';
1814
+                    if (!in_array($id, $ids)) {
1815
+                        echo ' class="facts_value new"';
1816
+                    }
1817
+                    echo ' id="li_', $id, '">';
1818
+                    echo Theme::theme()->individualBoxLarge(Individual::getInstance($id, $WT_TREE));
1819
+                    echo '<input type="hidden" name="order[', $id, ']" value="', $i, '">';
1820
+                    echo '</li>';
1821
+                    $i++;
1822
+                }
1823
+            ?>
1824 1824
 			</ul>
1825 1825
 			<p id="save-cancel">
1826 1826
 				<input type="submit" class="save" value="<?php echo I18N::translate('save'); ?>">
@@ -1830,66 +1830,66 @@  discard block
 block discarded – undo
1830 1830
 		</form>
1831 1831
 	</div>
1832 1832
 	<?php
1833
-	break;
1833
+    break;
1834 1834
 
1835 1835
 case 'reorder_update':
1836
-	$xref  = Filter::post('xref', WT_REGEX_XREF);
1837
-	$order = Filter::post('order');
1838
-
1839
-	if (!Filter::checkCsrf()) {
1840
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_children&xref=' . $xref);
1841
-
1842
-		return;
1843
-	}
1844
-
1845
-	$family = Family::getInstance($xref, $WT_TREE);
1846
-	check_record_access($family);
1847
-
1848
-	$controller
1849
-		->setPageTitle(I18N::translate('Re-order children'))
1850
-		->pageHeader();
1851
-
1852
-	if (is_array($order)) {
1853
-		$gedcom = array('0 @' . $family->getXref() . '@ FAM');
1854
-		$facts  = $family->getFacts();
1855
-
1856
-		// Move children to the end of the record
1857
-		foreach ($order as $child => $num) {
1858
-			foreach ($facts as $n => $fact) {
1859
-				if ($fact->getValue() === '@' . $child . '@') {
1860
-					$facts[] = $fact;
1861
-					unset($facts[$n]);
1862
-					break;
1863
-				}
1864
-			}
1865
-		}
1866
-		foreach ($facts as $fact) {
1867
-			$gedcom[] = $fact->getGedcom();
1868
-		}
1869
-
1870
-		$family->updateRecord(implode("\n", $gedcom), false);
1871
-	}
1872
-
1873
-	$controller->addInlineJavascript('closePopupAndReloadParent();');
1874
-	break;
1836
+    $xref  = Filter::post('xref', WT_REGEX_XREF);
1837
+    $order = Filter::post('order');
1838
+
1839
+    if (!Filter::checkCsrf()) {
1840
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_children&xref=' . $xref);
1841
+
1842
+        return;
1843
+    }
1844
+
1845
+    $family = Family::getInstance($xref, $WT_TREE);
1846
+    check_record_access($family);
1847
+
1848
+    $controller
1849
+        ->setPageTitle(I18N::translate('Re-order children'))
1850
+        ->pageHeader();
1851
+
1852
+    if (is_array($order)) {
1853
+        $gedcom = array('0 @' . $family->getXref() . '@ FAM');
1854
+        $facts  = $family->getFacts();
1855
+
1856
+        // Move children to the end of the record
1857
+        foreach ($order as $child => $num) {
1858
+            foreach ($facts as $n => $fact) {
1859
+                if ($fact->getValue() === '@' . $child . '@') {
1860
+                    $facts[] = $fact;
1861
+                    unset($facts[$n]);
1862
+                    break;
1863
+                }
1864
+            }
1865
+        }
1866
+        foreach ($facts as $fact) {
1867
+            $gedcom[] = $fact->getGedcom();
1868
+        }
1869
+
1870
+        $family->updateRecord(implode("\n", $gedcom), false);
1871
+    }
1872
+
1873
+    $controller->addInlineJavascript('closePopupAndReloadParent();');
1874
+    break;
1875 1875
 
1876 1876
 ////////////////////////////////////////////////////////////////////////////////
1877 1877
 // Change the members of a family record
1878 1878
 ////////////////////////////////////////////////////////////////////////////////
1879 1879
 case 'changefamily':
1880
-	$xref = Filter::get('xref', WT_REGEX_XREF);
1880
+    $xref = Filter::get('xref', WT_REGEX_XREF);
1881 1881
 
1882
-	$family = Family::getInstance($xref, $WT_TREE);
1883
-	check_record_access($family);
1882
+    $family = Family::getInstance($xref, $WT_TREE);
1883
+    check_record_access($family);
1884 1884
 
1885
-	$controller
1886
-		->setPageTitle(I18N::translate('Change family members') . ' – ' . $family->getFullName())
1887
-		->pageHeader();
1885
+    $controller
1886
+        ->setPageTitle(I18N::translate('Change family members') . ' – ' . $family->getFullName())
1887
+        ->pageHeader();
1888 1888
 
1889
-	$father   = $family->getHusband();
1890
-	$mother   = $family->getWife();
1891
-	$children = $family->getChildren();
1892
-	?>
1889
+    $father   = $family->getHusband();
1890
+    $mother   = $family->getWife();
1891
+    $children = $family->getChildren();
1892
+    ?>
1893 1893
 	<div id="edit_interface-page">
1894 1894
 		<h2><?php echo $controller->getPageTitle(); ?></h2>
1895 1895
 		<div id="changefam">
@@ -1904,12 +1904,12 @@  discard block
 block discarded – undo
1904 1904
 						<td class="descriptionbox">
1905 1905
 							<b>
1906 1906
 								<?php
1907
-								switch ($father->getSex()) {
1908
-								case 'M': echo I18N::translate('husband'); break;
1909
-								case 'F': echo I18N::translate('wife'); break;
1910
-								default:  echo I18N::translate('spouse'); break;
1911
-								}
1912
-								?>
1907
+                                switch ($father->getSex()) {
1908
+                                case 'M': echo I18N::translate('husband'); break;
1909
+                                case 'F': echo I18N::translate('wife'); break;
1910
+                                default:  echo I18N::translate('spouse'); break;
1911
+                                }
1912
+                                ?>
1913 1913
 							</b>
1914 1914
 							<input type="hidden" name="HUSB" value="<?php echo $father->getXref(); ?>">
1915 1915
 						</td>
@@ -1939,12 +1939,12 @@  discard block
 block discarded – undo
1939 1939
 						<td class="descriptionbox">
1940 1940
 							<b>
1941 1941
 								<?php
1942
-								switch ($mother->getSex()) {
1943
-								case 'M': echo I18N::translate('husband'); break;
1944
-								case 'F': echo I18N::translate('wife'); break;
1945
-								default:  echo I18N::translate('spouse'); break;
1946
-								}
1947
-								?>
1942
+                                switch ($mother->getSex()) {
1943
+                                case 'M': echo I18N::translate('husband'); break;
1944
+                                case 'F': echo I18N::translate('wife'); break;
1945
+                                default:  echo I18N::translate('spouse'); break;
1946
+                                }
1947
+                                ?>
1948 1948
 							</b>
1949 1949
 							<input type="hidden" name="WIFE" value="<?php echo $mother->getXref(); ?>">
1950 1950
 						</td>
@@ -1975,12 +1975,12 @@  discard block
 block discarded – undo
1975 1975
 						<td class="descriptionbox">
1976 1976
 							<b>
1977 1977
 								<?php
1978
-								switch ($child->getSex()) {
1979
-								case 'M': echo I18N::translate('son'); break;
1980
-								case 'F': echo I18N::translate('daughter'); break;
1981
-								default:  echo I18N::translate('child'); break;
1982
-								}
1983
-								?>
1978
+                                switch ($child->getSex()) {
1979
+                                case 'M': echo I18N::translate('son'); break;
1980
+                                case 'F': echo I18N::translate('daughter'); break;
1981
+                                default:  echo I18N::translate('child'); break;
1982
+                                }
1983
+                                ?>
1984 1984
 							</b>
1985 1985
 							<input type="hidden" name="CHIL<?php echo $i; ?>" value="<?php echo $child->getXref(); ?>">
1986 1986
 						</td>
@@ -2023,143 +2023,143 @@  discard block
 block discarded – undo
2023 2023
 		</div>
2024 2024
 	</div>
2025 2025
 	<?php
2026
-	break;
2026
+    break;
2027 2027
 
2028 2028
 case 'changefamily_update':
2029
-	$xref      = Filter::post('xref', WT_REGEX_XREF);
2030
-	$HUSB      = Filter::post('HUSB', WT_REGEX_XREF);
2031
-	$WIFE      = Filter::post('WIFE', WT_REGEX_XREF);
2032
-	$keep_chan = Filter::postBool('keep_chan');
2033
-
2034
-	if (!Filter::checkCsrf()) {
2035
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=changefamily&xref=' . $xref);
2036
-
2037
-		return;
2038
-	}
2039
-
2040
-	$CHIL = array();
2041
-	for ($i = 0; isset($_POST['CHIL' . $i]); ++$i) {
2042
-		$CHIL[] = Filter::post('CHIL' . $i, WT_REGEX_XREF);
2043
-	}
2044
-
2045
-	$family = Family::getInstance($xref, $WT_TREE);
2046
-	check_record_access($family);
2047
-
2048
-	$controller
2049
-		->setPageTitle(I18N::translate('Change family members') . ' – ' . $family->getFullName())
2050
-		->pageHeader();
2051
-
2052
-	// Current family members
2053
-	$old_father   = $family->getHusband();
2054
-	$old_mother   = $family->getWife();
2055
-	$old_children = $family->getChildren();
2056
-
2057
-	// New family members
2058
-	$new_father   = Individual::getInstance($HUSB, $WT_TREE);
2059
-	$new_mother   = Individual::getInstance($WIFE, $WT_TREE);
2060
-	$new_children = array();
2061
-	foreach ($CHIL as $child) {
2062
-		$new_children[] = Individual::getInstance($child, $WT_TREE);
2063
-	}
2064
-
2065
-	if ($old_father !== $new_father) {
2066
-		if ($old_father) {
2067
-			// Remove old FAMS link
2068
-			foreach ($old_father->getFacts('FAMS') as $fact) {
2069
-				if ($fact->getTarget() === $family) {
2070
-					$old_father->deleteFact($fact->getFactId(), !$keep_chan);
2071
-				}
2072
-			}
2073
-			// Remove old HUSB link
2074
-			foreach ($family->getFacts('HUSB|WIFE') as $fact) {
2075
-				if ($fact->getTarget() === $old_father) {
2076
-					$family->deleteFact($fact->getFactId(), !$keep_chan);
2077
-				}
2078
-			}
2079
-		}
2080
-		if ($new_father) {
2081
-			// Add new FAMS link
2082
-			$new_father->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan);
2083
-			// Add new HUSB link
2084
-			$family->createFact('1 HUSB @' . $new_father->getXref() . '@', !$keep_chan);
2085
-		}
2086
-	}
2087
-
2088
-	if ($old_mother !== $new_mother) {
2089
-		if ($old_mother) {
2090
-			// Remove old FAMS link
2091
-			foreach ($old_mother->getFacts('FAMS') as $fact) {
2092
-				if ($fact->getTarget() === $family) {
2093
-					$old_mother->deleteFact($fact->getFactId(), !$keep_chan);
2094
-				}
2095
-			}
2096
-			// Remove old WIFE link
2097
-			foreach ($family->getFacts('HUSB|WIFE') as $fact) {
2098
-				if ($fact->getTarget() === $old_mother) {
2099
-					$family->deleteFact($fact->getFactId(), !$keep_chan);
2100
-				}
2101
-			}
2102
-		}
2103
-		if ($new_mother) {
2104
-			// Add new FAMS link
2105
-			$new_mother->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan);
2106
-			// Add new WIFE link
2107
-			$family->createFact('1 WIFE @' . $new_mother->getXref() . '@', !$keep_chan);
2108
-		}
2109
-	}
2110
-
2111
-	foreach ($old_children as $old_child) {
2112
-		if ($old_child && !in_array($old_child, $new_children)) {
2113
-			// Remove old FAMC link
2114
-			foreach ($old_child->getFacts('FAMC') as $fact) {
2115
-				if ($fact->getTarget() === $family) {
2116
-					$old_child->deleteFact($fact->getFactId(), !$keep_chan);
2117
-				}
2118
-			}
2119
-			// Remove old CHIL link
2120
-			foreach ($family->getFacts('CHIL') as $fact) {
2121
-				if ($fact->getTarget() === $old_child) {
2122
-					$family->deleteFact($fact->getFactId(), !$keep_chan);
2123
-				}
2124
-			}
2125
-		}
2126
-	}
2127
-
2128
-	foreach ($new_children as $new_child) {
2129
-		if ($new_child && !in_array($new_child, $old_children)) {
2130
-			// Add new FAMC link
2131
-			$new_child->createFact('1 FAMC @' . $family->getXref() . '@', !$keep_chan);
2132
-			// Add new CHIL link
2133
-			$family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan);
2134
-		}
2135
-	}
2136
-
2137
-	$controller->addInlineJavascript('closePopupAndReloadParent();');
2138
-	break;
2029
+    $xref      = Filter::post('xref', WT_REGEX_XREF);
2030
+    $HUSB      = Filter::post('HUSB', WT_REGEX_XREF);
2031
+    $WIFE      = Filter::post('WIFE', WT_REGEX_XREF);
2032
+    $keep_chan = Filter::postBool('keep_chan');
2033
+
2034
+    if (!Filter::checkCsrf()) {
2035
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=changefamily&xref=' . $xref);
2036
+
2037
+        return;
2038
+    }
2039
+
2040
+    $CHIL = array();
2041
+    for ($i = 0; isset($_POST['CHIL' . $i]); ++$i) {
2042
+        $CHIL[] = Filter::post('CHIL' . $i, WT_REGEX_XREF);
2043
+    }
2044
+
2045
+    $family = Family::getInstance($xref, $WT_TREE);
2046
+    check_record_access($family);
2047
+
2048
+    $controller
2049
+        ->setPageTitle(I18N::translate('Change family members') . ' – ' . $family->getFullName())
2050
+        ->pageHeader();
2051
+
2052
+    // Current family members
2053
+    $old_father   = $family->getHusband();
2054
+    $old_mother   = $family->getWife();
2055
+    $old_children = $family->getChildren();
2056
+
2057
+    // New family members
2058
+    $new_father   = Individual::getInstance($HUSB, $WT_TREE);
2059
+    $new_mother   = Individual::getInstance($WIFE, $WT_TREE);
2060
+    $new_children = array();
2061
+    foreach ($CHIL as $child) {
2062
+        $new_children[] = Individual::getInstance($child, $WT_TREE);
2063
+    }
2064
+
2065
+    if ($old_father !== $new_father) {
2066
+        if ($old_father) {
2067
+            // Remove old FAMS link
2068
+            foreach ($old_father->getFacts('FAMS') as $fact) {
2069
+                if ($fact->getTarget() === $family) {
2070
+                    $old_father->deleteFact($fact->getFactId(), !$keep_chan);
2071
+                }
2072
+            }
2073
+            // Remove old HUSB link
2074
+            foreach ($family->getFacts('HUSB|WIFE') as $fact) {
2075
+                if ($fact->getTarget() === $old_father) {
2076
+                    $family->deleteFact($fact->getFactId(), !$keep_chan);
2077
+                }
2078
+            }
2079
+        }
2080
+        if ($new_father) {
2081
+            // Add new FAMS link
2082
+            $new_father->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan);
2083
+            // Add new HUSB link
2084
+            $family->createFact('1 HUSB @' . $new_father->getXref() . '@', !$keep_chan);
2085
+        }
2086
+    }
2087
+
2088
+    if ($old_mother !== $new_mother) {
2089
+        if ($old_mother) {
2090
+            // Remove old FAMS link
2091
+            foreach ($old_mother->getFacts('FAMS') as $fact) {
2092
+                if ($fact->getTarget() === $family) {
2093
+                    $old_mother->deleteFact($fact->getFactId(), !$keep_chan);
2094
+                }
2095
+            }
2096
+            // Remove old WIFE link
2097
+            foreach ($family->getFacts('HUSB|WIFE') as $fact) {
2098
+                if ($fact->getTarget() === $old_mother) {
2099
+                    $family->deleteFact($fact->getFactId(), !$keep_chan);
2100
+                }
2101
+            }
2102
+        }
2103
+        if ($new_mother) {
2104
+            // Add new FAMS link
2105
+            $new_mother->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan);
2106
+            // Add new WIFE link
2107
+            $family->createFact('1 WIFE @' . $new_mother->getXref() . '@', !$keep_chan);
2108
+        }
2109
+    }
2110
+
2111
+    foreach ($old_children as $old_child) {
2112
+        if ($old_child && !in_array($old_child, $new_children)) {
2113
+            // Remove old FAMC link
2114
+            foreach ($old_child->getFacts('FAMC') as $fact) {
2115
+                if ($fact->getTarget() === $family) {
2116
+                    $old_child->deleteFact($fact->getFactId(), !$keep_chan);
2117
+                }
2118
+            }
2119
+            // Remove old CHIL link
2120
+            foreach ($family->getFacts('CHIL') as $fact) {
2121
+                if ($fact->getTarget() === $old_child) {
2122
+                    $family->deleteFact($fact->getFactId(), !$keep_chan);
2123
+                }
2124
+            }
2125
+        }
2126
+    }
2127
+
2128
+    foreach ($new_children as $new_child) {
2129
+        if ($new_child && !in_array($new_child, $old_children)) {
2130
+            // Add new FAMC link
2131
+            $new_child->createFact('1 FAMC @' . $family->getXref() . '@', !$keep_chan);
2132
+            // Add new CHIL link
2133
+            $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan);
2134
+        }
2135
+    }
2136
+
2137
+    $controller->addInlineJavascript('closePopupAndReloadParent();');
2138
+    break;
2139 2139
 
2140 2140
 ////////////////////////////////////////////////////////////////////////////////
2141 2141
 // Change the order of FAMS records within an INDI record
2142 2142
 ////////////////////////////////////////////////////////////////////////////////
2143 2143
 case 'reorder_fams':
2144
-	$xref   = Filter::post('xref', WT_REGEX_XREF, Filter::get('xref', WT_REGEX_XREF));
2145
-	$option = Filter::post('option');
2146
-
2147
-	$person = Individual::getInstance($xref, $WT_TREE);
2148
-	check_record_access($person);
2149
-
2150
-	$controller
2151
-		->addInlineJavascript('jQuery("#reorder_list").sortable({forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"});')
2152
-		//-- update the order numbers after drag-n-drop sorting is complete
2153
-		->addInlineJavascript('jQuery("#reorder_list").bind("sortupdate", function(event, ui) { jQuery("#"+jQuery(this).attr("id")+" input").each( function (index, value) { value.value = index+1; }); });')
2154
-		->setPageTitle(I18N::translate('Re-order families'))
2155
-		->pageHeader();
2156
-
2157
-	$fams = $person->getSpouseFamilies();
2158
-	if ($option === 'bymarriage') {
2159
-		usort($fams, '\Fisharebest\Webtrees\Family::compareMarrDate');
2160
-	}
2144
+    $xref   = Filter::post('xref', WT_REGEX_XREF, Filter::get('xref', WT_REGEX_XREF));
2145
+    $option = Filter::post('option');
2161 2146
 
2162
-	?>
2147
+    $person = Individual::getInstance($xref, $WT_TREE);
2148
+    check_record_access($person);
2149
+
2150
+    $controller
2151
+        ->addInlineJavascript('jQuery("#reorder_list").sortable({forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"});')
2152
+        //-- update the order numbers after drag-n-drop sorting is complete
2153
+        ->addInlineJavascript('jQuery("#reorder_list").bind("sortupdate", function(event, ui) { jQuery("#"+jQuery(this).attr("id")+" input").each( function (index, value) { value.value = index+1; }); });')
2154
+        ->setPageTitle(I18N::translate('Re-order families'))
2155
+        ->pageHeader();
2156
+
2157
+    $fams = $person->getSpouseFamilies();
2158
+    if ($option === 'bymarriage') {
2159
+        usort($fams, '\Fisharebest\Webtrees\Family::compareMarrDate');
2160
+    }
2161
+
2162
+    ?>
2163 2163
 	<div id="edit_interface-page">
2164 2164
 	<h2><?php echo $controller->getPageTitle(); ?></h2>
2165 2165
 	<form name="reorder_form" method="post" action="edit_interface.php">
@@ -2185,48 +2185,48 @@  discard block
 block discarded – undo
2185 2185
 	</form>
2186 2186
 	</div>
2187 2187
 	<?php
2188
-	break;
2188
+    break;
2189 2189
 
2190 2190
 case 'reorder_fams_update':
2191
-	$xref  = Filter::post('xref', WT_REGEX_XREF);
2192
-	$order = Filter::post('order');
2193
-
2194
-	if (!Filter::checkCsrf()) {
2195
-		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_fams&xref=' . $xref);
2196
-
2197
-		return;
2198
-	}
2199
-
2200
-	$person = Individual::getInstance($xref, $WT_TREE);
2201
-	check_record_access($person);
2202
-
2203
-	$controller
2204
-		->setPageTitle(I18N::translate('Re-order families'))
2205
-		->pageHeader();
2206
-
2207
-	if (is_array($order)) {
2208
-		$gedcom = array('0 @' . $person->getXref() . '@ INDI');
2209
-		$facts  = $person->getFacts();
2210
-
2211
-		// Move families to the end of the record
2212
-		foreach ($order as $family => $num) {
2213
-			foreach ($facts as $n => $fact) {
2214
-				if ($fact->getValue() === '@' . $family . '@') {
2215
-					$facts[] = $fact;
2216
-					unset($facts[$n]);
2217
-					break;
2218
-				}
2219
-			}
2220
-		}
2221
-		foreach ($facts as $fact) {
2222
-			$gedcom[] = $fact->getGedcom();
2223
-		}
2224
-
2225
-		$person->updateRecord(implode("\n", $gedcom), false);
2226
-	}
2227
-
2228
-	$controller->addInlineJavascript('closePopupAndReloadParent();');
2229
-	break;
2191
+    $xref  = Filter::post('xref', WT_REGEX_XREF);
2192
+    $order = Filter::post('order');
2193
+
2194
+    if (!Filter::checkCsrf()) {
2195
+        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_fams&xref=' . $xref);
2196
+
2197
+        return;
2198
+    }
2199
+
2200
+    $person = Individual::getInstance($xref, $WT_TREE);
2201
+    check_record_access($person);
2202
+
2203
+    $controller
2204
+        ->setPageTitle(I18N::translate('Re-order families'))
2205
+        ->pageHeader();
2206
+
2207
+    if (is_array($order)) {
2208
+        $gedcom = array('0 @' . $person->getXref() . '@ INDI');
2209
+        $facts  = $person->getFacts();
2210
+
2211
+        // Move families to the end of the record
2212
+        foreach ($order as $family => $num) {
2213
+            foreach ($facts as $n => $fact) {
2214
+                if ($fact->getValue() === '@' . $family . '@') {
2215
+                    $facts[] = $fact;
2216
+                    unset($facts[$n]);
2217
+                    break;
2218
+                }
2219
+            }
2220
+        }
2221
+        foreach ($facts as $fact) {
2222
+            $gedcom[] = $fact->getGedcom();
2223
+        }
2224
+
2225
+        $person->updateRecord(implode("\n", $gedcom), false);
2226
+    }
2227
+
2228
+    $controller->addInlineJavascript('closePopupAndReloadParent();');
2229
+    break;
2230 2230
 }
2231 2231
 
2232 2232
 /**
@@ -2237,28 +2237,28 @@  discard block
 block discarded – undo
2237 2237
  * @return string
2238 2238
  */
2239 2239
 function keep_chan(GedcomRecord $record = null) {
2240
-	global $WT_TREE;
2241
-
2242
-	if (Auth::isAdmin()) {
2243
-		if ($record) {
2244
-			$details =
2245
-				GedcomTag::getLabelValue('DATE', $record->lastChangeTimestamp()) .
2246
-				GedcomTag::getLabelValue('_WT_USER', Filter::escapeHtml($record->lastChangeUser()));
2247
-		} else {
2248
-			$details = '';
2249
-		}
2250
-
2251
-		return
2252
-			'<tr><td class="descriptionbox wrap width25">' .
2253
-			GedcomTag::getLabel('CHAN') .
2254
-			'</td><td class="optionbox wrap">' .
2255
-			'<input type="checkbox" name="keep_chan" value="1" ' . ($WT_TREE->getPreference('NO_UPDATE_CHAN') ? 'checked' : '') . '>' .
2256
-			I18N::translate('Keep the existing “last change” information') .
2257
-			$details .
2258
-			'</td></tr>';
2259
-	} else {
2260
-		return '';
2261
-	}
2240
+    global $WT_TREE;
2241
+
2242
+    if (Auth::isAdmin()) {
2243
+        if ($record) {
2244
+            $details =
2245
+                GedcomTag::getLabelValue('DATE', $record->lastChangeTimestamp()) .
2246
+                GedcomTag::getLabelValue('_WT_USER', Filter::escapeHtml($record->lastChangeUser()));
2247
+        } else {
2248
+            $details = '';
2249
+        }
2250
+
2251
+        return
2252
+            '<tr><td class="descriptionbox wrap width25">' .
2253
+            GedcomTag::getLabel('CHAN') .
2254
+            '</td><td class="optionbox wrap">' .
2255
+            '<input type="checkbox" name="keep_chan" value="1" ' . ($WT_TREE->getPreference('NO_UPDATE_CHAN') ? 'checked' : '') . '>' .
2256
+            I18N::translate('Keep the existing “last change” information') .
2257
+            $details .
2258
+            '</td></tr>';
2259
+    } else {
2260
+        return '';
2261
+    }
2262 2262
 }
2263 2263
 
2264 2264
 /**
@@ -2272,303 +2272,303 @@  discard block
 block discarded – undo
2272 2272
  * @param string     $gender
2273 2273
  */
2274 2274
 function print_indi_form($nextaction, Individual $person = null, Family $family = null, Fact $name_fact = null, $famtag = 'CHIL', $gender = 'U') {
2275
-	global $WT_TREE, $bdm, $controller;
2276
-
2277
-	if ($person) {
2278
-		$xref = $person->getXref();
2279
-	} elseif ($family) {
2280
-		$xref = $family->getXref();
2281
-	} else {
2282
-		$xref = 'new';
2283
-	}
2284
-
2285
-	// Different cultures do surnames differently
2286
-	$surname_tradition = SurnameTradition::create($WT_TREE->getPreference('SURNAME_TRADITION'));
2287
-
2288
-	$name_fields = array();
2289
-	if ($name_fact) {
2290
-		// Editing an existing name
2291
-		$name_fact_id = $name_fact->getFactId();
2292
-		$name_type    = $name_fact->getAttribute('TYPE');
2293
-		$namerec      = $name_fact->getGedcom();
2294
-		foreach (Config::standardNameFacts() as $tag) {
2295
-			if ($tag === 'NAME') {
2296
-				$name_fields[$tag] = $name_fact->getValue();
2297
-			} else {
2298
-				$name_fields[$tag] = $name_fact->getAttribute($tag);
2299
-			}
2300
-		}
2301
-		// Populate any missing 2 XXXX fields from the 1 NAME field
2302
-		$npfx_accept = implode('|', Config::namePrefixes());
2303
-		if (preg_match('/(((' . $npfx_accept . ')\.? +)*)([^\n\/"]*)("(.*)")? *\/(([a-z]{2,3} +)*)(.*)\/ *(.*)/i', $name_fields['NAME'], $name_bits)) {
2304
-			if (empty($name_fields['NPFX'])) {
2305
-				$name_fields['NPFX'] = $name_bits[1];
2306
-			}
2307
-			if (empty($name_fields['SPFX']) && empty($name_fields['SURN'])) {
2308
-				$name_fields['SPFX'] = trim($name_bits[7]);
2309
-				// For names with two surnames, there will be four slashes.
2310
-				// Turn them into a list
2311
-				$name_fields['SURN'] = preg_replace('~/[^/]*/~', ',', $name_bits[9]);
2312
-			}
2313
-			if (empty($name_fields['GIVN'])) {
2314
-				$name_fields['GIVN'] = $name_bits[4];
2315
-			}
2316
-			if (empty($name_fields['NICK']) && !empty($name_bits[6]) && !preg_match('/^2 NICK/m', $namerec)) {
2317
-				$name_fields['NICK'] = $name_bits[6];
2318
-			}
2319
-		}
2320
-
2321
-	} else {
2322
-		// Creating a new name
2323
-		$name_fact_id = null;
2324
-		$name_type    = null;
2325
-		$namerec      = null;
2326
-		// Populate the standard NAME field and subfields
2327
-		foreach (Config::standardNameFacts() as $tag) {
2328
-			$name_fields[$tag] = '';
2329
-		}
2330
-		// Inherit surname from parents, spouse or child
2331
-		if ($family) {
2332
-			$father = $family->getHusband();
2333
-			if ($father && $father->getFirstFact('NAME')) {
2334
-				$father_name = $father->getFirstFact('NAME')->getValue();
2335
-			} else {
2336
-				$father_name = '';
2337
-			}
2338
-			$mother = $family->getWife();
2339
-			if ($mother && $mother->getFirstFact('NAME')) {
2340
-				$mother_name = $mother->getFirstFact('NAME')->getValue();
2341
-			} else {
2342
-				$mother_name = '';
2343
-			}
2344
-		} else {
2345
-			$father      = null;
2346
-			$mother      = null;
2347
-			$father_name = '';
2348
-			$mother_name = '';
2349
-		}
2350
-		if ($person && $person->getFirstFact('NAME')) {
2351
-			$indi_name = $person->getFirstFact('NAME')->getValue();
2352
-		} else {
2353
-			$indi_name = '';
2354
-		}
2355
-
2356
-		switch ($nextaction) {
2357
-		case 'add_child_to_family_action':
2358
-			$name_fields = array_merge($name_fields, $surname_tradition->newChildNames($father_name, $mother_name, $gender));
2359
-			break;
2360
-		case 'add_child_to_individual_action':
2361
-			if ($person->getSex() === 'F') {
2362
-				$name_fields = array_merge($name_fields, $surname_tradition->newChildNames('', $indi_name, $gender));
2363
-			} else {
2364
-				$name_fields = array_merge($name_fields, $surname_tradition->newChildNames($indi_name, '', $gender));
2365
-			}
2366
-			break;
2367
-		case 'add_parent_to_individual_action':
2368
-			$name_fields = array_merge($name_fields, $surname_tradition->newParentNames($indi_name, $gender));
2369
-			break;
2370
-		case 'add_spouse_to_family_action':
2371
-			if ($father) {
2372
-				$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($father_name, $gender));
2373
-			} else {
2374
-				$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($mother_name, $gender));
2375
-			}
2376
-			break;
2377
-		case 'add_spouse_to_individual_action':
2378
-			$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($indi_name, $gender));
2379
-			break;
2380
-		case 'add_unlinked_indi_action':
2381
-		case 'update':
2382
-			if ($surname_tradition->hasSurnames()) {
2383
-				$name_fields['NAME'] = '//';
2384
-			}
2385
-			break;
2386
-		}
2387
-	}
2388
-
2389
-	$bdm = ''; // used to copy '1 SOUR' to '2 SOUR' for BIRT DEAT MARR
2390
-
2391
-	echo '<div id="edit_interface-page">';
2392
-	echo '<h2>', $controller->getPageTitle(), '</h2>';
2393
-	FunctionsPrint::initializeCalendarPopup();
2394
-	echo '<form method="post" name="addchildform" onsubmit="return checkform();">';
2395
-	echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">';
2396
-	echo '<input type="hidden" name="action" value="', $nextaction, '">';
2397
-	echo '<input type="hidden" name="fact_id" value="', $name_fact_id, '">';
2398
-	echo '<input type="hidden" name="xref" value="', $xref, '">';
2399
-	echo '<input type="hidden" name="famtag" value="', $famtag, '">';
2400
-	echo '<input type="hidden" name="gender" value="', $gender, '">';
2401
-	echo '<input type="hidden" name="goto" value="">'; // set by javascript
2402
-	echo Filter::getCsrf();
2403
-	echo '<table class="facts_table">';
2404
-
2405
-	switch ($nextaction) {
2406
-	case 'add_child_to_family_action':
2407
-	case 'add_child_to_individual_action':
2408
-		// When adding a new child, specify the pedigree
2409
-		FunctionsEdit::addSimpleTag('0 PEDI');
2410
-		break;
2411
-	case 'update':
2412
-		// When adding/editing a name, specify the type
2413
-		FunctionsEdit::addSimpleTag('0 TYPE ' . $name_type, '', '', null, $person);
2414
-		break;
2415
-	}
2416
-
2417
-	// First - new/existing standard name fields
2418
-	foreach ($name_fields as $tag => $value) {
2419
-		if (substr_compare($tag, '_', 0, 1) !== 0) {
2420
-			FunctionsEdit::addSimpleTag('0 ' . $tag . ' ' . $value);
2421
-		}
2422
-	}
2423
-
2424
-	// Second - new/existing advanced name fields
2425
-	if ($surname_tradition->hasMarriedNames() || preg_match('/\n2 _MARNM /', $namerec)) {
2426
-		$adv_name_fields = array('_MARNM' => '');
2427
-	} else {
2428
-		$adv_name_fields = array();
2429
-	}
2430
-	if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('ADVANCED_NAME_FACTS'), $match)) {
2431
-		foreach ($match[1] as $tag) {
2432
-			$adv_name_fields[$tag] = '';
2433
-		}
2434
-	}
2435
-
2436
-	foreach (array_keys($adv_name_fields) as $tag) {
2437
-		// Edit existing tags, grouped together
2438
-		if (preg_match_all('/2 ' . $tag . ' (.+)/', $namerec, $match)) {
2439
-			foreach ($match[1] as $value) {
2440
-				FunctionsEdit::addSimpleTag('2 ' . $tag . ' ' . $value, '', GedcomTag::getLabel('NAME:' . $tag, $person));
2441
-				if ($tag === '_MARNM') {
2442
-					preg_match_all('/\/([^\/]*)\//', $value, $matches);
2443
-					FunctionsEdit::addSimpleTag('2 _MARNM_SURN ' . implode(',', $matches[1]));
2444
-				}
2445
-			}
2446
-		}
2447
-		// Allow a new tag to be entered
2448
-		if (!array_key_exists($tag, $name_fields)) {
2449
-			FunctionsEdit::addSimpleTag('0 ' . $tag, '', GedcomTag::getLabel('NAME:' . $tag, $person));
2450
-			if ($tag === '_MARNM') {
2451
-				FunctionsEdit::addSimpleTag('0 _MARNM_SURN');
2452
-			}
2453
-		}
2454
-	}
2455
-
2456
-	// Third - new/existing custom name fields
2457
-	foreach ($name_fields as $tag => $value) {
2458
-		if (substr_compare($tag, '_', 0, 1) === 0) {
2459
-			FunctionsEdit::addSimpleTag('0 ' . $tag . ' ' . $value);
2460
-			if ($tag === '_MARNM') {
2461
-				preg_match_all('/\/([^\/]*)\//', $value, $matches);
2462
-				FunctionsEdit::addSimpleTag('2 _MARNM_SURN ' . implode(',', $matches[1]));
2463
-			}
2464
-		}
2465
-	}
2466
-
2467
-	// Fourth - SOUR, NOTE, _CUSTOM, etc.
2468
-	if ($namerec) {
2469
-		$gedlines = explode("\n", $namerec); // -- find the number of lines in the record
2470
-		$fields   = explode(' ', $gedlines[0]);
2471
-		$glevel   = $fields[0];
2472
-		$level    = $glevel;
2473
-		$type     = $fields[1];
2474
-		$tags     = array();
2475
-		$i        = 0;
2476
-		do {
2477
-			if ($type !== 'TYPE' && !array_key_exists($type, $name_fields) && !array_key_exists($type, $adv_name_fields)) {
2478
-				$text = '';
2479
-				for ($j = 2; $j < count($fields); $j++) {
2480
-					if ($j > 2) {
2481
-						$text .= ' ';
2482
-					}
2483
-					$text .= $fields[$j];
2484
-				}
2485
-				while (($i + 1 < count($gedlines)) && (preg_match('/' . ($level + 1) . ' CONT ?(.*)/', $gedlines[$i + 1], $cmatch) > 0)) {
2486
-					$text .= "\n" . $cmatch[1];
2487
-					$i++;
2488
-				}
2489
-				FunctionsEdit::addSimpleTag($level . ' ' . $type . ' ' . $text);
2490
-			}
2491
-			$tags[] = $type;
2492
-			$i++;
2493
-			if (isset($gedlines[$i])) {
2494
-				$fields = explode(' ', $gedlines[$i]);
2495
-				$level  = $fields[0];
2496
-				if (isset($fields[1])) {
2497
-					$type = $fields[1];
2498
-				}
2499
-			}
2500
-		} while (($level > $glevel) && ($i < count($gedlines)));
2501
-	}
2502
-
2503
-	// If we are adding a new individual, add the basic details
2504
-	if ($nextaction !== 'update') {
2505
-		echo '</table><br><table class="facts_table">';
2506
-		// 1 SEX
2507
-		if ($famtag === 'HUSB' || $gender === 'M') {
2508
-			FunctionsEdit::addSimpleTag("0 SEX M");
2509
-		} elseif ($famtag === 'WIFE' || $gender === 'F') {
2510
-			FunctionsEdit::addSimpleTag('0 SEX F');
2511
-		} else {
2512
-			FunctionsEdit::addSimpleTag('0 SEX');
2513
-		}
2514
-		$bdm = 'BD';
2515
-		if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
2516
-			foreach ($matches[1] as $match) {
2517
-				if (!in_array($match, explode('|', WT_EVENTS_DEAT))) {
2518
-					FunctionsEdit::addSimpleTags($match);
2519
-				}
2520
-			}
2521
-		}
2522
-		//-- if adding a spouse add the option to add a marriage fact to the new family
2523
-		if ($nextaction === 'add_spouse_to_individual_action' || $nextaction === 'add_spouse_to_family_action') {
2524
-			$bdm .= 'M';
2525
-			if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) {
2526
-				foreach ($matches[1] as $match) {
2527
-					FunctionsEdit::addSimpleTags($match);
2528
-				}
2529
-			}
2530
-		}
2531
-		if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
2532
-			foreach ($matches[1] as $match) {
2533
-				if (in_array($match, explode('|', WT_EVENTS_DEAT))) {
2534
-					FunctionsEdit::addSimpleTags($match);
2535
-				}
2536
-			}
2537
-		}
2538
-	}
2539
-
2540
-	echo keep_chan($person);
2541
-	echo '</table>';
2542
-	if ($nextaction === 'update') {
2543
-		// GEDCOM 5.5.1 spec says NAME doesn’t get a OBJE
2544
-		FunctionsEdit::printAddLayer('SOUR');
2545
-		FunctionsEdit::printAddLayer('NOTE');
2546
-		FunctionsEdit::printAddLayer('SHARED_NOTE');
2547
-		FunctionsEdit::printAddLayer('RESN');
2548
-	} else {
2549
-		FunctionsEdit::printAddLayer('SOUR', 1);
2550
-		FunctionsEdit::printAddLayer('NOTE', 1);
2551
-		FunctionsEdit::printAddLayer('SHARED_NOTE', 1);
2552
-		FunctionsEdit::printAddLayer('RESN', 1);
2553
-	}
2554
-
2555
-	// If we are editing an existing name, allow raw GEDCOM editing
2556
-	if ($name_fact && (Auth::isAdmin() || $WT_TREE->getPreference('SHOW_GEDCOM_RECORD'))) {
2557
-		echo
2558
-			'<br><br><a href="edit_interface.php?action=editrawfact&amp;xref=', $xref, '&amp;fact_id=', $name_fact->getFactId(), '&amp;ged=', $WT_TREE->getNameUrl(), '">',
2559
-			I18N::translate('Edit the raw GEDCOM'),
2560
-			'</a>';
2561
-	}
2562
-
2563
-	echo '<p id="save-cancel">';
2564
-	echo '<input type="submit" class="save" value="', /* I18N: A button label. */ I18N::translate('save'), '">';
2565
-	if (preg_match('/^add_(child|spouse|parent|unlinked_indi)/', $nextaction)) {
2566
-		echo '<input type="submit" class="save" value="', /* I18N: A button label. */ I18N::translate('go to new individual'), '" onclick="document.addchildform.goto.value=\'new\';">';
2567
-	}
2568
-	echo '<input type="button" class="cancel" value="', /* I18N: A button label. */ I18N::translate('close'), '" onclick="window.close();">';
2569
-	echo '</p>';
2570
-	echo '</form>';
2571
-	$controller->addInlineJavascript('
2275
+    global $WT_TREE, $bdm, $controller;
2276
+
2277
+    if ($person) {
2278
+        $xref = $person->getXref();
2279
+    } elseif ($family) {
2280
+        $xref = $family->getXref();
2281
+    } else {
2282
+        $xref = 'new';
2283
+    }
2284
+
2285
+    // Different cultures do surnames differently
2286
+    $surname_tradition = SurnameTradition::create($WT_TREE->getPreference('SURNAME_TRADITION'));
2287
+
2288
+    $name_fields = array();
2289
+    if ($name_fact) {
2290
+        // Editing an existing name
2291
+        $name_fact_id = $name_fact->getFactId();
2292
+        $name_type    = $name_fact->getAttribute('TYPE');
2293
+        $namerec      = $name_fact->getGedcom();
2294
+        foreach (Config::standardNameFacts() as $tag) {
2295
+            if ($tag === 'NAME') {
2296
+                $name_fields[$tag] = $name_fact->getValue();
2297
+            } else {
2298
+                $name_fields[$tag] = $name_fact->getAttribute($tag);
2299
+            }
2300
+        }
2301
+        // Populate any missing 2 XXXX fields from the 1 NAME field
2302
+        $npfx_accept = implode('|', Config::namePrefixes());
2303
+        if (preg_match('/(((' . $npfx_accept . ')\.? +)*)([^\n\/"]*)("(.*)")? *\/(([a-z]{2,3} +)*)(.*)\/ *(.*)/i', $name_fields['NAME'], $name_bits)) {
2304
+            if (empty($name_fields['NPFX'])) {
2305
+                $name_fields['NPFX'] = $name_bits[1];
2306
+            }
2307
+            if (empty($name_fields['SPFX']) && empty($name_fields['SURN'])) {
2308
+                $name_fields['SPFX'] = trim($name_bits[7]);
2309
+                // For names with two surnames, there will be four slashes.
2310
+                // Turn them into a list
2311
+                $name_fields['SURN'] = preg_replace('~/[^/]*/~', ',', $name_bits[9]);
2312
+            }
2313
+            if (empty($name_fields['GIVN'])) {
2314
+                $name_fields['GIVN'] = $name_bits[4];
2315
+            }
2316
+            if (empty($name_fields['NICK']) && !empty($name_bits[6]) && !preg_match('/^2 NICK/m', $namerec)) {
2317
+                $name_fields['NICK'] = $name_bits[6];
2318
+            }
2319
+        }
2320
+
2321
+    } else {
2322
+        // Creating a new name
2323
+        $name_fact_id = null;
2324
+        $name_type    = null;
2325
+        $namerec      = null;
2326
+        // Populate the standard NAME field and subfields
2327
+        foreach (Config::standardNameFacts() as $tag) {
2328
+            $name_fields[$tag] = '';
2329
+        }
2330
+        // Inherit surname from parents, spouse or child
2331
+        if ($family) {
2332
+            $father = $family->getHusband();
2333
+            if ($father && $father->getFirstFact('NAME')) {
2334
+                $father_name = $father->getFirstFact('NAME')->getValue();
2335
+            } else {
2336
+                $father_name = '';
2337
+            }
2338
+            $mother = $family->getWife();
2339
+            if ($mother && $mother->getFirstFact('NAME')) {
2340
+                $mother_name = $mother->getFirstFact('NAME')->getValue();
2341
+            } else {
2342
+                $mother_name = '';
2343
+            }
2344
+        } else {
2345
+            $father      = null;
2346
+            $mother      = null;
2347
+            $father_name = '';
2348
+            $mother_name = '';
2349
+        }
2350
+        if ($person && $person->getFirstFact('NAME')) {
2351
+            $indi_name = $person->getFirstFact('NAME')->getValue();
2352
+        } else {
2353
+            $indi_name = '';
2354
+        }
2355
+
2356
+        switch ($nextaction) {
2357
+        case 'add_child_to_family_action':
2358
+            $name_fields = array_merge($name_fields, $surname_tradition->newChildNames($father_name, $mother_name, $gender));
2359
+            break;
2360
+        case 'add_child_to_individual_action':
2361
+            if ($person->getSex() === 'F') {
2362
+                $name_fields = array_merge($name_fields, $surname_tradition->newChildNames('', $indi_name, $gender));
2363
+            } else {
2364
+                $name_fields = array_merge($name_fields, $surname_tradition->newChildNames($indi_name, '', $gender));
2365
+            }
2366
+            break;
2367
+        case 'add_parent_to_individual_action':
2368
+            $name_fields = array_merge($name_fields, $surname_tradition->newParentNames($indi_name, $gender));
2369
+            break;
2370
+        case 'add_spouse_to_family_action':
2371
+            if ($father) {
2372
+                $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($father_name, $gender));
2373
+            } else {
2374
+                $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($mother_name, $gender));
2375
+            }
2376
+            break;
2377
+        case 'add_spouse_to_individual_action':
2378
+            $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($indi_name, $gender));
2379
+            break;
2380
+        case 'add_unlinked_indi_action':
2381
+        case 'update':
2382
+            if ($surname_tradition->hasSurnames()) {
2383
+                $name_fields['NAME'] = '//';
2384
+            }
2385
+            break;
2386
+        }
2387
+    }
2388
+
2389
+    $bdm = ''; // used to copy '1 SOUR' to '2 SOUR' for BIRT DEAT MARR
2390
+
2391
+    echo '<div id="edit_interface-page">';
2392
+    echo '<h2>', $controller->getPageTitle(), '</h2>';
2393
+    FunctionsPrint::initializeCalendarPopup();
2394
+    echo '<form method="post" name="addchildform" onsubmit="return checkform();">';
2395
+    echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">';
2396
+    echo '<input type="hidden" name="action" value="', $nextaction, '">';
2397
+    echo '<input type="hidden" name="fact_id" value="', $name_fact_id, '">';
2398
+    echo '<input type="hidden" name="xref" value="', $xref, '">';
2399
+    echo '<input type="hidden" name="famtag" value="', $famtag, '">';
2400
+    echo '<input type="hidden" name="gender" value="', $gender, '">';
2401
+    echo '<input type="hidden" name="goto" value="">'; // set by javascript
2402
+    echo Filter::getCsrf();
2403
+    echo '<table class="facts_table">';
2404
+
2405
+    switch ($nextaction) {
2406
+    case 'add_child_to_family_action':
2407
+    case 'add_child_to_individual_action':
2408
+        // When adding a new child, specify the pedigree
2409
+        FunctionsEdit::addSimpleTag('0 PEDI');
2410
+        break;
2411
+    case 'update':
2412
+        // When adding/editing a name, specify the type
2413
+        FunctionsEdit::addSimpleTag('0 TYPE ' . $name_type, '', '', null, $person);
2414
+        break;
2415
+    }
2416
+
2417
+    // First - new/existing standard name fields
2418
+    foreach ($name_fields as $tag => $value) {
2419
+        if (substr_compare($tag, '_', 0, 1) !== 0) {
2420
+            FunctionsEdit::addSimpleTag('0 ' . $tag . ' ' . $value);
2421
+        }
2422
+    }
2423
+
2424
+    // Second - new/existing advanced name fields
2425
+    if ($surname_tradition->hasMarriedNames() || preg_match('/\n2 _MARNM /', $namerec)) {
2426
+        $adv_name_fields = array('_MARNM' => '');
2427
+    } else {
2428
+        $adv_name_fields = array();
2429
+    }
2430
+    if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('ADVANCED_NAME_FACTS'), $match)) {
2431
+        foreach ($match[1] as $tag) {
2432
+            $adv_name_fields[$tag] = '';
2433
+        }
2434
+    }
2435
+
2436
+    foreach (array_keys($adv_name_fields) as $tag) {
2437
+        // Edit existing tags, grouped together
2438
+        if (preg_match_all('/2 ' . $tag . ' (.+)/', $namerec, $match)) {
2439
+            foreach ($match[1] as $value) {
2440
+                FunctionsEdit::addSimpleTag('2 ' . $tag . ' ' . $value, '', GedcomTag::getLabel('NAME:' . $tag, $person));
2441
+                if ($tag === '_MARNM') {
2442
+                    preg_match_all('/\/([^\/]*)\//', $value, $matches);
2443
+                    FunctionsEdit::addSimpleTag('2 _MARNM_SURN ' . implode(',', $matches[1]));
2444
+                }
2445
+            }
2446
+        }
2447
+        // Allow a new tag to be entered
2448
+        if (!array_key_exists($tag, $name_fields)) {
2449
+            FunctionsEdit::addSimpleTag('0 ' . $tag, '', GedcomTag::getLabel('NAME:' . $tag, $person));
2450
+            if ($tag === '_MARNM') {
2451
+                FunctionsEdit::addSimpleTag('0 _MARNM_SURN');
2452
+            }
2453
+        }
2454
+    }
2455
+
2456
+    // Third - new/existing custom name fields
2457
+    foreach ($name_fields as $tag => $value) {
2458
+        if (substr_compare($tag, '_', 0, 1) === 0) {
2459
+            FunctionsEdit::addSimpleTag('0 ' . $tag . ' ' . $value);
2460
+            if ($tag === '_MARNM') {
2461
+                preg_match_all('/\/([^\/]*)\//', $value, $matches);
2462
+                FunctionsEdit::addSimpleTag('2 _MARNM_SURN ' . implode(',', $matches[1]));
2463
+            }
2464
+        }
2465
+    }
2466
+
2467
+    // Fourth - SOUR, NOTE, _CUSTOM, etc.
2468
+    if ($namerec) {
2469
+        $gedlines = explode("\n", $namerec); // -- find the number of lines in the record
2470
+        $fields   = explode(' ', $gedlines[0]);
2471
+        $glevel   = $fields[0];
2472
+        $level    = $glevel;
2473
+        $type     = $fields[1];
2474
+        $tags     = array();
2475
+        $i        = 0;
2476
+        do {
2477
+            if ($type !== 'TYPE' && !array_key_exists($type, $name_fields) && !array_key_exists($type, $adv_name_fields)) {
2478
+                $text = '';
2479
+                for ($j = 2; $j < count($fields); $j++) {
2480
+                    if ($j > 2) {
2481
+                        $text .= ' ';
2482
+                    }
2483
+                    $text .= $fields[$j];
2484
+                }
2485
+                while (($i + 1 < count($gedlines)) && (preg_match('/' . ($level + 1) . ' CONT ?(.*)/', $gedlines[$i + 1], $cmatch) > 0)) {
2486
+                    $text .= "\n" . $cmatch[1];
2487
+                    $i++;
2488
+                }
2489
+                FunctionsEdit::addSimpleTag($level . ' ' . $type . ' ' . $text);
2490
+            }
2491
+            $tags[] = $type;
2492
+            $i++;
2493
+            if (isset($gedlines[$i])) {
2494
+                $fields = explode(' ', $gedlines[$i]);
2495
+                $level  = $fields[0];
2496
+                if (isset($fields[1])) {
2497
+                    $type = $fields[1];
2498
+                }
2499
+            }
2500
+        } while (($level > $glevel) && ($i < count($gedlines)));
2501
+    }
2502
+
2503
+    // If we are adding a new individual, add the basic details
2504
+    if ($nextaction !== 'update') {
2505
+        echo '</table><br><table class="facts_table">';
2506
+        // 1 SEX
2507
+        if ($famtag === 'HUSB' || $gender === 'M') {
2508
+            FunctionsEdit::addSimpleTag("0 SEX M");
2509
+        } elseif ($famtag === 'WIFE' || $gender === 'F') {
2510
+            FunctionsEdit::addSimpleTag('0 SEX F');
2511
+        } else {
2512
+            FunctionsEdit::addSimpleTag('0 SEX');
2513
+        }
2514
+        $bdm = 'BD';
2515
+        if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
2516
+            foreach ($matches[1] as $match) {
2517
+                if (!in_array($match, explode('|', WT_EVENTS_DEAT))) {
2518
+                    FunctionsEdit::addSimpleTags($match);
2519
+                }
2520
+            }
2521
+        }
2522
+        //-- if adding a spouse add the option to add a marriage fact to the new family
2523
+        if ($nextaction === 'add_spouse_to_individual_action' || $nextaction === 'add_spouse_to_family_action') {
2524
+            $bdm .= 'M';
2525
+            if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) {
2526
+                foreach ($matches[1] as $match) {
2527
+                    FunctionsEdit::addSimpleTags($match);
2528
+                }
2529
+            }
2530
+        }
2531
+        if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
2532
+            foreach ($matches[1] as $match) {
2533
+                if (in_array($match, explode('|', WT_EVENTS_DEAT))) {
2534
+                    FunctionsEdit::addSimpleTags($match);
2535
+                }
2536
+            }
2537
+        }
2538
+    }
2539
+
2540
+    echo keep_chan($person);
2541
+    echo '</table>';
2542
+    if ($nextaction === 'update') {
2543
+        // GEDCOM 5.5.1 spec says NAME doesn’t get a OBJE
2544
+        FunctionsEdit::printAddLayer('SOUR');
2545
+        FunctionsEdit::printAddLayer('NOTE');
2546
+        FunctionsEdit::printAddLayer('SHARED_NOTE');
2547
+        FunctionsEdit::printAddLayer('RESN');
2548
+    } else {
2549
+        FunctionsEdit::printAddLayer('SOUR', 1);
2550
+        FunctionsEdit::printAddLayer('NOTE', 1);
2551
+        FunctionsEdit::printAddLayer('SHARED_NOTE', 1);
2552
+        FunctionsEdit::printAddLayer('RESN', 1);
2553
+    }
2554
+
2555
+    // If we are editing an existing name, allow raw GEDCOM editing
2556
+    if ($name_fact && (Auth::isAdmin() || $WT_TREE->getPreference('SHOW_GEDCOM_RECORD'))) {
2557
+        echo
2558
+            '<br><br><a href="edit_interface.php?action=editrawfact&amp;xref=', $xref, '&amp;fact_id=', $name_fact->getFactId(), '&amp;ged=', $WT_TREE->getNameUrl(), '">',
2559
+            I18N::translate('Edit the raw GEDCOM'),
2560
+            '</a>';
2561
+    }
2562
+
2563
+    echo '<p id="save-cancel">';
2564
+    echo '<input type="submit" class="save" value="', /* I18N: A button label. */ I18N::translate('save'), '">';
2565
+    if (preg_match('/^add_(child|spouse|parent|unlinked_indi)/', $nextaction)) {
2566
+        echo '<input type="submit" class="save" value="', /* I18N: A button label. */ I18N::translate('go to new individual'), '" onclick="document.addchildform.goto.value=\'new\';">';
2567
+    }
2568
+    echo '<input type="button" class="cancel" value="', /* I18N: A button label. */ I18N::translate('close'), '" onclick="window.close();">';
2569
+    echo '</p>';
2570
+    echo '</form>';
2571
+    $controller->addInlineJavascript('
2572 2572
 	SURNAME_TRADITION="' . $WT_TREE->getPreference('SURNAME_TRADITION') . '";
2573 2573
 	gender="' . $gender . '";
2574 2574
 	famtag="' . $famtag . '";
@@ -2729,7 +2729,7 @@  discard block
 block discarded – undo
2729 2729
 		convertHidden("NAME");
2730 2730
 	}
2731 2731
 	');
2732
-	echo '</div>';
2732
+    echo '</div>';
2733 2733
 }
2734 2734
 
2735 2735
 /**
@@ -2738,12 +2738,12 @@  discard block
 block discarded – undo
2738 2738
  * @param GedcomRecord $object
2739 2739
  */
2740 2740
 function check_record_access(GedcomRecord $object = null) {
2741
-	global $controller;
2742
-
2743
-	if (!$object || !$object->canShow() || !$object->canEdit()) {
2744
-		$controller
2745
-			->pageHeader()
2746
-			->addInlineJavascript('closePopupAndReloadParent();');
2747
-		exit;
2748
-	}
2741
+    global $controller;
2742
+
2743
+    if (!$object || !$object->canShow() || !$object->canEdit()) {
2744
+        $controller
2745
+            ->pageHeader()
2746
+            ->addInlineJavascript('closePopupAndReloadParent();');
2747
+        exit;
2748
+    }
2749 2749
 }
Please login to merge, or discard this patch.
Switch Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -278,40 +278,40 @@  discard block
 block discarded – undo
278 278
 
279 279
 	$level1type = $edit_fact->getTag();
280 280
 	switch ($record::RECORD_TYPE) {
281
-	case 'REPO':
282
-		// REPO:NAME facts may take a NOTE (but the REPO record may not).
283
-		if ($level1type === 'NAME') {
284
-			FunctionsEdit::printAddLayer('NOTE');
285
-			FunctionsEdit::printAddLayer('SHARED_NOTE');
286
-		}
287
-		break;
288
-	case 'FAM':
289
-	case 'INDI':
290
-		// FAM and INDI records have real facts. They can take NOTE/SOUR/OBJE/etc.
291
-		if ($level1type !== 'SEX' && $level1type !== 'NOTE' && $level1type !== 'ALIA') {
292
-			if ($level1type !== 'SOUR') {
293
-				FunctionsEdit::printAddLayer('SOUR');
294
-			}
295
-			if ($level1type !== 'OBJE') {
296
-				FunctionsEdit::printAddLayer('OBJE');
297
-			}
298
-			FunctionsEdit::printAddLayer('NOTE');
299
-			FunctionsEdit::printAddLayer('SHARED_NOTE', 2, $level1type);
300
-			if ($level1type !== 'ASSO' && $level1type !== 'NOTE' && $level1type !== 'SOUR') {
301
-				FunctionsEdit::printAddLayer('ASSO');
302
-			}
303
-			// allow to add godfather and godmother for CHR fact or best man and bridesmaid  for MARR fact in one window
304
-			if (in_array($level1type, Config::twoAssociates())) {
305
-				FunctionsEdit::printAddLayer('ASSO2');
306
-			}
307
-			if ($level1type !== 'SOUR') {
308
-				FunctionsEdit::printAddLayer('RESN');
309
-			}
310
-		}
311
-		break;
312
-	default:
313
-		// Other types of record do not have these lower-level records
314
-		break;
281
+	    case 'REPO':
282
+		    // REPO:NAME facts may take a NOTE (but the REPO record may not).
283
+		    if ($level1type === 'NAME') {
284
+			    FunctionsEdit::printAddLayer('NOTE');
285
+			    FunctionsEdit::printAddLayer('SHARED_NOTE');
286
+		    }
287
+		    break;
288
+	    case 'FAM':
289
+	    case 'INDI':
290
+		    // FAM and INDI records have real facts. They can take NOTE/SOUR/OBJE/etc.
291
+		    if ($level1type !== 'SEX' && $level1type !== 'NOTE' && $level1type !== 'ALIA') {
292
+			    if ($level1type !== 'SOUR') {
293
+				    FunctionsEdit::printAddLayer('SOUR');
294
+			    }
295
+			    if ($level1type !== 'OBJE') {
296
+				    FunctionsEdit::printAddLayer('OBJE');
297
+			    }
298
+			    FunctionsEdit::printAddLayer('NOTE');
299
+			    FunctionsEdit::printAddLayer('SHARED_NOTE', 2, $level1type);
300
+			    if ($level1type !== 'ASSO' && $level1type !== 'NOTE' && $level1type !== 'SOUR') {
301
+				    FunctionsEdit::printAddLayer('ASSO');
302
+			    }
303
+			    // allow to add godfather and godmother for CHR fact or best man and bridesmaid  for MARR fact in one window
304
+			    if (in_array($level1type, Config::twoAssociates())) {
305
+				    FunctionsEdit::printAddLayer('ASSO2');
306
+			    }
307
+			    if ($level1type !== 'SOUR') {
308
+				    FunctionsEdit::printAddLayer('RESN');
309
+			    }
310
+		    }
311
+		    break;
312
+	    default:
313
+		    // Other types of record do not have these lower-level records
314
+		    break;
315 315
 	}
316 316
 	if (Auth::isAdmin() || $WT_TREE->getPreference('SHOW_GEDCOM_RECORD')) {
317 317
 		echo
@@ -1905,9 +1905,9 @@  discard block
 block discarded – undo
1905 1905
 							<b>
1906 1906
 								<?php
1907 1907
 								switch ($father->getSex()) {
1908
-								case 'M': echo I18N::translate('husband'); break;
1909
-								case 'F': echo I18N::translate('wife'); break;
1910
-								default:  echo I18N::translate('spouse'); break;
1908
+								    case 'M': echo I18N::translate('husband'); break;
1909
+								    case 'F': echo I18N::translate('wife'); break;
1910
+								    default:  echo I18N::translate('spouse'); break;
1911 1911
 								}
1912 1912
 								?>
1913 1913
 							</b>
@@ -1940,9 +1940,9 @@  discard block
 block discarded – undo
1940 1940
 							<b>
1941 1941
 								<?php
1942 1942
 								switch ($mother->getSex()) {
1943
-								case 'M': echo I18N::translate('husband'); break;
1944
-								case 'F': echo I18N::translate('wife'); break;
1945
-								default:  echo I18N::translate('spouse'); break;
1943
+								    case 'M': echo I18N::translate('husband'); break;
1944
+								    case 'F': echo I18N::translate('wife'); break;
1945
+								    default:  echo I18N::translate('spouse'); break;
1946 1946
 								}
1947 1947
 								?>
1948 1948
 							</b>
@@ -1976,9 +1976,9 @@  discard block
 block discarded – undo
1976 1976
 							<b>
1977 1977
 								<?php
1978 1978
 								switch ($child->getSex()) {
1979
-								case 'M': echo I18N::translate('son'); break;
1980
-								case 'F': echo I18N::translate('daughter'); break;
1981
-								default:  echo I18N::translate('child'); break;
1979
+								    case 'M': echo I18N::translate('son'); break;
1980
+								    case 'F': echo I18N::translate('daughter'); break;
1981
+								    default:  echo I18N::translate('child'); break;
1982 1982
 								}
1983 1983
 								?>
1984 1984
 							</b>
@@ -2354,35 +2354,35 @@  discard block
 block discarded – undo
2354 2354
 		}
2355 2355
 
2356 2356
 		switch ($nextaction) {
2357
-		case 'add_child_to_family_action':
2358
-			$name_fields = array_merge($name_fields, $surname_tradition->newChildNames($father_name, $mother_name, $gender));
2359
-			break;
2360
-		case 'add_child_to_individual_action':
2361
-			if ($person->getSex() === 'F') {
2362
-				$name_fields = array_merge($name_fields, $surname_tradition->newChildNames('', $indi_name, $gender));
2363
-			} else {
2364
-				$name_fields = array_merge($name_fields, $surname_tradition->newChildNames($indi_name, '', $gender));
2365
-			}
2366
-			break;
2367
-		case 'add_parent_to_individual_action':
2368
-			$name_fields = array_merge($name_fields, $surname_tradition->newParentNames($indi_name, $gender));
2369
-			break;
2370
-		case 'add_spouse_to_family_action':
2371
-			if ($father) {
2372
-				$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($father_name, $gender));
2373
-			} else {
2374
-				$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($mother_name, $gender));
2375
-			}
2376
-			break;
2377
-		case 'add_spouse_to_individual_action':
2378
-			$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($indi_name, $gender));
2379
-			break;
2380
-		case 'add_unlinked_indi_action':
2381
-		case 'update':
2382
-			if ($surname_tradition->hasSurnames()) {
2383
-				$name_fields['NAME'] = '//';
2384
-			}
2385
-			break;
2357
+		    case 'add_child_to_family_action':
2358
+			    $name_fields = array_merge($name_fields, $surname_tradition->newChildNames($father_name, $mother_name, $gender));
2359
+			    break;
2360
+		    case 'add_child_to_individual_action':
2361
+			    if ($person->getSex() === 'F') {
2362
+				    $name_fields = array_merge($name_fields, $surname_tradition->newChildNames('', $indi_name, $gender));
2363
+			    } else {
2364
+				    $name_fields = array_merge($name_fields, $surname_tradition->newChildNames($indi_name, '', $gender));
2365
+			    }
2366
+			    break;
2367
+		    case 'add_parent_to_individual_action':
2368
+			    $name_fields = array_merge($name_fields, $surname_tradition->newParentNames($indi_name, $gender));
2369
+			    break;
2370
+		    case 'add_spouse_to_family_action':
2371
+			    if ($father) {
2372
+				    $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($father_name, $gender));
2373
+			    } else {
2374
+				    $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($mother_name, $gender));
2375
+			    }
2376
+			    break;
2377
+		    case 'add_spouse_to_individual_action':
2378
+			    $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($indi_name, $gender));
2379
+			    break;
2380
+		    case 'add_unlinked_indi_action':
2381
+		    case 'update':
2382
+			    if ($surname_tradition->hasSurnames()) {
2383
+				    $name_fields['NAME'] = '//';
2384
+			    }
2385
+			    break;
2386 2386
 		}
2387 2387
 	}
2388 2388
 
@@ -2403,15 +2403,15 @@  discard block
 block discarded – undo
2403 2403
 	echo '<table class="facts_table">';
2404 2404
 
2405 2405
 	switch ($nextaction) {
2406
-	case 'add_child_to_family_action':
2407
-	case 'add_child_to_individual_action':
2408
-		// When adding a new child, specify the pedigree
2409
-		FunctionsEdit::addSimpleTag('0 PEDI');
2410
-		break;
2411
-	case 'update':
2412
-		// When adding/editing a name, specify the type
2413
-		FunctionsEdit::addSimpleTag('0 TYPE ' . $name_type, '', '', null, $person);
2414
-		break;
2406
+	    case 'add_child_to_family_action':
2407
+	    case 'add_child_to_individual_action':
2408
+		    // When adding a new child, specify the pedigree
2409
+		    FunctionsEdit::addSimpleTag('0 PEDI');
2410
+		    break;
2411
+	    case 'update':
2412
+		    // When adding/editing a name, specify the type
2413
+		    FunctionsEdit::addSimpleTag('0 TYPE ' . $name_type, '', '', null, $person);
2414
+		    break;
2415 2415
 	}
2416 2416
 
2417 2417
 	// First - new/existing standard name fields
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2236,7 +2236,8 @@  discard block
 block discarded – undo
2236 2236
  *
2237 2237
  * @return string
2238 2238
  */
2239
-function keep_chan(GedcomRecord $record = null) {
2239
+function keep_chan(GedcomRecord $record = null)
2240
+{
2240 2241
 	global $WT_TREE;
2241 2242
 
2242 2243
 	if (Auth::isAdmin()) {
@@ -2271,7 +2272,8 @@  discard block
 block discarded – undo
2271 2272
  * @param string     $famtag
2272 2273
  * @param string     $gender
2273 2274
  */
2274
-function print_indi_form($nextaction, Individual $person = null, Family $family = null, Fact $name_fact = null, $famtag = 'CHIL', $gender = 'U') {
2275
+function print_indi_form($nextaction, Individual $person = null, Family $family = null, Fact $name_fact = null, $famtag = 'CHIL', $gender = 'U')
2276
+{
2275 2277
 	global $WT_TREE, $bdm, $controller;
2276 2278
 
2277 2279
 	if ($person) {
@@ -2737,7 +2739,8 @@  discard block
 block discarded – undo
2737 2739
  *
2738 2740
  * @param GedcomRecord $object
2739 2741
  */
2740
-function check_record_access(GedcomRecord $object = null) {
2742
+function check_record_access(GedcomRecord $object = null)
2743
+{
2741 2744
 	global $controller;
2742 2745
 
2743 2746
 	if (!$object || !$object->canShow() || !$object->canEdit()) {
Please login to merge, or discard this patch.
admin_site_config.php 2 patches
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -26,136 +26,136 @@  discard block
 block discarded – undo
26 26
 
27 27
 switch (Filter::post('action')) {
28 28
 case 'site':
29
-	if (Filter::checkCsrf()) {
30
-		$INDEX_DIRECTORY = Filter::post('INDEX_DIRECTORY');
31
-		if (substr($INDEX_DIRECTORY, -1) !== '/') {
32
-			$INDEX_DIRECTORY .= '/';
33
-		}
34
-		if (File::mkdir($INDEX_DIRECTORY)) {
35
-			Site::setPreference('INDEX_DIRECTORY', $INDEX_DIRECTORY);
36
-		} else {
37
-			FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Filter::escapeHtml($INDEX_DIRECTORY)), 'danger');
38
-		}
39
-		Site::setPreference('MEMORY_LIMIT', Filter::post('MEMORY_LIMIT'));
40
-		Site::setPreference('MAX_EXECUTION_TIME', Filter::post('MAX_EXECUTION_TIME'));
41
-		Site::setPreference('ALLOW_USER_THEMES', Filter::postBool('ALLOW_USER_THEMES'));
42
-		Site::setPreference('THEME_DIR', Filter::post('THEME_DIR'));
43
-		Site::setPreference('ALLOW_CHANGE_GEDCOM', Filter::postBool('ALLOW_CHANGE_GEDCOM'));
44
-		Site::setPreference('SESSION_TIME', Filter::post('SESSION_TIME'));
45
-		Site::setPreference('SERVER_URL', Filter::post('SERVER_URL'));
46
-		Site::setPreference('TIMEZONE', Filter::post('TIMEZONE'));
47
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
48
-	}
49
-	header('Location: ' . WT_BASE_URL . 'admin.php');
50
-
51
-	return;
29
+    if (Filter::checkCsrf()) {
30
+        $INDEX_DIRECTORY = Filter::post('INDEX_DIRECTORY');
31
+        if (substr($INDEX_DIRECTORY, -1) !== '/') {
32
+            $INDEX_DIRECTORY .= '/';
33
+        }
34
+        if (File::mkdir($INDEX_DIRECTORY)) {
35
+            Site::setPreference('INDEX_DIRECTORY', $INDEX_DIRECTORY);
36
+        } else {
37
+            FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Filter::escapeHtml($INDEX_DIRECTORY)), 'danger');
38
+        }
39
+        Site::setPreference('MEMORY_LIMIT', Filter::post('MEMORY_LIMIT'));
40
+        Site::setPreference('MAX_EXECUTION_TIME', Filter::post('MAX_EXECUTION_TIME'));
41
+        Site::setPreference('ALLOW_USER_THEMES', Filter::postBool('ALLOW_USER_THEMES'));
42
+        Site::setPreference('THEME_DIR', Filter::post('THEME_DIR'));
43
+        Site::setPreference('ALLOW_CHANGE_GEDCOM', Filter::postBool('ALLOW_CHANGE_GEDCOM'));
44
+        Site::setPreference('SESSION_TIME', Filter::post('SESSION_TIME'));
45
+        Site::setPreference('SERVER_URL', Filter::post('SERVER_URL'));
46
+        Site::setPreference('TIMEZONE', Filter::post('TIMEZONE'));
47
+        FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
48
+    }
49
+    header('Location: ' . WT_BASE_URL . 'admin.php');
50
+
51
+    return;
52 52
 
53 53
 case 'email':
54
-	if (Filter::checkCsrf()) {
55
-		Site::setPreference('SMTP_ACTIVE', Filter::post('SMTP_ACTIVE'));
56
-		Site::setPreference('SMTP_FROM_NAME', Filter::post('SMTP_FROM_NAME'));
57
-		Site::setPreference('SMTP_HOST', Filter::post('SMTP_HOST'));
58
-		Site::setPreference('SMTP_PORT', Filter::post('SMTP_PORT'));
59
-		Site::setPreference('SMTP_AUTH', Filter::post('SMTP_AUTH'));
60
-		Site::setPreference('SMTP_AUTH_USER', Filter::post('SMTP_AUTH_USER'));
61
-		Site::setPreference('SMTP_SSL', Filter::post('SMTP_SSL'));
62
-		Site::setPreference('SMTP_HELO', Filter::post('SMTP_HELO'));
63
-		if (Filter::post('SMTP_AUTH_PASS')) {
64
-			Site::setPreference('SMTP_AUTH_PASS', Filter::post('SMTP_AUTH_PASS'));
65
-		}
66
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
67
-	}
68
-	header('Location: ' . WT_BASE_URL . 'admin.php');
69
-
70
-	return;
54
+    if (Filter::checkCsrf()) {
55
+        Site::setPreference('SMTP_ACTIVE', Filter::post('SMTP_ACTIVE'));
56
+        Site::setPreference('SMTP_FROM_NAME', Filter::post('SMTP_FROM_NAME'));
57
+        Site::setPreference('SMTP_HOST', Filter::post('SMTP_HOST'));
58
+        Site::setPreference('SMTP_PORT', Filter::post('SMTP_PORT'));
59
+        Site::setPreference('SMTP_AUTH', Filter::post('SMTP_AUTH'));
60
+        Site::setPreference('SMTP_AUTH_USER', Filter::post('SMTP_AUTH_USER'));
61
+        Site::setPreference('SMTP_SSL', Filter::post('SMTP_SSL'));
62
+        Site::setPreference('SMTP_HELO', Filter::post('SMTP_HELO'));
63
+        if (Filter::post('SMTP_AUTH_PASS')) {
64
+            Site::setPreference('SMTP_AUTH_PASS', Filter::post('SMTP_AUTH_PASS'));
65
+        }
66
+        FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
67
+    }
68
+    header('Location: ' . WT_BASE_URL . 'admin.php');
69
+
70
+    return;
71 71
 case 'login':
72
-	if (Filter::checkCsrf()) {
73
-		Site::setPreference('LOGIN_URL', Filter::post('LOGIN_URL'));
74
-		Site::setPreference('WELCOME_TEXT_AUTH_MODE', Filter::post('WELCOME_TEXT_AUTH_MODE'));
75
-		Site::setPreference('WELCOME_TEXT_AUTH_MODE_' . WT_LOCALE, Filter::post('WELCOME_TEXT_AUTH_MODE_4'));
76
-		Site::setPreference('USE_REGISTRATION_MODULE', Filter::post('USE_REGISTRATION_MODULE'));
77
-		Site::setPreference('SHOW_REGISTER_CAUTION', Filter::post('SHOW_REGISTER_CAUTION'));
78
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
79
-	}
80
-	header('Location: ' . WT_BASE_URL . 'admin.php');
81
-
82
-	return;
72
+    if (Filter::checkCsrf()) {
73
+        Site::setPreference('LOGIN_URL', Filter::post('LOGIN_URL'));
74
+        Site::setPreference('WELCOME_TEXT_AUTH_MODE', Filter::post('WELCOME_TEXT_AUTH_MODE'));
75
+        Site::setPreference('WELCOME_TEXT_AUTH_MODE_' . WT_LOCALE, Filter::post('WELCOME_TEXT_AUTH_MODE_4'));
76
+        Site::setPreference('USE_REGISTRATION_MODULE', Filter::post('USE_REGISTRATION_MODULE'));
77
+        Site::setPreference('SHOW_REGISTER_CAUTION', Filter::post('SHOW_REGISTER_CAUTION'));
78
+        FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
79
+    }
80
+    header('Location: ' . WT_BASE_URL . 'admin.php');
81
+
82
+    return;
83 83
 
84 84
 case 'tracking':
85
-	if (Filter::checkCsrf()) {
86
-		Site::setPreference('BING_WEBMASTER_ID', Filter::post('BING_WEBMASTER_ID'));
87
-		Site::setPreference('GOOGLE_WEBMASTER_ID', Filter::post('GOOGLE_WEBMASTER_ID'));
88
-		Site::setPreference('GOOGLE_ANALYTICS_ID', Filter::post('GOOGLE_ANALYTICS_ID'));
89
-		Site::setPreference('PIWIK_URL', Filter::post('PIWIK_URL'));
90
-		Site::setPreference('PIWIK_SITE_ID', Filter::post('PIWIK_SITE_ID'));
91
-		Site::setPreference('STATCOUNTER_PROJECT_ID', Filter::post('STATCOUNTER_PROJECT_ID'));
92
-		Site::setPreference('STATCOUNTER_SECURITY_ID', Filter::post('STATCOUNTER_SECURITY_ID'));
93
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
94
-	}
95
-	header('Location: ' . WT_BASE_URL . 'admin.php');
96
-
97
-	return;
85
+    if (Filter::checkCsrf()) {
86
+        Site::setPreference('BING_WEBMASTER_ID', Filter::post('BING_WEBMASTER_ID'));
87
+        Site::setPreference('GOOGLE_WEBMASTER_ID', Filter::post('GOOGLE_WEBMASTER_ID'));
88
+        Site::setPreference('GOOGLE_ANALYTICS_ID', Filter::post('GOOGLE_ANALYTICS_ID'));
89
+        Site::setPreference('PIWIK_URL', Filter::post('PIWIK_URL'));
90
+        Site::setPreference('PIWIK_SITE_ID', Filter::post('PIWIK_SITE_ID'));
91
+        Site::setPreference('STATCOUNTER_PROJECT_ID', Filter::post('STATCOUNTER_PROJECT_ID'));
92
+        Site::setPreference('STATCOUNTER_SECURITY_ID', Filter::post('STATCOUNTER_SECURITY_ID'));
93
+        FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
94
+    }
95
+    header('Location: ' . WT_BASE_URL . 'admin.php');
96
+
97
+    return;
98 98
 
99 99
 case 'languages':
100
-	if (Filter::checkCsrf()) {
101
-		Site::setPreference('LANGUAGES', implode(',', Filter::postArray('LANGUAGES')));
102
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
103
-	}
104
-	header('Location: ' . WT_BASE_URL . 'admin.php');
100
+    if (Filter::checkCsrf()) {
101
+        Site::setPreference('LANGUAGES', implode(',', Filter::postArray('LANGUAGES')));
102
+        FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
103
+    }
104
+    header('Location: ' . WT_BASE_URL . 'admin.php');
105 105
 
106
-	return;
106
+    return;
107 107
 }
108 108
 
109 109
 // Lists of options for <select> controls.
110 110
 $SMTP_SSL_OPTIONS = array(
111
-	'none'                                                                        => I18N::translate('none'),
112
-	/* I18N: Secure Sockets Layer - a secure communications protocol*/ 'ssl'      => I18N::translate('ssl'),
113
-	/* I18N: Transport Layer Security - a secure communications protocol */ 'tls' => I18N::translate('tls'),
111
+    'none'                                                                        => I18N::translate('none'),
112
+    /* I18N: Secure Sockets Layer - a secure communications protocol*/ 'ssl'      => I18N::translate('ssl'),
113
+    /* I18N: Transport Layer Security - a secure communications protocol */ 'tls' => I18N::translate('tls'),
114 114
 );
115 115
 
116 116
 $SMTP_ACTIVE_OPTIONS = array(
117
-	'internal' => I18N::translate('Use PHP mail to send messages'),
118
-	'sendmail' => /* I18N: "sendmail" is the name of some mail software */ I18N::translate('Use sendmail to send messages'),
119
-	'external' => I18N::translate('Use SMTP to send messages'),
117
+    'internal' => I18N::translate('Use PHP mail to send messages'),
118
+    'sendmail' => /* I18N: "sendmail" is the name of some mail software */ I18N::translate('Use sendmail to send messages'),
119
+    'external' => I18N::translate('Use SMTP to send messages'),
120 120
 );
121 121
 
122 122
 if (!function_exists('proc_open')) {
123
-	unset($SMTP_ACTIVE_OPTIONS['sendmail']);
123
+    unset($SMTP_ACTIVE_OPTIONS['sendmail']);
124 124
 }
125 125
 
126 126
 $WELCOME_TEXT_AUTH_MODE_OPTIONS = array(
127
-	0 => I18N::translate('No predefined text'),
128
-	1 => I18N::translate('Predefined text that states all users can request a user account'),
129
-	2 => I18N::translate('Predefined text that states admin will decide on each request for a user account'),
130
-	3 => I18N::translate('Predefined text that states only family members can request a user account'),
131
-	4 => I18N::translate('Choose user defined welcome text typed below'),
127
+    0 => I18N::translate('No predefined text'),
128
+    1 => I18N::translate('Predefined text that states all users can request a user account'),
129
+    2 => I18N::translate('Predefined text that states admin will decide on each request for a user account'),
130
+    3 => I18N::translate('Predefined text that states only family members can request a user account'),
131
+    4 => I18N::translate('Choose user defined welcome text typed below'),
132 132
 );
133 133
 
134 134
 $language_tags = array();
135 135
 foreach (I18N::activeLocales() as $active_locale) {
136
-	$language_tags[] = $active_locale->languageTag();
136
+    $language_tags[] = $active_locale->languageTag();
137 137
 }
138 138
 
139 139
 switch (Filter::get('action')) {
140 140
 case 'site':
141
-	$controller->setPageTitle(I18N::translate('Website preferences'));
142
-	break;
141
+    $controller->setPageTitle(I18N::translate('Website preferences'));
142
+    break;
143 143
 case 'email':
144
-	$controller->setPageTitle(I18N::translate('Sending email'));
145
-	break;
144
+    $controller->setPageTitle(I18N::translate('Sending email'));
145
+    break;
146 146
 case 'login':
147
-	$controller->setPageTitle(I18N::translate('Sign-in and registration'));
148
-	break;
147
+    $controller->setPageTitle(I18N::translate('Sign-in and registration'));
148
+    break;
149 149
 case 'tracking':
150
-	$controller->setPageTitle(/* I18N: e.g. http://www.google.com/analytics */ I18N::translate('Tracking and analytics'));
151
-	break;
150
+    $controller->setPageTitle(/* I18N: e.g. http://www.google.com/analytics */ I18N::translate('Tracking and analytics'));
151
+    break;
152 152
 case 'languages':
153
-	$controller->setPageTitle(I18N::translate('Languages'));
154
-	break;
153
+    $controller->setPageTitle(I18N::translate('Languages'));
154
+    break;
155 155
 default:
156
-	header('Location: ' . WT_BASE_URL . 'admin.php');
156
+    header('Location: ' . WT_BASE_URL . 'admin.php');
157 157
 
158
-	return;
158
+    return;
159 159
 }
160 160
 
161 161
 $controller->pageHeader();
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 			<input type="text" class="form-control" id="MAX_EXECUTION_TIME" name="MAX_EXECUTION_TIME" value="<?php echo Filter::escapeHtml(Site::getPreference('MAX_EXECUTION_TIME')) ?>" pattern="[0-9]*" placeholder="<?php echo get_cfg_var('max_execution_time') ?>" maxlength="255">
222 222
 			<p class="small text-muted">
223 223
 				<?php echo I18N::plural(
224
-					'By default, your server allows scripts to run for %s second.',
225
-					'By default, your server allows scripts to run for %s seconds.',
226
-					get_cfg_var('max_execution_time'), I18N::number(get_cfg_var('max_execution_time')));
227
-				?>
224
+                    'By default, your server allows scripts to run for %s second.',
225
+                    'By default, your server allows scripts to run for %s seconds.',
226
+                    get_cfg_var('max_execution_time'), I18N::number(get_cfg_var('max_execution_time')));
227
+                ?>
228 228
 				<?php echo I18N::translate('You can request a higher or lower limit, although the server may ignore this request.') ?>
229 229
 				<?php echo I18N::translate('Leave this blank to use the default value.') ?>
230 230
 			</p>
Please login to merge, or discard this patch.
Switch Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -25,85 +25,85 @@
 block discarded – undo
25 25
 $controller->restrictAccess(Auth::isAdmin());
26 26
 
27 27
 switch (Filter::post('action')) {
28
-case 'site':
29
-	if (Filter::checkCsrf()) {
30
-		$INDEX_DIRECTORY = Filter::post('INDEX_DIRECTORY');
31
-		if (substr($INDEX_DIRECTORY, -1) !== '/') {
32
-			$INDEX_DIRECTORY .= '/';
33
-		}
34
-		if (File::mkdir($INDEX_DIRECTORY)) {
35
-			Site::setPreference('INDEX_DIRECTORY', $INDEX_DIRECTORY);
36
-		} else {
37
-			FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Filter::escapeHtml($INDEX_DIRECTORY)), 'danger');
38
-		}
39
-		Site::setPreference('MEMORY_LIMIT', Filter::post('MEMORY_LIMIT'));
40
-		Site::setPreference('MAX_EXECUTION_TIME', Filter::post('MAX_EXECUTION_TIME'));
41
-		Site::setPreference('ALLOW_USER_THEMES', Filter::postBool('ALLOW_USER_THEMES'));
42
-		Site::setPreference('THEME_DIR', Filter::post('THEME_DIR'));
43
-		Site::setPreference('ALLOW_CHANGE_GEDCOM', Filter::postBool('ALLOW_CHANGE_GEDCOM'));
44
-		Site::setPreference('SESSION_TIME', Filter::post('SESSION_TIME'));
45
-		Site::setPreference('SERVER_URL', Filter::post('SERVER_URL'));
46
-		Site::setPreference('TIMEZONE', Filter::post('TIMEZONE'));
47
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
48
-	}
49
-	header('Location: ' . WT_BASE_URL . 'admin.php');
50
-
51
-	return;
52
-
53
-case 'email':
54
-	if (Filter::checkCsrf()) {
55
-		Site::setPreference('SMTP_ACTIVE', Filter::post('SMTP_ACTIVE'));
56
-		Site::setPreference('SMTP_FROM_NAME', Filter::post('SMTP_FROM_NAME'));
57
-		Site::setPreference('SMTP_HOST', Filter::post('SMTP_HOST'));
58
-		Site::setPreference('SMTP_PORT', Filter::post('SMTP_PORT'));
59
-		Site::setPreference('SMTP_AUTH', Filter::post('SMTP_AUTH'));
60
-		Site::setPreference('SMTP_AUTH_USER', Filter::post('SMTP_AUTH_USER'));
61
-		Site::setPreference('SMTP_SSL', Filter::post('SMTP_SSL'));
62
-		Site::setPreference('SMTP_HELO', Filter::post('SMTP_HELO'));
63
-		if (Filter::post('SMTP_AUTH_PASS')) {
64
-			Site::setPreference('SMTP_AUTH_PASS', Filter::post('SMTP_AUTH_PASS'));
65
-		}
66
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
67
-	}
68
-	header('Location: ' . WT_BASE_URL . 'admin.php');
69
-
70
-	return;
71
-case 'login':
72
-	if (Filter::checkCsrf()) {
73
-		Site::setPreference('LOGIN_URL', Filter::post('LOGIN_URL'));
74
-		Site::setPreference('WELCOME_TEXT_AUTH_MODE', Filter::post('WELCOME_TEXT_AUTH_MODE'));
75
-		Site::setPreference('WELCOME_TEXT_AUTH_MODE_' . WT_LOCALE, Filter::post('WELCOME_TEXT_AUTH_MODE_4'));
76
-		Site::setPreference('USE_REGISTRATION_MODULE', Filter::post('USE_REGISTRATION_MODULE'));
77
-		Site::setPreference('SHOW_REGISTER_CAUTION', Filter::post('SHOW_REGISTER_CAUTION'));
78
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
79
-	}
80
-	header('Location: ' . WT_BASE_URL . 'admin.php');
81
-
82
-	return;
83
-
84
-case 'tracking':
85
-	if (Filter::checkCsrf()) {
86
-		Site::setPreference('BING_WEBMASTER_ID', Filter::post('BING_WEBMASTER_ID'));
87
-		Site::setPreference('GOOGLE_WEBMASTER_ID', Filter::post('GOOGLE_WEBMASTER_ID'));
88
-		Site::setPreference('GOOGLE_ANALYTICS_ID', Filter::post('GOOGLE_ANALYTICS_ID'));
89
-		Site::setPreference('PIWIK_URL', Filter::post('PIWIK_URL'));
90
-		Site::setPreference('PIWIK_SITE_ID', Filter::post('PIWIK_SITE_ID'));
91
-		Site::setPreference('STATCOUNTER_PROJECT_ID', Filter::post('STATCOUNTER_PROJECT_ID'));
92
-		Site::setPreference('STATCOUNTER_SECURITY_ID', Filter::post('STATCOUNTER_SECURITY_ID'));
93
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
94
-	}
95
-	header('Location: ' . WT_BASE_URL . 'admin.php');
96
-
97
-	return;
98
-
99
-case 'languages':
100
-	if (Filter::checkCsrf()) {
101
-		Site::setPreference('LANGUAGES', implode(',', Filter::postArray('LANGUAGES')));
102
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
103
-	}
104
-	header('Location: ' . WT_BASE_URL . 'admin.php');
105
-
106
-	return;
28
+    case 'site':
29
+	    if (Filter::checkCsrf()) {
30
+		    $INDEX_DIRECTORY = Filter::post('INDEX_DIRECTORY');
31
+		    if (substr($INDEX_DIRECTORY, -1) !== '/') {
32
+			    $INDEX_DIRECTORY .= '/';
33
+		    }
34
+		    if (File::mkdir($INDEX_DIRECTORY)) {
35
+			    Site::setPreference('INDEX_DIRECTORY', $INDEX_DIRECTORY);
36
+		    } else {
37
+			    FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Filter::escapeHtml($INDEX_DIRECTORY)), 'danger');
38
+		    }
39
+		    Site::setPreference('MEMORY_LIMIT', Filter::post('MEMORY_LIMIT'));
40
+		    Site::setPreference('MAX_EXECUTION_TIME', Filter::post('MAX_EXECUTION_TIME'));
41
+		    Site::setPreference('ALLOW_USER_THEMES', Filter::postBool('ALLOW_USER_THEMES'));
42
+		    Site::setPreference('THEME_DIR', Filter::post('THEME_DIR'));
43
+		    Site::setPreference('ALLOW_CHANGE_GEDCOM', Filter::postBool('ALLOW_CHANGE_GEDCOM'));
44
+		    Site::setPreference('SESSION_TIME', Filter::post('SESSION_TIME'));
45
+		    Site::setPreference('SERVER_URL', Filter::post('SERVER_URL'));
46
+		    Site::setPreference('TIMEZONE', Filter::post('TIMEZONE'));
47
+		    FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
48
+	    }
49
+	    header('Location: ' . WT_BASE_URL . 'admin.php');
50
+
51
+	    return;
52
+
53
+    case 'email':
54
+	    if (Filter::checkCsrf()) {
55
+		    Site::setPreference('SMTP_ACTIVE', Filter::post('SMTP_ACTIVE'));
56
+		    Site::setPreference('SMTP_FROM_NAME', Filter::post('SMTP_FROM_NAME'));
57
+		    Site::setPreference('SMTP_HOST', Filter::post('SMTP_HOST'));
58
+		    Site::setPreference('SMTP_PORT', Filter::post('SMTP_PORT'));
59
+		    Site::setPreference('SMTP_AUTH', Filter::post('SMTP_AUTH'));
60
+		    Site::setPreference('SMTP_AUTH_USER', Filter::post('SMTP_AUTH_USER'));
61
+		    Site::setPreference('SMTP_SSL', Filter::post('SMTP_SSL'));
62
+		    Site::setPreference('SMTP_HELO', Filter::post('SMTP_HELO'));
63
+		    if (Filter::post('SMTP_AUTH_PASS')) {
64
+			    Site::setPreference('SMTP_AUTH_PASS', Filter::post('SMTP_AUTH_PASS'));
65
+		    }
66
+		    FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
67
+	    }
68
+	    header('Location: ' . WT_BASE_URL . 'admin.php');
69
+
70
+	    return;
71
+    case 'login':
72
+	    if (Filter::checkCsrf()) {
73
+		    Site::setPreference('LOGIN_URL', Filter::post('LOGIN_URL'));
74
+		    Site::setPreference('WELCOME_TEXT_AUTH_MODE', Filter::post('WELCOME_TEXT_AUTH_MODE'));
75
+		    Site::setPreference('WELCOME_TEXT_AUTH_MODE_' . WT_LOCALE, Filter::post('WELCOME_TEXT_AUTH_MODE_4'));
76
+		    Site::setPreference('USE_REGISTRATION_MODULE', Filter::post('USE_REGISTRATION_MODULE'));
77
+		    Site::setPreference('SHOW_REGISTER_CAUTION', Filter::post('SHOW_REGISTER_CAUTION'));
78
+		    FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
79
+	    }
80
+	    header('Location: ' . WT_BASE_URL . 'admin.php');
81
+
82
+	    return;
83
+
84
+    case 'tracking':
85
+	    if (Filter::checkCsrf()) {
86
+		    Site::setPreference('BING_WEBMASTER_ID', Filter::post('BING_WEBMASTER_ID'));
87
+		    Site::setPreference('GOOGLE_WEBMASTER_ID', Filter::post('GOOGLE_WEBMASTER_ID'));
88
+		    Site::setPreference('GOOGLE_ANALYTICS_ID', Filter::post('GOOGLE_ANALYTICS_ID'));
89
+		    Site::setPreference('PIWIK_URL', Filter::post('PIWIK_URL'));
90
+		    Site::setPreference('PIWIK_SITE_ID', Filter::post('PIWIK_SITE_ID'));
91
+		    Site::setPreference('STATCOUNTER_PROJECT_ID', Filter::post('STATCOUNTER_PROJECT_ID'));
92
+		    Site::setPreference('STATCOUNTER_SECURITY_ID', Filter::post('STATCOUNTER_SECURITY_ID'));
93
+		    FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
94
+	    }
95
+	    header('Location: ' . WT_BASE_URL . 'admin.php');
96
+
97
+	    return;
98
+
99
+    case 'languages':
100
+	    if (Filter::checkCsrf()) {
101
+		    Site::setPreference('LANGUAGES', implode(',', Filter::postArray('LANGUAGES')));
102
+		    FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
103
+	    }
104
+	    header('Location: ' . WT_BASE_URL . 'admin.php');
105
+
106
+	    return;
107 107
 }
108 108
 
109 109
 // Lists of options for <select> controls.
Please login to merge, or discard this patch.
reportengine.php 2 patches
Indentation   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -43,80 +43,80 @@  discard block
 block discarded – undo
43 43
 $varnames = Filter::get('varnames');
44 44
 $type     = Filter::get('type');
45 45
 if (!is_array($vars)) {
46
-	$vars = array();
46
+    $vars = array();
47 47
 }
48 48
 if (!is_array($varnames)) {
49
-	$varnames = array();
49
+    $varnames = array();
50 50
 }
51 51
 if (!is_array($type)) {
52
-	$type = array();
52
+    $type = array();
53 53
 }
54 54
 
55 55
 //-- setup the arrays
56 56
 $newvars = array();
57 57
 foreach ($vars as $name => $var) {
58
-	$newvars[$name]['id'] = $var;
59
-	if (!empty($type[$name])) {
60
-		switch ($type[$name]) {
61
-		case 'INDI':
62
-			$record = Individual::getInstance($var, $WT_TREE);
63
-			if ($record && $record->canShowName()) {
64
-				$newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
65
-			} else {
66
-				$action = 'setup';
67
-			}
68
-			break;
69
-		case 'FAM':
70
-			$record = Family::getInstance($var, $WT_TREE);
71
-			if ($record && $record->canShowName()) {
72
-				$newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
73
-			} else {
74
-				$action = 'setup';
75
-			}
76
-			break;
77
-		case 'SOUR':
78
-			$record = Source::getInstance($var, $WT_TREE);
79
-			if ($record && $record->canShowName()) {
80
-				$newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
81
-			} else {
82
-				$action = 'setup';
83
-			}
84
-			break;
85
-		default:
86
-			break;
87
-		}
88
-	}
58
+    $newvars[$name]['id'] = $var;
59
+    if (!empty($type[$name])) {
60
+        switch ($type[$name]) {
61
+        case 'INDI':
62
+            $record = Individual::getInstance($var, $WT_TREE);
63
+            if ($record && $record->canShowName()) {
64
+                $newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
65
+            } else {
66
+                $action = 'setup';
67
+            }
68
+            break;
69
+        case 'FAM':
70
+            $record = Family::getInstance($var, $WT_TREE);
71
+            if ($record && $record->canShowName()) {
72
+                $newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
73
+            } else {
74
+                $action = 'setup';
75
+            }
76
+            break;
77
+        case 'SOUR':
78
+            $record = Source::getInstance($var, $WT_TREE);
79
+            if ($record && $record->canShowName()) {
80
+                $newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
81
+            } else {
82
+                $action = 'setup';
83
+            }
84
+            break;
85
+        default:
86
+            break;
87
+        }
88
+    }
89 89
 }
90 90
 $vars = $newvars;
91 91
 
92 92
 foreach ($varnames as $name) {
93
-	if (!isset($vars[$name])) {
94
-		$vars[$name]['id'] = '';
95
-	}
93
+    if (!isset($vars[$name])) {
94
+        $vars[$name]['id'] = '';
95
+    }
96 96
 }
97 97
 
98 98
 $reports = array();
99 99
 foreach (Module::getActiveReports($WT_TREE) as $rep) {
100
-	$menu = $rep->getReportMenu();
101
-	if (preg_match('/report=(' . preg_quote(WT_MODULES_DIR, '/') . '[a-z0-9_]+\/[a-z0-9_]+\.xml)/', $menu->getLink(), $match)) {
102
-		$reports[$match[1]] = $menu->getLabel();
103
-	}
100
+    $menu = $rep->getReportMenu();
101
+    if (preg_match('/report=(' . preg_quote(WT_MODULES_DIR, '/') . '[a-z0-9_]+\/[a-z0-9_]+\.xml)/', $menu->getLink(), $match)) {
102
+        $reports[$match[1]] = $menu->getLabel();
103
+    }
104 104
 }
105 105
 
106 106
 if (!empty($report)) {
107
-	if (!array_key_exists($report, $reports)) {
108
-		$action = 'choose';
109
-	}
107
+    if (!array_key_exists($report, $reports)) {
108
+        $action = 'choose';
109
+    }
110 110
 }
111 111
 
112 112
 //-- choose a report to run
113 113
 switch ($action) {
114 114
 case 'choose':
115
-	$controller
116
-		->setPageTitle(I18N::translate('Choose a report to run'))
117
-		->pageHeader();
115
+    $controller
116
+        ->setPageTitle(I18N::translate('Choose a report to run'))
117
+        ->pageHeader();
118 118
 
119
-	echo '<div id="reportengine-page">
119
+    echo '<div id="reportengine-page">
120 120
 		<h2 class="center">', I18N::translate('Choose a report to run'), '</h2>
121 121
 		<form name="choosereport" method="get" action="reportengine.php">
122 122
 		<input type="hidden" name="action" value="setup">
@@ -124,27 +124,27 @@  discard block
 block discarded – undo
124 124
 		<table class="facts_table width40">
125 125
 		<tr><td class="descriptionbox wrap width33 vmiddle">', I18N::translate('Report'), '</td>
126 126
 		<td class="optionbox"><select name="report">';
127
-	foreach ($reports as $file => $report) {
128
-		echo '<option value="', Filter::escapeHtml($file), '">', Filter::escapeHtml($report), '</option>';
129
-	}
130
-	echo '</select></td></tr>
127
+    foreach ($reports as $file => $report) {
128
+        echo '<option value="', Filter::escapeHtml($file), '">', Filter::escapeHtml($report), '</option>';
129
+    }
130
+    echo '</select></td></tr>
131 131
 		<tr><td class="topbottombar" colspan="2"><input type="submit" value="', I18N::translate('continue'), '"></td></tr>
132 132
 		</table></form></div>';
133
-	break;
133
+    break;
134 134
 
135 135
 case 'setup':
136
-	$report_setup = new ReportParserSetup($report);
137
-	$report_array = $report_setup->reportProperties();
136
+    $report_setup = new ReportParserSetup($report);
137
+    $report_array = $report_setup->reportProperties();
138 138
 
139
-	$controller
140
-		->setPageTitle($report_array['title'])
141
-		->pageHeader()
142
-		->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
143
-		->addInlineJavascript('autocomplete();');
139
+    $controller
140
+        ->setPageTitle($report_array['title'])
141
+        ->pageHeader()
142
+        ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
143
+        ->addInlineJavascript('autocomplete();');
144 144
 
145
-	FunctionsPrint::initializeCalendarPopup();
145
+    FunctionsPrint::initializeCalendarPopup();
146 146
 
147
-	echo '<div id="reportengine-page">
147
+    echo '<div id="reportengine-page">
148 148
 		<h2 class="center">', $report_array['title'], '</h2>
149 149
 		<form name="setupreport" method="get" action="reportengine.php">
150 150
 		<input type="hidden" name="action" value="run">
@@ -152,102 +152,102 @@  discard block
 block discarded – undo
152 152
 		<table class="facts_table width50">
153 153
 		<tr><td class="descriptionbox width30 wrap">', I18N::translate('Report'), '</td><td class="optionbox">', $report_array['description'], '</td></tr>';
154 154
 
155
-	if (!isset($report_array['inputs'])) {
156
-		$report_array['inputs'] = array();
157
-	}
158
-	foreach ($report_array['inputs'] as $input) {
159
-		echo '<tr><td class="descriptionbox wrap">';
160
-		echo '<input type="hidden" name="varnames[]" value="', Filter::escapeHtml($input["name"]), '">';
161
-		echo I18N::translate($input['value']), '</td><td class="optionbox">';
162
-		if (!isset($input['type'])) {
163
-			$input['type'] = 'text';
164
-		}
165
-		if (!isset($input['default'])) {
166
-			$input['default'] = '';
167
-		}
168
-		if (!isset($input['lookup'])) {
169
-			$input['lookup'] = '';
170
-		}
155
+    if (!isset($report_array['inputs'])) {
156
+        $report_array['inputs'] = array();
157
+    }
158
+    foreach ($report_array['inputs'] as $input) {
159
+        echo '<tr><td class="descriptionbox wrap">';
160
+        echo '<input type="hidden" name="varnames[]" value="', Filter::escapeHtml($input["name"]), '">';
161
+        echo I18N::translate($input['value']), '</td><td class="optionbox">';
162
+        if (!isset($input['type'])) {
163
+            $input['type'] = 'text';
164
+        }
165
+        if (!isset($input['default'])) {
166
+            $input['default'] = '';
167
+        }
168
+        if (!isset($input['lookup'])) {
169
+            $input['lookup'] = '';
170
+        }
171 171
 
172
-		if ($input['type'] == 'text') {
173
-			echo '<input';
172
+        if ($input['type'] == 'text') {
173
+            echo '<input';
174 174
 
175
-			switch ($input['lookup']) {
176
-			case 'INDI':
177
-				echo ' data-autocomplete-type="INDI"';
178
-				if (!empty($pid)) {
179
-					$input['default'] = $pid;
180
-				} else {
181
-					$input['default'] = $controller->getSignificantIndividual()->getXref();
182
-				}
183
-				break;
184
-			case 'FAM':
185
-				echo ' data-autocomplete-type="FAM"';
186
-				if (!empty($famid)) {
187
-					$input['default'] = $famid;
188
-				} else {
189
-					$input['default'] = $controller->getSignificantFamily()->getXref();
190
-				}
191
-				break;
192
-			case 'SOUR':
193
-				echo ' data-autocomplete-type="SOUR"';
194
-				if (!empty($sid)) {
195
-					$input['default'] = $sid;
196
-				}
197
-				break;
198
-			case 'DATE':
199
-				if (isset($input['default'])) {
200
-					$input['default'] = strtoupper($input['default']);
201
-				}
202
-				break;
203
-			}
175
+            switch ($input['lookup']) {
176
+            case 'INDI':
177
+                echo ' data-autocomplete-type="INDI"';
178
+                if (!empty($pid)) {
179
+                    $input['default'] = $pid;
180
+                } else {
181
+                    $input['default'] = $controller->getSignificantIndividual()->getXref();
182
+                }
183
+                break;
184
+            case 'FAM':
185
+                echo ' data-autocomplete-type="FAM"';
186
+                if (!empty($famid)) {
187
+                    $input['default'] = $famid;
188
+                } else {
189
+                    $input['default'] = $controller->getSignificantFamily()->getXref();
190
+                }
191
+                break;
192
+            case 'SOUR':
193
+                echo ' data-autocomplete-type="SOUR"';
194
+                if (!empty($sid)) {
195
+                    $input['default'] = $sid;
196
+                }
197
+                break;
198
+            case 'DATE':
199
+                if (isset($input['default'])) {
200
+                    $input['default'] = strtoupper($input['default']);
201
+                }
202
+                break;
203
+            }
204 204
 
205
-			echo ' type="text" name="vars[', Filter::escapeHtml($input['name']), ']" id="', Filter::escapeHtml($input['name']), '" value="', Filter::escapeHtml($input['default']), '" style="direction: ltr;">';
206
-		}
207
-		if ($input['type'] == 'checkbox') {
208
-			echo '<input type="checkbox" name="vars[', Filter::escapeHtml($input['name']), ']" id="', Filter::escapeHtml($input['name']), '" value="1" ';
209
-			echo $input['default'] == '1' ? 'checked' : '';
210
-			echo '>';
211
-		}
212
-		if ($input['type'] == 'select') {
213
-			echo '<select name="vars[', Filter::escapeHtml($input['name']), ']" id="', Filter::escapeHtml($input['name']), '_var">';
214
-			$options = preg_split('/[|]+/', $input['options']);
215
-			foreach ($options as $option) {
216
-				$opt                   = explode('=>', $option);
217
-				list($value, $display) = $opt;
218
-				if (preg_match('/^I18N::number\((.+?)(,([\d+]))?\)$/', $display, $match)) {
219
-					$display = I18N::number($match[1], isset($match[3]) ? $match[3] : 0);
220
-				} elseif (preg_match('/^I18N::translate\(\'(.+)\'\)$/', $display, $match)) {
221
-					$display = I18N::translate($match[1]);
222
-				} elseif (preg_match('/^I18N::translateContext\(\'(.+)\', *\'(.+)\'\)$/', $display, $match)) {
223
-					$display = I18N::translateContext($match[1], $match[2]);
224
-				}
225
-				echo '<option value="', Filter::escapeHtml($value), '" ';
226
-				if ($opt[0] == $input['default']) {
227
-					echo 'selected';
228
-				}
229
-				echo '>', Filter::escapeHtml($display), '</option>';
230
-			}
231
-			echo '</select>';
232
-		}
233
-		if (isset($input['lookup'])) {
234
-			echo '<input type="hidden" name="type[', Filter::escapeHtml($input['name']), ']" value="', Filter::escapeHtml($input['lookup']), '">';
235
-			if ($input['lookup'] == 'INDI') {
236
-				echo FunctionsPrint::printFindIndividualLink('pid');
237
-			} elseif ($input['lookup'] == 'PLAC') {
238
-				echo FunctionsPrint::printFindPlaceLink($input['name']);
239
-			} elseif ($input['lookup'] == 'FAM') {
240
-				echo FunctionsPrint::printFindFamilyLink('famid');
241
-			} elseif ($input['lookup'] == 'SOUR') {
242
-				echo FunctionsPrint::printFindSourceLink($input['name']);
243
-			} elseif ($input['lookup'] == 'DATE') {
244
-				echo ' <a href="#" onclick="cal_toggleDate(\'div_', Filter::escapeJs($input['name']), '\', \'', Filter::escapeJs($input['name']), '\'); return false;" class="icon-button_calendar" title="', I18N::translate('Select a date'), '"></a>';
245
-				echo '<div id="div_', Filter::escapeHtml($input['name']), '" style="position:absolute;visibility:hidden;background-color:white;"></div>';
246
-			}
247
-		}
248
-		echo '</td></tr>';
249
-	}
250
-	echo '<tr>
205
+            echo ' type="text" name="vars[', Filter::escapeHtml($input['name']), ']" id="', Filter::escapeHtml($input['name']), '" value="', Filter::escapeHtml($input['default']), '" style="direction: ltr;">';
206
+        }
207
+        if ($input['type'] == 'checkbox') {
208
+            echo '<input type="checkbox" name="vars[', Filter::escapeHtml($input['name']), ']" id="', Filter::escapeHtml($input['name']), '" value="1" ';
209
+            echo $input['default'] == '1' ? 'checked' : '';
210
+            echo '>';
211
+        }
212
+        if ($input['type'] == 'select') {
213
+            echo '<select name="vars[', Filter::escapeHtml($input['name']), ']" id="', Filter::escapeHtml($input['name']), '_var">';
214
+            $options = preg_split('/[|]+/', $input['options']);
215
+            foreach ($options as $option) {
216
+                $opt                   = explode('=>', $option);
217
+                list($value, $display) = $opt;
218
+                if (preg_match('/^I18N::number\((.+?)(,([\d+]))?\)$/', $display, $match)) {
219
+                    $display = I18N::number($match[1], isset($match[3]) ? $match[3] : 0);
220
+                } elseif (preg_match('/^I18N::translate\(\'(.+)\'\)$/', $display, $match)) {
221
+                    $display = I18N::translate($match[1]);
222
+                } elseif (preg_match('/^I18N::translateContext\(\'(.+)\', *\'(.+)\'\)$/', $display, $match)) {
223
+                    $display = I18N::translateContext($match[1], $match[2]);
224
+                }
225
+                echo '<option value="', Filter::escapeHtml($value), '" ';
226
+                if ($opt[0] == $input['default']) {
227
+                    echo 'selected';
228
+                }
229
+                echo '>', Filter::escapeHtml($display), '</option>';
230
+            }
231
+            echo '</select>';
232
+        }
233
+        if (isset($input['lookup'])) {
234
+            echo '<input type="hidden" name="type[', Filter::escapeHtml($input['name']), ']" value="', Filter::escapeHtml($input['lookup']), '">';
235
+            if ($input['lookup'] == 'INDI') {
236
+                echo FunctionsPrint::printFindIndividualLink('pid');
237
+            } elseif ($input['lookup'] == 'PLAC') {
238
+                echo FunctionsPrint::printFindPlaceLink($input['name']);
239
+            } elseif ($input['lookup'] == 'FAM') {
240
+                echo FunctionsPrint::printFindFamilyLink('famid');
241
+            } elseif ($input['lookup'] == 'SOUR') {
242
+                echo FunctionsPrint::printFindSourceLink($input['name']);
243
+            } elseif ($input['lookup'] == 'DATE') {
244
+                echo ' <a href="#" onclick="cal_toggleDate(\'div_', Filter::escapeJs($input['name']), '\', \'', Filter::escapeJs($input['name']), '\'); return false;" class="icon-button_calendar" title="', I18N::translate('Select a date'), '"></a>';
245
+                echo '<div id="div_', Filter::escapeHtml($input['name']), '" style="position:absolute;visibility:hidden;background-color:white;"></div>';
246
+            }
247
+        }
248
+        echo '</td></tr>';
249
+    }
250
+    echo '<tr>
251 251
 		<td colspan="2" class="optionbox">
252 252
 		<div class="report-type">
253 253
 		<div>
@@ -264,22 +264,22 @@  discard block
 block discarded – undo
264 264
 		<tr><td class="topbottombar" colspan="2">
265 265
 		<input type="submit" value="', I18N::translate('continue'), '">
266 266
 		</td></tr></table></form></div>';
267
-	break;
267
+    break;
268 268
 
269 269
 case 'run':
270
-	if (strstr($report, 'report_singlepage.xml') !== false) {
271
-		// This is a custom module?
272
-		new \ReportPedigree;
273
-		break;
274
-	}
270
+    if (strstr($report, 'report_singlepage.xml') !== false) {
271
+        // This is a custom module?
272
+        new \ReportPedigree;
273
+        break;
274
+    }
275 275
 
276
-	switch ($output) {
277
-	case 'HTML':
278
-		header('Content-type: text/html; charset=UTF-8');
279
-		new ReportParserGenerate($report, new ReportHtml, $vars);
280
-		break;
281
-	case 'PDF':
282
-		new ReportParserGenerate($report, new ReportPdf, $vars);
283
-		break;
284
-	}
276
+    switch ($output) {
277
+    case 'HTML':
278
+        header('Content-type: text/html; charset=UTF-8');
279
+        new ReportParserGenerate($report, new ReportHtml, $vars);
280
+        break;
281
+    case 'PDF':
282
+        new ReportParserGenerate($report, new ReportPdf, $vars);
283
+        break;
284
+    }
285 285
 }
Please login to merge, or discard this patch.
Switch Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -58,32 +58,32 @@  discard block
 block discarded – undo
58 58
 	$newvars[$name]['id'] = $var;
59 59
 	if (!empty($type[$name])) {
60 60
 		switch ($type[$name]) {
61
-		case 'INDI':
62
-			$record = Individual::getInstance($var, $WT_TREE);
63
-			if ($record && $record->canShowName()) {
64
-				$newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
65
-			} else {
66
-				$action = 'setup';
67
-			}
68
-			break;
69
-		case 'FAM':
70
-			$record = Family::getInstance($var, $WT_TREE);
71
-			if ($record && $record->canShowName()) {
72
-				$newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
73
-			} else {
74
-				$action = 'setup';
75
-			}
76
-			break;
77
-		case 'SOUR':
78
-			$record = Source::getInstance($var, $WT_TREE);
79
-			if ($record && $record->canShowName()) {
80
-				$newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
81
-			} else {
82
-				$action = 'setup';
83
-			}
84
-			break;
85
-		default:
86
-			break;
61
+		    case 'INDI':
62
+			    $record = Individual::getInstance($var, $WT_TREE);
63
+			    if ($record && $record->canShowName()) {
64
+				    $newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
65
+			    } else {
66
+				    $action = 'setup';
67
+			    }
68
+			    break;
69
+		    case 'FAM':
70
+			    $record = Family::getInstance($var, $WT_TREE);
71
+			    if ($record && $record->canShowName()) {
72
+				    $newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
73
+			    } else {
74
+				    $action = 'setup';
75
+			    }
76
+			    break;
77
+		    case 'SOUR':
78
+			    $record = Source::getInstance($var, $WT_TREE);
79
+			    if ($record && $record->canShowName()) {
80
+				    $newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
81
+			    } else {
82
+				    $action = 'setup';
83
+			    }
84
+			    break;
85
+		    default:
86
+			    break;
87 87
 		}
88 88
 	}
89 89
 }
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
 
112 112
 //-- choose a report to run
113 113
 switch ($action) {
114
-case 'choose':
115
-	$controller
116
-		->setPageTitle(I18N::translate('Choose a report to run'))
117
-		->pageHeader();
114
+    case 'choose':
115
+	    $controller
116
+		    ->setPageTitle(I18N::translate('Choose a report to run'))
117
+		    ->pageHeader();
118 118
 
119
-	echo '<div id="reportengine-page">
119
+	    echo '<div id="reportengine-page">
120 120
 		<h2 class="center">', I18N::translate('Choose a report to run'), '</h2>
121 121
 		<form name="choosereport" method="get" action="reportengine.php">
122 122
 		<input type="hidden" name="action" value="setup">
@@ -124,27 +124,27 @@  discard block
 block discarded – undo
124 124
 		<table class="facts_table width40">
125 125
 		<tr><td class="descriptionbox wrap width33 vmiddle">', I18N::translate('Report'), '</td>
126 126
 		<td class="optionbox"><select name="report">';
127
-	foreach ($reports as $file => $report) {
128
-		echo '<option value="', Filter::escapeHtml($file), '">', Filter::escapeHtml($report), '</option>';
129
-	}
130
-	echo '</select></td></tr>
127
+	    foreach ($reports as $file => $report) {
128
+		    echo '<option value="', Filter::escapeHtml($file), '">', Filter::escapeHtml($report), '</option>';
129
+	    }
130
+	    echo '</select></td></tr>
131 131
 		<tr><td class="topbottombar" colspan="2"><input type="submit" value="', I18N::translate('continue'), '"></td></tr>
132 132
 		</table></form></div>';
133
-	break;
133
+	    break;
134 134
 
135
-case 'setup':
136
-	$report_setup = new ReportParserSetup($report);
137
-	$report_array = $report_setup->reportProperties();
135
+    case 'setup':
136
+	    $report_setup = new ReportParserSetup($report);
137
+	    $report_array = $report_setup->reportProperties();
138 138
 
139
-	$controller
140
-		->setPageTitle($report_array['title'])
141
-		->pageHeader()
142
-		->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
143
-		->addInlineJavascript('autocomplete();');
139
+	    $controller
140
+		    ->setPageTitle($report_array['title'])
141
+		    ->pageHeader()
142
+		    ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
143
+		    ->addInlineJavascript('autocomplete();');
144 144
 
145
-	FunctionsPrint::initializeCalendarPopup();
145
+	    FunctionsPrint::initializeCalendarPopup();
146 146
 
147
-	echo '<div id="reportengine-page">
147
+	    echo '<div id="reportengine-page">
148 148
 		<h2 class="center">', $report_array['title'], '</h2>
149 149
 		<form name="setupreport" method="get" action="reportengine.php">
150 150
 		<input type="hidden" name="action" value="run">
@@ -152,55 +152,55 @@  discard block
 block discarded – undo
152 152
 		<table class="facts_table width50">
153 153
 		<tr><td class="descriptionbox width30 wrap">', I18N::translate('Report'), '</td><td class="optionbox">', $report_array['description'], '</td></tr>';
154 154
 
155
-	if (!isset($report_array['inputs'])) {
156
-		$report_array['inputs'] = array();
157
-	}
158
-	foreach ($report_array['inputs'] as $input) {
159
-		echo '<tr><td class="descriptionbox wrap">';
160
-		echo '<input type="hidden" name="varnames[]" value="', Filter::escapeHtml($input["name"]), '">';
161
-		echo I18N::translate($input['value']), '</td><td class="optionbox">';
162
-		if (!isset($input['type'])) {
163
-			$input['type'] = 'text';
164
-		}
165
-		if (!isset($input['default'])) {
166
-			$input['default'] = '';
167
-		}
168
-		if (!isset($input['lookup'])) {
169
-			$input['lookup'] = '';
170
-		}
155
+	    if (!isset($report_array['inputs'])) {
156
+		    $report_array['inputs'] = array();
157
+	    }
158
+	    foreach ($report_array['inputs'] as $input) {
159
+		    echo '<tr><td class="descriptionbox wrap">';
160
+		    echo '<input type="hidden" name="varnames[]" value="', Filter::escapeHtml($input["name"]), '">';
161
+		    echo I18N::translate($input['value']), '</td><td class="optionbox">';
162
+		    if (!isset($input['type'])) {
163
+			    $input['type'] = 'text';
164
+		    }
165
+		    if (!isset($input['default'])) {
166
+			    $input['default'] = '';
167
+		    }
168
+		    if (!isset($input['lookup'])) {
169
+			    $input['lookup'] = '';
170
+		    }
171 171
 
172
-		if ($input['type'] == 'text') {
173
-			echo '<input';
172
+		    if ($input['type'] == 'text') {
173
+			    echo '<input';
174 174
 
175
-			switch ($input['lookup']) {
176
-			case 'INDI':
177
-				echo ' data-autocomplete-type="INDI"';
178
-				if (!empty($pid)) {
179
-					$input['default'] = $pid;
180
-				} else {
181
-					$input['default'] = $controller->getSignificantIndividual()->getXref();
182
-				}
183
-				break;
184
-			case 'FAM':
185
-				echo ' data-autocomplete-type="FAM"';
186
-				if (!empty($famid)) {
187
-					$input['default'] = $famid;
188
-				} else {
189
-					$input['default'] = $controller->getSignificantFamily()->getXref();
190
-				}
191
-				break;
192
-			case 'SOUR':
193
-				echo ' data-autocomplete-type="SOUR"';
194
-				if (!empty($sid)) {
195
-					$input['default'] = $sid;
196
-				}
197
-				break;
198
-			case 'DATE':
199
-				if (isset($input['default'])) {
200
-					$input['default'] = strtoupper($input['default']);
201
-				}
202
-				break;
203
-			}
175
+			    switch ($input['lookup']) {
176
+			        case 'INDI':
177
+				        echo ' data-autocomplete-type="INDI"';
178
+				        if (!empty($pid)) {
179
+					        $input['default'] = $pid;
180
+				        } else {
181
+					        $input['default'] = $controller->getSignificantIndividual()->getXref();
182
+				        }
183
+				        break;
184
+			        case 'FAM':
185
+				        echo ' data-autocomplete-type="FAM"';
186
+				        if (!empty($famid)) {
187
+					        $input['default'] = $famid;
188
+				        } else {
189
+					        $input['default'] = $controller->getSignificantFamily()->getXref();
190
+				        }
191
+				        break;
192
+			        case 'SOUR':
193
+				        echo ' data-autocomplete-type="SOUR"';
194
+				        if (!empty($sid)) {
195
+					        $input['default'] = $sid;
196
+				        }
197
+				        break;
198
+			        case 'DATE':
199
+				        if (isset($input['default'])) {
200
+					        $input['default'] = strtoupper($input['default']);
201
+				        }
202
+				        break;
203
+			    }
204 204
 
205 205
 			echo ' type="text" name="vars[', Filter::escapeHtml($input['name']), ']" id="', Filter::escapeHtml($input['name']), '" value="', Filter::escapeHtml($input['default']), '" style="direction: ltr;">';
206 206
 		}
@@ -266,20 +266,20 @@  discard block
 block discarded – undo
266 266
 		</td></tr></table></form></div>';
267 267
 	break;
268 268
 
269
-case 'run':
270
-	if (strstr($report, 'report_singlepage.xml') !== false) {
271
-		// This is a custom module?
272
-		new \ReportPedigree;
273
-		break;
274
-	}
269
+    case 'run':
270
+	    if (strstr($report, 'report_singlepage.xml') !== false) {
271
+		    // This is a custom module?
272
+		    new \ReportPedigree;
273
+		    break;
274
+	    }
275 275
 
276
-	switch ($output) {
277
-	case 'HTML':
278
-		header('Content-type: text/html; charset=UTF-8');
279
-		new ReportParserGenerate($report, new ReportHtml, $vars);
280
-		break;
281
-	case 'PDF':
282
-		new ReportParserGenerate($report, new ReportPdf, $vars);
283
-		break;
284
-	}
276
+	    switch ($output) {
277
+	        case 'HTML':
278
+		        header('Content-type: text/html; charset=UTF-8');
279
+		        new ReportParserGenerate($report, new ReportHtml, $vars);
280
+		        break;
281
+	        case 'PDF':
282
+		        new ReportParserGenerate($report, new ReportPdf, $vars);
283
+		        break;
284
+	    }
285 285
 }
Please login to merge, or discard this patch.
relationship.php 3 patches
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -45,20 +45,20 @@  discard block
 block discarded – undo
45 45
 $person2 = Individual::getInstance($pid2, $WT_TREE);
46 46
 
47 47
 $controller
48
-	->restrictAccess(Module::isActiveChart($WT_TREE, 'relationships_chart'))
49
-	->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
50
-	->addInlineJavascript('autocomplete();');
48
+    ->restrictAccess(Module::isActiveChart($WT_TREE, 'relationships_chart'))
49
+    ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
50
+    ->addInlineJavascript('autocomplete();');
51 51
 
52 52
 if ($person1 && $person2) {
53
-	$controller
54
-		->setPageTitle(I18N::translate(/* I18N: %s are individual’s names */ 'Relationships between %1$s and %2$s', $person1->getFullName(), $person2->getFullName()))
55
-		->pageHeader();
56
-	$paths = $controller->calculateRelationships($person1, $person2, $recursion, (bool) $ancestors);
53
+    $controller
54
+        ->setPageTitle(I18N::translate(/* I18N: %s are individual’s names */ 'Relationships between %1$s and %2$s', $person1->getFullName(), $person2->getFullName()))
55
+        ->pageHeader();
56
+    $paths = $controller->calculateRelationships($person1, $person2, $recursion, (bool) $ancestors);
57 57
 } else {
58
-	$controller
59
-		->setPageTitle(I18N::translate('Relationships'))
60
-		->pageHeader();
61
-	$paths = array();
58
+    $controller
59
+        ->setPageTitle(I18N::translate('Relationships'))
60
+        ->pageHeader();
61
+    $paths = array();
62 62
 }
63 63
 
64 64
 ?>
@@ -143,102 +143,102 @@  discard block
 block discarded – undo
143 143
 <?php
144 144
 
145 145
 if ($person1 && $person2) {
146
-	if (I18N::direction() === 'ltr') {
147
-		$horizontal_arrow = '<br><i class="icon-rarrow"></i>';
148
-		$diagonal1        = Theme::theme()->parameter('image-dline');
149
-		$diagonal2        = Theme::theme()->parameter('image-dline2');
150
-	} else {
151
-		$horizontal_arrow = '<br><i class="icon-larrow"></i>';
152
-		$diagonal1        = Theme::theme()->parameter('image-dline2');
153
-		$diagonal2        = Theme::theme()->parameter('image-dline');
154
-	}
155
-	$up_arrow   = ' <i class="icon-uarrow"></i>';
156
-	$down_arrow = ' <i class="icon-darrow"></i>';
146
+    if (I18N::direction() === 'ltr') {
147
+        $horizontal_arrow = '<br><i class="icon-rarrow"></i>';
148
+        $diagonal1        = Theme::theme()->parameter('image-dline');
149
+        $diagonal2        = Theme::theme()->parameter('image-dline2');
150
+    } else {
151
+        $horizontal_arrow = '<br><i class="icon-larrow"></i>';
152
+        $diagonal1        = Theme::theme()->parameter('image-dline2');
153
+        $diagonal2        = Theme::theme()->parameter('image-dline');
154
+    }
155
+    $up_arrow   = ' <i class="icon-uarrow"></i>';
156
+    $down_arrow = ' <i class="icon-darrow"></i>';
157 157
 
158
-	$num_paths = 0;
159
-	foreach ($paths as $path) {
160
-		// Extract the relationship names between pairs of individuals
161
-		$relationships = $controller->oldStyleRelationshipPath($path);
162
-		if (empty($relationships)) {
163
-			// Cannot see one of the families/individuals, due to privacy;
164
-			continue;
165
-		}
166
-		echo '<h3>', I18N::translate('Relationship: %s', Functions::getRelationshipNameFromPath(implode('', $relationships), $person1, $person2)), '</h3>';
167
-		$num_paths++;
158
+    $num_paths = 0;
159
+    foreach ($paths as $path) {
160
+        // Extract the relationship names between pairs of individuals
161
+        $relationships = $controller->oldStyleRelationshipPath($path);
162
+        if (empty($relationships)) {
163
+            // Cannot see one of the families/individuals, due to privacy;
164
+            continue;
165
+        }
166
+        echo '<h3>', I18N::translate('Relationship: %s', Functions::getRelationshipNameFromPath(implode('', $relationships), $person1, $person2)), '</h3>';
167
+        $num_paths++;
168 168
 
169
-		// Use a table/grid for layout.
170
-		$table = array();
171
-		// Current position in the grid.
172
-		$x     = 0;
173
-		$y     = 0;
174
-		// Extent of the grid.
175
-		$min_y = 0;
176
-		$max_y = 0;
177
-		$max_x = 0;
178
-		// For each node in the path.
179
-		foreach ($path as $n => $xref) {
180
-			if ($n % 2 === 1) {
181
-				switch ($relationships[$n]) {
182
-				case 'hus':
183
-				case 'wif':
184
-				case 'spo':
185
-				case 'bro':
186
-				case 'sis':
187
-				case 'sib':
188
-					$table[$x + 1][$y] = '<div style="background:url(' . Theme::theme()->parameter('image-hline') . ') repeat-x center;  width: 94px; text-align: center"><div class="hline-text" style="height: 32px;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="height: 32px;">' . $horizontal_arrow . '</div></div>';
189
-					$x += 2;
190
-					break;
191
-				case 'son':
192
-				case 'dau':
193
-				case 'chi':
194
-					if ($n > 2 && preg_match('/fat|mot|par/', $relationships[$n - 2])) {
195
-						$table[$x + 1][$y - 1] = '<div style="background:url(' . $diagonal2 . '); width: 64px; height: 64px; text-align: center;"><div style="height: 32px; text-align: end;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="height: 32px; text-align: start;">' . $down_arrow . '</div></div>';
196
-						$x += 2;
197
-					} else {
198
-						$table[$x][$y - 1] = '<div style="background:url(' . Theme::theme()
199
-								->parameter('image-vline') . ') repeat-y center; height: 64px; text-align: center;"><div class="vline-text" style="display: inline-block; width:50%; line-height: 64px;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="display: inline-block; width:50%; line-height: 64px;">' . $down_arrow . '</div></div>';
200
-					}
201
-					$y -= 2;
202
-					break;
203
-				case 'fat':
204
-				case 'mot':
205
-				case 'par':
206
-					if ($n > 2 && preg_match('/son|dau|chi/', $relationships[$n - 2])) {
207
-						$table[$x + 1][$y + 1] = '<div style="background:url(' . $diagonal1 . '); background-position: top right; width: 64px; height: 64px; text-align: center;"><div style="height: 32px; text-align: start;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="height: 32px; text-align: end;">' . $up_arrow . '</div></div>';
208
-						$x += 2;
209
-					} else {
210
-						$table[$x][$y + 1] = '<div style="background:url(' . Theme::theme()
211
-								->parameter('image-vline') . ') repeat-y center; height: 64px; text-align:center; "><div class="vline-text" style="display: inline-block; width: 50%; line-height: 32px;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="display: inline-block; width: 50%; line-height: 32px">' . $up_arrow . '</div></div>';
212
-					}
213
-					$y += 2;
214
-					break;
215
-				}
216
-				$max_x = max($max_x, $x);
217
-				$min_y = min($min_y, $y);
218
-				$max_y = max($max_y, $y);
219
-			} else {
220
-				$individual = Individual::getInstance($xref, $WT_TREE);
221
-				ob_start();
222
-				FunctionsPrint::printPedigreePerson($individual, $show_full);
223
-				$table[$x][$y] = ob_get_clean();
224
-			}
225
-		}
226
-		echo '<table id="relationship-page" style="border-collapse: collapse; margin: 20px 50px;">';
227
-		for ($y = $max_y; $y >= $min_y; --$y) {
228
-			echo '<tr>';
229
-			for ($x = 0; $x <= $max_x; ++$x) {
230
-				echo '<td style="padding: 0;">';
231
-				if (isset($table[$x][$y])) {
232
-					echo $table[$x][$y];
233
-				}
234
-				echo '</td>';
235
-			}
236
-			echo '</tr>';
237
-		}
238
-		echo '</table>';
239
-	}
169
+        // Use a table/grid for layout.
170
+        $table = array();
171
+        // Current position in the grid.
172
+        $x     = 0;
173
+        $y     = 0;
174
+        // Extent of the grid.
175
+        $min_y = 0;
176
+        $max_y = 0;
177
+        $max_x = 0;
178
+        // For each node in the path.
179
+        foreach ($path as $n => $xref) {
180
+            if ($n % 2 === 1) {
181
+                switch ($relationships[$n]) {
182
+                case 'hus':
183
+                case 'wif':
184
+                case 'spo':
185
+                case 'bro':
186
+                case 'sis':
187
+                case 'sib':
188
+                    $table[$x + 1][$y] = '<div style="background:url(' . Theme::theme()->parameter('image-hline') . ') repeat-x center;  width: 94px; text-align: center"><div class="hline-text" style="height: 32px;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="height: 32px;">' . $horizontal_arrow . '</div></div>';
189
+                    $x += 2;
190
+                    break;
191
+                case 'son':
192
+                case 'dau':
193
+                case 'chi':
194
+                    if ($n > 2 && preg_match('/fat|mot|par/', $relationships[$n - 2])) {
195
+                        $table[$x + 1][$y - 1] = '<div style="background:url(' . $diagonal2 . '); width: 64px; height: 64px; text-align: center;"><div style="height: 32px; text-align: end;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="height: 32px; text-align: start;">' . $down_arrow . '</div></div>';
196
+                        $x += 2;
197
+                    } else {
198
+                        $table[$x][$y - 1] = '<div style="background:url(' . Theme::theme()
199
+                                ->parameter('image-vline') . ') repeat-y center; height: 64px; text-align: center;"><div class="vline-text" style="display: inline-block; width:50%; line-height: 64px;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="display: inline-block; width:50%; line-height: 64px;">' . $down_arrow . '</div></div>';
200
+                    }
201
+                    $y -= 2;
202
+                    break;
203
+                case 'fat':
204
+                case 'mot':
205
+                case 'par':
206
+                    if ($n > 2 && preg_match('/son|dau|chi/', $relationships[$n - 2])) {
207
+                        $table[$x + 1][$y + 1] = '<div style="background:url(' . $diagonal1 . '); background-position: top right; width: 64px; height: 64px; text-align: center;"><div style="height: 32px; text-align: start;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="height: 32px; text-align: end;">' . $up_arrow . '</div></div>';
208
+                        $x += 2;
209
+                    } else {
210
+                        $table[$x][$y + 1] = '<div style="background:url(' . Theme::theme()
211
+                                ->parameter('image-vline') . ') repeat-y center; height: 64px; text-align:center; "><div class="vline-text" style="display: inline-block; width: 50%; line-height: 32px;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="display: inline-block; width: 50%; line-height: 32px">' . $up_arrow . '</div></div>';
212
+                    }
213
+                    $y += 2;
214
+                    break;
215
+                }
216
+                $max_x = max($max_x, $x);
217
+                $min_y = min($min_y, $y);
218
+                $max_y = max($max_y, $y);
219
+            } else {
220
+                $individual = Individual::getInstance($xref, $WT_TREE);
221
+                ob_start();
222
+                FunctionsPrint::printPedigreePerson($individual, $show_full);
223
+                $table[$x][$y] = ob_get_clean();
224
+            }
225
+        }
226
+        echo '<table id="relationship-page" style="border-collapse: collapse; margin: 20px 50px;">';
227
+        for ($y = $max_y; $y >= $min_y; --$y) {
228
+            echo '<tr>';
229
+            for ($x = 0; $x <= $max_x; ++$x) {
230
+                echo '<td style="padding: 0;">';
231
+                if (isset($table[$x][$y])) {
232
+                    echo $table[$x][$y];
233
+                }
234
+                echo '</td>';
235
+            }
236
+            echo '</tr>';
237
+        }
238
+        echo '</table>';
239
+    }
240 240
 
241
-	if (!$num_paths) {
242
-		echo '<p>', I18N::translate('No link between the two individuals could be found.'), '</p>';
243
-	}
241
+    if (!$num_paths) {
242
+        echo '<p>', I18N::translate('No link between the two individuals could be found.'), '</p>';
243
+    }
244 244
 }
Please login to merge, or discard this patch.
Switch Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -179,39 +179,39 @@
 block discarded – undo
179 179
 		foreach ($path as $n => $xref) {
180 180
 			if ($n % 2 === 1) {
181 181
 				switch ($relationships[$n]) {
182
-				case 'hus':
183
-				case 'wif':
184
-				case 'spo':
185
-				case 'bro':
186
-				case 'sis':
187
-				case 'sib':
188
-					$table[$x + 1][$y] = '<div style="background:url(' . Theme::theme()->parameter('image-hline') . ') repeat-x center;  width: 94px; text-align: center"><div class="hline-text" style="height: 32px;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="height: 32px;">' . $horizontal_arrow . '</div></div>';
189
-					$x += 2;
190
-					break;
191
-				case 'son':
192
-				case 'dau':
193
-				case 'chi':
194
-					if ($n > 2 && preg_match('/fat|mot|par/', $relationships[$n - 2])) {
195
-						$table[$x + 1][$y - 1] = '<div style="background:url(' . $diagonal2 . '); width: 64px; height: 64px; text-align: center;"><div style="height: 32px; text-align: end;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="height: 32px; text-align: start;">' . $down_arrow . '</div></div>';
196
-						$x += 2;
197
-					} else {
198
-						$table[$x][$y - 1] = '<div style="background:url(' . Theme::theme()
199
-								->parameter('image-vline') . ') repeat-y center; height: 64px; text-align: center;"><div class="vline-text" style="display: inline-block; width:50%; line-height: 64px;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="display: inline-block; width:50%; line-height: 64px;">' . $down_arrow . '</div></div>';
200
-					}
201
-					$y -= 2;
202
-					break;
203
-				case 'fat':
204
-				case 'mot':
205
-				case 'par':
206
-					if ($n > 2 && preg_match('/son|dau|chi/', $relationships[$n - 2])) {
207
-						$table[$x + 1][$y + 1] = '<div style="background:url(' . $diagonal1 . '); background-position: top right; width: 64px; height: 64px; text-align: center;"><div style="height: 32px; text-align: start;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="height: 32px; text-align: end;">' . $up_arrow . '</div></div>';
208
-						$x += 2;
209
-					} else {
210
-						$table[$x][$y + 1] = '<div style="background:url(' . Theme::theme()
211
-								->parameter('image-vline') . ') repeat-y center; height: 64px; text-align:center; "><div class="vline-text" style="display: inline-block; width: 50%; line-height: 32px;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="display: inline-block; width: 50%; line-height: 32px">' . $up_arrow . '</div></div>';
212
-					}
213
-					$y += 2;
214
-					break;
182
+				    case 'hus':
183
+				    case 'wif':
184
+				    case 'spo':
185
+				    case 'bro':
186
+				    case 'sis':
187
+				    case 'sib':
188
+					    $table[$x + 1][$y] = '<div style="background:url(' . Theme::theme()->parameter('image-hline') . ') repeat-x center;  width: 94px; text-align: center"><div class="hline-text" style="height: 32px;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="height: 32px;">' . $horizontal_arrow . '</div></div>';
189
+					    $x += 2;
190
+					    break;
191
+				    case 'son':
192
+				    case 'dau':
193
+				    case 'chi':
194
+					    if ($n > 2 && preg_match('/fat|mot|par/', $relationships[$n - 2])) {
195
+						    $table[$x + 1][$y - 1] = '<div style="background:url(' . $diagonal2 . '); width: 64px; height: 64px; text-align: center;"><div style="height: 32px; text-align: end;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="height: 32px; text-align: start;">' . $down_arrow . '</div></div>';
196
+						    $x += 2;
197
+					    } else {
198
+						    $table[$x][$y - 1] = '<div style="background:url(' . Theme::theme()
199
+								    ->parameter('image-vline') . ') repeat-y center; height: 64px; text-align: center;"><div class="vline-text" style="display: inline-block; width:50%; line-height: 64px;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="display: inline-block; width:50%; line-height: 64px;">' . $down_arrow . '</div></div>';
200
+					    }
201
+					    $y -= 2;
202
+					    break;
203
+				    case 'fat':
204
+				    case 'mot':
205
+				    case 'par':
206
+					    if ($n > 2 && preg_match('/son|dau|chi/', $relationships[$n - 2])) {
207
+						    $table[$x + 1][$y + 1] = '<div style="background:url(' . $diagonal1 . '); background-position: top right; width: 64px; height: 64px; text-align: center;"><div style="height: 32px; text-align: start;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="height: 32px; text-align: end;">' . $up_arrow . '</div></div>';
208
+						    $x += 2;
209
+					    } else {
210
+						    $table[$x][$y + 1] = '<div style="background:url(' . Theme::theme()
211
+								    ->parameter('image-vline') . ') repeat-y center; height: 64px; text-align:center; "><div class="vline-text" style="display: inline-block; width: 50%; line-height: 32px;">' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '</div><div style="display: inline-block; width: 50%; line-height: 32px">' . $up_arrow . '</div></div>';
212
+					    }
213
+					    $y += 2;
214
+					    break;
215 215
 				}
216 216
 				$max_x = max($max_x, $x);
217 217
 				$min_y = min($min_y, $y);
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -103,7 +103,8 @@  discard block
 block discarded – undo
103 103
 					<?php if ($ancestors_only === '1'): ?>
104 104
 						<input type="hidden" name="ancestors" value="1">
105 105
 						<?php echo I18N::translate('Find relationships via ancestors') ?>
106
-					<?php else: ?>
106
+					<?php else {
107
+    : ?>
107 108
 						<label>
108 109
 							<input type="radio" name="ancestors" value="0" <?php echo $ancestors == 0 ? 'checked' : '' ?>>
109 110
 							<?php echo I18N::translate('Find any relationship') ?>
@@ -113,14 +114,17 @@  discard block
 block discarded – undo
113 114
 							<input type="radio" name="ancestors" value="1" <?php echo $ancestors == 1 ? 'checked' : '' ?>>
114 115
 							<?php echo I18N::translate('Find relationships via ancestors') ?>
115 116
 						</label>
116
-					<?php endif; ?>
117
+					<?php endif;
118
+}
119
+?>
117 120
 
118 121
 					<hr>
119 122
 
120 123
 					<?php if ($max_recursion == 0): ?>
121 124
 						<?php echo I18N::translate('Find the closest relationships') ?>
122 125
 						<input type="hidden" name="recursion" value="0">
123
-					<?php else: ?>
126
+					<?php else {
127
+    : ?>
124 128
 						<label>
125 129
 							<input type="radio" name="recursion" value="0" <?php echo $recursion == 0 ? 'checked' : '' ?>>
126 130
 							<?php echo I18N::translate('Find the closest relationships') ?>
@@ -132,7 +136,9 @@  discard block
 block discarded – undo
132 136
 								<?php echo I18N::translate('Find all possible relationships') ?>
133 137
 							<?php else: ?>
134 138
 								<?php echo I18N::translate('Find other relationships') ?>
135
-							<?php endif; ?>
139
+							<?php endif;
140
+}
141
+?>
136 142
 						</label>
137 143
 					<?php endif; ?>
138 144
 				</td>
Please login to merge, or discard this patch.
fanchart.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
 global $WT_TREE;
27 27
 
28 28
 if (Filter::getBool('img')) {
29
-	header('Content-Type: image/png');
30
-	echo $controller->generateFanChart('png');
29
+    header('Content-Type: image/png');
30
+    echo $controller->generateFanChart('png');
31 31
 
32
-	return;
32
+    return;
33 33
 }
34 34
 
35 35
 $controller
36
-	->restrictAccess(Module::isActiveChart($WT_TREE, 'fan_chart'))
37
-	->pageHeader()
38
-	->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
39
-	->addInlineJavascript('
36
+    ->restrictAccess(Module::isActiveChart($WT_TREE, 'fan_chart'))
37
+    ->pageHeader()
38
+    ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
39
+    ->addInlineJavascript('
40 40
 		autocomplete();
41 41
 		var WT_FANCHART = (function() {
42 42
 			jQuery("area")
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
 <?php
120 120
 
121 121
 if ($controller->error_message) {
122
-	echo '<p class="ui-state-error">', $controller->error_message, '</p>';
122
+    echo '<p class="ui-state-error">', $controller->error_message, '</p>';
123 123
 
124
-	return;
124
+    return;
125 125
 }
126 126
 
127 127
 if ($controller->root) {
128
-	echo '<div id="fan_chart">', $controller->generateFanChart('html'), '</div>';
128
+    echo '<div id="fan_chart">', $controller->generateFanChart('html'), '</div>';
129 129
 }
130 130
 echo '</div>';
Please login to merge, or discard this patch.
descendancy.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 
33 33
 $controller = new DescendancyController;
34 34
 $controller
35
-	->restrictAccess(Module::isActiveChart($WT_TREE, 'descendancy_chart'))
36
-	->pageHeader()
37
-	->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
38
-	->addInlineJavascript('autocomplete();');
35
+    ->restrictAccess(Module::isActiveChart($WT_TREE, 'descendancy_chart'))
36
+    ->pageHeader()
37
+    ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
38
+    ->addInlineJavascript('autocomplete();');
39 39
 
40 40
 ?>
41 41
 <div id="descendancy-page"><h2><?php echo $controller->getPageTitle(); ?></h2>
@@ -93,29 +93,29 @@  discard block
 block discarded – undo
93 93
 
94 94
 <?php
95 95
 if ($controller->error_message) {
96
-	echo '<p class="ui-state-error">', $controller->error_message, '</p>';
96
+    echo '<p class="ui-state-error">', $controller->error_message, '</p>';
97 97
 } else {
98
-	switch ($controller->chart_style) {
99
-	case 0: // List
100
-		echo '<ul id="descendancy_chart" class="chart_common">';
101
-		$controller->printChildDescendancy($controller->root, $controller->generations);
102
-		echo '</ul>';
103
-		break;
104
-	case 1: // Booklet
105
-		$show_cousins = true;
106
-		echo '<div id="descendancy_booklet">';
107
-		$controller->printChildFamily($controller->root, $controller->generations);
108
-		echo '</div>';
109
-		break;
110
-	case 2: // Individual list
111
-		$descendants = $controller->individualDescendancy($controller->root, $controller->generations, array());
112
-		echo '<div id="descendancy-list">', FunctionsPrintLists::individualTable($descendants), '</div>';
113
-		break;
114
-	case 3: // Family list
115
-		$descendants = $controller->familyDescendancy($controller->root, $controller->generations, array());
116
-		echo '<div id="descendancy-list">', FunctionsPrintLists::familyTable($descendants), '</div>';
117
-		break;
118
-	}
98
+    switch ($controller->chart_style) {
99
+    case 0: // List
100
+        echo '<ul id="descendancy_chart" class="chart_common">';
101
+        $controller->printChildDescendancy($controller->root, $controller->generations);
102
+        echo '</ul>';
103
+        break;
104
+    case 1: // Booklet
105
+        $show_cousins = true;
106
+        echo '<div id="descendancy_booklet">';
107
+        $controller->printChildFamily($controller->root, $controller->generations);
108
+        echo '</div>';
109
+        break;
110
+    case 2: // Individual list
111
+        $descendants = $controller->individualDescendancy($controller->root, $controller->generations, array());
112
+        echo '<div id="descendancy-list">', FunctionsPrintLists::individualTable($descendants), '</div>';
113
+        break;
114
+    case 3: // Family list
115
+        $descendants = $controller->familyDescendancy($controller->root, $controller->generations, array());
116
+        echo '<div id="descendancy-list">', FunctionsPrintLists::familyTable($descendants), '</div>';
117
+        break;
118
+    }
119 119
 }
120 120
 ?>
121 121
 </div>
Please login to merge, or discard this patch.
Switch Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -96,25 +96,25 @@
 block discarded – undo
96 96
 	echo '<p class="ui-state-error">', $controller->error_message, '</p>';
97 97
 } else {
98 98
 	switch ($controller->chart_style) {
99
-	case 0: // List
100
-		echo '<ul id="descendancy_chart" class="chart_common">';
101
-		$controller->printChildDescendancy($controller->root, $controller->generations);
102
-		echo '</ul>';
103
-		break;
104
-	case 1: // Booklet
105
-		$show_cousins = true;
106
-		echo '<div id="descendancy_booklet">';
107
-		$controller->printChildFamily($controller->root, $controller->generations);
108
-		echo '</div>';
109
-		break;
110
-	case 2: // Individual list
111
-		$descendants = $controller->individualDescendancy($controller->root, $controller->generations, array());
112
-		echo '<div id="descendancy-list">', FunctionsPrintLists::individualTable($descendants), '</div>';
113
-		break;
114
-	case 3: // Family list
115
-		$descendants = $controller->familyDescendancy($controller->root, $controller->generations, array());
116
-		echo '<div id="descendancy-list">', FunctionsPrintLists::familyTable($descendants), '</div>';
117
-		break;
99
+	    case 0: // List
100
+		    echo '<ul id="descendancy_chart" class="chart_common">';
101
+		    $controller->printChildDescendancy($controller->root, $controller->generations);
102
+		    echo '</ul>';
103
+		    break;
104
+	    case 1: // Booklet
105
+		    $show_cousins = true;
106
+		    echo '<div id="descendancy_booklet">';
107
+		    $controller->printChildFamily($controller->root, $controller->generations);
108
+		    echo '</div>';
109
+		    break;
110
+	    case 2: // Individual list
111
+		    $descendants = $controller->individualDescendancy($controller->root, $controller->generations, array());
112
+		    echo '<div id="descendancy-list">', FunctionsPrintLists::individualTable($descendants), '</div>';
113
+		    break;
114
+	    case 3: // Family list
115
+		    $descendants = $controller->familyDescendancy($controller->root, $controller->generations, array());
116
+		    echo '<div id="descendancy-list">', FunctionsPrintLists::familyTable($descendants), '</div>';
117
+		    break;
118 118
 	}
119 119
 }
120 120
 ?>
Please login to merge, or discard this patch.
autocomplete.php 3 patches
Indentation   +498 added lines, -498 removed lines patch added patch discarded remove patch
@@ -32,470 +32,470 @@  discard block
 block discarded – undo
32 32
 
33 33
 switch ($type) {
34 34
 case 'ASSO': // Associates of an individuals, whose name contains the search terms
35
-	$data = array();
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(array(
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
-				}
68
-			}
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] = array('value' => $row->xref, 'label' => $label);
77
-		}
78
-	}
79
-	echo json_encode($data);
80
-
81
-	return;
35
+    $data = array();
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(array(
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
+                }
68
+            }
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] = array('value' => $row->xref, 'label' => $label);
77
+        }
78
+    }
79
+    echo json_encode($data);
80
+
81
+    return;
82 82
 
83 83
 case 'CEME': // Cemetery fields, that contain the search term
84
-	$data = array();
85
-	// Fetch all data, regardless of privacy
86
-	$rows = Database::prepare(
87
-		"SELECT i_id AS xref, i_gedcom AS gedcom" .
88
-		" FROM `##individuals`" .
89
-		" WHERE i_gedcom LIKE '%\n2 CEME %' AND i_file = :tree_id" .
90
-		" ORDER BY SUBSTRING_INDEX(i_gedcom, '\n2 CEME ', -1) COLLATE :collation"
91
-	)->execute(array(
92
-		'tree_id'   => $WT_TREE->getTreeId(),
93
-		'collation' => I18N::collation(),
94
-	))->fetchAll();
95
-	// Filter for privacy
96
-	foreach ($rows as $row) {
97
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
98
-		if (preg_match('/\n2 CEME (.*' . preg_quote($term, '/') . '.*)/i', $person->getGedcom(), $match)) {
99
-			if (!in_array($match[1], $data)) {
100
-				$data[] = $match[1];
101
-			}
102
-		}
103
-	}
104
-	echo json_encode($data);
105
-
106
-	return;
84
+    $data = array();
85
+    // Fetch all data, regardless of privacy
86
+    $rows = Database::prepare(
87
+        "SELECT i_id AS xref, i_gedcom AS gedcom" .
88
+        " FROM `##individuals`" .
89
+        " WHERE i_gedcom LIKE '%\n2 CEME %' AND i_file = :tree_id" .
90
+        " ORDER BY SUBSTRING_INDEX(i_gedcom, '\n2 CEME ', -1) COLLATE :collation"
91
+    )->execute(array(
92
+        'tree_id'   => $WT_TREE->getTreeId(),
93
+        'collation' => I18N::collation(),
94
+    ))->fetchAll();
95
+    // Filter for privacy
96
+    foreach ($rows as $row) {
97
+        $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
98
+        if (preg_match('/\n2 CEME (.*' . preg_quote($term, '/') . '.*)/i', $person->getGedcom(), $match)) {
99
+            if (!in_array($match[1], $data)) {
100
+                $data[] = $match[1];
101
+            }
102
+        }
103
+    }
104
+    echo json_encode($data);
105
+
106
+    return;
107 107
 
108 108
 case 'FAM': // Families, whose name contains the search terms
109
-	$data = array();
110
-	// Fetch all data, regardless of privacy
111
-	$rows = get_FAM_rows($WT_TREE, $term);
112
-	// Filter for privacy
113
-	foreach ($rows as $row) {
114
-		$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
115
-		if ($family->canShowName()) {
116
-			$marriage_year = $family->getMarriageYear();
117
-			if ($marriage_year) {
118
-				$data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>');
119
-			} else {
120
-				$data[] = array('value' => $family->getXref(), 'label' => $family->getFullName());
121
-			}
122
-		}
123
-	}
124
-	echo json_encode($data);
125
-
126
-	return;
109
+    $data = array();
110
+    // Fetch all data, regardless of privacy
111
+    $rows = get_FAM_rows($WT_TREE, $term);
112
+    // Filter for privacy
113
+    foreach ($rows as $row) {
114
+        $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
115
+        if ($family->canShowName()) {
116
+            $marriage_year = $family->getMarriageYear();
117
+            if ($marriage_year) {
118
+                $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>');
119
+            } else {
120
+                $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName());
121
+            }
122
+        }
123
+    }
124
+    echo json_encode($data);
125
+
126
+    return;
127 127
 
128 128
 case 'GIVN': // Given names, that start with the search term
129
-	// Do not filter by privacy. Given names on their own do not identify individuals.
130
-	echo json_encode(
131
-		Database::prepare(
132
-			"SELECT DISTINCT n_givn" .
133
-			" FROM `##name`" .
134
-			" WHERE n_givn LIKE CONCAT(:term, '%') AND n_file = :tree_id" .
135
-			" ORDER BY n_givn COLLATE :collation"
136
-		)->execute(array(
137
-			'term'      => $term,
138
-			'tree_id'   => $WT_TREE->getTreeId(),
139
-			'collation' => I18N::collation(),
140
-		))->fetchOneColumn()
141
-	);
142
-
143
-	return;
129
+    // Do not filter by privacy. Given names on their own do not identify individuals.
130
+    echo json_encode(
131
+        Database::prepare(
132
+            "SELECT DISTINCT n_givn" .
133
+            " FROM `##name`" .
134
+            " WHERE n_givn LIKE CONCAT(:term, '%') AND n_file = :tree_id" .
135
+            " ORDER BY n_givn COLLATE :collation"
136
+        )->execute(array(
137
+            'term'      => $term,
138
+            'tree_id'   => $WT_TREE->getTreeId(),
139
+            'collation' => I18N::collation(),
140
+        ))->fetchOneColumn()
141
+    );
142
+
143
+    return;
144 144
 
145 145
 case 'INDI': // Individuals, whose name contains the search terms
146
-	$data = array();
147
-	// Fetch all data, regardless of privacy
148
-	$rows = Database::prepare(
149
-		"SELECT i_id AS xref, i_gedcom AS gedcom, n_full" .
150
-		" FROM `##individuals`" .
151
-		" JOIN `##name` ON i_id = n_id AND i_file = n_file" .
152
-		" WHERE (n_full LIKE CONCAT('%', REPLACE(:term_1, ' ', '%'), '%') OR n_surn LIKE CONCAT('%', REPLACE(:term_2, ' ', '%'), '%')) AND i_file = :tree_id" .
153
-		" ORDER BY n_full COLLATE :collation"
154
-	)->execute(array(
155
-		'term_1'    => $term,
156
-		'term_2'    => $term,
157
-		'tree_id'   => $WT_TREE->getTreeId(),
158
-		'collation' => I18N::collation(),
159
-	))->fetchAll();
160
-	// Filter for privacy
161
-	foreach ($rows as $row) {
162
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
163
-		if ($person->canShowName()) {
164
-			$data[] = array('value' => $row->xref, 'label' => str_replace(array('@N.N.', '@P.N.'), array(I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')), $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>');
165
-		}
166
-	}
167
-	echo json_encode($data);
168
-
169
-	return;
146
+    $data = array();
147
+    // Fetch all data, regardless of privacy
148
+    $rows = Database::prepare(
149
+        "SELECT i_id AS xref, i_gedcom AS gedcom, n_full" .
150
+        " FROM `##individuals`" .
151
+        " JOIN `##name` ON i_id = n_id AND i_file = n_file" .
152
+        " WHERE (n_full LIKE CONCAT('%', REPLACE(:term_1, ' ', '%'), '%') OR n_surn LIKE CONCAT('%', REPLACE(:term_2, ' ', '%'), '%')) AND i_file = :tree_id" .
153
+        " ORDER BY n_full COLLATE :collation"
154
+    )->execute(array(
155
+        'term_1'    => $term,
156
+        'term_2'    => $term,
157
+        'tree_id'   => $WT_TREE->getTreeId(),
158
+        'collation' => I18N::collation(),
159
+    ))->fetchAll();
160
+    // Filter for privacy
161
+    foreach ($rows as $row) {
162
+        $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
163
+        if ($person->canShowName()) {
164
+            $data[] = array('value' => $row->xref, 'label' => str_replace(array('@N.N.', '@P.N.'), array(I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')), $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>');
165
+        }
166
+    }
167
+    echo json_encode($data);
168
+
169
+    return;
170 170
 
171 171
 case 'NOTE': // Notes which contain the search terms
172
-	$data = array();
173
-	// Fetch all data, regardless of privacy
174
-	$rows = get_NOTE_rows($WT_TREE, $term);
175
-	// Filter for privacy
176
-	foreach ($rows as $row) {
177
-		$note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom);
178
-		if ($note->canShowName()) {
179
-			$data[] = array('value' => $note->getXref(), 'label' => $note->getFullName());
180
-		}
181
-	}
182
-	echo json_encode($data);
183
-
184
-	return;
172
+    $data = array();
173
+    // Fetch all data, regardless of privacy
174
+    $rows = get_NOTE_rows($WT_TREE, $term);
175
+    // Filter for privacy
176
+    foreach ($rows as $row) {
177
+        $note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom);
178
+        if ($note->canShowName()) {
179
+            $data[] = array('value' => $note->getXref(), 'label' => $note->getFullName());
180
+        }
181
+    }
182
+    echo json_encode($data);
183
+
184
+    return;
185 185
 
186 186
 case 'OBJE':
187
-	$data = array();
188
-	// Fetch all data, regardless of privacy
189
-	$rows = get_OBJE_rows($WT_TREE, $term);
190
-	// Filter for privacy
191
-	foreach ($rows as $row) {
192
-		$media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
193
-		if ($media->canShowName()) {
194
-			$data[] = array('value' => $row->xref, 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName());
195
-		}
196
-	}
197
-	echo json_encode($data);
198
-
199
-	return;
187
+    $data = array();
188
+    // Fetch all data, regardless of privacy
189
+    $rows = get_OBJE_rows($WT_TREE, $term);
190
+    // Filter for privacy
191
+    foreach ($rows as $row) {
192
+        $media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
193
+        if ($media->canShowName()) {
194
+            $data[] = array('value' => $row->xref, 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName());
195
+        }
196
+    }
197
+    echo json_encode($data);
198
+
199
+    return;
200 200
 
201 201
 case 'PLAC': // Place names (with hierarchy), that include the search term
202
-	// Do not filter by privacy. Place names on their own do not identify individuals.
203
-	$data = array();
204
-	foreach (Place::findPlaces($term, $WT_TREE) as $place) {
205
-		$data[] = $place->getGedcomName();
206
-	}
207
-	if (!$data && $WT_TREE->getPreference('GEONAMES_ACCOUNT')) {
208
-		// No place found? Use an external gazetteer
209
-		$url =
210
-			"http://api.geonames.org/searchJSON" .
211
-			"?name_startsWith=" . urlencode($term) .
212
-			"&lang=" . WT_LOCALE .
213
-			"&fcode=CMTY&fcode=ADM4&fcode=PPL&fcode=PPLA&fcode=PPLC" .
214
-			"&style=full" .
215
-			"&username=" . $WT_TREE->getPreference('GEONAMES_ACCOUNT');
216
-		// try to use curl when file_get_contents not allowed
217
-		if (ini_get('allow_url_fopen')) {
218
-			$json = file_get_contents($url);
219
-		} elseif (function_exists('curl_init')) {
220
-			$ch = curl_init();
221
-			curl_setopt($ch, CURLOPT_URL, $url);
222
-			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
223
-			$json = curl_exec($ch);
224
-			curl_close($ch);
225
-		} else {
226
-			return $data;
227
-		}
228
-		$places = json_decode($json, true);
229
-		if (isset($places['geonames']) && is_array($places['geonames'])) {
230
-			foreach ($places['geonames'] as $k => $place) {
231
-				$data[] = $place['name'] . ', ' . $place['adminName2'] . ', ' . $place['adminName1'] . ', ' . $place['countryName'];
232
-			}
233
-		}
234
-	}
235
-	echo json_encode($data);
236
-
237
-	return;
202
+    // Do not filter by privacy. Place names on their own do not identify individuals.
203
+    $data = array();
204
+    foreach (Place::findPlaces($term, $WT_TREE) as $place) {
205
+        $data[] = $place->getGedcomName();
206
+    }
207
+    if (!$data && $WT_TREE->getPreference('GEONAMES_ACCOUNT')) {
208
+        // No place found? Use an external gazetteer
209
+        $url =
210
+            "http://api.geonames.org/searchJSON" .
211
+            "?name_startsWith=" . urlencode($term) .
212
+            "&lang=" . WT_LOCALE .
213
+            "&fcode=CMTY&fcode=ADM4&fcode=PPL&fcode=PPLA&fcode=PPLC" .
214
+            "&style=full" .
215
+            "&username=" . $WT_TREE->getPreference('GEONAMES_ACCOUNT');
216
+        // try to use curl when file_get_contents not allowed
217
+        if (ini_get('allow_url_fopen')) {
218
+            $json = file_get_contents($url);
219
+        } elseif (function_exists('curl_init')) {
220
+            $ch = curl_init();
221
+            curl_setopt($ch, CURLOPT_URL, $url);
222
+            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
223
+            $json = curl_exec($ch);
224
+            curl_close($ch);
225
+        } else {
226
+            return $data;
227
+        }
228
+        $places = json_decode($json, true);
229
+        if (isset($places['geonames']) && is_array($places['geonames'])) {
230
+            foreach ($places['geonames'] as $k => $place) {
231
+                $data[] = $place['name'] . ', ' . $place['adminName2'] . ', ' . $place['adminName1'] . ', ' . $place['countryName'];
232
+            }
233
+        }
234
+    }
235
+    echo json_encode($data);
236
+
237
+    return;
238 238
 
239 239
 case 'PLAC2': // Place names (without hierarchy), that include the search term
240
-	// Do not filter by privacy. Place names on their own do not identify individuals.
241
-	echo json_encode(
242
-		Database::prepare(
243
-			"SELECT p_place" .
244
-			" FROM `##places`" .
245
-			" WHERE p_place LIKE CONCAT('%', :term, '%') AND p_file = :tree_id" .
246
-			" ORDER BY p_place COLLATE :collation"
247
-		)->execute(array(
248
-			'term'      => $term,
249
-			'tree_id'   => $WT_TREE->getTreeId(),
250
-			'collation' => I18N::collation(),
251
-		))->fetchOneColumn()
252
-	);
253
-
254
-	return;
240
+    // Do not filter by privacy. Place names on their own do not identify individuals.
241
+    echo json_encode(
242
+        Database::prepare(
243
+            "SELECT p_place" .
244
+            " FROM `##places`" .
245
+            " WHERE p_place LIKE CONCAT('%', :term, '%') AND p_file = :tree_id" .
246
+            " ORDER BY p_place COLLATE :collation"
247
+        )->execute(array(
248
+            'term'      => $term,
249
+            'tree_id'   => $WT_TREE->getTreeId(),
250
+            'collation' => I18N::collation(),
251
+        ))->fetchOneColumn()
252
+    );
253
+
254
+    return;
255 255
 
256 256
 case 'REPO': // Repositories, that include the search terms
257
-	$data = array();
258
-	// Fetch all data, regardless of privacy
259
-	$rows = get_REPO_rows($WT_TREE, $term);
260
-	// Filter for privacy
261
-	foreach ($rows as $row) {
262
-		$record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
263
-		if ($record->canShowName()) {
264
-			foreach ($record->getFacts('NAME') as $fact) {
265
-				$data[] = array('value' => $record->getXref(), 'label' => $fact->getValue());
266
-			}
267
-		}
268
-	}
269
-	echo json_encode($data);
270
-
271
-	return;
257
+    $data = array();
258
+    // Fetch all data, regardless of privacy
259
+    $rows = get_REPO_rows($WT_TREE, $term);
260
+    // Filter for privacy
261
+    foreach ($rows as $row) {
262
+        $record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
263
+        if ($record->canShowName()) {
264
+            foreach ($record->getFacts('NAME') as $fact) {
265
+                $data[] = array('value' => $record->getXref(), 'label' => $fact->getValue());
266
+            }
267
+        }
268
+    }
269
+    echo json_encode($data);
270
+
271
+    return;
272 272
 
273 273
 case 'REPO_NAME': // Repository names, that include the search terms
274
-	$data = array();
275
-	// Fetch all data, regardless of privacy
276
-	$rows = get_REPO_rows($WT_TREE, $term);
277
-	// Filter for privacy
278
-	foreach ($rows as $row) {
279
-		$record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
280
-		if ($record->canShowName()) {
281
-			$data[] = strip_tags($record->getFullName());
282
-		}
283
-	}
284
-	echo json_encode($data);
285
-
286
-	return;
274
+    $data = array();
275
+    // Fetch all data, regardless of privacy
276
+    $rows = get_REPO_rows($WT_TREE, $term);
277
+    // Filter for privacy
278
+    foreach ($rows as $row) {
279
+        $record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
280
+        if ($record->canShowName()) {
281
+            $data[] = strip_tags($record->getFullName());
282
+        }
283
+    }
284
+    echo json_encode($data);
285
+
286
+    return;
287 287
 
288 288
 case 'SOUR': // Sources, that include the search terms
289
-	$data = array();
290
-	// Fetch all data, regardless of privacy
291
-	$rows = get_SOUR_rows($WT_TREE, $term);
292
-	// Filter for privacy
293
-	foreach ($rows as $row) {
294
-		$record = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
295
-		if ($record->canShowName()) {
296
-			foreach ($record->getFacts('TITL') as $fact) {
297
-				$data[] = array('value' => $record->getXref(), 'label' => $fact->getValue());
298
-			}
299
-		}
300
-	}
301
-	echo json_encode($data);
302
-
303
-	return;
289
+    $data = array();
290
+    // Fetch all data, regardless of privacy
291
+    $rows = get_SOUR_rows($WT_TREE, $term);
292
+    // Filter for privacy
293
+    foreach ($rows as $row) {
294
+        $record = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
295
+        if ($record->canShowName()) {
296
+            foreach ($record->getFacts('TITL') as $fact) {
297
+                $data[] = array('value' => $record->getXref(), 'label' => $fact->getValue());
298
+            }
299
+        }
300
+    }
301
+    echo json_encode($data);
302
+
303
+    return;
304 304
 
305 305
 case 'PAGE': // Citation details, for a given source, that contain the search term
306
-	$data = array();
307
-	$sid  = Filter::get('extra', WT_REGEX_XREF);
308
-	// Fetch all data, regardless of privacy
309
-	$rows = Database::prepare(
310
-		"SELECT i_id AS xref, i_gedcom AS gedcom" .
311
-		" FROM `##individuals`" .
312
-		" WHERE i_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND i_file = :tree_id"
313
-	)->execute(array(
314
-		'xref'    => $sid,
315
-		'term'    => $term,
316
-		'tree_id' => $WT_TREE->getTreeId(),
317
-	))->fetchAll();
318
-	// Filter for privacy
319
-	foreach ($rows as $row) {
320
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
321
-		if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) {
322
-			$data[] = $match[1];
323
-		}
324
-		if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) {
325
-			$data[] = $match[1];
326
-		}
327
-	}
328
-	// Fetch all data, regardless of privacy
329
-	$rows = Database::prepare(
330
-		"SELECT f_id AS xref, f_gedcom AS gedcom" .
331
-		" FROM `##families`" .
332
-		" WHERE f_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND f_file = :tree_id"
333
-	)->execute(array(
334
-		'xref'    => $sid,
335
-		'term'    => $term,
336
-		'tree_id' => $WT_TREE->getTreeId(),
337
-	))->fetchAll();
338
-	// Filter for privacy
339
-	foreach ($rows as $row) {
340
-		$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
341
-		if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) {
342
-			$data[] = $match[1];
343
-		}
344
-		if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) {
345
-			$data[] = $match[1];
346
-		}
347
-	}
348
-	// array_unique() converts the keys from integer to string, which breaks
349
-	// the JSON encoding - so need to call array_values() to convert them
350
-	// back into integers.
351
-	$data = array_values(array_unique($data));
352
-	echo json_encode($data);
353
-
354
-	return;
306
+    $data = array();
307
+    $sid  = Filter::get('extra', WT_REGEX_XREF);
308
+    // Fetch all data, regardless of privacy
309
+    $rows = Database::prepare(
310
+        "SELECT i_id AS xref, i_gedcom AS gedcom" .
311
+        " FROM `##individuals`" .
312
+        " WHERE i_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND i_file = :tree_id"
313
+    )->execute(array(
314
+        'xref'    => $sid,
315
+        'term'    => $term,
316
+        'tree_id' => $WT_TREE->getTreeId(),
317
+    ))->fetchAll();
318
+    // Filter for privacy
319
+    foreach ($rows as $row) {
320
+        $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
321
+        if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) {
322
+            $data[] = $match[1];
323
+        }
324
+        if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) {
325
+            $data[] = $match[1];
326
+        }
327
+    }
328
+    // Fetch all data, regardless of privacy
329
+    $rows = Database::prepare(
330
+        "SELECT f_id AS xref, f_gedcom AS gedcom" .
331
+        " FROM `##families`" .
332
+        " WHERE f_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND f_file = :tree_id"
333
+    )->execute(array(
334
+        'xref'    => $sid,
335
+        'term'    => $term,
336
+        'tree_id' => $WT_TREE->getTreeId(),
337
+    ))->fetchAll();
338
+    // Filter for privacy
339
+    foreach ($rows as $row) {
340
+        $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
341
+        if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) {
342
+            $data[] = $match[1];
343
+        }
344
+        if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) {
345
+            $data[] = $match[1];
346
+        }
347
+    }
348
+    // array_unique() converts the keys from integer to string, which breaks
349
+    // the JSON encoding - so need to call array_values() to convert them
350
+    // back into integers.
351
+    $data = array_values(array_unique($data));
352
+    echo json_encode($data);
353
+
354
+    return;
355 355
 
356 356
 case 'SOUR_TITL': // Source titles, that include the search terms
357
-	$data = array();
358
-	// Fetch all data, regardless of privacy
359
-	$rows = Database::prepare(
360
-		"SELECT s_id AS xref, s_gedcom AS gedcom, s_name" .
361
-		" FROM `##sources`" .
362
-		" WHERE s_name LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND s_file = :tree_id" .
363
-		" ORDER BY s_name COLLATE :collation"
364
-	)->execute(array(
365
-		'term'      => $term,
366
-		'tree_id'   => $WT_TREE->getTreeId(),
367
-		'collation' => I18N::collation(),
368
-	))->fetchAll();
369
-	// Filter for privacy
370
-	foreach ($rows as $row) {
371
-		$source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
372
-		if ($source->canShowName()) {
373
-			$data[] = $row->s_name;
374
-		}
375
-	}
376
-	echo json_encode($data);
377
-
378
-	return;
357
+    $data = array();
358
+    // Fetch all data, regardless of privacy
359
+    $rows = Database::prepare(
360
+        "SELECT s_id AS xref, s_gedcom AS gedcom, s_name" .
361
+        " FROM `##sources`" .
362
+        " WHERE s_name LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND s_file = :tree_id" .
363
+        " ORDER BY s_name COLLATE :collation"
364
+    )->execute(array(
365
+        'term'      => $term,
366
+        'tree_id'   => $WT_TREE->getTreeId(),
367
+        'collation' => I18N::collation(),
368
+    ))->fetchAll();
369
+    // Filter for privacy
370
+    foreach ($rows as $row) {
371
+        $source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
372
+        if ($source->canShowName()) {
373
+            $data[] = $row->s_name;
374
+        }
375
+    }
376
+    echo json_encode($data);
377
+
378
+    return;
379 379
 
380 380
 case 'SURN': // Surnames, that start with the search term
381
-	// Do not filter by privacy. Surnames on their own do not identify individuals.
382
-	echo json_encode(
383
-		Database::prepare(
384
-			"SELECT DISTINCT n_surname" .
385
-			" FROM `##name`" .
386
-			" WHERE n_surname LIKE CONCAT(:term, '%') AND n_file = :tree_id" .
387
-			" ORDER BY n_surname COLLATE :collation"
388
-		)->execute(array(
389
-			'term'      => $term,
390
-			'tree_id'   => $WT_TREE->getTreeId(),
391
-			'collation' => I18N::collation(),
392
-		))->fetchOneColumn()
393
-	);
394
-
395
-	return;
381
+    // Do not filter by privacy. Surnames on their own do not identify individuals.
382
+    echo json_encode(
383
+        Database::prepare(
384
+            "SELECT DISTINCT n_surname" .
385
+            " FROM `##name`" .
386
+            " WHERE n_surname LIKE CONCAT(:term, '%') AND n_file = :tree_id" .
387
+            " ORDER BY n_surname COLLATE :collation"
388
+        )->execute(array(
389
+            'term'      => $term,
390
+            'tree_id'   => $WT_TREE->getTreeId(),
391
+            'collation' => I18N::collation(),
392
+        ))->fetchOneColumn()
393
+    );
394
+
395
+    return;
396 396
 
397 397
 case 'IFSRO':
398
-	$data = array();
399
-	// Fetch all data, regardless of privacy
400
-	$rows = get_INDI_rows($WT_TREE, $term);
401
-	// Filter for privacy
402
-	foreach ($rows as $row) {
403
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
404
-		if ($person->canShowName()) {
405
-			$data[] = array('value' => $person->getXref(), 'label' => str_replace(array('@N.N.', '@P.N.'), array(I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')), $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>');
406
-		}
407
-	}
408
-	// Fetch all data, regardless of privacy
409
-	$rows = get_SOUR_rows($WT_TREE, $term);
410
-	// Filter for privacy
411
-	foreach ($rows as $row) {
412
-		$source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
413
-		if ($source->canShowName()) {
414
-			$data[] = array('value' => $source->getXref(), 'label' => $source->getFullName());
415
-		}
416
-	}
417
-	// Fetch all data, regardless of privacy
418
-	$rows = get_REPO_rows($WT_TREE, $term);
419
-	// Filter for privacy
420
-	foreach ($rows as $row) {
421
-		$repository = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
422
-		if ($repository->canShowName()) {
423
-			$data[] = array('value' => $repository->getXref(), 'label' => $repository->getFullName());
424
-		}
425
-	}
426
-	// Fetch all data, regardless of privacy
427
-	$rows = get_OBJE_rows($WT_TREE, $term);
428
-	// Filter for privacy
429
-	foreach ($rows as $row) {
430
-		$media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
431
-		if ($media->canShowName()) {
432
-			$data[] = array('value' => $media->getXref(), 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName());
433
-		}
434
-	}
435
-	// Fetch all data, regardless of privacy
436
-	$rows = get_FAM_rows($WT_TREE, $term);
437
-	// Filter for privacy
438
-	foreach ($rows as $row) {
439
-		$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
440
-		if ($family->canShowName()) {
441
-			$marriage_year = $family->getMarriageYear();
442
-			if ($marriage_year) {
443
-				$data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>');
444
-			} else {
445
-				$data[] = array('value' => $family->getXref(), 'label' => $family->getFullName());
446
-			}
447
-		}
448
-	}
449
-	// Fetch all data, regardless of privacy
450
-	$rows = get_NOTE_rows($WT_TREE, $term);
451
-	// Filter for privacy
452
-	foreach ($rows as $row) {
453
-		$note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom);
454
-		if ($note->canShowName()) {
455
-			$data[] = array('value' => $note->getXref(), 'label' => $note->getFullName());
456
-		}
457
-	}
458
-	echo json_encode($data);
459
-
460
-	return;
398
+    $data = array();
399
+    // Fetch all data, regardless of privacy
400
+    $rows = get_INDI_rows($WT_TREE, $term);
401
+    // Filter for privacy
402
+    foreach ($rows as $row) {
403
+        $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
404
+        if ($person->canShowName()) {
405
+            $data[] = array('value' => $person->getXref(), 'label' => str_replace(array('@N.N.', '@P.N.'), array(I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')), $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>');
406
+        }
407
+    }
408
+    // Fetch all data, regardless of privacy
409
+    $rows = get_SOUR_rows($WT_TREE, $term);
410
+    // Filter for privacy
411
+    foreach ($rows as $row) {
412
+        $source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
413
+        if ($source->canShowName()) {
414
+            $data[] = array('value' => $source->getXref(), 'label' => $source->getFullName());
415
+        }
416
+    }
417
+    // Fetch all data, regardless of privacy
418
+    $rows = get_REPO_rows($WT_TREE, $term);
419
+    // Filter for privacy
420
+    foreach ($rows as $row) {
421
+        $repository = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
422
+        if ($repository->canShowName()) {
423
+            $data[] = array('value' => $repository->getXref(), 'label' => $repository->getFullName());
424
+        }
425
+    }
426
+    // Fetch all data, regardless of privacy
427
+    $rows = get_OBJE_rows($WT_TREE, $term);
428
+    // Filter for privacy
429
+    foreach ($rows as $row) {
430
+        $media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
431
+        if ($media->canShowName()) {
432
+            $data[] = array('value' => $media->getXref(), 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName());
433
+        }
434
+    }
435
+    // Fetch all data, regardless of privacy
436
+    $rows = get_FAM_rows($WT_TREE, $term);
437
+    // Filter for privacy
438
+    foreach ($rows as $row) {
439
+        $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
440
+        if ($family->canShowName()) {
441
+            $marriage_year = $family->getMarriageYear();
442
+            if ($marriage_year) {
443
+                $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>');
444
+            } else {
445
+                $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName());
446
+            }
447
+        }
448
+    }
449
+    // Fetch all data, regardless of privacy
450
+    $rows = get_NOTE_rows($WT_TREE, $term);
451
+    // Filter for privacy
452
+    foreach ($rows as $row) {
453
+        $note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom);
454
+        if ($note->canShowName()) {
455
+            $data[] = array('value' => $note->getXref(), 'label' => $note->getFullName());
456
+        }
457
+    }
458
+    echo json_encode($data);
459
+
460
+    return;
461 461
 
462 462
 case 'IFS':
463
-	$data = array();
464
-	// Fetch all data, regardless of privacy
465
-	$rows = get_INDI_rows($WT_TREE, $term);
466
-	// Filter for privacy
467
-	foreach ($rows as $row) {
468
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
469
-		if ($person->canShowName()) {
470
-			$data[] = array('value' => $person->getXref(), 'label' => str_replace(array('@N.N.', '@P.N.'), array(I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')), $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>');
471
-		}
472
-	}
473
-	// Fetch all data, regardless of privacy
474
-	$rows = get_SOUR_rows($WT_TREE, $term);
475
-	// Filter for privacy
476
-	foreach ($rows as $row) {
477
-		$source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
478
-		if ($source->canShowName()) {
479
-			$data[] = array('value' => $source->getXref(), 'label' => $source->getFullName());
480
-		}
481
-	}
482
-	// Fetch all data, regardless of privacy
483
-	$rows = get_FAM_rows($WT_TREE, $term);
484
-	// Filter for privacy
485
-	foreach ($rows as $row) {
486
-		$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
487
-		if ($family->canShowName()) {
488
-			$marriage_year = $family->getMarriageYear();
489
-			if ($marriage_year) {
490
-				$data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>');
491
-			} else {
492
-				$data[] = array('value' => $family->getXref(), 'label' => $family->getFullName());
493
-			}
494
-		}
495
-	}
496
-	echo json_encode($data);
497
-
498
-	return;
463
+    $data = array();
464
+    // Fetch all data, regardless of privacy
465
+    $rows = get_INDI_rows($WT_TREE, $term);
466
+    // Filter for privacy
467
+    foreach ($rows as $row) {
468
+        $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
469
+        if ($person->canShowName()) {
470
+            $data[] = array('value' => $person->getXref(), 'label' => str_replace(array('@N.N.', '@P.N.'), array(I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')), $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>');
471
+        }
472
+    }
473
+    // Fetch all data, regardless of privacy
474
+    $rows = get_SOUR_rows($WT_TREE, $term);
475
+    // Filter for privacy
476
+    foreach ($rows as $row) {
477
+        $source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
478
+        if ($source->canShowName()) {
479
+            $data[] = array('value' => $source->getXref(), 'label' => $source->getFullName());
480
+        }
481
+    }
482
+    // Fetch all data, regardless of privacy
483
+    $rows = get_FAM_rows($WT_TREE, $term);
484
+    // Filter for privacy
485
+    foreach ($rows as $row) {
486
+        $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
487
+        if ($family->canShowName()) {
488
+            $marriage_year = $family->getMarriageYear();
489
+            if ($marriage_year) {
490
+                $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>');
491
+            } else {
492
+                $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName());
493
+            }
494
+        }
495
+    }
496
+    echo json_encode($data);
497
+
498
+    return;
499 499
 }
500 500
 
501 501
 /**
@@ -507,19 +507,19 @@  discard block
 block discarded – undo
507 507
  * @return \stdClass[]
508 508
  */
509 509
 function get_FAM_rows(Tree $tree, $term) {
510
-	return Database::prepare(
511
-		"SELECT DISTINCT 'FAM' AS type, f_id AS xref, f_gedcom AS gedcom, husb_name.n_sort, wife_name.n_sort" .
512
-		" FROM `##families`" .
513
-		" JOIN `##name` AS husb_name ON f_husb = husb_name.n_id AND f_file = husb_name.n_file" .
514
-		" JOIN `##name` AS wife_name ON f_wife = wife_name.n_id AND f_file = wife_name.n_file" .
515
-		" WHERE CONCAT(husb_name.n_full, ' ', wife_name.n_full) LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND f_file = :tree_id" .
516
-		" AND husb_name.n_type <> '_MARNM' AND wife_name.n_type <> '_MARNM'" .
517
-		" ORDER BY husb_name.n_sort, wife_name.n_sort COLLATE :collation"
518
-	)->execute(array(
519
-		'term'      => $term,
520
-		'tree_id'   => $tree->getTreeId(),
521
-		'collation' => I18N::collation(),
522
-	))->fetchAll();
510
+    return Database::prepare(
511
+        "SELECT DISTINCT 'FAM' AS type, f_id AS xref, f_gedcom AS gedcom, husb_name.n_sort, wife_name.n_sort" .
512
+        " FROM `##families`" .
513
+        " JOIN `##name` AS husb_name ON f_husb = husb_name.n_id AND f_file = husb_name.n_file" .
514
+        " JOIN `##name` AS wife_name ON f_wife = wife_name.n_id AND f_file = wife_name.n_file" .
515
+        " WHERE CONCAT(husb_name.n_full, ' ', wife_name.n_full) LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND f_file = :tree_id" .
516
+        " AND husb_name.n_type <> '_MARNM' AND wife_name.n_type <> '_MARNM'" .
517
+        " ORDER BY husb_name.n_sort, wife_name.n_sort COLLATE :collation"
518
+    )->execute(array(
519
+        'term'      => $term,
520
+        'tree_id'   => $tree->getTreeId(),
521
+        'collation' => I18N::collation(),
522
+    ))->fetchAll();
523 523
 }
524 524
 
525 525
 /**
@@ -531,16 +531,16 @@  discard block
 block discarded – undo
531 531
  * @return \stdClass[]
532 532
  */
533 533
 function get_INDI_rows(Tree $tree, $term) {
534
-	return Database::prepare(
535
-		"SELECT 'INDI' AS type, i_id AS xref, i_gedcom AS gedcom, n_full" .
536
-		" FROM `##individuals`" .
537
-		" JOIN `##name` ON i_id = n_id AND i_file = n_file" .
538
-		" WHERE n_full LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND i_file = :tree_id ORDER BY n_full COLLATE :collation"
539
-	)->execute(array(
540
-		'term'      => $term,
541
-		'tree_id'   => $tree->getTreeId(),
542
-		'collation' => I18N::collation(),
543
-	))->fetchAll();
534
+    return Database::prepare(
535
+        "SELECT 'INDI' AS type, i_id AS xref, i_gedcom AS gedcom, n_full" .
536
+        " FROM `##individuals`" .
537
+        " JOIN `##name` ON i_id = n_id AND i_file = n_file" .
538
+        " WHERE n_full LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND i_file = :tree_id ORDER BY n_full COLLATE :collation"
539
+    )->execute(array(
540
+        'term'      => $term,
541
+        'tree_id'   => $tree->getTreeId(),
542
+        'collation' => I18N::collation(),
543
+    ))->fetchAll();
544 544
 }
545 545
 
546 546
 /**
@@ -552,17 +552,17 @@  discard block
 block discarded – undo
552 552
  * @return \stdClass[]
553 553
  */
554 554
 function get_NOTE_rows(Tree $tree, $term) {
555
-	return Database::prepare(
556
-		"SELECT o_id AS xref, o_gedcom AS gedcom" .
557
-		" FROM `##other`" .
558
-		" JOIN `##name` ON o_id = n_id AND o_file = n_file" .
559
-		" WHERE o_gedcom LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND o_file = :tree_id AND o_type = 'NOTE'" .
560
-		" ORDER BY n_full COLLATE :collation"
561
-	)->execute(array(
562
-		'term'      => $term,
563
-		'tree_id'   => $tree->getTreeId(),
564
-		'collation' => I18N::collation(),
565
-	))->fetchAll();
555
+    return Database::prepare(
556
+        "SELECT o_id AS xref, o_gedcom AS gedcom" .
557
+        " FROM `##other`" .
558
+        " JOIN `##name` ON o_id = n_id AND o_file = n_file" .
559
+        " WHERE o_gedcom LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND o_file = :tree_id AND o_type = 'NOTE'" .
560
+        " ORDER BY n_full COLLATE :collation"
561
+    )->execute(array(
562
+        'term'      => $term,
563
+        'tree_id'   => $tree->getTreeId(),
564
+        'collation' => I18N::collation(),
565
+    ))->fetchAll();
566 566
 }
567 567
 
568 568
 /**
@@ -574,17 +574,17 @@  discard block
 block discarded – undo
574 574
  * @return \stdClass[]
575 575
  */
576 576
 function get_OBJE_rows(Tree $tree, $term) {
577
-	return Database::prepare(
578
-		"SELECT 'OBJE' AS type, m_id AS xref, m_gedcom AS gedcom" .
579
-		" FROM `##media`" .
580
-		" WHERE (m_titl LIKE CONCAT('%', REPLACE(:term_1, ' ', '%'), '%') OR m_id LIKE CONCAT('%', REPLACE(:term_2, ' ', '%'), '%')) AND m_file = :tree_id" .
581
-		" ORDER BY m_titl COLLATE :collation"
582
-	)->execute(array(
583
-		'term_1'    => $term,
584
-		'term_2'    => $term,
585
-		'tree_id'   => $tree->getTreeId(),
586
-		'collation' => I18N::collation(),
587
-	))->fetchAll();
577
+    return Database::prepare(
578
+        "SELECT 'OBJE' AS type, m_id AS xref, m_gedcom AS gedcom" .
579
+        " FROM `##media`" .
580
+        " WHERE (m_titl LIKE CONCAT('%', REPLACE(:term_1, ' ', '%'), '%') OR m_id LIKE CONCAT('%', REPLACE(:term_2, ' ', '%'), '%')) AND m_file = :tree_id" .
581
+        " ORDER BY m_titl COLLATE :collation"
582
+    )->execute(array(
583
+        'term_1'    => $term,
584
+        'term_2'    => $term,
585
+        'tree_id'   => $tree->getTreeId(),
586
+        'collation' => I18N::collation(),
587
+    ))->fetchAll();
588 588
 }
589 589
 
590 590
 /**
@@ -596,17 +596,17 @@  discard block
 block discarded – undo
596 596
  * @return \stdClass[]
597 597
  */
598 598
 function get_REPO_rows(Tree $tree, $term) {
599
-	return Database::prepare(
600
-		"SELECT o_id AS xref, o_gedcom AS gedcom" .
601
-		" FROM `##other`" .
602
-		" JOIN `##name` ON o_id = n_id AND o_file = n_file" .
603
-		" WHERE n_full LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND o_file = :tree_id AND o_type = 'REPO'" .
604
-		" ORDER BY n_full COLLATE :collation"
605
-	)->execute(array(
606
-		'term'      => $term,
607
-		'tree_id'   => $tree->getTreeId(),
608
-		'collation' => I18N::collation(),
609
-	))->fetchAll();
599
+    return Database::prepare(
600
+        "SELECT o_id AS xref, o_gedcom AS gedcom" .
601
+        " FROM `##other`" .
602
+        " JOIN `##name` ON o_id = n_id AND o_file = n_file" .
603
+        " WHERE n_full LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND o_file = :tree_id AND o_type = 'REPO'" .
604
+        " ORDER BY n_full COLLATE :collation"
605
+    )->execute(array(
606
+        'term'      => $term,
607
+        'tree_id'   => $tree->getTreeId(),
608
+        'collation' => I18N::collation(),
609
+    ))->fetchAll();
610 610
 }
611 611
 
612 612
 /**
@@ -618,14 +618,14 @@  discard block
 block discarded – undo
618 618
  * @return \stdClass[]
619 619
  */
620 620
 function get_SOUR_rows(Tree $tree, $term) {
621
-	return Database::prepare(
622
-		"SELECT s_id AS xref, s_gedcom AS gedcom" .
623
-		" FROM `##sources`" .
624
-		" WHERE s_name LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND s_file = :tree_id" .
625
-		" ORDER BY s_name COLLATE :collation"
626
-	)->execute(array(
627
-		'term'      => $term,
628
-		'tree_id'   => $tree->getTreeId(),
629
-		'collation' => I18N::collation(),
630
-	))->fetchAll();
621
+    return Database::prepare(
622
+        "SELECT s_id AS xref, s_gedcom AS gedcom" .
623
+        " FROM `##sources`" .
624
+        " WHERE s_name LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND s_file = :tree_id" .
625
+        " ORDER BY s_name COLLATE :collation"
626
+    )->execute(array(
627
+        'term'      => $term,
628
+        'tree_id'   => $tree->getTreeId(),
629
+        'collation' => I18N::collation(),
630
+    ))->fetchAll();
631 631
 }
Please login to merge, or discard this patch.
Switch Indentation   +465 added lines, -465 removed lines patch added patch discarded remove patch
@@ -31,471 +31,471 @@
 block discarded – undo
31 31
 $type = Filter::get('field');
32 32
 
33 33
 switch ($type) {
34
-case 'ASSO': // Associates of an individuals, whose name contains the search terms
35
-	$data = array();
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(array(
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
-				}
68
-			}
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] = array('value' => $row->xref, 'label' => $label);
77
-		}
78
-	}
79
-	echo json_encode($data);
80
-
81
-	return;
82
-
83
-case 'CEME': // Cemetery fields, that contain the search term
84
-	$data = array();
85
-	// Fetch all data, regardless of privacy
86
-	$rows = Database::prepare(
87
-		"SELECT i_id AS xref, i_gedcom AS gedcom" .
88
-		" FROM `##individuals`" .
89
-		" WHERE i_gedcom LIKE '%\n2 CEME %' AND i_file = :tree_id" .
90
-		" ORDER BY SUBSTRING_INDEX(i_gedcom, '\n2 CEME ', -1) COLLATE :collation"
91
-	)->execute(array(
92
-		'tree_id'   => $WT_TREE->getTreeId(),
93
-		'collation' => I18N::collation(),
94
-	))->fetchAll();
95
-	// Filter for privacy
96
-	foreach ($rows as $row) {
97
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
98
-		if (preg_match('/\n2 CEME (.*' . preg_quote($term, '/') . '.*)/i', $person->getGedcom(), $match)) {
99
-			if (!in_array($match[1], $data)) {
100
-				$data[] = $match[1];
101
-			}
102
-		}
103
-	}
104
-	echo json_encode($data);
105
-
106
-	return;
107
-
108
-case 'FAM': // Families, whose name contains the search terms
109
-	$data = array();
110
-	// Fetch all data, regardless of privacy
111
-	$rows = get_FAM_rows($WT_TREE, $term);
112
-	// Filter for privacy
113
-	foreach ($rows as $row) {
114
-		$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
115
-		if ($family->canShowName()) {
116
-			$marriage_year = $family->getMarriageYear();
117
-			if ($marriage_year) {
118
-				$data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>');
119
-			} else {
120
-				$data[] = array('value' => $family->getXref(), 'label' => $family->getFullName());
121
-			}
122
-		}
123
-	}
124
-	echo json_encode($data);
125
-
126
-	return;
127
-
128
-case 'GIVN': // Given names, that start with the search term
129
-	// Do not filter by privacy. Given names on their own do not identify individuals.
130
-	echo json_encode(
131
-		Database::prepare(
132
-			"SELECT DISTINCT n_givn" .
133
-			" FROM `##name`" .
134
-			" WHERE n_givn LIKE CONCAT(:term, '%') AND n_file = :tree_id" .
135
-			" ORDER BY n_givn COLLATE :collation"
136
-		)->execute(array(
137
-			'term'      => $term,
138
-			'tree_id'   => $WT_TREE->getTreeId(),
139
-			'collation' => I18N::collation(),
140
-		))->fetchOneColumn()
141
-	);
142
-
143
-	return;
144
-
145
-case 'INDI': // Individuals, whose name contains the search terms
146
-	$data = array();
147
-	// Fetch all data, regardless of privacy
148
-	$rows = Database::prepare(
149
-		"SELECT i_id AS xref, i_gedcom AS gedcom, n_full" .
150
-		" FROM `##individuals`" .
151
-		" JOIN `##name` ON i_id = n_id AND i_file = n_file" .
152
-		" WHERE (n_full LIKE CONCAT('%', REPLACE(:term_1, ' ', '%'), '%') OR n_surn LIKE CONCAT('%', REPLACE(:term_2, ' ', '%'), '%')) AND i_file = :tree_id" .
153
-		" ORDER BY n_full COLLATE :collation"
154
-	)->execute(array(
155
-		'term_1'    => $term,
156
-		'term_2'    => $term,
157
-		'tree_id'   => $WT_TREE->getTreeId(),
158
-		'collation' => I18N::collation(),
159
-	))->fetchAll();
160
-	// Filter for privacy
161
-	foreach ($rows as $row) {
162
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
163
-		if ($person->canShowName()) {
164
-			$data[] = array('value' => $row->xref, 'label' => str_replace(array('@N.N.', '@P.N.'), array(I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')), $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>');
165
-		}
166
-	}
167
-	echo json_encode($data);
168
-
169
-	return;
170
-
171
-case 'NOTE': // Notes which contain the search terms
172
-	$data = array();
173
-	// Fetch all data, regardless of privacy
174
-	$rows = get_NOTE_rows($WT_TREE, $term);
175
-	// Filter for privacy
176
-	foreach ($rows as $row) {
177
-		$note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom);
178
-		if ($note->canShowName()) {
179
-			$data[] = array('value' => $note->getXref(), 'label' => $note->getFullName());
180
-		}
181
-	}
182
-	echo json_encode($data);
183
-
184
-	return;
185
-
186
-case 'OBJE':
187
-	$data = array();
188
-	// Fetch all data, regardless of privacy
189
-	$rows = get_OBJE_rows($WT_TREE, $term);
190
-	// Filter for privacy
191
-	foreach ($rows as $row) {
192
-		$media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
193
-		if ($media->canShowName()) {
194
-			$data[] = array('value' => $row->xref, 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName());
195
-		}
196
-	}
197
-	echo json_encode($data);
198
-
199
-	return;
200
-
201
-case 'PLAC': // Place names (with hierarchy), that include the search term
202
-	// Do not filter by privacy. Place names on their own do not identify individuals.
203
-	$data = array();
204
-	foreach (Place::findPlaces($term, $WT_TREE) as $place) {
205
-		$data[] = $place->getGedcomName();
206
-	}
207
-	if (!$data && $WT_TREE->getPreference('GEONAMES_ACCOUNT')) {
208
-		// No place found? Use an external gazetteer
209
-		$url =
210
-			"http://api.geonames.org/searchJSON" .
211
-			"?name_startsWith=" . urlencode($term) .
212
-			"&lang=" . WT_LOCALE .
213
-			"&fcode=CMTY&fcode=ADM4&fcode=PPL&fcode=PPLA&fcode=PPLC" .
214
-			"&style=full" .
215
-			"&username=" . $WT_TREE->getPreference('GEONAMES_ACCOUNT');
216
-		// try to use curl when file_get_contents not allowed
217
-		if (ini_get('allow_url_fopen')) {
218
-			$json = file_get_contents($url);
219
-		} elseif (function_exists('curl_init')) {
220
-			$ch = curl_init();
221
-			curl_setopt($ch, CURLOPT_URL, $url);
222
-			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
223
-			$json = curl_exec($ch);
224
-			curl_close($ch);
225
-		} else {
226
-			return $data;
227
-		}
228
-		$places = json_decode($json, true);
229
-		if (isset($places['geonames']) && is_array($places['geonames'])) {
230
-			foreach ($places['geonames'] as $k => $place) {
231
-				$data[] = $place['name'] . ', ' . $place['adminName2'] . ', ' . $place['adminName1'] . ', ' . $place['countryName'];
232
-			}
233
-		}
234
-	}
235
-	echo json_encode($data);
236
-
237
-	return;
238
-
239
-case 'PLAC2': // Place names (without hierarchy), that include the search term
240
-	// Do not filter by privacy. Place names on their own do not identify individuals.
241
-	echo json_encode(
242
-		Database::prepare(
243
-			"SELECT p_place" .
244
-			" FROM `##places`" .
245
-			" WHERE p_place LIKE CONCAT('%', :term, '%') AND p_file = :tree_id" .
246
-			" ORDER BY p_place COLLATE :collation"
247
-		)->execute(array(
248
-			'term'      => $term,
249
-			'tree_id'   => $WT_TREE->getTreeId(),
250
-			'collation' => I18N::collation(),
251
-		))->fetchOneColumn()
252
-	);
253
-
254
-	return;
255
-
256
-case 'REPO': // Repositories, that include the search terms
257
-	$data = array();
258
-	// Fetch all data, regardless of privacy
259
-	$rows = get_REPO_rows($WT_TREE, $term);
260
-	// Filter for privacy
261
-	foreach ($rows as $row) {
262
-		$record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
263
-		if ($record->canShowName()) {
264
-			foreach ($record->getFacts('NAME') as $fact) {
265
-				$data[] = array('value' => $record->getXref(), 'label' => $fact->getValue());
266
-			}
267
-		}
268
-	}
269
-	echo json_encode($data);
270
-
271
-	return;
272
-
273
-case 'REPO_NAME': // Repository names, that include the search terms
274
-	$data = array();
275
-	// Fetch all data, regardless of privacy
276
-	$rows = get_REPO_rows($WT_TREE, $term);
277
-	// Filter for privacy
278
-	foreach ($rows as $row) {
279
-		$record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
280
-		if ($record->canShowName()) {
281
-			$data[] = strip_tags($record->getFullName());
282
-		}
283
-	}
284
-	echo json_encode($data);
285
-
286
-	return;
287
-
288
-case 'SOUR': // Sources, that include the search terms
289
-	$data = array();
290
-	// Fetch all data, regardless of privacy
291
-	$rows = get_SOUR_rows($WT_TREE, $term);
292
-	// Filter for privacy
293
-	foreach ($rows as $row) {
294
-		$record = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
295
-		if ($record->canShowName()) {
296
-			foreach ($record->getFacts('TITL') as $fact) {
297
-				$data[] = array('value' => $record->getXref(), 'label' => $fact->getValue());
298
-			}
299
-		}
300
-	}
301
-	echo json_encode($data);
302
-
303
-	return;
304
-
305
-case 'PAGE': // Citation details, for a given source, that contain the search term
306
-	$data = array();
307
-	$sid  = Filter::get('extra', WT_REGEX_XREF);
308
-	// Fetch all data, regardless of privacy
309
-	$rows = Database::prepare(
310
-		"SELECT i_id AS xref, i_gedcom AS gedcom" .
311
-		" FROM `##individuals`" .
312
-		" WHERE i_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND i_file = :tree_id"
313
-	)->execute(array(
314
-		'xref'    => $sid,
315
-		'term'    => $term,
316
-		'tree_id' => $WT_TREE->getTreeId(),
317
-	))->fetchAll();
318
-	// Filter for privacy
319
-	foreach ($rows as $row) {
320
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
321
-		if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) {
322
-			$data[] = $match[1];
323
-		}
324
-		if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) {
325
-			$data[] = $match[1];
326
-		}
327
-	}
328
-	// Fetch all data, regardless of privacy
329
-	$rows = Database::prepare(
330
-		"SELECT f_id AS xref, f_gedcom AS gedcom" .
331
-		" FROM `##families`" .
332
-		" WHERE f_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND f_file = :tree_id"
333
-	)->execute(array(
334
-		'xref'    => $sid,
335
-		'term'    => $term,
336
-		'tree_id' => $WT_TREE->getTreeId(),
337
-	))->fetchAll();
338
-	// Filter for privacy
339
-	foreach ($rows as $row) {
340
-		$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
341
-		if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) {
342
-			$data[] = $match[1];
343
-		}
344
-		if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) {
345
-			$data[] = $match[1];
346
-		}
347
-	}
348
-	// array_unique() converts the keys from integer to string, which breaks
349
-	// the JSON encoding - so need to call array_values() to convert them
350
-	// back into integers.
351
-	$data = array_values(array_unique($data));
352
-	echo json_encode($data);
353
-
354
-	return;
355
-
356
-case 'SOUR_TITL': // Source titles, that include the search terms
357
-	$data = array();
358
-	// Fetch all data, regardless of privacy
359
-	$rows = Database::prepare(
360
-		"SELECT s_id AS xref, s_gedcom AS gedcom, s_name" .
361
-		" FROM `##sources`" .
362
-		" WHERE s_name LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND s_file = :tree_id" .
363
-		" ORDER BY s_name COLLATE :collation"
364
-	)->execute(array(
365
-		'term'      => $term,
366
-		'tree_id'   => $WT_TREE->getTreeId(),
367
-		'collation' => I18N::collation(),
368
-	))->fetchAll();
369
-	// Filter for privacy
370
-	foreach ($rows as $row) {
371
-		$source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
372
-		if ($source->canShowName()) {
373
-			$data[] = $row->s_name;
374
-		}
375
-	}
376
-	echo json_encode($data);
377
-
378
-	return;
379
-
380
-case 'SURN': // Surnames, that start with the search term
381
-	// Do not filter by privacy. Surnames on their own do not identify individuals.
382
-	echo json_encode(
383
-		Database::prepare(
384
-			"SELECT DISTINCT n_surname" .
385
-			" FROM `##name`" .
386
-			" WHERE n_surname LIKE CONCAT(:term, '%') AND n_file = :tree_id" .
387
-			" ORDER BY n_surname COLLATE :collation"
388
-		)->execute(array(
389
-			'term'      => $term,
390
-			'tree_id'   => $WT_TREE->getTreeId(),
391
-			'collation' => I18N::collation(),
392
-		))->fetchOneColumn()
393
-	);
394
-
395
-	return;
396
-
397
-case 'IFSRO':
398
-	$data = array();
399
-	// Fetch all data, regardless of privacy
400
-	$rows = get_INDI_rows($WT_TREE, $term);
401
-	// Filter for privacy
402
-	foreach ($rows as $row) {
403
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
404
-		if ($person->canShowName()) {
405
-			$data[] = array('value' => $person->getXref(), 'label' => str_replace(array('@N.N.', '@P.N.'), array(I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')), $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>');
406
-		}
407
-	}
408
-	// Fetch all data, regardless of privacy
409
-	$rows = get_SOUR_rows($WT_TREE, $term);
410
-	// Filter for privacy
411
-	foreach ($rows as $row) {
412
-		$source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
413
-		if ($source->canShowName()) {
414
-			$data[] = array('value' => $source->getXref(), 'label' => $source->getFullName());
415
-		}
416
-	}
417
-	// Fetch all data, regardless of privacy
418
-	$rows = get_REPO_rows($WT_TREE, $term);
419
-	// Filter for privacy
420
-	foreach ($rows as $row) {
421
-		$repository = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
422
-		if ($repository->canShowName()) {
423
-			$data[] = array('value' => $repository->getXref(), 'label' => $repository->getFullName());
424
-		}
425
-	}
426
-	// Fetch all data, regardless of privacy
427
-	$rows = get_OBJE_rows($WT_TREE, $term);
428
-	// Filter for privacy
429
-	foreach ($rows as $row) {
430
-		$media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
431
-		if ($media->canShowName()) {
432
-			$data[] = array('value' => $media->getXref(), 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName());
433
-		}
434
-	}
435
-	// Fetch all data, regardless of privacy
436
-	$rows = get_FAM_rows($WT_TREE, $term);
437
-	// Filter for privacy
438
-	foreach ($rows as $row) {
439
-		$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
440
-		if ($family->canShowName()) {
441
-			$marriage_year = $family->getMarriageYear();
442
-			if ($marriage_year) {
443
-				$data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>');
444
-			} else {
445
-				$data[] = array('value' => $family->getXref(), 'label' => $family->getFullName());
446
-			}
447
-		}
448
-	}
449
-	// Fetch all data, regardless of privacy
450
-	$rows = get_NOTE_rows($WT_TREE, $term);
451
-	// Filter for privacy
452
-	foreach ($rows as $row) {
453
-		$note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom);
454
-		if ($note->canShowName()) {
455
-			$data[] = array('value' => $note->getXref(), 'label' => $note->getFullName());
456
-		}
457
-	}
458
-	echo json_encode($data);
459
-
460
-	return;
461
-
462
-case 'IFS':
463
-	$data = array();
464
-	// Fetch all data, regardless of privacy
465
-	$rows = get_INDI_rows($WT_TREE, $term);
466
-	// Filter for privacy
467
-	foreach ($rows as $row) {
468
-		$person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
469
-		if ($person->canShowName()) {
470
-			$data[] = array('value' => $person->getXref(), 'label' => str_replace(array('@N.N.', '@P.N.'), array(I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')), $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>');
471
-		}
472
-	}
473
-	// Fetch all data, regardless of privacy
474
-	$rows = get_SOUR_rows($WT_TREE, $term);
475
-	// Filter for privacy
476
-	foreach ($rows as $row) {
477
-		$source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
478
-		if ($source->canShowName()) {
479
-			$data[] = array('value' => $source->getXref(), 'label' => $source->getFullName());
480
-		}
481
-	}
482
-	// Fetch all data, regardless of privacy
483
-	$rows = get_FAM_rows($WT_TREE, $term);
484
-	// Filter for privacy
485
-	foreach ($rows as $row) {
486
-		$family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
487
-		if ($family->canShowName()) {
488
-			$marriage_year = $family->getMarriageYear();
489
-			if ($marriage_year) {
490
-				$data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>');
491
-			} else {
492
-				$data[] = array('value' => $family->getXref(), 'label' => $family->getFullName());
493
-			}
494
-		}
495
-	}
496
-	echo json_encode($data);
497
-
498
-	return;
34
+    case 'ASSO': // Associates of an individuals, whose name contains the search terms
35
+	    $data = array();
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(array(
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
+				    }
68
+			    }
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] = array('value' => $row->xref, 'label' => $label);
77
+		    }
78
+	    }
79
+	    echo json_encode($data);
80
+
81
+	    return;
82
+
83
+    case 'CEME': // Cemetery fields, that contain the search term
84
+	    $data = array();
85
+	    // Fetch all data, regardless of privacy
86
+	    $rows = Database::prepare(
87
+		    "SELECT i_id AS xref, i_gedcom AS gedcom" .
88
+		    " FROM `##individuals`" .
89
+		    " WHERE i_gedcom LIKE '%\n2 CEME %' AND i_file = :tree_id" .
90
+		    " ORDER BY SUBSTRING_INDEX(i_gedcom, '\n2 CEME ', -1) COLLATE :collation"
91
+	    )->execute(array(
92
+		    'tree_id'   => $WT_TREE->getTreeId(),
93
+		    'collation' => I18N::collation(),
94
+	    ))->fetchAll();
95
+	    // Filter for privacy
96
+	    foreach ($rows as $row) {
97
+		    $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
98
+		    if (preg_match('/\n2 CEME (.*' . preg_quote($term, '/') . '.*)/i', $person->getGedcom(), $match)) {
99
+			    if (!in_array($match[1], $data)) {
100
+				    $data[] = $match[1];
101
+			    }
102
+		    }
103
+	    }
104
+	    echo json_encode($data);
105
+
106
+	    return;
107
+
108
+    case 'FAM': // Families, whose name contains the search terms
109
+	    $data = array();
110
+	    // Fetch all data, regardless of privacy
111
+	    $rows = get_FAM_rows($WT_TREE, $term);
112
+	    // Filter for privacy
113
+	    foreach ($rows as $row) {
114
+		    $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
115
+		    if ($family->canShowName()) {
116
+			    $marriage_year = $family->getMarriageYear();
117
+			    if ($marriage_year) {
118
+				    $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>');
119
+			    } else {
120
+				    $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName());
121
+			    }
122
+		    }
123
+	    }
124
+	    echo json_encode($data);
125
+
126
+	    return;
127
+
128
+    case 'GIVN': // Given names, that start with the search term
129
+	    // Do not filter by privacy. Given names on their own do not identify individuals.
130
+	    echo json_encode(
131
+		    Database::prepare(
132
+			    "SELECT DISTINCT n_givn" .
133
+			    " FROM `##name`" .
134
+			    " WHERE n_givn LIKE CONCAT(:term, '%') AND n_file = :tree_id" .
135
+			    " ORDER BY n_givn COLLATE :collation"
136
+		    )->execute(array(
137
+			    'term'      => $term,
138
+			    'tree_id'   => $WT_TREE->getTreeId(),
139
+			    'collation' => I18N::collation(),
140
+		    ))->fetchOneColumn()
141
+	    );
142
+
143
+	    return;
144
+
145
+    case 'INDI': // Individuals, whose name contains the search terms
146
+	    $data = array();
147
+	    // Fetch all data, regardless of privacy
148
+	    $rows = Database::prepare(
149
+		    "SELECT i_id AS xref, i_gedcom AS gedcom, n_full" .
150
+		    " FROM `##individuals`" .
151
+		    " JOIN `##name` ON i_id = n_id AND i_file = n_file" .
152
+		    " WHERE (n_full LIKE CONCAT('%', REPLACE(:term_1, ' ', '%'), '%') OR n_surn LIKE CONCAT('%', REPLACE(:term_2, ' ', '%'), '%')) AND i_file = :tree_id" .
153
+		    " ORDER BY n_full COLLATE :collation"
154
+	    )->execute(array(
155
+		    'term_1'    => $term,
156
+		    'term_2'    => $term,
157
+		    'tree_id'   => $WT_TREE->getTreeId(),
158
+		    'collation' => I18N::collation(),
159
+	    ))->fetchAll();
160
+	    // Filter for privacy
161
+	    foreach ($rows as $row) {
162
+		    $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
163
+		    if ($person->canShowName()) {
164
+			    $data[] = array('value' => $row->xref, 'label' => str_replace(array('@N.N.', '@P.N.'), array(I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')), $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>');
165
+		    }
166
+	    }
167
+	    echo json_encode($data);
168
+
169
+	    return;
170
+
171
+    case 'NOTE': // Notes which contain the search terms
172
+	    $data = array();
173
+	    // Fetch all data, regardless of privacy
174
+	    $rows = get_NOTE_rows($WT_TREE, $term);
175
+	    // Filter for privacy
176
+	    foreach ($rows as $row) {
177
+		    $note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom);
178
+		    if ($note->canShowName()) {
179
+			    $data[] = array('value' => $note->getXref(), 'label' => $note->getFullName());
180
+		    }
181
+	    }
182
+	    echo json_encode($data);
183
+
184
+	    return;
185
+
186
+    case 'OBJE':
187
+	    $data = array();
188
+	    // Fetch all data, regardless of privacy
189
+	    $rows = get_OBJE_rows($WT_TREE, $term);
190
+	    // Filter for privacy
191
+	    foreach ($rows as $row) {
192
+		    $media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
193
+		    if ($media->canShowName()) {
194
+			    $data[] = array('value' => $row->xref, 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName());
195
+		    }
196
+	    }
197
+	    echo json_encode($data);
198
+
199
+	    return;
200
+
201
+    case 'PLAC': // Place names (with hierarchy), that include the search term
202
+	    // Do not filter by privacy. Place names on their own do not identify individuals.
203
+	    $data = array();
204
+	    foreach (Place::findPlaces($term, $WT_TREE) as $place) {
205
+		    $data[] = $place->getGedcomName();
206
+	    }
207
+	    if (!$data && $WT_TREE->getPreference('GEONAMES_ACCOUNT')) {
208
+		    // No place found? Use an external gazetteer
209
+		    $url =
210
+			    "http://api.geonames.org/searchJSON" .
211
+			    "?name_startsWith=" . urlencode($term) .
212
+			    "&lang=" . WT_LOCALE .
213
+			    "&fcode=CMTY&fcode=ADM4&fcode=PPL&fcode=PPLA&fcode=PPLC" .
214
+			    "&style=full" .
215
+			    "&username=" . $WT_TREE->getPreference('GEONAMES_ACCOUNT');
216
+		    // try to use curl when file_get_contents not allowed
217
+		    if (ini_get('allow_url_fopen')) {
218
+			    $json = file_get_contents($url);
219
+		    } elseif (function_exists('curl_init')) {
220
+			    $ch = curl_init();
221
+			    curl_setopt($ch, CURLOPT_URL, $url);
222
+			    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
223
+			    $json = curl_exec($ch);
224
+			    curl_close($ch);
225
+		    } else {
226
+			    return $data;
227
+		    }
228
+		    $places = json_decode($json, true);
229
+		    if (isset($places['geonames']) && is_array($places['geonames'])) {
230
+			    foreach ($places['geonames'] as $k => $place) {
231
+				    $data[] = $place['name'] . ', ' . $place['adminName2'] . ', ' . $place['adminName1'] . ', ' . $place['countryName'];
232
+			    }
233
+		    }
234
+	    }
235
+	    echo json_encode($data);
236
+
237
+	    return;
238
+
239
+    case 'PLAC2': // Place names (without hierarchy), that include the search term
240
+	    // Do not filter by privacy. Place names on their own do not identify individuals.
241
+	    echo json_encode(
242
+		    Database::prepare(
243
+			    "SELECT p_place" .
244
+			    " FROM `##places`" .
245
+			    " WHERE p_place LIKE CONCAT('%', :term, '%') AND p_file = :tree_id" .
246
+			    " ORDER BY p_place COLLATE :collation"
247
+		    )->execute(array(
248
+			    'term'      => $term,
249
+			    'tree_id'   => $WT_TREE->getTreeId(),
250
+			    'collation' => I18N::collation(),
251
+		    ))->fetchOneColumn()
252
+	    );
253
+
254
+	    return;
255
+
256
+    case 'REPO': // Repositories, that include the search terms
257
+	    $data = array();
258
+	    // Fetch all data, regardless of privacy
259
+	    $rows = get_REPO_rows($WT_TREE, $term);
260
+	    // Filter for privacy
261
+	    foreach ($rows as $row) {
262
+		    $record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
263
+		    if ($record->canShowName()) {
264
+			    foreach ($record->getFacts('NAME') as $fact) {
265
+				    $data[] = array('value' => $record->getXref(), 'label' => $fact->getValue());
266
+			    }
267
+		    }
268
+	    }
269
+	    echo json_encode($data);
270
+
271
+	    return;
272
+
273
+    case 'REPO_NAME': // Repository names, that include the search terms
274
+	    $data = array();
275
+	    // Fetch all data, regardless of privacy
276
+	    $rows = get_REPO_rows($WT_TREE, $term);
277
+	    // Filter for privacy
278
+	    foreach ($rows as $row) {
279
+		    $record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
280
+		    if ($record->canShowName()) {
281
+			    $data[] = strip_tags($record->getFullName());
282
+		    }
283
+	    }
284
+	    echo json_encode($data);
285
+
286
+	    return;
287
+
288
+    case 'SOUR': // Sources, that include the search terms
289
+	    $data = array();
290
+	    // Fetch all data, regardless of privacy
291
+	    $rows = get_SOUR_rows($WT_TREE, $term);
292
+	    // Filter for privacy
293
+	    foreach ($rows as $row) {
294
+		    $record = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
295
+		    if ($record->canShowName()) {
296
+			    foreach ($record->getFacts('TITL') as $fact) {
297
+				    $data[] = array('value' => $record->getXref(), 'label' => $fact->getValue());
298
+			    }
299
+		    }
300
+	    }
301
+	    echo json_encode($data);
302
+
303
+	    return;
304
+
305
+    case 'PAGE': // Citation details, for a given source, that contain the search term
306
+	    $data = array();
307
+	    $sid  = Filter::get('extra', WT_REGEX_XREF);
308
+	    // Fetch all data, regardless of privacy
309
+	    $rows = Database::prepare(
310
+		    "SELECT i_id AS xref, i_gedcom AS gedcom" .
311
+		    " FROM `##individuals`" .
312
+		    " WHERE i_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND i_file = :tree_id"
313
+	    )->execute(array(
314
+		    'xref'    => $sid,
315
+		    'term'    => $term,
316
+		    'tree_id' => $WT_TREE->getTreeId(),
317
+	    ))->fetchAll();
318
+	    // Filter for privacy
319
+	    foreach ($rows as $row) {
320
+		    $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
321
+		    if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) {
322
+			    $data[] = $match[1];
323
+		    }
324
+		    if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) {
325
+			    $data[] = $match[1];
326
+		    }
327
+	    }
328
+	    // Fetch all data, regardless of privacy
329
+	    $rows = Database::prepare(
330
+		    "SELECT f_id AS xref, f_gedcom AS gedcom" .
331
+		    " FROM `##families`" .
332
+		    " WHERE f_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND f_file = :tree_id"
333
+	    )->execute(array(
334
+		    'xref'    => $sid,
335
+		    'term'    => $term,
336
+		    'tree_id' => $WT_TREE->getTreeId(),
337
+	    ))->fetchAll();
338
+	    // Filter for privacy
339
+	    foreach ($rows as $row) {
340
+		    $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
341
+		    if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) {
342
+			    $data[] = $match[1];
343
+		    }
344
+		    if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) {
345
+			    $data[] = $match[1];
346
+		    }
347
+	    }
348
+	    // array_unique() converts the keys from integer to string, which breaks
349
+	    // the JSON encoding - so need to call array_values() to convert them
350
+	    // back into integers.
351
+	    $data = array_values(array_unique($data));
352
+	    echo json_encode($data);
353
+
354
+	    return;
355
+
356
+    case 'SOUR_TITL': // Source titles, that include the search terms
357
+	    $data = array();
358
+	    // Fetch all data, regardless of privacy
359
+	    $rows = Database::prepare(
360
+		    "SELECT s_id AS xref, s_gedcom AS gedcom, s_name" .
361
+		    " FROM `##sources`" .
362
+		    " WHERE s_name LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND s_file = :tree_id" .
363
+		    " ORDER BY s_name COLLATE :collation"
364
+	    )->execute(array(
365
+		    'term'      => $term,
366
+		    'tree_id'   => $WT_TREE->getTreeId(),
367
+		    'collation' => I18N::collation(),
368
+	    ))->fetchAll();
369
+	    // Filter for privacy
370
+	    foreach ($rows as $row) {
371
+		    $source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
372
+		    if ($source->canShowName()) {
373
+			    $data[] = $row->s_name;
374
+		    }
375
+	    }
376
+	    echo json_encode($data);
377
+
378
+	    return;
379
+
380
+    case 'SURN': // Surnames, that start with the search term
381
+	    // Do not filter by privacy. Surnames on their own do not identify individuals.
382
+	    echo json_encode(
383
+		    Database::prepare(
384
+			    "SELECT DISTINCT n_surname" .
385
+			    " FROM `##name`" .
386
+			    " WHERE n_surname LIKE CONCAT(:term, '%') AND n_file = :tree_id" .
387
+			    " ORDER BY n_surname COLLATE :collation"
388
+		    )->execute(array(
389
+			    'term'      => $term,
390
+			    'tree_id'   => $WT_TREE->getTreeId(),
391
+			    'collation' => I18N::collation(),
392
+		    ))->fetchOneColumn()
393
+	    );
394
+
395
+	    return;
396
+
397
+    case 'IFSRO':
398
+	    $data = array();
399
+	    // Fetch all data, regardless of privacy
400
+	    $rows = get_INDI_rows($WT_TREE, $term);
401
+	    // Filter for privacy
402
+	    foreach ($rows as $row) {
403
+		    $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
404
+		    if ($person->canShowName()) {
405
+			    $data[] = array('value' => $person->getXref(), 'label' => str_replace(array('@N.N.', '@P.N.'), array(I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')), $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>');
406
+		    }
407
+	    }
408
+	    // Fetch all data, regardless of privacy
409
+	    $rows = get_SOUR_rows($WT_TREE, $term);
410
+	    // Filter for privacy
411
+	    foreach ($rows as $row) {
412
+		    $source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
413
+		    if ($source->canShowName()) {
414
+			    $data[] = array('value' => $source->getXref(), 'label' => $source->getFullName());
415
+		    }
416
+	    }
417
+	    // Fetch all data, regardless of privacy
418
+	    $rows = get_REPO_rows($WT_TREE, $term);
419
+	    // Filter for privacy
420
+	    foreach ($rows as $row) {
421
+		    $repository = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
422
+		    if ($repository->canShowName()) {
423
+			    $data[] = array('value' => $repository->getXref(), 'label' => $repository->getFullName());
424
+		    }
425
+	    }
426
+	    // Fetch all data, regardless of privacy
427
+	    $rows = get_OBJE_rows($WT_TREE, $term);
428
+	    // Filter for privacy
429
+	    foreach ($rows as $row) {
430
+		    $media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
431
+		    if ($media->canShowName()) {
432
+			    $data[] = array('value' => $media->getXref(), 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName());
433
+		    }
434
+	    }
435
+	    // Fetch all data, regardless of privacy
436
+	    $rows = get_FAM_rows($WT_TREE, $term);
437
+	    // Filter for privacy
438
+	    foreach ($rows as $row) {
439
+		    $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
440
+		    if ($family->canShowName()) {
441
+			    $marriage_year = $family->getMarriageYear();
442
+			    if ($marriage_year) {
443
+				    $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>');
444
+			    } else {
445
+				    $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName());
446
+			    }
447
+		    }
448
+	    }
449
+	    // Fetch all data, regardless of privacy
450
+	    $rows = get_NOTE_rows($WT_TREE, $term);
451
+	    // Filter for privacy
452
+	    foreach ($rows as $row) {
453
+		    $note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom);
454
+		    if ($note->canShowName()) {
455
+			    $data[] = array('value' => $note->getXref(), 'label' => $note->getFullName());
456
+		    }
457
+	    }
458
+	    echo json_encode($data);
459
+
460
+	    return;
461
+
462
+    case 'IFS':
463
+	    $data = array();
464
+	    // Fetch all data, regardless of privacy
465
+	    $rows = get_INDI_rows($WT_TREE, $term);
466
+	    // Filter for privacy
467
+	    foreach ($rows as $row) {
468
+		    $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom);
469
+		    if ($person->canShowName()) {
470
+			    $data[] = array('value' => $person->getXref(), 'label' => str_replace(array('@N.N.', '@P.N.'), array(I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')), $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>');
471
+		    }
472
+	    }
473
+	    // Fetch all data, regardless of privacy
474
+	    $rows = get_SOUR_rows($WT_TREE, $term);
475
+	    // Filter for privacy
476
+	    foreach ($rows as $row) {
477
+		    $source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
478
+		    if ($source->canShowName()) {
479
+			    $data[] = array('value' => $source->getXref(), 'label' => $source->getFullName());
480
+		    }
481
+	    }
482
+	    // Fetch all data, regardless of privacy
483
+	    $rows = get_FAM_rows($WT_TREE, $term);
484
+	    // Filter for privacy
485
+	    foreach ($rows as $row) {
486
+		    $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
487
+		    if ($family->canShowName()) {
488
+			    $marriage_year = $family->getMarriageYear();
489
+			    if ($marriage_year) {
490
+				    $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>');
491
+			    } else {
492
+				    $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName());
493
+			    }
494
+		    }
495
+	    }
496
+	    echo json_encode($data);
497
+
498
+	    return;
499 499
 }
500 500
 
501 501
 /**
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -506,7 +506,8 @@  discard block
 block discarded – undo
506 506
  *
507 507
  * @return \stdClass[]
508 508
  */
509
-function get_FAM_rows(Tree $tree, $term) {
509
+function get_FAM_rows(Tree $tree, $term)
510
+{
510 511
 	return Database::prepare(
511 512
 		"SELECT DISTINCT 'FAM' AS type, f_id AS xref, f_gedcom AS gedcom, husb_name.n_sort, wife_name.n_sort" .
512 513
 		" FROM `##families`" .
@@ -530,7 +531,8 @@  discard block
 block discarded – undo
530 531
  *
531 532
  * @return \stdClass[]
532 533
  */
533
-function get_INDI_rows(Tree $tree, $term) {
534
+function get_INDI_rows(Tree $tree, $term)
535
+{
534 536
 	return Database::prepare(
535 537
 		"SELECT 'INDI' AS type, i_id AS xref, i_gedcom AS gedcom, n_full" .
536 538
 		" FROM `##individuals`" .
@@ -551,7 +553,8 @@  discard block
 block discarded – undo
551 553
  *
552 554
  * @return \stdClass[]
553 555
  */
554
-function get_NOTE_rows(Tree $tree, $term) {
556
+function get_NOTE_rows(Tree $tree, $term)
557
+{
555 558
 	return Database::prepare(
556 559
 		"SELECT o_id AS xref, o_gedcom AS gedcom" .
557 560
 		" FROM `##other`" .
@@ -573,7 +576,8 @@  discard block
 block discarded – undo
573 576
  *
574 577
  * @return \stdClass[]
575 578
  */
576
-function get_OBJE_rows(Tree $tree, $term) {
579
+function get_OBJE_rows(Tree $tree, $term)
580
+{
577 581
 	return Database::prepare(
578 582
 		"SELECT 'OBJE' AS type, m_id AS xref, m_gedcom AS gedcom" .
579 583
 		" FROM `##media`" .
@@ -595,7 +599,8 @@  discard block
 block discarded – undo
595 599
  *
596 600
  * @return \stdClass[]
597 601
  */
598
-function get_REPO_rows(Tree $tree, $term) {
602
+function get_REPO_rows(Tree $tree, $term)
603
+{
599 604
 	return Database::prepare(
600 605
 		"SELECT o_id AS xref, o_gedcom AS gedcom" .
601 606
 		" FROM `##other`" .
@@ -617,7 +622,8 @@  discard block
 block discarded – undo
617 622
  *
618 623
  * @return \stdClass[]
619 624
  */
620
-function get_SOUR_rows(Tree $tree, $term) {
625
+function get_SOUR_rows(Tree $tree, $term)
626
+{
621 627
 	return Database::prepare(
622 628
 		"SELECT s_id AS xref, s_gedcom AS gedcom" .
623 629
 		" FROM `##sources`" .
Please login to merge, or discard this patch.
help_text.php 2 patches
Indentation   +269 added lines, -269 removed lines patch added patch discarded remove patch
@@ -20,306 +20,306 @@
 block discarded – undo
20 20
 
21 21
 $help = Filter::get('help');
22 22
 switch ($help) {
23
-	//////////////////////////////////////////////////////////////////////////////
24
-	// This is a list of all known gedcom tags. We list them all here so that
25
-	// xgettext() may find them.
26
-	//
27
-	// Tags such as BIRT:PLAC are only used as labels, and do not require help
28
-	// text. These are only used for translating labels.
29
-	//
30
-	// Tags such as _BIRT_CHIL are pseudo-tags, used to create family events.
31
-	//
32
-	// Generally, these tags need to be lists explicitly in FunctionsEdit::add_simple_tag()
33
-	//////////////////////////////////////////////////////////////////////////////
23
+    //////////////////////////////////////////////////////////////////////////////
24
+    // This is a list of all known gedcom tags. We list them all here so that
25
+    // xgettext() may find them.
26
+    //
27
+    // Tags such as BIRT:PLAC are only used as labels, and do not require help
28
+    // text. These are only used for translating labels.
29
+    //
30
+    // Tags such as _BIRT_CHIL are pseudo-tags, used to create family events.
31
+    //
32
+    // Generally, these tags need to be lists explicitly in FunctionsEdit::add_simple_tag()
33
+    //////////////////////////////////////////////////////////////////////////////
34 34
 
35 35
 case 'DATE':
36
-	$title = GedcomTag::getLabel('DATE');
37
-	$dates = array(
38
-		'1900'                                                       => new Date('1900'),
39
-		'JAN 1900'                                                   => new Date('JAN 1900'),
40
-		'FEB 1900'                                                   => new Date('FEB 1900'),
41
-		'MAR 1900'                                                   => new Date('MAR 1900'),
42
-		'APR 1900'                                                   => new Date('APR 1900'),
43
-		'MAY 1900'                                                   => new Date('MAY 1900'),
44
-		'JUN 1900'                                                   => new Date('JUN 1900'),
45
-		'JUL 1900'                                                   => new Date('JUL 1900'),
46
-		'AUG 1900'                                                   => new Date('AUG 1900'),
47
-		'SEP 1900'                                                   => new Date('SEP 1900'),
48
-		'OCT 1900'                                                   => new Date('OCT 1900'),
49
-		'NOV 1900'                                                   => new Date('NOV 1900'),
50
-		'DEC 1900'                                                   => new Date('DEC 1900'),
51
-		'11 DEC 1913'                                                => new Date('11 DEC 1913'),
52
-		'01 FEB 2003'                                                => new Date('01 FEB 2003'),
53
-		'ABT 1900'                                                   => new Date('ABT 1900'),
54
-		'EST 1900'                                                   => new Date('EST 1900'),
55
-		'CAL 1900'                                                   => new Date('CAL 1900'),
56
-		'INT 1900 (...)'                                             => new Date('INT 1900 (...)'),
57
-		'@#DJULIAN@ 44 B.C.'                                         => new Date('@#DJULIAN@ 44 B.C.'),
58
-		'@#DJULIAN@ 14 JAN 1700'                                     => new Date('@#DJULIAN@ 14 JAN 1700'),
59
-		'BET @#DJULIAN@ 01 SEP 1752 AND @#DGREGORIAN@ 30 SEP 1752'   => new Date('BET @#DJULIAN@ 01 SEP 1752 AND @#DGREGORIAN@ 30 SEP 1752'),
60
-		'@#DJULIAN@ 20 FEB 1742/43'                                  => new Date('@#DJULIAN@ 20 FEB 1742/43'),
61
-		'FROM 1900 TO 1910'                                          => new Date('FROM 1900 TO 1910'),
62
-		'FROM 1900'                                                  => new Date('FROM 1900'),
63
-		'TO 1910'                                                    => new Date('TO 1910'),
64
-		'BET 1900 AND 1910'                                          => new Date('BET 1900 AND 1910'),
65
-		'BET JAN 1900 AND MAR 1900'                                  => new Date('BET JAN 1900 AND MAR 1900'),
66
-		'BET APR 1900 AND JUN 1900'                                  => new Date('BET APR 1900 AND JUN 1900'),
67
-		'BET JUL 1900 AND SEP 1900'                                  => new Date('BET JUL 1900 AND SEP 1900'),
68
-		'BET OCT 1900 AND DEC 1900'                                  => new Date('BET OCT 1900 AND DEC 1900'),
69
-		'AFT 1900'                                                   => new Date('AFT 1900'),
70
-		'BEF 1910'                                                   => new Date('BEF 1910'),
71
-		// Hijri dates
72
-		'@#DHIJRI@ 1497'                                    => new Date('@#DHIJRI@ 1497'),
73
-		'@#DHIJRI@ MUHAR 1497'                              => new Date('@#DHIJRI@ MUHAR 1497'),
74
-		'ABT @#DHIJRI@ SAFAR 1497'                          => new Date('ABT @#DHIJRI@ SAFAR 1497'),
75
-		'BET @#DHIJRI@ RABIA 1497 AND @#DHIJRI@ RABIT 1497' => new Date('BET @#DHIJRI@ RABIA 1497 AND @#DHIJRI@ RABIT 1497'),
76
-		'FROM @#DHIJRI@ JUMAA 1497 TO @#DHIJRI@ JUMAT 1497' => new Date('FROM @#DHIJRI@ JUMAA 1497 TO @#DHIJRI@ JUMAT 1497'),
77
-		'AFT @#DHIJRI@ RAJAB 1497'                          => new Date('AFT @#DHIJRI@ RAJAB 1497'),
78
-		'BEF @#DHIJRI@ SHAAB 1497'                          => new Date('BEF @#DHIJRI@ SHAAB 1497'),
79
-		'ABT @#DHIJRI@ RAMAD 1497'                          => new Date('ABT @#DHIJRI@ RAMAD 1497'),
80
-		'FROM @#DHIJRI@ SHAWW 1497'                         => new Date('FROM @#DHIJRI@ SHAWW 1497'),
81
-		'TO @#DHIJRI@ DHUAQ 1497'                           => new Date('TO @#DHIJRI@ DHUAQ 1497'),
82
-		'@#DHIJRI@ 03 DHUAH 1497'                           => new Date('@#DHIJRI@ 03 DHUAH 1497'),
83
-		// French dates
84
-		'@#DFRENCH R@ 12'                                   => new Date('@#DFRENCH R@ 12'),
85
-		'@#DFRENCH R@ VEND 12'                              => new Date('@#DFRENCH R@ VEND 12'),
86
-		'ABT @#DFRENCH R@ BRUM 12'                          => new Date('ABT @#DFRENCH R@ BRUM 12'),
87
-		'BET @#DFRENCH R@ FRIM 12 AND @#DFRENCH R@ NIVO 12' => new Date('BET @#DFRENCH R@ FRIM 12 AND @#DFRENCH R@ NIVO 12'),
88
-		'FROM @#DFRENCH R@ PLUV 12 TO @#DFRENCH R@ VENT 12' => new Date('FROM @#DFRENCH R@ PLUV 12 TO @#DFRENCH R@ VENT 12'),
89
-		'AFT @#DFRENCH R@ GERM 12'                          => new Date('AFT @#DFRENCH R@ GERM 12'),
90
-		'BEF @#DFRENCH R@ FLOR 12'                          => new Date('BEF @#DFRENCH R@ FLOR 12'),
91
-		'ABT @#DFRENCH R@ PRAI 12'                          => new Date('ABT @#DFRENCH R@ PRAI 12'),
92
-		'FROM @#DFRENCH R@ MESS 12'                         => new Date('FROM @#DFRENCH R@ MESS 12'),
93
-		'TO @#DFRENCH R@ THER 12'                           => new Date('TO @#DFRENCH R@ THER 12'),
94
-		'EST @#DFRENCH R@ FRUC 12'                          => new Date('EST @#DFRENCH R@ FRUC 12'),
95
-		'@#DFRENCH R@ 03 COMP 12'                           => new Date('@#DFRENCH R@ 03 COMP 12'),
96
-		// Jewish dates
97
-		'@#DHEBREW@ 5481'                                 => new Date('@#DHEBREW@ 5481'),
98
-		'@#DHEBREW@ TSH 5481'                             => new Date('@#DHEBREW@ TSH 5481'),
99
-		'ABT @#DHEBREW@ CSH 5481'                         => new Date('ABT @#DHEBREW@ CSH 5481'),
100
-		'BET @#DHEBREW@ KSL 5481 AND @#DHEBREW@ TVT 5481' => new Date('BET @#DHEBREW@ KSL 5481 AND @#DHEBREW@ TVT 5481'),
101
-		'FROM @#DHEBREW@ SHV 5481 TO @#DHEBREW@ ADR 5481' => new Date('FROM @#DHEBREW@ SHV 5481 TO @#DHEBREW@ ADR 5481'),
102
-		'AFT @#DHEBREW@ ADR 5481'                         => new Date('AFT @#DHEBREW@ ADR 5481'),
103
-		'AFT @#DHEBREW@ ADS 5480'                         => new Date('AFT @#DHEBREW@ ADS 5480'),
104
-		'BEF @#DHEBREW@ NSN 5481'                         => new Date('BEF @#DHEBREW@ NSN 5481'),
105
-		'ABT @#DHEBREW@ IYR 5481'                         => new Date('ABT @#DHEBREW@ IYR 5481'),
106
-		'FROM @#DHEBREW@ SVN 5481'                        => new Date('FROM @#DHEBREW@ SVN 5481'),
107
-		'TO @#DHEBREW@ TMZ 5481'                          => new Date('TO @#DHEBREW@ TMZ 5481'),
108
-		'EST @#DHEBREW@ AAV 5481'                         => new Date('EST @#DHEBREW@ AAV 5481'),
109
-		'@#DHEBREW@ 03 ELL 5481'                          => new Date('@#DHEBREW@ 03 ELL 5481'),
110
-	);
36
+    $title = GedcomTag::getLabel('DATE');
37
+    $dates = array(
38
+        '1900'                                                       => new Date('1900'),
39
+        'JAN 1900'                                                   => new Date('JAN 1900'),
40
+        'FEB 1900'                                                   => new Date('FEB 1900'),
41
+        'MAR 1900'                                                   => new Date('MAR 1900'),
42
+        'APR 1900'                                                   => new Date('APR 1900'),
43
+        'MAY 1900'                                                   => new Date('MAY 1900'),
44
+        'JUN 1900'                                                   => new Date('JUN 1900'),
45
+        'JUL 1900'                                                   => new Date('JUL 1900'),
46
+        'AUG 1900'                                                   => new Date('AUG 1900'),
47
+        'SEP 1900'                                                   => new Date('SEP 1900'),
48
+        'OCT 1900'                                                   => new Date('OCT 1900'),
49
+        'NOV 1900'                                                   => new Date('NOV 1900'),
50
+        'DEC 1900'                                                   => new Date('DEC 1900'),
51
+        '11 DEC 1913'                                                => new Date('11 DEC 1913'),
52
+        '01 FEB 2003'                                                => new Date('01 FEB 2003'),
53
+        'ABT 1900'                                                   => new Date('ABT 1900'),
54
+        'EST 1900'                                                   => new Date('EST 1900'),
55
+        'CAL 1900'                                                   => new Date('CAL 1900'),
56
+        'INT 1900 (...)'                                             => new Date('INT 1900 (...)'),
57
+        '@#DJULIAN@ 44 B.C.'                                         => new Date('@#DJULIAN@ 44 B.C.'),
58
+        '@#DJULIAN@ 14 JAN 1700'                                     => new Date('@#DJULIAN@ 14 JAN 1700'),
59
+        'BET @#DJULIAN@ 01 SEP 1752 AND @#DGREGORIAN@ 30 SEP 1752'   => new Date('BET @#DJULIAN@ 01 SEP 1752 AND @#DGREGORIAN@ 30 SEP 1752'),
60
+        '@#DJULIAN@ 20 FEB 1742/43'                                  => new Date('@#DJULIAN@ 20 FEB 1742/43'),
61
+        'FROM 1900 TO 1910'                                          => new Date('FROM 1900 TO 1910'),
62
+        'FROM 1900'                                                  => new Date('FROM 1900'),
63
+        'TO 1910'                                                    => new Date('TO 1910'),
64
+        'BET 1900 AND 1910'                                          => new Date('BET 1900 AND 1910'),
65
+        'BET JAN 1900 AND MAR 1900'                                  => new Date('BET JAN 1900 AND MAR 1900'),
66
+        'BET APR 1900 AND JUN 1900'                                  => new Date('BET APR 1900 AND JUN 1900'),
67
+        'BET JUL 1900 AND SEP 1900'                                  => new Date('BET JUL 1900 AND SEP 1900'),
68
+        'BET OCT 1900 AND DEC 1900'                                  => new Date('BET OCT 1900 AND DEC 1900'),
69
+        'AFT 1900'                                                   => new Date('AFT 1900'),
70
+        'BEF 1910'                                                   => new Date('BEF 1910'),
71
+        // Hijri dates
72
+        '@#DHIJRI@ 1497'                                    => new Date('@#DHIJRI@ 1497'),
73
+        '@#DHIJRI@ MUHAR 1497'                              => new Date('@#DHIJRI@ MUHAR 1497'),
74
+        'ABT @#DHIJRI@ SAFAR 1497'                          => new Date('ABT @#DHIJRI@ SAFAR 1497'),
75
+        'BET @#DHIJRI@ RABIA 1497 AND @#DHIJRI@ RABIT 1497' => new Date('BET @#DHIJRI@ RABIA 1497 AND @#DHIJRI@ RABIT 1497'),
76
+        'FROM @#DHIJRI@ JUMAA 1497 TO @#DHIJRI@ JUMAT 1497' => new Date('FROM @#DHIJRI@ JUMAA 1497 TO @#DHIJRI@ JUMAT 1497'),
77
+        'AFT @#DHIJRI@ RAJAB 1497'                          => new Date('AFT @#DHIJRI@ RAJAB 1497'),
78
+        'BEF @#DHIJRI@ SHAAB 1497'                          => new Date('BEF @#DHIJRI@ SHAAB 1497'),
79
+        'ABT @#DHIJRI@ RAMAD 1497'                          => new Date('ABT @#DHIJRI@ RAMAD 1497'),
80
+        'FROM @#DHIJRI@ SHAWW 1497'                         => new Date('FROM @#DHIJRI@ SHAWW 1497'),
81
+        'TO @#DHIJRI@ DHUAQ 1497'                           => new Date('TO @#DHIJRI@ DHUAQ 1497'),
82
+        '@#DHIJRI@ 03 DHUAH 1497'                           => new Date('@#DHIJRI@ 03 DHUAH 1497'),
83
+        // French dates
84
+        '@#DFRENCH R@ 12'                                   => new Date('@#DFRENCH R@ 12'),
85
+        '@#DFRENCH R@ VEND 12'                              => new Date('@#DFRENCH R@ VEND 12'),
86
+        'ABT @#DFRENCH R@ BRUM 12'                          => new Date('ABT @#DFRENCH R@ BRUM 12'),
87
+        'BET @#DFRENCH R@ FRIM 12 AND @#DFRENCH R@ NIVO 12' => new Date('BET @#DFRENCH R@ FRIM 12 AND @#DFRENCH R@ NIVO 12'),
88
+        'FROM @#DFRENCH R@ PLUV 12 TO @#DFRENCH R@ VENT 12' => new Date('FROM @#DFRENCH R@ PLUV 12 TO @#DFRENCH R@ VENT 12'),
89
+        'AFT @#DFRENCH R@ GERM 12'                          => new Date('AFT @#DFRENCH R@ GERM 12'),
90
+        'BEF @#DFRENCH R@ FLOR 12'                          => new Date('BEF @#DFRENCH R@ FLOR 12'),
91
+        'ABT @#DFRENCH R@ PRAI 12'                          => new Date('ABT @#DFRENCH R@ PRAI 12'),
92
+        'FROM @#DFRENCH R@ MESS 12'                         => new Date('FROM @#DFRENCH R@ MESS 12'),
93
+        'TO @#DFRENCH R@ THER 12'                           => new Date('TO @#DFRENCH R@ THER 12'),
94
+        'EST @#DFRENCH R@ FRUC 12'                          => new Date('EST @#DFRENCH R@ FRUC 12'),
95
+        '@#DFRENCH R@ 03 COMP 12'                           => new Date('@#DFRENCH R@ 03 COMP 12'),
96
+        // Jewish dates
97
+        '@#DHEBREW@ 5481'                                 => new Date('@#DHEBREW@ 5481'),
98
+        '@#DHEBREW@ TSH 5481'                             => new Date('@#DHEBREW@ TSH 5481'),
99
+        'ABT @#DHEBREW@ CSH 5481'                         => new Date('ABT @#DHEBREW@ CSH 5481'),
100
+        'BET @#DHEBREW@ KSL 5481 AND @#DHEBREW@ TVT 5481' => new Date('BET @#DHEBREW@ KSL 5481 AND @#DHEBREW@ TVT 5481'),
101
+        'FROM @#DHEBREW@ SHV 5481 TO @#DHEBREW@ ADR 5481' => new Date('FROM @#DHEBREW@ SHV 5481 TO @#DHEBREW@ ADR 5481'),
102
+        'AFT @#DHEBREW@ ADR 5481'                         => new Date('AFT @#DHEBREW@ ADR 5481'),
103
+        'AFT @#DHEBREW@ ADS 5480'                         => new Date('AFT @#DHEBREW@ ADS 5480'),
104
+        'BEF @#DHEBREW@ NSN 5481'                         => new Date('BEF @#DHEBREW@ NSN 5481'),
105
+        'ABT @#DHEBREW@ IYR 5481'                         => new Date('ABT @#DHEBREW@ IYR 5481'),
106
+        'FROM @#DHEBREW@ SVN 5481'                        => new Date('FROM @#DHEBREW@ SVN 5481'),
107
+        'TO @#DHEBREW@ TMZ 5481'                          => new Date('TO @#DHEBREW@ TMZ 5481'),
108
+        'EST @#DHEBREW@ AAV 5481'                         => new Date('EST @#DHEBREW@ AAV 5481'),
109
+        '@#DHEBREW@ 03 ELL 5481'                          => new Date('@#DHEBREW@ 03 ELL 5481'),
110
+    );
111 111
 
112
-	foreach ($dates as &$date) {
113
-		$date = strip_tags($date->display(false, null, false));
114
-	}
115
-	// These shortcuts work differently for different languages
116
-	switch (preg_replace('/[^DMY]/', '', str_replace(array('J', 'F'), array('D', 'M'), I18N::dateFormat()))) {
117
-	case 'YMD':
118
-		$example1 = '11/12/1913'; // Note: we ignore the DMY order if it doesn't make sense.
119
-		$example2 = '03/02/01';
120
-		break;
121
-	case 'MDY':
122
-		$example1 = '12/11/1913';
123
-		$example2 = '02/01/03';
124
-		break;
125
-	case 'DMY':
126
-	default:
127
-		$example1 = '11/12/1913';
128
-		$example2 = '01/02/03';
129
-		break;
130
-	}
131
-	$example1 .= '<br>' . str_replace('/', '-', $example1) . '<br>' . str_replace('/', '.', $example1);
132
-	$example2 .= '<br>' . str_replace('/', '-', $example2) . '<br>' . str_replace('/', '.', $example2);
133
-	$text =
134
-		'<p>' . I18N::translate('Dates are stored using English abbreviations and keywords. Shortcuts are available as alternatives to these abbreviations and keywords.') . '</p>' .
135
-		'<table border="1">' .
136
-		'<tr><th>' . I18N::translate('Date') . '</th><th>' . I18N::translate('Format') . '</th><th>' . I18N::translate('Shortcut') . '</th></tr>' .
137
-		'<tr><td>' . $dates['1900'] . '</td><td><kbd dir="ltr" lang="en">1900</kbd></td><td></td></tr>' .
138
-		'<tr><td>' . $dates['JAN 1900'] . '<br>' . $dates['FEB 1900'] . '<br>' . $dates['MAR 1900'] . '<br>' . $dates['APR 1900'] . '<br>' . $dates['MAY 1900'] . '<br>' . $dates['JUN 1900'] . '<br>' . $dates['JUL 1900'] . '<br>' . $dates['AUG 1900'] . '<br>' . $dates['SEP 1900'] . '<br>' . $dates['OCT 1900'] . '<br>' . $dates['NOV 1900'] . '<br>' . $dates['DEC 1900'] . '</td><td><kbd dir="ltr" lang="en">JAN 1900<br>FEB 1900<br>MAR 1900<br>APR 1900<br>MAY 1900<br>JUN 1900<br>JUL 1900<br>AUG 1900<br>SEP 1900<br>OCT 1900<br>NOV 1900<br>DEC 1900</kbd></td><td></td></tr>' .
139
-		'<tr><td>' . $dates['11 DEC 1913'] . '</td><td><kbd dir="ltr" lang="en">11 DEC 1913</kbd></td><td><kbd dir="ltr" lang="en">' . $example1 . '</kbd></td></tr>' .
140
-		'<tr><td>' . $dates['01 FEB 2003'] . '</td><td><kbd dir="ltr" lang="en">01 FEB 2003</kbd></td><td><kbd dir="ltr" lang="en">' . $example2 . '</kbd></td></tr>' .
141
-		'<tr><td>' . $dates['ABT 1900'] . '</td><td><kbd dir="ltr" lang="en">ABT 1900</kbd></td><td><kbd dir="ltr" lang="en">~1900</kbd></td></tr>' .
142
-		'<tr><td>' . $dates['EST 1900'] . '</td><td><kbd dir="ltr" lang="en">EST 1900</kbd></td><td><kbd dir="ltr" lang="en">*1900</kbd></td></tr>' .
143
-		'<tr><td>' . $dates['CAL 1900'] . '</td><td><kbd dir="ltr" lang="en">CAL 1900</kbd></td><td><kbd dir="ltr" lang="en">#1900</kbd></td></tr>' .
144
-		'<tr><td>' . $dates['INT 1900 (...)'] . '</td><td><kbd dir="ltr" lang="en">INT 1900 (...)</kbd></td><td></td></tr>' .
145
-		'</table>' .
146
-		'<p>' . I18N::translate('Date ranges are used to indicate that an event, such as a birth, happened on an unknown date within a possible range.') . '</p>' .
147
-		'<table border="1">' .
148
-		'<tr><th>' . I18N::translate('Date range') . '</th><th>' . I18N::translate('Format') . '</th><th>' . I18N::translate('Shortcut') . '</th></tr>' .
149
-		'<tr><td>' . $dates['BET 1900 AND 1910'] . '</td><td><kbd dir="ltr" lang="en">BET 1900 AND 1910</kbd></td><td><kbd dir="ltr" lang="en">1900-1910</kbd></td></tr>' .
150
-		'<tr><td>' . $dates['AFT 1900'] . '</td><td><kbd dir="ltr" lang="en">AFT 1900</kbd></td><td><kbd dir="ltr" lang="en">&gt;1900</kbd></td></tr>' .
151
-		'<tr><td>' . $dates['BEF 1910'] . '</td><td><kbd dir="ltr" lang="en">BEF 1910</kbd></td><td><kbd dir="ltr" lang="en">&lt;1910</kbd></td></tr>' .
152
-		'<tr><td>' . $dates['BET JAN 1900 AND MAR 1900'] . '</td><td><kbd dir="ltr" lang="en">BET JAN 1900 AND MAR 1900</kbd></td><td><kbd dir="ltr" lang="en">Q1 1900</kbd></td></tr>' .
153
-		'<tr><td>' . $dates['BET APR 1900 AND JUN 1900'] . '</td><td><kbd dir="ltr" lang="en">BET APR 1900 AND JUN 1900</kbd></td><td><kbd dir="ltr" lang="en">Q2 1900</kbd></td></tr>' .
154
-		'<tr><td>' . $dates['BET JUL 1900 AND SEP 1900'] . '</td><td><kbd dir="ltr" lang="en">BET JUL 1900 AND SEP 1900</kbd></td><td><kbd dir="ltr" lang="en">Q3 1900</kbd></td></tr>' .
155
-		'<tr><td>' . $dates['BET OCT 1900 AND DEC 1900'] . '</td><td><kbd dir="ltr" lang="en">BET OCT 1900 AND DEC 1900</kbd></td><td><kbd dir="ltr" lang="en">Q4 1900</kbd></td></tr>' .
156
-		'</table>' .
157
-		'<p>' . I18N::translate('Date periods are used to indicate that a fact, such as an occupation, continued for a period of time.') . '</p>' .
158
-		'<table border="1">' .
159
-		'<tr><th>' . I18N::translate('Date period') . '</th><th>' . I18N::translate('Format') . '</th><th>' . I18N::translate('Shortcut') . '</th></tr>' .
160
-		'<tr><td>' . $dates['FROM 1900 TO 1910'] . '</td><td><kbd dir="ltr" lang="en">FROM 1900 TO 1910</kbd></td><td><kbd dir="ltr" lang="en">1900~1910</kbd></td></tr>' .
161
-		'<tr><td>' . $dates['FROM 1900'] . '</td><td><kbd dir="ltr" lang="en">FROM 1900</kbd></td><td><kbd dir="ltr" lang="en">1900-</kbd></td></tr>' .
162
-		'<tr><td>' . $dates['TO 1910'] . '</td><td><kbd dir="ltr" lang="en">TO 1910</kbd></td><td><kbd dir="ltr" lang="en">-1900</kbd></td></tr>' .
163
-		'</table>' .
164
-		'<p>' . I18N::translate('Simple dates are assumed to be in the gregorian calendar. To specify a date in another calendar, add a keyword before the date. This keyword is optional if the month or year format make the date unambiguous.') . '</p>' .
165
-		'<table border="1">' .
166
-		'<tr><th>' . I18N::translate('Date') . '</th><th>' . I18N::translate('Format') . '</th></tr>' .
167
-		'<tr><th colspan="2">' . I18N::translate('Julian') . '</th></tr>' .
168
-		'<tr><td>' . $dates['@#DJULIAN@ 14 JAN 1700'] . '</td><td><kbd dir="ltr" lang="en">@#DJULIAN@ 14 JAN 1700</kbd></td></tr>' .
169
-		'<tr><td>' . $dates['@#DJULIAN@ 44 B.C.'] . '</td><td><kbd dir="ltr" lang="en">@#DJULIAN@ 44 B.C.</kbd></td></tr>' .
170
-		'<tr><td>' . $dates['@#DJULIAN@ 20 FEB 1742/43'] . '</td><td><kbd dir="ltr" lang="en">@#DJULIAN@ 20 FEB 1742/43</kbd></td></tr>' .
171
-		'<tr><td>' . $dates['BET @#DJULIAN@ 01 SEP 1752 AND @#DGREGORIAN@ 30 SEP 1752'] . '</td><td><kbd dir="ltr" lang="en">BET @#DJULIAN@ 01 SEP 1752 AND @#DGREGORIAN@ 30 SEP 1752</kbd></td></tr>' .
172
-		'<tr><th colspan="2">' . I18N::translate('Jewish') . '</th></tr>' .
173
-		'<tr><td>' . $dates['@#DHEBREW@ 5481'] . '</td><td><kbd dir="ltr" lang="en">@#DHEBREW@ 5481</kbd></td></tr>' .
174
-		'<tr><td>' . $dates['@#DHEBREW@ TSH 5481'] . '</td><td><kbd dir="ltr" lang="en">@#DHEBREW@ TSH 5481</kbd></td></tr>' .
175
-		'<tr><td>' . $dates['ABT @#DHEBREW@ CSH 5481'] . '</td><td><kbd dir="ltr" lang="en">ABT @#DHEBREW@ CSH 5481</kbd></td></tr>' .
176
-		'<tr><td>' . $dates['BET @#DHEBREW@ KSL 5481 AND @#DHEBREW@ TVT 5481'] . '</td><td><kbd dir="ltr" lang="en">BET @#DHEBREW@ KSL 5481 AND @#DHEBREW@ TVT 5481</kbd></td></tr>' .
177
-		'<tr><td>' . $dates['FROM @#DHEBREW@ SHV 5481 TO @#DHEBREW@ ADR 5481'] . '</td><td><kbd dir="ltr" lang="en">FROM @#DHEBREW@ SHV 5481 TO @#DHEBREW@ ADR 5481</kbd></td></tr>' .
178
-		'<tr><td>' . $dates['AFT @#DHEBREW@ ADR 5481'] . '</td><td><kbd dir="ltr" lang="en">AFT @#DHEBREW@ ADR 5481</kbd></td></tr>' .
179
-		'<tr><td>' . $dates['AFT @#DHEBREW@ ADS 5480'] . '</td><td><kbd dir="ltr" lang="en">AFT @#DHEBREW@ ADS 5480</kbd></td></tr>' .
180
-		'<tr><td>' . $dates['BEF @#DHEBREW@ NSN 5481'] . '</td><td><kbd dir="ltr" lang="en">BEF @#DHEBREW@ NSN 5481</kbd></td></tr>' .
181
-		'<tr><td>' . $dates['ABT @#DHEBREW@ IYR 5481'] . '</td><td><kbd dir="ltr" lang="en">ABT @#DHEBREW@ IYR 5481</kbd></td></tr>' .
182
-		'<tr><td>' . $dates['FROM @#DHEBREW@ SVN 5481'] . '</td><td><kbd dir="ltr" lang="en">FROM @#DHEBREW@ SVN 5481</kbd></td></tr>' .
183
-		'<tr><td>' . $dates['TO @#DHEBREW@ TMZ 5481'] . '</td><td><kbd dir="ltr" lang="en">TO @#DHEBREW@ TMZ 5481</kbd></td></tr>' .
184
-		'<tr><td>' . $dates['EST @#DHEBREW@ AAV 5481'] . '</td><td><kbd dir="ltr" lang="en">EST @#DHEBREW@ AAV 5481</kbd></td></tr>' .
185
-		'<tr><td>' . $dates['@#DHEBREW@ 03 ELL 5481'] . '</td><td><kbd dir="ltr" lang="en">@#DHEBREW@ 03 ELL 5481</kbd></td></tr>' .
186
-		'<tr><th colspan="2">' . I18N::translate('Hijri') . '</th></tr>' .
187
-		'<tr><td>' . $dates['@#DHIJRI@ 1497'] . '</td><td><kbd dir="ltr" lang="en">@#DHIJRI@ 1497</kbd></td></tr>' .
188
-		'<tr><td>' . $dates['@#DHIJRI@ MUHAR 1497'] . '</td><td><kbd dir="ltr" lang="en">@#DHIJRI@ MUHAR 1497</kbd></td></tr>' .
189
-		'<tr><td>' . $dates['ABT @#DHIJRI@ SAFAR 1497'] . '</td><td><kbd dir="ltr" lang="en">ABT @#DHIJRI@ SAFAR 1497</kbd></td></tr>' .
190
-		'<tr><td>' . $dates['BET @#DHIJRI@ RABIA 1497 AND @#DHIJRI@ RABIT 1497'] . '</td><td><kbd dir="ltr" lang="en">BET @#DHIJRI@ RABIA 1497 AND @#DHIJRI@ RABIT 1497</kbd></td></tr>' .
191
-		'<tr><td>' . $dates['FROM @#DHIJRI@ JUMAA 1497 TO @#DHIJRI@ JUMAT 1497'] . '</td><td><kbd dir="ltr" lang="en">FROM @#DHIJRI@ JUMAA 1497 TO @#DHIJRI@ JUMAT 1497</kbd></td></tr>' .
192
-		'<tr><td>' . $dates['AFT @#DHIJRI@ RAJAB 1497'] . '</td><td><kbd dir="ltr" lang="en">AFT @#DHIJRI@ RAJAB 1497</kbd></td></tr>' .
193
-		'<tr><td>' . $dates['BEF @#DHIJRI@ SHAAB 1497'] . '</td><td><kbd dir="ltr" lang="en">BEF @#DHIJRI@ SHAAB 1497</kbd></td></tr>' .
194
-		'<tr><td>' . $dates['ABT @#DHIJRI@ RAMAD 1497'] . '</td><td><kbd dir="ltr" lang="en">ABT @#DHIJRI@ RAMAD 1497</kbd></td></tr>' .
195
-		'<tr><td>' . $dates['FROM @#DHIJRI@ SHAWW 1497'] . '</td><td><kbd dir="ltr" lang="en">FROM @#DHIJRI@ SHAWW 1497</kbd></td></tr>' .
196
-		'<tr><td>' . $dates['TO @#DHIJRI@ DHUAQ 1497'] . '</td><td><kbd dir="ltr" lang="en">TO @#DHIJRI@ DHUAQ 1497</kbd></td></tr>' .
197
-		'<tr><td>' . $dates['@#DHIJRI@ 03 DHUAH 1497'] . '</td><td><kbd dir="ltr" lang="en">@#DHIJRI@ 03 DHUAH 1497</kbd></td></tr>' .
198
-		'<tr><th colspan="2">' . I18N::translate('French') . '</th></tr>' .
199
-		'<tr><td>' . $dates['@#DFRENCH R@ 12'] . '</td><td><kbd dir="ltr" lang="en">@#DFRENCH R@ 12</kbd></td></tr>' .
200
-		'<tr><td>' . $dates['@#DFRENCH R@ VEND 12'] . '</td><td><kbd dir="ltr" lang="en">@#DFRENCH R@ VEND 12</kbd></td></tr>' .
201
-		'<tr><td>' . $dates['ABT @#DFRENCH R@ BRUM 12'] . '</td><td><kbd dir="ltr" lang="en">ABT @#DFRENCH R@ BRUM 12</kbd></td></tr>' .
202
-		'<tr><td>' . $dates['BET @#DFRENCH R@ FRIM 12 AND @#DFRENCH R@ NIVO 12'] . '</td><td><kbd dir="ltr" lang="en">BET @#DFRENCH R@ FRIM 12 AND @#DFRENCH R@ NIVO 12</kbd></td></tr>' .
203
-		'<tr><td>' . $dates['FROM @#DFRENCH R@ PLUV 12 TO @#DFRENCH R@ VENT 12'] . '</td><td><kbd dir="ltr" lang="en">FROM @#DFRENCH R@ PLUV 12 TO @#DFRENCH R@ VENT 12</kbd></td></tr>' .
204
-		'<tr><td>' . $dates['AFT @#DFRENCH R@ GERM 12'] . '</td><td><kbd dir="ltr" lang="en">AFT @#DFRENCH R@ GERM 12</kbd></td></tr>' .
205
-		'<tr><td>' . $dates['BEF @#DFRENCH R@ FLOR 12'] . '</td><td><kbd dir="ltr" lang="en">BEF @#DFRENCH R@ FLOR 12</kbd></td></tr>' .
206
-		'<tr><td>' . $dates['ABT @#DFRENCH R@ PRAI 12'] . '</td><td><kbd dir="ltr" lang="en">ABT @#DFRENCH R@ PRAI 12</kbd></td></tr>' .
207
-		'<tr><td>' . $dates['FROM @#DFRENCH R@ MESS 12'] . '</td><td><kbd dir="ltr" lang="en">FROM @#DFRENCH R@ MESS 12</kbd></td></tr>' .
208
-		'<tr><td>' . $dates['TO @#DFRENCH R@ THER 12'] . '</td><td><kbd dir="ltr" lang="en">TO @#DFRENCH R@ THER 12</kbd></td></tr>' .
209
-		'<tr><td>' . $dates['EST @#DFRENCH R@ FRUC 12'] . '</td><td><kbd dir="ltr" lang="en">EST @#DFRENCH R@ FRUC 12</kbd></td></tr>' .
210
-		'<tr><td>' . $dates['@#DFRENCH R@ 03 COMP 12'] . '</td><td><kbd dir="ltr" lang="en">@#DFRENCH R@ 03 COMP 12</kbd></td></tr>' .
211
-		'</table>';
212
-	break;
112
+    foreach ($dates as &$date) {
113
+        $date = strip_tags($date->display(false, null, false));
114
+    }
115
+    // These shortcuts work differently for different languages
116
+    switch (preg_replace('/[^DMY]/', '', str_replace(array('J', 'F'), array('D', 'M'), I18N::dateFormat()))) {
117
+    case 'YMD':
118
+        $example1 = '11/12/1913'; // Note: we ignore the DMY order if it doesn't make sense.
119
+        $example2 = '03/02/01';
120
+        break;
121
+    case 'MDY':
122
+        $example1 = '12/11/1913';
123
+        $example2 = '02/01/03';
124
+        break;
125
+    case 'DMY':
126
+    default:
127
+        $example1 = '11/12/1913';
128
+        $example2 = '01/02/03';
129
+        break;
130
+    }
131
+    $example1 .= '<br>' . str_replace('/', '-', $example1) . '<br>' . str_replace('/', '.', $example1);
132
+    $example2 .= '<br>' . str_replace('/', '-', $example2) . '<br>' . str_replace('/', '.', $example2);
133
+    $text =
134
+        '<p>' . I18N::translate('Dates are stored using English abbreviations and keywords. Shortcuts are available as alternatives to these abbreviations and keywords.') . '</p>' .
135
+        '<table border="1">' .
136
+        '<tr><th>' . I18N::translate('Date') . '</th><th>' . I18N::translate('Format') . '</th><th>' . I18N::translate('Shortcut') . '</th></tr>' .
137
+        '<tr><td>' . $dates['1900'] . '</td><td><kbd dir="ltr" lang="en">1900</kbd></td><td></td></tr>' .
138
+        '<tr><td>' . $dates['JAN 1900'] . '<br>' . $dates['FEB 1900'] . '<br>' . $dates['MAR 1900'] . '<br>' . $dates['APR 1900'] . '<br>' . $dates['MAY 1900'] . '<br>' . $dates['JUN 1900'] . '<br>' . $dates['JUL 1900'] . '<br>' . $dates['AUG 1900'] . '<br>' . $dates['SEP 1900'] . '<br>' . $dates['OCT 1900'] . '<br>' . $dates['NOV 1900'] . '<br>' . $dates['DEC 1900'] . '</td><td><kbd dir="ltr" lang="en">JAN 1900<br>FEB 1900<br>MAR 1900<br>APR 1900<br>MAY 1900<br>JUN 1900<br>JUL 1900<br>AUG 1900<br>SEP 1900<br>OCT 1900<br>NOV 1900<br>DEC 1900</kbd></td><td></td></tr>' .
139
+        '<tr><td>' . $dates['11 DEC 1913'] . '</td><td><kbd dir="ltr" lang="en">11 DEC 1913</kbd></td><td><kbd dir="ltr" lang="en">' . $example1 . '</kbd></td></tr>' .
140
+        '<tr><td>' . $dates['01 FEB 2003'] . '</td><td><kbd dir="ltr" lang="en">01 FEB 2003</kbd></td><td><kbd dir="ltr" lang="en">' . $example2 . '</kbd></td></tr>' .
141
+        '<tr><td>' . $dates['ABT 1900'] . '</td><td><kbd dir="ltr" lang="en">ABT 1900</kbd></td><td><kbd dir="ltr" lang="en">~1900</kbd></td></tr>' .
142
+        '<tr><td>' . $dates['EST 1900'] . '</td><td><kbd dir="ltr" lang="en">EST 1900</kbd></td><td><kbd dir="ltr" lang="en">*1900</kbd></td></tr>' .
143
+        '<tr><td>' . $dates['CAL 1900'] . '</td><td><kbd dir="ltr" lang="en">CAL 1900</kbd></td><td><kbd dir="ltr" lang="en">#1900</kbd></td></tr>' .
144
+        '<tr><td>' . $dates['INT 1900 (...)'] . '</td><td><kbd dir="ltr" lang="en">INT 1900 (...)</kbd></td><td></td></tr>' .
145
+        '</table>' .
146
+        '<p>' . I18N::translate('Date ranges are used to indicate that an event, such as a birth, happened on an unknown date within a possible range.') . '</p>' .
147
+        '<table border="1">' .
148
+        '<tr><th>' . I18N::translate('Date range') . '</th><th>' . I18N::translate('Format') . '</th><th>' . I18N::translate('Shortcut') . '</th></tr>' .
149
+        '<tr><td>' . $dates['BET 1900 AND 1910'] . '</td><td><kbd dir="ltr" lang="en">BET 1900 AND 1910</kbd></td><td><kbd dir="ltr" lang="en">1900-1910</kbd></td></tr>' .
150
+        '<tr><td>' . $dates['AFT 1900'] . '</td><td><kbd dir="ltr" lang="en">AFT 1900</kbd></td><td><kbd dir="ltr" lang="en">&gt;1900</kbd></td></tr>' .
151
+        '<tr><td>' . $dates['BEF 1910'] . '</td><td><kbd dir="ltr" lang="en">BEF 1910</kbd></td><td><kbd dir="ltr" lang="en">&lt;1910</kbd></td></tr>' .
152
+        '<tr><td>' . $dates['BET JAN 1900 AND MAR 1900'] . '</td><td><kbd dir="ltr" lang="en">BET JAN 1900 AND MAR 1900</kbd></td><td><kbd dir="ltr" lang="en">Q1 1900</kbd></td></tr>' .
153
+        '<tr><td>' . $dates['BET APR 1900 AND JUN 1900'] . '</td><td><kbd dir="ltr" lang="en">BET APR 1900 AND JUN 1900</kbd></td><td><kbd dir="ltr" lang="en">Q2 1900</kbd></td></tr>' .
154
+        '<tr><td>' . $dates['BET JUL 1900 AND SEP 1900'] . '</td><td><kbd dir="ltr" lang="en">BET JUL 1900 AND SEP 1900</kbd></td><td><kbd dir="ltr" lang="en">Q3 1900</kbd></td></tr>' .
155
+        '<tr><td>' . $dates['BET OCT 1900 AND DEC 1900'] . '</td><td><kbd dir="ltr" lang="en">BET OCT 1900 AND DEC 1900</kbd></td><td><kbd dir="ltr" lang="en">Q4 1900</kbd></td></tr>' .
156
+        '</table>' .
157
+        '<p>' . I18N::translate('Date periods are used to indicate that a fact, such as an occupation, continued for a period of time.') . '</p>' .
158
+        '<table border="1">' .
159
+        '<tr><th>' . I18N::translate('Date period') . '</th><th>' . I18N::translate('Format') . '</th><th>' . I18N::translate('Shortcut') . '</th></tr>' .
160
+        '<tr><td>' . $dates['FROM 1900 TO 1910'] . '</td><td><kbd dir="ltr" lang="en">FROM 1900 TO 1910</kbd></td><td><kbd dir="ltr" lang="en">1900~1910</kbd></td></tr>' .
161
+        '<tr><td>' . $dates['FROM 1900'] . '</td><td><kbd dir="ltr" lang="en">FROM 1900</kbd></td><td><kbd dir="ltr" lang="en">1900-</kbd></td></tr>' .
162
+        '<tr><td>' . $dates['TO 1910'] . '</td><td><kbd dir="ltr" lang="en">TO 1910</kbd></td><td><kbd dir="ltr" lang="en">-1900</kbd></td></tr>' .
163
+        '</table>' .
164
+        '<p>' . I18N::translate('Simple dates are assumed to be in the gregorian calendar. To specify a date in another calendar, add a keyword before the date. This keyword is optional if the month or year format make the date unambiguous.') . '</p>' .
165
+        '<table border="1">' .
166
+        '<tr><th>' . I18N::translate('Date') . '</th><th>' . I18N::translate('Format') . '</th></tr>' .
167
+        '<tr><th colspan="2">' . I18N::translate('Julian') . '</th></tr>' .
168
+        '<tr><td>' . $dates['@#DJULIAN@ 14 JAN 1700'] . '</td><td><kbd dir="ltr" lang="en">@#DJULIAN@ 14 JAN 1700</kbd></td></tr>' .
169
+        '<tr><td>' . $dates['@#DJULIAN@ 44 B.C.'] . '</td><td><kbd dir="ltr" lang="en">@#DJULIAN@ 44 B.C.</kbd></td></tr>' .
170
+        '<tr><td>' . $dates['@#DJULIAN@ 20 FEB 1742/43'] . '</td><td><kbd dir="ltr" lang="en">@#DJULIAN@ 20 FEB 1742/43</kbd></td></tr>' .
171
+        '<tr><td>' . $dates['BET @#DJULIAN@ 01 SEP 1752 AND @#DGREGORIAN@ 30 SEP 1752'] . '</td><td><kbd dir="ltr" lang="en">BET @#DJULIAN@ 01 SEP 1752 AND @#DGREGORIAN@ 30 SEP 1752</kbd></td></tr>' .
172
+        '<tr><th colspan="2">' . I18N::translate('Jewish') . '</th></tr>' .
173
+        '<tr><td>' . $dates['@#DHEBREW@ 5481'] . '</td><td><kbd dir="ltr" lang="en">@#DHEBREW@ 5481</kbd></td></tr>' .
174
+        '<tr><td>' . $dates['@#DHEBREW@ TSH 5481'] . '</td><td><kbd dir="ltr" lang="en">@#DHEBREW@ TSH 5481</kbd></td></tr>' .
175
+        '<tr><td>' . $dates['ABT @#DHEBREW@ CSH 5481'] . '</td><td><kbd dir="ltr" lang="en">ABT @#DHEBREW@ CSH 5481</kbd></td></tr>' .
176
+        '<tr><td>' . $dates['BET @#DHEBREW@ KSL 5481 AND @#DHEBREW@ TVT 5481'] . '</td><td><kbd dir="ltr" lang="en">BET @#DHEBREW@ KSL 5481 AND @#DHEBREW@ TVT 5481</kbd></td></tr>' .
177
+        '<tr><td>' . $dates['FROM @#DHEBREW@ SHV 5481 TO @#DHEBREW@ ADR 5481'] . '</td><td><kbd dir="ltr" lang="en">FROM @#DHEBREW@ SHV 5481 TO @#DHEBREW@ ADR 5481</kbd></td></tr>' .
178
+        '<tr><td>' . $dates['AFT @#DHEBREW@ ADR 5481'] . '</td><td><kbd dir="ltr" lang="en">AFT @#DHEBREW@ ADR 5481</kbd></td></tr>' .
179
+        '<tr><td>' . $dates['AFT @#DHEBREW@ ADS 5480'] . '</td><td><kbd dir="ltr" lang="en">AFT @#DHEBREW@ ADS 5480</kbd></td></tr>' .
180
+        '<tr><td>' . $dates['BEF @#DHEBREW@ NSN 5481'] . '</td><td><kbd dir="ltr" lang="en">BEF @#DHEBREW@ NSN 5481</kbd></td></tr>' .
181
+        '<tr><td>' . $dates['ABT @#DHEBREW@ IYR 5481'] . '</td><td><kbd dir="ltr" lang="en">ABT @#DHEBREW@ IYR 5481</kbd></td></tr>' .
182
+        '<tr><td>' . $dates['FROM @#DHEBREW@ SVN 5481'] . '</td><td><kbd dir="ltr" lang="en">FROM @#DHEBREW@ SVN 5481</kbd></td></tr>' .
183
+        '<tr><td>' . $dates['TO @#DHEBREW@ TMZ 5481'] . '</td><td><kbd dir="ltr" lang="en">TO @#DHEBREW@ TMZ 5481</kbd></td></tr>' .
184
+        '<tr><td>' . $dates['EST @#DHEBREW@ AAV 5481'] . '</td><td><kbd dir="ltr" lang="en">EST @#DHEBREW@ AAV 5481</kbd></td></tr>' .
185
+        '<tr><td>' . $dates['@#DHEBREW@ 03 ELL 5481'] . '</td><td><kbd dir="ltr" lang="en">@#DHEBREW@ 03 ELL 5481</kbd></td></tr>' .
186
+        '<tr><th colspan="2">' . I18N::translate('Hijri') . '</th></tr>' .
187
+        '<tr><td>' . $dates['@#DHIJRI@ 1497'] . '</td><td><kbd dir="ltr" lang="en">@#DHIJRI@ 1497</kbd></td></tr>' .
188
+        '<tr><td>' . $dates['@#DHIJRI@ MUHAR 1497'] . '</td><td><kbd dir="ltr" lang="en">@#DHIJRI@ MUHAR 1497</kbd></td></tr>' .
189
+        '<tr><td>' . $dates['ABT @#DHIJRI@ SAFAR 1497'] . '</td><td><kbd dir="ltr" lang="en">ABT @#DHIJRI@ SAFAR 1497</kbd></td></tr>' .
190
+        '<tr><td>' . $dates['BET @#DHIJRI@ RABIA 1497 AND @#DHIJRI@ RABIT 1497'] . '</td><td><kbd dir="ltr" lang="en">BET @#DHIJRI@ RABIA 1497 AND @#DHIJRI@ RABIT 1497</kbd></td></tr>' .
191
+        '<tr><td>' . $dates['FROM @#DHIJRI@ JUMAA 1497 TO @#DHIJRI@ JUMAT 1497'] . '</td><td><kbd dir="ltr" lang="en">FROM @#DHIJRI@ JUMAA 1497 TO @#DHIJRI@ JUMAT 1497</kbd></td></tr>' .
192
+        '<tr><td>' . $dates['AFT @#DHIJRI@ RAJAB 1497'] . '</td><td><kbd dir="ltr" lang="en">AFT @#DHIJRI@ RAJAB 1497</kbd></td></tr>' .
193
+        '<tr><td>' . $dates['BEF @#DHIJRI@ SHAAB 1497'] . '</td><td><kbd dir="ltr" lang="en">BEF @#DHIJRI@ SHAAB 1497</kbd></td></tr>' .
194
+        '<tr><td>' . $dates['ABT @#DHIJRI@ RAMAD 1497'] . '</td><td><kbd dir="ltr" lang="en">ABT @#DHIJRI@ RAMAD 1497</kbd></td></tr>' .
195
+        '<tr><td>' . $dates['FROM @#DHIJRI@ SHAWW 1497'] . '</td><td><kbd dir="ltr" lang="en">FROM @#DHIJRI@ SHAWW 1497</kbd></td></tr>' .
196
+        '<tr><td>' . $dates['TO @#DHIJRI@ DHUAQ 1497'] . '</td><td><kbd dir="ltr" lang="en">TO @#DHIJRI@ DHUAQ 1497</kbd></td></tr>' .
197
+        '<tr><td>' . $dates['@#DHIJRI@ 03 DHUAH 1497'] . '</td><td><kbd dir="ltr" lang="en">@#DHIJRI@ 03 DHUAH 1497</kbd></td></tr>' .
198
+        '<tr><th colspan="2">' . I18N::translate('French') . '</th></tr>' .
199
+        '<tr><td>' . $dates['@#DFRENCH R@ 12'] . '</td><td><kbd dir="ltr" lang="en">@#DFRENCH R@ 12</kbd></td></tr>' .
200
+        '<tr><td>' . $dates['@#DFRENCH R@ VEND 12'] . '</td><td><kbd dir="ltr" lang="en">@#DFRENCH R@ VEND 12</kbd></td></tr>' .
201
+        '<tr><td>' . $dates['ABT @#DFRENCH R@ BRUM 12'] . '</td><td><kbd dir="ltr" lang="en">ABT @#DFRENCH R@ BRUM 12</kbd></td></tr>' .
202
+        '<tr><td>' . $dates['BET @#DFRENCH R@ FRIM 12 AND @#DFRENCH R@ NIVO 12'] . '</td><td><kbd dir="ltr" lang="en">BET @#DFRENCH R@ FRIM 12 AND @#DFRENCH R@ NIVO 12</kbd></td></tr>' .
203
+        '<tr><td>' . $dates['FROM @#DFRENCH R@ PLUV 12 TO @#DFRENCH R@ VENT 12'] . '</td><td><kbd dir="ltr" lang="en">FROM @#DFRENCH R@ PLUV 12 TO @#DFRENCH R@ VENT 12</kbd></td></tr>' .
204
+        '<tr><td>' . $dates['AFT @#DFRENCH R@ GERM 12'] . '</td><td><kbd dir="ltr" lang="en">AFT @#DFRENCH R@ GERM 12</kbd></td></tr>' .
205
+        '<tr><td>' . $dates['BEF @#DFRENCH R@ FLOR 12'] . '</td><td><kbd dir="ltr" lang="en">BEF @#DFRENCH R@ FLOR 12</kbd></td></tr>' .
206
+        '<tr><td>' . $dates['ABT @#DFRENCH R@ PRAI 12'] . '</td><td><kbd dir="ltr" lang="en">ABT @#DFRENCH R@ PRAI 12</kbd></td></tr>' .
207
+        '<tr><td>' . $dates['FROM @#DFRENCH R@ MESS 12'] . '</td><td><kbd dir="ltr" lang="en">FROM @#DFRENCH R@ MESS 12</kbd></td></tr>' .
208
+        '<tr><td>' . $dates['TO @#DFRENCH R@ THER 12'] . '</td><td><kbd dir="ltr" lang="en">TO @#DFRENCH R@ THER 12</kbd></td></tr>' .
209
+        '<tr><td>' . $dates['EST @#DFRENCH R@ FRUC 12'] . '</td><td><kbd dir="ltr" lang="en">EST @#DFRENCH R@ FRUC 12</kbd></td></tr>' .
210
+        '<tr><td>' . $dates['@#DFRENCH R@ 03 COMP 12'] . '</td><td><kbd dir="ltr" lang="en">@#DFRENCH R@ 03 COMP 12</kbd></td></tr>' .
211
+        '</table>';
212
+    break;
213 213
 
214 214
 // This help text is used for all NAME components
215 215
 case 'NAME':
216
-	$title = GedcomTag::getLabel('NAME');
217
-	$text  =
218
-		'<p>' .
219
-		I18N::translate('The <b>name</b> field contains the individual’s full name, as they would have spelled it or as it was recorded. This is how it will be displayed on screen. It uses standard genealogy annotations to identify different parts of the name.') .
220
-		'</p>' .
221
-		'<ul><li>' .
222
-		I18N::translate('The surname is enclosed by slashes: <%s>John Paul /Smith/<%s>', 'span style="color:#0000ff;"', '/span') .
223
-		'</li><li>' .
224
-		I18N::translate('If the surname is unknown, use empty slashes: <%s>Mary //<%s>', 'span style="color:#0000ff;"', '/span') .
225
-		'</li><li>' .
226
-		I18N::translate('If an individual has two separate surnames, both should be enclosed by slashes: <%s>José Antonio /Gómez/ /Iglesias/<%s>', 'span style="color:#0000ff;"', '/span') .
227
-		'</li><li>' .
228
-		I18N::translate('If an individual does not have a surname, no slashes are needed: <%s>Jón Einarsson<%s>', 'span style="color:#0000ff;"', '/span') .
229
-		'</li><li>' .
230
-		I18N::translate('If an individual was not known by their first given name, the preferred name should be indicated with an asterisk: <%s>John Paul* /Smith/<%s>', 'span style="color:#0000ff;"', '/span') .
231
-		'</li><li>' .
232
-		I18N::translate('If an individual was known by a nickname which is not part of their formal name, it should be enclosed by quotation marks. For example, <%s>John &quot;Nobby&quot; /Clark/<%s>.', 'span style="color:#0000ff;"', '/span') .
233
-		'</li></ul>';
234
-	break;
216
+    $title = GedcomTag::getLabel('NAME');
217
+    $text  =
218
+        '<p>' .
219
+        I18N::translate('The <b>name</b> field contains the individual’s full name, as they would have spelled it or as it was recorded. This is how it will be displayed on screen. It uses standard genealogy annotations to identify different parts of the name.') .
220
+        '</p>' .
221
+        '<ul><li>' .
222
+        I18N::translate('The surname is enclosed by slashes: <%s>John Paul /Smith/<%s>', 'span style="color:#0000ff;"', '/span') .
223
+        '</li><li>' .
224
+        I18N::translate('If the surname is unknown, use empty slashes: <%s>Mary //<%s>', 'span style="color:#0000ff;"', '/span') .
225
+        '</li><li>' .
226
+        I18N::translate('If an individual has two separate surnames, both should be enclosed by slashes: <%s>José Antonio /Gómez/ /Iglesias/<%s>', 'span style="color:#0000ff;"', '/span') .
227
+        '</li><li>' .
228
+        I18N::translate('If an individual does not have a surname, no slashes are needed: <%s>Jón Einarsson<%s>', 'span style="color:#0000ff;"', '/span') .
229
+        '</li><li>' .
230
+        I18N::translate('If an individual was not known by their first given name, the preferred name should be indicated with an asterisk: <%s>John Paul* /Smith/<%s>', 'span style="color:#0000ff;"', '/span') .
231
+        '</li><li>' .
232
+        I18N::translate('If an individual was known by a nickname which is not part of their formal name, it should be enclosed by quotation marks. For example, <%s>John &quot;Nobby&quot; /Clark/<%s>.', 'span style="color:#0000ff;"', '/span') .
233
+        '</li></ul>';
234
+    break;
235 235
 
236 236
 case 'SURN':
237
-	$title = GedcomTag::getLabel('SURN');
238
-	$text  = '<p>' .
239
-		I18N::translate('The <b>surname</b> field contains a name that is used for sorting and grouping. It can be different to the individual’s actual surname which is always taken from the <b>name</b> field. This field can be used to sort surnames with or without a prefix (Gogh / van Gogh) and to group spelling variations or inflections (Kowalski / Kowalska). If an individual needs to be listed under more than one surname, each name should be separated by a comma.') .
240
-		'</p>';
241
-	break;
237
+    $title = GedcomTag::getLabel('SURN');
238
+    $text  = '<p>' .
239
+        I18N::translate('The <b>surname</b> field contains a name that is used for sorting and grouping. It can be different to the individual’s actual surname which is always taken from the <b>name</b> field. This field can be used to sort surnames with or without a prefix (Gogh / van Gogh) and to group spelling variations or inflections (Kowalski / Kowalska). If an individual needs to be listed under more than one surname, each name should be separated by a comma.') .
240
+        '</p>';
241
+    break;
242 242
 
243 243
 case 'OBJE':
244
-	$title = GedcomTag::getLabel('OBJE');
245
-	$text  =
246
-		'<p>' .
247
-		I18N::translate('A media object is a record in the family tree which contains information about a media file. This information may include a title, a copyright notice, a transcript, privacy restrictions, etc. The media file, such as the photo or video, can be stored locally (on this webserver) or remotely (on a different webserver).') .
248
-		'</p>';
249
-	break;
244
+    $title = GedcomTag::getLabel('OBJE');
245
+    $text  =
246
+        '<p>' .
247
+        I18N::translate('A media object is a record in the family tree which contains information about a media file. This information may include a title, a copyright notice, a transcript, privacy restrictions, etc. The media file, such as the photo or video, can be stored locally (on this webserver) or remotely (on a different webserver).') .
248
+        '</p>';
249
+    break;
250 250
 
251 251
 case 'PLAC':
252
-	$title = GedcomTag::getLabel('PLAC');
253
-	$text  = I18N::translate('Places should be entered according to the standards for genealogy. In genealogy, places are recorded with the most specific information about the place first and then working up to the least specific place last, using commas to separate the different place levels. The level at which you record the place information should represent the levels of government or church where vital records for that place are kept.<br><br>For example, a place like Salt Lake City would be entered as “Salt Lake City, Salt Lake, Utah, USA”.<br><br>Let’s examine each part of this place. The first part, “Salt Lake City,” is the city or township where the event occurred. In some countries, there may be municipalities or districts inside a city which are important to note. In that case, they should come before the city. The next part, “Salt Lake,” is the county. “Utah” is the state, and “USA” is the country. It is important to note each place because genealogy records are kept by the governments of each level.<br><br>If a level of the place is unknown, you should leave a space between the commas. Suppose, in the example above, you didn’t know the county for Salt Lake City. You should then record it like this: “Salt Lake City, , Utah, USA”. Suppose you only know that an individual was born in Utah. You would enter the information like this: “, , Utah, USA”. <br><br>You can use the <b>Find Place</b> link to help you find places that already exist in the database.');
254
-	break;
252
+    $title = GedcomTag::getLabel('PLAC');
253
+    $text  = I18N::translate('Places should be entered according to the standards for genealogy. In genealogy, places are recorded with the most specific information about the place first and then working up to the least specific place last, using commas to separate the different place levels. The level at which you record the place information should represent the levels of government or church where vital records for that place are kept.<br><br>For example, a place like Salt Lake City would be entered as “Salt Lake City, Salt Lake, Utah, USA”.<br><br>Let’s examine each part of this place. The first part, “Salt Lake City,” is the city or township where the event occurred. In some countries, there may be municipalities or districts inside a city which are important to note. In that case, they should come before the city. The next part, “Salt Lake,” is the county. “Utah” is the state, and “USA” is the country. It is important to note each place because genealogy records are kept by the governments of each level.<br><br>If a level of the place is unknown, you should leave a space between the commas. Suppose, in the example above, you didn’t know the county for Salt Lake City. You should then record it like this: “Salt Lake City, , Utah, USA”. Suppose you only know that an individual was born in Utah. You would enter the information like this: “, , Utah, USA”. <br><br>You can use the <b>Find Place</b> link to help you find places that already exist in the database.');
254
+    break;
255 255
 
256 256
 case 'RESN':
257
-	$title = GedcomTag::getLabel('RESN');
258
-	$text  =
259
-		I18N::translate('Restrictions can be added to records and/or facts. They restrict who can view the data and who can edit it.') .
260
-		'<br><br>' .
261
-		I18N::translate('Note that if a user account is linked to a record, then that user will always be able to view that record.');
262
-	break;
257
+    $title = GedcomTag::getLabel('RESN');
258
+    $text  =
259
+        I18N::translate('Restrictions can be added to records and/or facts. They restrict who can view the data and who can edit it.') .
260
+        '<br><br>' .
261
+        I18N::translate('Note that if a user account is linked to a record, then that user will always be able to view that record.');
262
+    break;
263 263
 
264 264
 case 'ROMN':
265
-	$title = GedcomTag::getLabel('ROMN');
266
-	$text  = I18N::translate('In many cultures it is customary to have a traditional name spelled in the traditional characters and also a romanized version of the name as it would be spelled or pronounced in languages based on the Latin alphabet, such as English.<br><br>If you prefer to use a non-Latin alphabet such as Hebrew, Greek, Russian, Chinese, or Arabic to enter the name in the standard name fields, then you can use this field to enter the same name using the Latin alphabet. Both versions of the name will appear in lists and charts.<br><br>Although this field is labeled “Romanized”, it is not restricted to containing only characters based on the Latin alphabet. This might be of use with Japanese names, where three different alphabets may occur.');
267
-	break;
265
+    $title = GedcomTag::getLabel('ROMN');
266
+    $text  = I18N::translate('In many cultures it is customary to have a traditional name spelled in the traditional characters and also a romanized version of the name as it would be spelled or pronounced in languages based on the Latin alphabet, such as English.<br><br>If you prefer to use a non-Latin alphabet such as Hebrew, Greek, Russian, Chinese, or Arabic to enter the name in the standard name fields, then you can use this field to enter the same name using the Latin alphabet. Both versions of the name will appear in lists and charts.<br><br>Although this field is labeled “Romanized”, it is not restricted to containing only characters based on the Latin alphabet. This might be of use with Japanese names, where three different alphabets may occur.');
267
+    break;
268 268
 
269 269
 case '_HEB':
270
-	$title = GedcomTag::getLabel('_HEB');
271
-	$text  = I18N::translate('In many cultures it is customary to have a traditional name spelled in the traditional characters and also a romanized version of the name as it would be spelled or pronounced in languages based on the Latin alphabet, such as English.<br><br>If you prefer to use the Latin alphabet to enter the name in the standard name fields, then you can use this field to enter the same name in the non-Latin alphabet such as Greek, Hebrew, Russian, Arabic, or Chinese. Both versions of the name will appear in lists and charts.<br><br>Although this field is labeled “Hebrew”, it is not restricted to containing only Hebrew characters.');
272
-	break;
270
+    $title = GedcomTag::getLabel('_HEB');
271
+    $text  = I18N::translate('In many cultures it is customary to have a traditional name spelled in the traditional characters and also a romanized version of the name as it would be spelled or pronounced in languages based on the Latin alphabet, such as English.<br><br>If you prefer to use the Latin alphabet to enter the name in the standard name fields, then you can use this field to enter the same name in the non-Latin alphabet such as Greek, Hebrew, Russian, Arabic, or Chinese. Both versions of the name will appear in lists and charts.<br><br>Although this field is labeled “Hebrew”, it is not restricted to containing only Hebrew characters.');
272
+    break;
273 273
 
274
-	//////////////////////////////////////////////////////////////////////////////
275
-	// This section contains all the other help items.
276
-	//////////////////////////////////////////////////////////////////////////////
274
+    //////////////////////////////////////////////////////////////////////////////
275
+    // This section contains all the other help items.
276
+    //////////////////////////////////////////////////////////////////////////////
277 277
 
278 278
 case 'annivers_year_select':
279
-	$title = I18N::translate('Year input box');
280
-	$text  = I18N::translate('This input box lets you change that year of the calendar. Type a year into the box and press <b>Enter</b> to change the calendar to that year.<br><br><b>Advanced features</b> for <b>View the year</b><dl><dt><b>More than one year</b></dt><dd>You can search for dates in a range of years.<br><br>Year ranges are <u>inclusive</u>. This means that the date range extends from 1 January of the first year of the range to 31 December of the last year mentioned. Here are a few examples of year ranges:<br><br><b>1992-5</b> for all events from 1992 to 1995.<br><b>1972-89</b> for all events from 1972 to 1989.<br><b>1610-759</b> for all events from 1610 to 1759.<br><b>1880-1905</b> for all events from 1880 to 1905.<br><b>880-1105</b> for all events from 880 to 1105.<br><br>To see all the events in a given decade or century, you can use <b>?</b> in place of the final digits. For example, <b>197?</b> for all events from 1970 to 1979 or <b>16??</b> for all events from 1600 to 1699.<br><br>Selecting a range of years will change the calendar to the year view.</dd></dl>');
281
-	break;
279
+    $title = I18N::translate('Year input box');
280
+    $text  = I18N::translate('This input box lets you change that year of the calendar. Type a year into the box and press <b>Enter</b> to change the calendar to that year.<br><br><b>Advanced features</b> for <b>View the year</b><dl><dt><b>More than one year</b></dt><dd>You can search for dates in a range of years.<br><br>Year ranges are <u>inclusive</u>. This means that the date range extends from 1 January of the first year of the range to 31 December of the last year mentioned. Here are a few examples of year ranges:<br><br><b>1992-5</b> for all events from 1992 to 1995.<br><b>1972-89</b> for all events from 1972 to 1989.<br><b>1610-759</b> for all events from 1610 to 1759.<br><b>1880-1905</b> for all events from 1880 to 1905.<br><b>880-1105</b> for all events from 880 to 1105.<br><br>To see all the events in a given decade or century, you can use <b>?</b> in place of the final digits. For example, <b>197?</b> for all events from 1970 to 1979 or <b>16??</b> for all events from 1600 to 1699.<br><br>Selecting a range of years will change the calendar to the year view.</dd></dl>');
281
+    break;
282 282
 
283 283
 case 'edit_edit_raw':
284
-	$title = I18N::translate('Edit the raw GEDCOM');
285
-	$text  =
286
-		I18N::translate('This page allows you to bypass the usual forms, and edit the underlying data directly. It is an advanced option, and you should not use it unless you understand the GEDCOM format. If you make a mistake here, it can be difficult to fix.') .
287
-		'<br><br>' .
288
-		/* I18N: %s is a URL */ I18N::translate('You can download a copy of the GEDCOM specification from %s.', '<a href="https://wiki.webtrees.net/w/images-en/Ged551-5.pdf">https://wiki.webtrees.net/w/images-en/Ged551-5.pdf</a>');
289
-	break;
284
+    $title = I18N::translate('Edit the raw GEDCOM');
285
+    $text  =
286
+        I18N::translate('This page allows you to bypass the usual forms, and edit the underlying data directly. It is an advanced option, and you should not use it unless you understand the GEDCOM format. If you make a mistake here, it can be difficult to fix.') .
287
+        '<br><br>' .
288
+        /* I18N: %s is a URL */ I18N::translate('You can download a copy of the GEDCOM specification from %s.', '<a href="https://wiki.webtrees.net/w/images-en/Ged551-5.pdf">https://wiki.webtrees.net/w/images-en/Ged551-5.pdf</a>');
289
+    break;
290 290
 
291 291
 case 'edit_SOUR_EVEN':
292
-	$title = I18N::translate('Associate events with this source');
293
-	$text  = I18N::translate('Each source records specific events, generally for a given date range and for a place jurisdiction. For example a Census records census events and church records record birth, marriage, and death events.<br><br>Select the events that are recorded by this source from the list of events provided. The date should be specified in a range format such as <i>FROM 1900 TO 1910</i>. The place jurisdiction is the name of the lowest jurisdiction that encompasses all lower-level places named in this source. For example, “Oneida, Idaho, USA” would be used as a source jurisdiction place for events occurring in the various towns within Oneida County. “Idaho, USA” would be the source jurisdiction place if the events recorded took place not only in Oneida County but also in other counties in Idaho.');
294
-	break;
292
+    $title = I18N::translate('Associate events with this source');
293
+    $text  = I18N::translate('Each source records specific events, generally for a given date range and for a place jurisdiction. For example a Census records census events and church records record birth, marriage, and death events.<br><br>Select the events that are recorded by this source from the list of events provided. The date should be specified in a range format such as <i>FROM 1900 TO 1910</i>. The place jurisdiction is the name of the lowest jurisdiction that encompasses all lower-level places named in this source. For example, “Oneida, Idaho, USA” would be used as a source jurisdiction place for events occurring in the various towns within Oneida County. “Idaho, USA” would be the source jurisdiction place if the events recorded took place not only in Oneida County but also in other counties in Idaho.');
294
+    break;
295 295
 
296 296
 case 'google_chart_surname':
297
-	$title = I18N::translate('Surname');
298
-	$text  = I18N::translate('The number of occurrences of the specified name will be shown on the map. If you leave this field empty, the most common surname will be used.');
299
-	break;
297
+    $title = I18N::translate('Surname');
298
+    $text  = I18N::translate('The number of occurrences of the specified name will be shown on the map. If you leave this field empty, the most common surname will be used.');
299
+    break;
300 300
 
301 301
 case 'pending_changes':
302
-	$title = I18N::translate('Pending changes');
303
-	$text  =
304
-		'<p>' .
305
-		I18N::translate('When you add, edit, or delete information, the changes are not saved immediately. Instead, they are kept in a “pending” area. These pending changes need to be reviewed by a moderator before they are accepted.') .
306
-		'</p><p>' .
307
-		I18N::translate('This process allows the site’s owner to ensure that the new information follows the site’s standards and conventions, has proper source attributions, etc.') .
308
-		'</p><p>' .
309
-		I18N::translate('Pending changes are only shown when your account has permission to edit. When you sign out, you will no longer be able to see them. Also, pending changes are only shown on certain pages. For example, they are not shown in lists, reports, or search results.') .
310
-		'</p>';
311
-	if (Auth::isAdmin()) {
312
-		$text .=
313
-			'<p>' .
314
-			I18N::translate('Each user account has an option to “automatically accept changes”. When this is enabled, any changes made by that user are saved immediately. Many administrators enable this for their own user account.') .
315
-			'</p>';
316
-	}
317
-	break;
302
+    $title = I18N::translate('Pending changes');
303
+    $text  =
304
+        '<p>' .
305
+        I18N::translate('When you add, edit, or delete information, the changes are not saved immediately. Instead, they are kept in a “pending” area. These pending changes need to be reviewed by a moderator before they are accepted.') .
306
+        '</p><p>' .
307
+        I18N::translate('This process allows the site’s owner to ensure that the new information follows the site’s standards and conventions, has proper source attributions, etc.') .
308
+        '</p><p>' .
309
+        I18N::translate('Pending changes are only shown when your account has permission to edit. When you sign out, you will no longer be able to see them. Also, pending changes are only shown on certain pages. For example, they are not shown in lists, reports, or search results.') .
310
+        '</p>';
311
+    if (Auth::isAdmin()) {
312
+        $text .=
313
+            '<p>' .
314
+            I18N::translate('Each user account has an option to “automatically accept changes”. When this is enabled, any changes made by that user are saved immediately. Many administrators enable this for their own user account.') .
315
+            '</p>';
316
+    }
317
+    break;
318 318
 
319 319
 default:
320
-	$title = I18N::translate('Help');
321
-	$text  = I18N::translate('The help text has not been written for this item.');
322
-	break;
320
+    $title = I18N::translate('Help');
321
+    $text  = I18N::translate('The help text has not been written for this item.');
322
+    break;
323 323
 }
324 324
 // This file is called by a getJSON call so return the data
325 325
 // in correct format
Please login to merge, or discard this patch.
Switch Indentation   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -32,102 +32,102 @@  discard block
 block discarded – undo
32 32
 	// Generally, these tags need to be lists explicitly in FunctionsEdit::add_simple_tag()
33 33
 	//////////////////////////////////////////////////////////////////////////////
34 34
 
35
-case 'DATE':
36
-	$title = GedcomTag::getLabel('DATE');
37
-	$dates = array(
38
-		'1900'                                                       => new Date('1900'),
39
-		'JAN 1900'                                                   => new Date('JAN 1900'),
40
-		'FEB 1900'                                                   => new Date('FEB 1900'),
41
-		'MAR 1900'                                                   => new Date('MAR 1900'),
42
-		'APR 1900'                                                   => new Date('APR 1900'),
43
-		'MAY 1900'                                                   => new Date('MAY 1900'),
44
-		'JUN 1900'                                                   => new Date('JUN 1900'),
45
-		'JUL 1900'                                                   => new Date('JUL 1900'),
46
-		'AUG 1900'                                                   => new Date('AUG 1900'),
47
-		'SEP 1900'                                                   => new Date('SEP 1900'),
48
-		'OCT 1900'                                                   => new Date('OCT 1900'),
49
-		'NOV 1900'                                                   => new Date('NOV 1900'),
50
-		'DEC 1900'                                                   => new Date('DEC 1900'),
51
-		'11 DEC 1913'                                                => new Date('11 DEC 1913'),
52
-		'01 FEB 2003'                                                => new Date('01 FEB 2003'),
53
-		'ABT 1900'                                                   => new Date('ABT 1900'),
54
-		'EST 1900'                                                   => new Date('EST 1900'),
55
-		'CAL 1900'                                                   => new Date('CAL 1900'),
56
-		'INT 1900 (...)'                                             => new Date('INT 1900 (...)'),
57
-		'@#DJULIAN@ 44 B.C.'                                         => new Date('@#DJULIAN@ 44 B.C.'),
58
-		'@#DJULIAN@ 14 JAN 1700'                                     => new Date('@#DJULIAN@ 14 JAN 1700'),
59
-		'BET @#DJULIAN@ 01 SEP 1752 AND @#DGREGORIAN@ 30 SEP 1752'   => new Date('BET @#DJULIAN@ 01 SEP 1752 AND @#DGREGORIAN@ 30 SEP 1752'),
60
-		'@#DJULIAN@ 20 FEB 1742/43'                                  => new Date('@#DJULIAN@ 20 FEB 1742/43'),
61
-		'FROM 1900 TO 1910'                                          => new Date('FROM 1900 TO 1910'),
62
-		'FROM 1900'                                                  => new Date('FROM 1900'),
63
-		'TO 1910'                                                    => new Date('TO 1910'),
64
-		'BET 1900 AND 1910'                                          => new Date('BET 1900 AND 1910'),
65
-		'BET JAN 1900 AND MAR 1900'                                  => new Date('BET JAN 1900 AND MAR 1900'),
66
-		'BET APR 1900 AND JUN 1900'                                  => new Date('BET APR 1900 AND JUN 1900'),
67
-		'BET JUL 1900 AND SEP 1900'                                  => new Date('BET JUL 1900 AND SEP 1900'),
68
-		'BET OCT 1900 AND DEC 1900'                                  => new Date('BET OCT 1900 AND DEC 1900'),
69
-		'AFT 1900'                                                   => new Date('AFT 1900'),
70
-		'BEF 1910'                                                   => new Date('BEF 1910'),
71
-		// Hijri dates
72
-		'@#DHIJRI@ 1497'                                    => new Date('@#DHIJRI@ 1497'),
73
-		'@#DHIJRI@ MUHAR 1497'                              => new Date('@#DHIJRI@ MUHAR 1497'),
74
-		'ABT @#DHIJRI@ SAFAR 1497'                          => new Date('ABT @#DHIJRI@ SAFAR 1497'),
75
-		'BET @#DHIJRI@ RABIA 1497 AND @#DHIJRI@ RABIT 1497' => new Date('BET @#DHIJRI@ RABIA 1497 AND @#DHIJRI@ RABIT 1497'),
76
-		'FROM @#DHIJRI@ JUMAA 1497 TO @#DHIJRI@ JUMAT 1497' => new Date('FROM @#DHIJRI@ JUMAA 1497 TO @#DHIJRI@ JUMAT 1497'),
77
-		'AFT @#DHIJRI@ RAJAB 1497'                          => new Date('AFT @#DHIJRI@ RAJAB 1497'),
78
-		'BEF @#DHIJRI@ SHAAB 1497'                          => new Date('BEF @#DHIJRI@ SHAAB 1497'),
79
-		'ABT @#DHIJRI@ RAMAD 1497'                          => new Date('ABT @#DHIJRI@ RAMAD 1497'),
80
-		'FROM @#DHIJRI@ SHAWW 1497'                         => new Date('FROM @#DHIJRI@ SHAWW 1497'),
81
-		'TO @#DHIJRI@ DHUAQ 1497'                           => new Date('TO @#DHIJRI@ DHUAQ 1497'),
82
-		'@#DHIJRI@ 03 DHUAH 1497'                           => new Date('@#DHIJRI@ 03 DHUAH 1497'),
83
-		// French dates
84
-		'@#DFRENCH R@ 12'                                   => new Date('@#DFRENCH R@ 12'),
85
-		'@#DFRENCH R@ VEND 12'                              => new Date('@#DFRENCH R@ VEND 12'),
86
-		'ABT @#DFRENCH R@ BRUM 12'                          => new Date('ABT @#DFRENCH R@ BRUM 12'),
87
-		'BET @#DFRENCH R@ FRIM 12 AND @#DFRENCH R@ NIVO 12' => new Date('BET @#DFRENCH R@ FRIM 12 AND @#DFRENCH R@ NIVO 12'),
88
-		'FROM @#DFRENCH R@ PLUV 12 TO @#DFRENCH R@ VENT 12' => new Date('FROM @#DFRENCH R@ PLUV 12 TO @#DFRENCH R@ VENT 12'),
89
-		'AFT @#DFRENCH R@ GERM 12'                          => new Date('AFT @#DFRENCH R@ GERM 12'),
90
-		'BEF @#DFRENCH R@ FLOR 12'                          => new Date('BEF @#DFRENCH R@ FLOR 12'),
91
-		'ABT @#DFRENCH R@ PRAI 12'                          => new Date('ABT @#DFRENCH R@ PRAI 12'),
92
-		'FROM @#DFRENCH R@ MESS 12'                         => new Date('FROM @#DFRENCH R@ MESS 12'),
93
-		'TO @#DFRENCH R@ THER 12'                           => new Date('TO @#DFRENCH R@ THER 12'),
94
-		'EST @#DFRENCH R@ FRUC 12'                          => new Date('EST @#DFRENCH R@ FRUC 12'),
95
-		'@#DFRENCH R@ 03 COMP 12'                           => new Date('@#DFRENCH R@ 03 COMP 12'),
96
-		// Jewish dates
97
-		'@#DHEBREW@ 5481'                                 => new Date('@#DHEBREW@ 5481'),
98
-		'@#DHEBREW@ TSH 5481'                             => new Date('@#DHEBREW@ TSH 5481'),
99
-		'ABT @#DHEBREW@ CSH 5481'                         => new Date('ABT @#DHEBREW@ CSH 5481'),
100
-		'BET @#DHEBREW@ KSL 5481 AND @#DHEBREW@ TVT 5481' => new Date('BET @#DHEBREW@ KSL 5481 AND @#DHEBREW@ TVT 5481'),
101
-		'FROM @#DHEBREW@ SHV 5481 TO @#DHEBREW@ ADR 5481' => new Date('FROM @#DHEBREW@ SHV 5481 TO @#DHEBREW@ ADR 5481'),
102
-		'AFT @#DHEBREW@ ADR 5481'                         => new Date('AFT @#DHEBREW@ ADR 5481'),
103
-		'AFT @#DHEBREW@ ADS 5480'                         => new Date('AFT @#DHEBREW@ ADS 5480'),
104
-		'BEF @#DHEBREW@ NSN 5481'                         => new Date('BEF @#DHEBREW@ NSN 5481'),
105
-		'ABT @#DHEBREW@ IYR 5481'                         => new Date('ABT @#DHEBREW@ IYR 5481'),
106
-		'FROM @#DHEBREW@ SVN 5481'                        => new Date('FROM @#DHEBREW@ SVN 5481'),
107
-		'TO @#DHEBREW@ TMZ 5481'                          => new Date('TO @#DHEBREW@ TMZ 5481'),
108
-		'EST @#DHEBREW@ AAV 5481'                         => new Date('EST @#DHEBREW@ AAV 5481'),
109
-		'@#DHEBREW@ 03 ELL 5481'                          => new Date('@#DHEBREW@ 03 ELL 5481'),
110
-	);
35
+    case 'DATE':
36
+	    $title = GedcomTag::getLabel('DATE');
37
+	    $dates = array(
38
+		    '1900'                                                       => new Date('1900'),
39
+		    'JAN 1900'                                                   => new Date('JAN 1900'),
40
+		    'FEB 1900'                                                   => new Date('FEB 1900'),
41
+		    'MAR 1900'                                                   => new Date('MAR 1900'),
42
+		    'APR 1900'                                                   => new Date('APR 1900'),
43
+		    'MAY 1900'                                                   => new Date('MAY 1900'),
44
+		    'JUN 1900'                                                   => new Date('JUN 1900'),
45
+		    'JUL 1900'                                                   => new Date('JUL 1900'),
46
+		    'AUG 1900'                                                   => new Date('AUG 1900'),
47
+		    'SEP 1900'                                                   => new Date('SEP 1900'),
48
+		    'OCT 1900'                                                   => new Date('OCT 1900'),
49
+		    'NOV 1900'                                                   => new Date('NOV 1900'),
50
+		    'DEC 1900'                                                   => new Date('DEC 1900'),
51
+		    '11 DEC 1913'                                                => new Date('11 DEC 1913'),
52
+		    '01 FEB 2003'                                                => new Date('01 FEB 2003'),
53
+		    'ABT 1900'                                                   => new Date('ABT 1900'),
54
+		    'EST 1900'                                                   => new Date('EST 1900'),
55
+		    'CAL 1900'                                                   => new Date('CAL 1900'),
56
+		    'INT 1900 (...)'                                             => new Date('INT 1900 (...)'),
57
+		    '@#DJULIAN@ 44 B.C.'                                         => new Date('@#DJULIAN@ 44 B.C.'),
58
+		    '@#DJULIAN@ 14 JAN 1700'                                     => new Date('@#DJULIAN@ 14 JAN 1700'),
59
+		    'BET @#DJULIAN@ 01 SEP 1752 AND @#DGREGORIAN@ 30 SEP 1752'   => new Date('BET @#DJULIAN@ 01 SEP 1752 AND @#DGREGORIAN@ 30 SEP 1752'),
60
+		    '@#DJULIAN@ 20 FEB 1742/43'                                  => new Date('@#DJULIAN@ 20 FEB 1742/43'),
61
+		    'FROM 1900 TO 1910'                                          => new Date('FROM 1900 TO 1910'),
62
+		    'FROM 1900'                                                  => new Date('FROM 1900'),
63
+		    'TO 1910'                                                    => new Date('TO 1910'),
64
+		    'BET 1900 AND 1910'                                          => new Date('BET 1900 AND 1910'),
65
+		    'BET JAN 1900 AND MAR 1900'                                  => new Date('BET JAN 1900 AND MAR 1900'),
66
+		    'BET APR 1900 AND JUN 1900'                                  => new Date('BET APR 1900 AND JUN 1900'),
67
+		    'BET JUL 1900 AND SEP 1900'                                  => new Date('BET JUL 1900 AND SEP 1900'),
68
+		    'BET OCT 1900 AND DEC 1900'                                  => new Date('BET OCT 1900 AND DEC 1900'),
69
+		    'AFT 1900'                                                   => new Date('AFT 1900'),
70
+		    'BEF 1910'                                                   => new Date('BEF 1910'),
71
+		    // Hijri dates
72
+		    '@#DHIJRI@ 1497'                                    => new Date('@#DHIJRI@ 1497'),
73
+		    '@#DHIJRI@ MUHAR 1497'                              => new Date('@#DHIJRI@ MUHAR 1497'),
74
+		    'ABT @#DHIJRI@ SAFAR 1497'                          => new Date('ABT @#DHIJRI@ SAFAR 1497'),
75
+		    'BET @#DHIJRI@ RABIA 1497 AND @#DHIJRI@ RABIT 1497' => new Date('BET @#DHIJRI@ RABIA 1497 AND @#DHIJRI@ RABIT 1497'),
76
+		    'FROM @#DHIJRI@ JUMAA 1497 TO @#DHIJRI@ JUMAT 1497' => new Date('FROM @#DHIJRI@ JUMAA 1497 TO @#DHIJRI@ JUMAT 1497'),
77
+		    'AFT @#DHIJRI@ RAJAB 1497'                          => new Date('AFT @#DHIJRI@ RAJAB 1497'),
78
+		    'BEF @#DHIJRI@ SHAAB 1497'                          => new Date('BEF @#DHIJRI@ SHAAB 1497'),
79
+		    'ABT @#DHIJRI@ RAMAD 1497'                          => new Date('ABT @#DHIJRI@ RAMAD 1497'),
80
+		    'FROM @#DHIJRI@ SHAWW 1497'                         => new Date('FROM @#DHIJRI@ SHAWW 1497'),
81
+		    'TO @#DHIJRI@ DHUAQ 1497'                           => new Date('TO @#DHIJRI@ DHUAQ 1497'),
82
+		    '@#DHIJRI@ 03 DHUAH 1497'                           => new Date('@#DHIJRI@ 03 DHUAH 1497'),
83
+		    // French dates
84
+		    '@#DFRENCH R@ 12'                                   => new Date('@#DFRENCH R@ 12'),
85
+		    '@#DFRENCH R@ VEND 12'                              => new Date('@#DFRENCH R@ VEND 12'),
86
+		    'ABT @#DFRENCH R@ BRUM 12'                          => new Date('ABT @#DFRENCH R@ BRUM 12'),
87
+		    'BET @#DFRENCH R@ FRIM 12 AND @#DFRENCH R@ NIVO 12' => new Date('BET @#DFRENCH R@ FRIM 12 AND @#DFRENCH R@ NIVO 12'),
88
+		    'FROM @#DFRENCH R@ PLUV 12 TO @#DFRENCH R@ VENT 12' => new Date('FROM @#DFRENCH R@ PLUV 12 TO @#DFRENCH R@ VENT 12'),
89
+		    'AFT @#DFRENCH R@ GERM 12'                          => new Date('AFT @#DFRENCH R@ GERM 12'),
90
+		    'BEF @#DFRENCH R@ FLOR 12'                          => new Date('BEF @#DFRENCH R@ FLOR 12'),
91
+		    'ABT @#DFRENCH R@ PRAI 12'                          => new Date('ABT @#DFRENCH R@ PRAI 12'),
92
+		    'FROM @#DFRENCH R@ MESS 12'                         => new Date('FROM @#DFRENCH R@ MESS 12'),
93
+		    'TO @#DFRENCH R@ THER 12'                           => new Date('TO @#DFRENCH R@ THER 12'),
94
+		    'EST @#DFRENCH R@ FRUC 12'                          => new Date('EST @#DFRENCH R@ FRUC 12'),
95
+		    '@#DFRENCH R@ 03 COMP 12'                           => new Date('@#DFRENCH R@ 03 COMP 12'),
96
+		    // Jewish dates
97
+		    '@#DHEBREW@ 5481'                                 => new Date('@#DHEBREW@ 5481'),
98
+		    '@#DHEBREW@ TSH 5481'                             => new Date('@#DHEBREW@ TSH 5481'),
99
+		    'ABT @#DHEBREW@ CSH 5481'                         => new Date('ABT @#DHEBREW@ CSH 5481'),
100
+		    'BET @#DHEBREW@ KSL 5481 AND @#DHEBREW@ TVT 5481' => new Date('BET @#DHEBREW@ KSL 5481 AND @#DHEBREW@ TVT 5481'),
101
+		    'FROM @#DHEBREW@ SHV 5481 TO @#DHEBREW@ ADR 5481' => new Date('FROM @#DHEBREW@ SHV 5481 TO @#DHEBREW@ ADR 5481'),
102
+		    'AFT @#DHEBREW@ ADR 5481'                         => new Date('AFT @#DHEBREW@ ADR 5481'),
103
+		    'AFT @#DHEBREW@ ADS 5480'                         => new Date('AFT @#DHEBREW@ ADS 5480'),
104
+		    'BEF @#DHEBREW@ NSN 5481'                         => new Date('BEF @#DHEBREW@ NSN 5481'),
105
+		    'ABT @#DHEBREW@ IYR 5481'                         => new Date('ABT @#DHEBREW@ IYR 5481'),
106
+		    'FROM @#DHEBREW@ SVN 5481'                        => new Date('FROM @#DHEBREW@ SVN 5481'),
107
+		    'TO @#DHEBREW@ TMZ 5481'                          => new Date('TO @#DHEBREW@ TMZ 5481'),
108
+		    'EST @#DHEBREW@ AAV 5481'                         => new Date('EST @#DHEBREW@ AAV 5481'),
109
+		    '@#DHEBREW@ 03 ELL 5481'                          => new Date('@#DHEBREW@ 03 ELL 5481'),
110
+	    );
111 111
 
112
-	foreach ($dates as &$date) {
113
-		$date = strip_tags($date->display(false, null, false));
114
-	}
115
-	// These shortcuts work differently for different languages
116
-	switch (preg_replace('/[^DMY]/', '', str_replace(array('J', 'F'), array('D', 'M'), I18N::dateFormat()))) {
117
-	case 'YMD':
118
-		$example1 = '11/12/1913'; // Note: we ignore the DMY order if it doesn't make sense.
119
-		$example2 = '03/02/01';
120
-		break;
121
-	case 'MDY':
122
-		$example1 = '12/11/1913';
123
-		$example2 = '02/01/03';
124
-		break;
125
-	case 'DMY':
126
-	default:
127
-		$example1 = '11/12/1913';
128
-		$example2 = '01/02/03';
129
-		break;
130
-	}
112
+	    foreach ($dates as &$date) {
113
+		    $date = strip_tags($date->display(false, null, false));
114
+	    }
115
+	    // These shortcuts work differently for different languages
116
+	    switch (preg_replace('/[^DMY]/', '', str_replace(array('J', 'F'), array('D', 'M'), I18N::dateFormat()))) {
117
+	        case 'YMD':
118
+		        $example1 = '11/12/1913'; // Note: we ignore the DMY order if it doesn't make sense.
119
+		        $example2 = '03/02/01';
120
+		        break;
121
+	        case 'MDY':
122
+		        $example1 = '12/11/1913';
123
+		        $example2 = '02/01/03';
124
+		        break;
125
+	        case 'DMY':
126
+	        default:
127
+		        $example1 = '11/12/1913';
128
+		        $example2 = '01/02/03';
129
+		        break;
130
+	    }
131 131
 	$example1 .= '<br>' . str_replace('/', '-', $example1) . '<br>' . str_replace('/', '.', $example1);
132 132
 	$example2 .= '<br>' . str_replace('/', '-', $example2) . '<br>' . str_replace('/', '.', $example2);
133 133
 	$text =
@@ -212,114 +212,114 @@  discard block
 block discarded – undo
212 212
 	break;
213 213
 
214 214
 // This help text is used for all NAME components
215
-case 'NAME':
216
-	$title = GedcomTag::getLabel('NAME');
217
-	$text  =
218
-		'<p>' .
219
-		I18N::translate('The <b>name</b> field contains the individual’s full name, as they would have spelled it or as it was recorded. This is how it will be displayed on screen. It uses standard genealogy annotations to identify different parts of the name.') .
220
-		'</p>' .
221
-		'<ul><li>' .
222
-		I18N::translate('The surname is enclosed by slashes: <%s>John Paul /Smith/<%s>', 'span style="color:#0000ff;"', '/span') .
223
-		'</li><li>' .
224
-		I18N::translate('If the surname is unknown, use empty slashes: <%s>Mary //<%s>', 'span style="color:#0000ff;"', '/span') .
225
-		'</li><li>' .
226
-		I18N::translate('If an individual has two separate surnames, both should be enclosed by slashes: <%s>José Antonio /Gómez/ /Iglesias/<%s>', 'span style="color:#0000ff;"', '/span') .
227
-		'</li><li>' .
228
-		I18N::translate('If an individual does not have a surname, no slashes are needed: <%s>Jón Einarsson<%s>', 'span style="color:#0000ff;"', '/span') .
229
-		'</li><li>' .
230
-		I18N::translate('If an individual was not known by their first given name, the preferred name should be indicated with an asterisk: <%s>John Paul* /Smith/<%s>', 'span style="color:#0000ff;"', '/span') .
231
-		'</li><li>' .
232
-		I18N::translate('If an individual was known by a nickname which is not part of their formal name, it should be enclosed by quotation marks. For example, <%s>John &quot;Nobby&quot; /Clark/<%s>.', 'span style="color:#0000ff;"', '/span') .
233
-		'</li></ul>';
234
-	break;
215
+    case 'NAME':
216
+	    $title = GedcomTag::getLabel('NAME');
217
+	    $text  =
218
+		    '<p>' .
219
+		    I18N::translate('The <b>name</b> field contains the individual’s full name, as they would have spelled it or as it was recorded. This is how it will be displayed on screen. It uses standard genealogy annotations to identify different parts of the name.') .
220
+		    '</p>' .
221
+		    '<ul><li>' .
222
+		    I18N::translate('The surname is enclosed by slashes: <%s>John Paul /Smith/<%s>', 'span style="color:#0000ff;"', '/span') .
223
+		    '</li><li>' .
224
+		    I18N::translate('If the surname is unknown, use empty slashes: <%s>Mary //<%s>', 'span style="color:#0000ff;"', '/span') .
225
+		    '</li><li>' .
226
+		    I18N::translate('If an individual has two separate surnames, both should be enclosed by slashes: <%s>José Antonio /Gómez/ /Iglesias/<%s>', 'span style="color:#0000ff;"', '/span') .
227
+		    '</li><li>' .
228
+		    I18N::translate('If an individual does not have a surname, no slashes are needed: <%s>Jón Einarsson<%s>', 'span style="color:#0000ff;"', '/span') .
229
+		    '</li><li>' .
230
+		    I18N::translate('If an individual was not known by their first given name, the preferred name should be indicated with an asterisk: <%s>John Paul* /Smith/<%s>', 'span style="color:#0000ff;"', '/span') .
231
+		    '</li><li>' .
232
+		    I18N::translate('If an individual was known by a nickname which is not part of their formal name, it should be enclosed by quotation marks. For example, <%s>John &quot;Nobby&quot; /Clark/<%s>.', 'span style="color:#0000ff;"', '/span') .
233
+		    '</li></ul>';
234
+	    break;
235 235
 
236
-case 'SURN':
237
-	$title = GedcomTag::getLabel('SURN');
238
-	$text  = '<p>' .
239
-		I18N::translate('The <b>surname</b> field contains a name that is used for sorting and grouping. It can be different to the individual’s actual surname which is always taken from the <b>name</b> field. This field can be used to sort surnames with or without a prefix (Gogh / van Gogh) and to group spelling variations or inflections (Kowalski / Kowalska). If an individual needs to be listed under more than one surname, each name should be separated by a comma.') .
240
-		'</p>';
241
-	break;
236
+    case 'SURN':
237
+	    $title = GedcomTag::getLabel('SURN');
238
+	    $text  = '<p>' .
239
+		    I18N::translate('The <b>surname</b> field contains a name that is used for sorting and grouping. It can be different to the individual’s actual surname which is always taken from the <b>name</b> field. This field can be used to sort surnames with or without a prefix (Gogh / van Gogh) and to group spelling variations or inflections (Kowalski / Kowalska). If an individual needs to be listed under more than one surname, each name should be separated by a comma.') .
240
+		    '</p>';
241
+	    break;
242 242
 
243
-case 'OBJE':
244
-	$title = GedcomTag::getLabel('OBJE');
245
-	$text  =
246
-		'<p>' .
247
-		I18N::translate('A media object is a record in the family tree which contains information about a media file. This information may include a title, a copyright notice, a transcript, privacy restrictions, etc. The media file, such as the photo or video, can be stored locally (on this webserver) or remotely (on a different webserver).') .
248
-		'</p>';
249
-	break;
243
+    case 'OBJE':
244
+	    $title = GedcomTag::getLabel('OBJE');
245
+	    $text  =
246
+		    '<p>' .
247
+		    I18N::translate('A media object is a record in the family tree which contains information about a media file. This information may include a title, a copyright notice, a transcript, privacy restrictions, etc. The media file, such as the photo or video, can be stored locally (on this webserver) or remotely (on a different webserver).') .
248
+		    '</p>';
249
+	    break;
250 250
 
251
-case 'PLAC':
252
-	$title = GedcomTag::getLabel('PLAC');
253
-	$text  = I18N::translate('Places should be entered according to the standards for genealogy. In genealogy, places are recorded with the most specific information about the place first and then working up to the least specific place last, using commas to separate the different place levels. The level at which you record the place information should represent the levels of government or church where vital records for that place are kept.<br><br>For example, a place like Salt Lake City would be entered as “Salt Lake City, Salt Lake, Utah, USA”.<br><br>Let’s examine each part of this place. The first part, “Salt Lake City,” is the city or township where the event occurred. In some countries, there may be municipalities or districts inside a city which are important to note. In that case, they should come before the city. The next part, “Salt Lake,” is the county. “Utah” is the state, and “USA” is the country. It is important to note each place because genealogy records are kept by the governments of each level.<br><br>If a level of the place is unknown, you should leave a space between the commas. Suppose, in the example above, you didn’t know the county for Salt Lake City. You should then record it like this: “Salt Lake City, , Utah, USA”. Suppose you only know that an individual was born in Utah. You would enter the information like this: “, , Utah, USA”. <br><br>You can use the <b>Find Place</b> link to help you find places that already exist in the database.');
254
-	break;
251
+    case 'PLAC':
252
+	    $title = GedcomTag::getLabel('PLAC');
253
+	    $text  = I18N::translate('Places should be entered according to the standards for genealogy. In genealogy, places are recorded with the most specific information about the place first and then working up to the least specific place last, using commas to separate the different place levels. The level at which you record the place information should represent the levels of government or church where vital records for that place are kept.<br><br>For example, a place like Salt Lake City would be entered as “Salt Lake City, Salt Lake, Utah, USA”.<br><br>Let’s examine each part of this place. The first part, “Salt Lake City,” is the city or township where the event occurred. In some countries, there may be municipalities or districts inside a city which are important to note. In that case, they should come before the city. The next part, “Salt Lake,” is the county. “Utah” is the state, and “USA” is the country. It is important to note each place because genealogy records are kept by the governments of each level.<br><br>If a level of the place is unknown, you should leave a space between the commas. Suppose, in the example above, you didn’t know the county for Salt Lake City. You should then record it like this: “Salt Lake City, , Utah, USA”. Suppose you only know that an individual was born in Utah. You would enter the information like this: “, , Utah, USA”. <br><br>You can use the <b>Find Place</b> link to help you find places that already exist in the database.');
254
+	    break;
255 255
 
256
-case 'RESN':
257
-	$title = GedcomTag::getLabel('RESN');
258
-	$text  =
259
-		I18N::translate('Restrictions can be added to records and/or facts. They restrict who can view the data and who can edit it.') .
260
-		'<br><br>' .
261
-		I18N::translate('Note that if a user account is linked to a record, then that user will always be able to view that record.');
262
-	break;
256
+    case 'RESN':
257
+	    $title = GedcomTag::getLabel('RESN');
258
+	    $text  =
259
+		    I18N::translate('Restrictions can be added to records and/or facts. They restrict who can view the data and who can edit it.') .
260
+		    '<br><br>' .
261
+		    I18N::translate('Note that if a user account is linked to a record, then that user will always be able to view that record.');
262
+	    break;
263 263
 
264
-case 'ROMN':
265
-	$title = GedcomTag::getLabel('ROMN');
266
-	$text  = I18N::translate('In many cultures it is customary to have a traditional name spelled in the traditional characters and also a romanized version of the name as it would be spelled or pronounced in languages based on the Latin alphabet, such as English.<br><br>If you prefer to use a non-Latin alphabet such as Hebrew, Greek, Russian, Chinese, or Arabic to enter the name in the standard name fields, then you can use this field to enter the same name using the Latin alphabet. Both versions of the name will appear in lists and charts.<br><br>Although this field is labeled “Romanized”, it is not restricted to containing only characters based on the Latin alphabet. This might be of use with Japanese names, where three different alphabets may occur.');
267
-	break;
264
+    case 'ROMN':
265
+	    $title = GedcomTag::getLabel('ROMN');
266
+	    $text  = I18N::translate('In many cultures it is customary to have a traditional name spelled in the traditional characters and also a romanized version of the name as it would be spelled or pronounced in languages based on the Latin alphabet, such as English.<br><br>If you prefer to use a non-Latin alphabet such as Hebrew, Greek, Russian, Chinese, or Arabic to enter the name in the standard name fields, then you can use this field to enter the same name using the Latin alphabet. Both versions of the name will appear in lists and charts.<br><br>Although this field is labeled “Romanized”, it is not restricted to containing only characters based on the Latin alphabet. This might be of use with Japanese names, where three different alphabets may occur.');
267
+	    break;
268 268
 
269
-case '_HEB':
270
-	$title = GedcomTag::getLabel('_HEB');
271
-	$text  = I18N::translate('In many cultures it is customary to have a traditional name spelled in the traditional characters and also a romanized version of the name as it would be spelled or pronounced in languages based on the Latin alphabet, such as English.<br><br>If you prefer to use the Latin alphabet to enter the name in the standard name fields, then you can use this field to enter the same name in the non-Latin alphabet such as Greek, Hebrew, Russian, Arabic, or Chinese. Both versions of the name will appear in lists and charts.<br><br>Although this field is labeled “Hebrew”, it is not restricted to containing only Hebrew characters.');
272
-	break;
269
+    case '_HEB':
270
+	    $title = GedcomTag::getLabel('_HEB');
271
+	    $text  = I18N::translate('In many cultures it is customary to have a traditional name spelled in the traditional characters and also a romanized version of the name as it would be spelled or pronounced in languages based on the Latin alphabet, such as English.<br><br>If you prefer to use the Latin alphabet to enter the name in the standard name fields, then you can use this field to enter the same name in the non-Latin alphabet such as Greek, Hebrew, Russian, Arabic, or Chinese. Both versions of the name will appear in lists and charts.<br><br>Although this field is labeled “Hebrew”, it is not restricted to containing only Hebrew characters.');
272
+	    break;
273 273
 
274
-	//////////////////////////////////////////////////////////////////////////////
275
-	// This section contains all the other help items.
276
-	//////////////////////////////////////////////////////////////////////////////
274
+	    //////////////////////////////////////////////////////////////////////////////
275
+	    // This section contains all the other help items.
276
+	    //////////////////////////////////////////////////////////////////////////////
277 277
 
278
-case 'annivers_year_select':
279
-	$title = I18N::translate('Year input box');
280
-	$text  = I18N::translate('This input box lets you change that year of the calendar. Type a year into the box and press <b>Enter</b> to change the calendar to that year.<br><br><b>Advanced features</b> for <b>View the year</b><dl><dt><b>More than one year</b></dt><dd>You can search for dates in a range of years.<br><br>Year ranges are <u>inclusive</u>. This means that the date range extends from 1 January of the first year of the range to 31 December of the last year mentioned. Here are a few examples of year ranges:<br><br><b>1992-5</b> for all events from 1992 to 1995.<br><b>1972-89</b> for all events from 1972 to 1989.<br><b>1610-759</b> for all events from 1610 to 1759.<br><b>1880-1905</b> for all events from 1880 to 1905.<br><b>880-1105</b> for all events from 880 to 1105.<br><br>To see all the events in a given decade or century, you can use <b>?</b> in place of the final digits. For example, <b>197?</b> for all events from 1970 to 1979 or <b>16??</b> for all events from 1600 to 1699.<br><br>Selecting a range of years will change the calendar to the year view.</dd></dl>');
281
-	break;
278
+    case 'annivers_year_select':
279
+	    $title = I18N::translate('Year input box');
280
+	    $text  = I18N::translate('This input box lets you change that year of the calendar. Type a year into the box and press <b>Enter</b> to change the calendar to that year.<br><br><b>Advanced features</b> for <b>View the year</b><dl><dt><b>More than one year</b></dt><dd>You can search for dates in a range of years.<br><br>Year ranges are <u>inclusive</u>. This means that the date range extends from 1 January of the first year of the range to 31 December of the last year mentioned. Here are a few examples of year ranges:<br><br><b>1992-5</b> for all events from 1992 to 1995.<br><b>1972-89</b> for all events from 1972 to 1989.<br><b>1610-759</b> for all events from 1610 to 1759.<br><b>1880-1905</b> for all events from 1880 to 1905.<br><b>880-1105</b> for all events from 880 to 1105.<br><br>To see all the events in a given decade or century, you can use <b>?</b> in place of the final digits. For example, <b>197?</b> for all events from 1970 to 1979 or <b>16??</b> for all events from 1600 to 1699.<br><br>Selecting a range of years will change the calendar to the year view.</dd></dl>');
281
+	    break;
282 282
 
283
-case 'edit_edit_raw':
284
-	$title = I18N::translate('Edit the raw GEDCOM');
285
-	$text  =
286
-		I18N::translate('This page allows you to bypass the usual forms, and edit the underlying data directly. It is an advanced option, and you should not use it unless you understand the GEDCOM format. If you make a mistake here, it can be difficult to fix.') .
287
-		'<br><br>' .
288
-		/* I18N: %s is a URL */ I18N::translate('You can download a copy of the GEDCOM specification from %s.', '<a href="https://wiki.webtrees.net/w/images-en/Ged551-5.pdf">https://wiki.webtrees.net/w/images-en/Ged551-5.pdf</a>');
289
-	break;
283
+    case 'edit_edit_raw':
284
+	    $title = I18N::translate('Edit the raw GEDCOM');
285
+	    $text  =
286
+		    I18N::translate('This page allows you to bypass the usual forms, and edit the underlying data directly. It is an advanced option, and you should not use it unless you understand the GEDCOM format. If you make a mistake here, it can be difficult to fix.') .
287
+		    '<br><br>' .
288
+		    /* I18N: %s is a URL */ I18N::translate('You can download a copy of the GEDCOM specification from %s.', '<a href="https://wiki.webtrees.net/w/images-en/Ged551-5.pdf">https://wiki.webtrees.net/w/images-en/Ged551-5.pdf</a>');
289
+	    break;
290 290
 
291
-case 'edit_SOUR_EVEN':
292
-	$title = I18N::translate('Associate events with this source');
293
-	$text  = I18N::translate('Each source records specific events, generally for a given date range and for a place jurisdiction. For example a Census records census events and church records record birth, marriage, and death events.<br><br>Select the events that are recorded by this source from the list of events provided. The date should be specified in a range format such as <i>FROM 1900 TO 1910</i>. The place jurisdiction is the name of the lowest jurisdiction that encompasses all lower-level places named in this source. For example, “Oneida, Idaho, USA” would be used as a source jurisdiction place for events occurring in the various towns within Oneida County. “Idaho, USA” would be the source jurisdiction place if the events recorded took place not only in Oneida County but also in other counties in Idaho.');
294
-	break;
291
+    case 'edit_SOUR_EVEN':
292
+	    $title = I18N::translate('Associate events with this source');
293
+	    $text  = I18N::translate('Each source records specific events, generally for a given date range and for a place jurisdiction. For example a Census records census events and church records record birth, marriage, and death events.<br><br>Select the events that are recorded by this source from the list of events provided. The date should be specified in a range format such as <i>FROM 1900 TO 1910</i>. The place jurisdiction is the name of the lowest jurisdiction that encompasses all lower-level places named in this source. For example, “Oneida, Idaho, USA” would be used as a source jurisdiction place for events occurring in the various towns within Oneida County. “Idaho, USA” would be the source jurisdiction place if the events recorded took place not only in Oneida County but also in other counties in Idaho.');
294
+	    break;
295 295
 
296
-case 'google_chart_surname':
297
-	$title = I18N::translate('Surname');
298
-	$text  = I18N::translate('The number of occurrences of the specified name will be shown on the map. If you leave this field empty, the most common surname will be used.');
299
-	break;
296
+    case 'google_chart_surname':
297
+	    $title = I18N::translate('Surname');
298
+	    $text  = I18N::translate('The number of occurrences of the specified name will be shown on the map. If you leave this field empty, the most common surname will be used.');
299
+	    break;
300 300
 
301
-case 'pending_changes':
302
-	$title = I18N::translate('Pending changes');
303
-	$text  =
304
-		'<p>' .
305
-		I18N::translate('When you add, edit, or delete information, the changes are not saved immediately. Instead, they are kept in a “pending” area. These pending changes need to be reviewed by a moderator before they are accepted.') .
306
-		'</p><p>' .
307
-		I18N::translate('This process allows the site’s owner to ensure that the new information follows the site’s standards and conventions, has proper source attributions, etc.') .
308
-		'</p><p>' .
309
-		I18N::translate('Pending changes are only shown when your account has permission to edit. When you sign out, you will no longer be able to see them. Also, pending changes are only shown on certain pages. For example, they are not shown in lists, reports, or search results.') .
310
-		'</p>';
311
-	if (Auth::isAdmin()) {
312
-		$text .=
313
-			'<p>' .
314
-			I18N::translate('Each user account has an option to “automatically accept changes”. When this is enabled, any changes made by that user are saved immediately. Many administrators enable this for their own user account.') .
315
-			'</p>';
316
-	}
317
-	break;
301
+    case 'pending_changes':
302
+	    $title = I18N::translate('Pending changes');
303
+	    $text  =
304
+		    '<p>' .
305
+		    I18N::translate('When you add, edit, or delete information, the changes are not saved immediately. Instead, they are kept in a “pending” area. These pending changes need to be reviewed by a moderator before they are accepted.') .
306
+		    '</p><p>' .
307
+		    I18N::translate('This process allows the site’s owner to ensure that the new information follows the site’s standards and conventions, has proper source attributions, etc.') .
308
+		    '</p><p>' .
309
+		    I18N::translate('Pending changes are only shown when your account has permission to edit. When you sign out, you will no longer be able to see them. Also, pending changes are only shown on certain pages. For example, they are not shown in lists, reports, or search results.') .
310
+		    '</p>';
311
+	    if (Auth::isAdmin()) {
312
+		    $text .=
313
+			    '<p>' .
314
+			    I18N::translate('Each user account has an option to “automatically accept changes”. When this is enabled, any changes made by that user are saved immediately. Many administrators enable this for their own user account.') .
315
+			    '</p>';
316
+	    }
317
+	    break;
318 318
 
319
-default:
320
-	$title = I18N::translate('Help');
321
-	$text  = I18N::translate('The help text has not been written for this item.');
322
-	break;
319
+    default:
320
+	    $title = I18N::translate('Help');
321
+	    $text  = I18N::translate('The help text has not been written for this item.');
322
+	    break;
323 323
 }
324 324
 // This file is called by a getJSON call so return the data
325 325
 // in correct format
Please login to merge, or discard this patch.
admin_trees_duplicates.php 2 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -29,119 +29,119 @@
 block discarded – undo
29 29
 
30 30
 $controller = new PageController;
31 31
 $controller
32
-	->restrictAccess(Auth::isManager($WT_TREE))
33
-	->setPageTitle(I18N::translate('Find duplicates') . ' — ' . $WT_TREE->getTitleHtml())
34
-	->pageHeader();
32
+    ->restrictAccess(Auth::isManager($WT_TREE))
33
+    ->setPageTitle(I18N::translate('Find duplicates') . ' — ' . $WT_TREE->getTitleHtml())
34
+    ->pageHeader();
35 35
 
36 36
 $repositories = Database::prepare(
37
-	"SELECT GROUP_CONCAT(n_id) AS xrefs " .
38
-	" FROM `##other`" .
39
-	" JOIN `##name` ON o_id = n_id AND o_file = n_file" .
40
-	" WHERE o_file = :tree_id AND o_type = 'REPO'" .
41
-	" GROUP BY n_full" .
42
-	" HAVING COUNT(n_id) > 1"
37
+    "SELECT GROUP_CONCAT(n_id) AS xrefs " .
38
+    " FROM `##other`" .
39
+    " JOIN `##name` ON o_id = n_id AND o_file = n_file" .
40
+    " WHERE o_file = :tree_id AND o_type = 'REPO'" .
41
+    " GROUP BY n_full" .
42
+    " HAVING COUNT(n_id) > 1"
43 43
 )->execute(array(
44
-	'tree_id' => $WT_TREE->getTreeId(),
44
+    'tree_id' => $WT_TREE->getTreeId(),
45 45
 ))->fetchAll();
46 46
 
47 47
 $repositories = array_map(
48
-	function (\stdClass $x) use ($WT_TREE) {
49
-		$tmp = explode(',', $x->xrefs);
48
+    function (\stdClass $x) use ($WT_TREE) {
49
+        $tmp = explode(',', $x->xrefs);
50 50
 
51
-		return array_map(function ($y) use ($WT_TREE) {
52
-			return Repository::getInstance($y, $WT_TREE);
53
-		}, $tmp);
54
-	}, $repositories
51
+        return array_map(function ($y) use ($WT_TREE) {
52
+            return Repository::getInstance($y, $WT_TREE);
53
+        }, $tmp);
54
+    }, $repositories
55 55
 );
56 56
 
57 57
 $sources = Database::prepare(
58
-	"SELECT GROUP_CONCAT(n_id) AS xrefs " .
59
-	" FROM `##sources`" .
60
-	" JOIN `##name` ON s_id = n_id AND s_file = n_file" .
61
-	" WHERE s_file = :tree_id" .
62
-	" GROUP BY n_full" .
63
-	" HAVING COUNT(n_id) > 1"
58
+    "SELECT GROUP_CONCAT(n_id) AS xrefs " .
59
+    " FROM `##sources`" .
60
+    " JOIN `##name` ON s_id = n_id AND s_file = n_file" .
61
+    " WHERE s_file = :tree_id" .
62
+    " GROUP BY n_full" .
63
+    " HAVING COUNT(n_id) > 1"
64 64
 )->execute(array(
65
-	'tree_id' => $WT_TREE->getTreeId(),
65
+    'tree_id' => $WT_TREE->getTreeId(),
66 66
 ))->fetchAll();
67 67
 
68 68
 $sources = array_map(
69
-	function (\stdClass $x) use ($WT_TREE) {
70
-		$tmp = explode(',', $x->xrefs);
69
+    function (\stdClass $x) use ($WT_TREE) {
70
+        $tmp = explode(',', $x->xrefs);
71 71
 
72
-		return array_map(function ($y) use ($WT_TREE) {
73
-			return Source::getInstance($y, $WT_TREE);
74
-		}, $tmp);
75
-	}, $sources
72
+        return array_map(function ($y) use ($WT_TREE) {
73
+            return Source::getInstance($y, $WT_TREE);
74
+        }, $tmp);
75
+    }, $sources
76 76
 );
77 77
 
78 78
 $individuals = Database::prepare(
79
-	"SELECT DISTINCT GROUP_CONCAT(d_gid ORDER BY d_gid) AS xrefs" .
80
-	" FROM `##dates` AS d" .
81
-	" JOIN `##name` ON d_file = n_file AND d_gid = n_id" .
82
-	" WHERE d_file = :tree_id AND d_fact IN ('BIRT', 'CHR', 'BAPM', 'DEAT', 'BURI')" .
83
-	" GROUP BY d_day, d_month, d_year, d_type, d_fact, n_type, n_full" .
84
-	" HAVING COUNT(DISTINCT d_gid) > 1"
79
+    "SELECT DISTINCT GROUP_CONCAT(d_gid ORDER BY d_gid) AS xrefs" .
80
+    " FROM `##dates` AS d" .
81
+    " JOIN `##name` ON d_file = n_file AND d_gid = n_id" .
82
+    " WHERE d_file = :tree_id AND d_fact IN ('BIRT', 'CHR', 'BAPM', 'DEAT', 'BURI')" .
83
+    " GROUP BY d_day, d_month, d_year, d_type, d_fact, n_type, n_full" .
84
+    " HAVING COUNT(DISTINCT d_gid) > 1"
85 85
 )->execute(array(
86
-	'tree_id' => $WT_TREE->getTreeId(),
86
+    'tree_id' => $WT_TREE->getTreeId(),
87 87
 ))->fetchAll();
88 88
 
89 89
 $individuals = array_map(
90
-	function (\stdClass $x) use ($WT_TREE) {
91
-		$tmp = explode(',', $x->xrefs);
90
+    function (\stdClass $x) use ($WT_TREE) {
91
+        $tmp = explode(',', $x->xrefs);
92 92
 
93
-		return array_map(function ($y) use ($WT_TREE) {
94
-			return Individual::getInstance($y, $WT_TREE);
95
-		}, $tmp);
96
-	}, $individuals
93
+        return array_map(function ($y) use ($WT_TREE) {
94
+            return Individual::getInstance($y, $WT_TREE);
95
+        }, $tmp);
96
+    }, $individuals
97 97
 );
98 98
 
99 99
 $families = Database::prepare(
100
-	"SELECT GROUP_CONCAT(f_id) AS xrefs " .
101
-	" FROM `##families`" .
102
-	" WHERE f_file = :tree_id" .
103
-	" GROUP BY LEAST(f_husb, f_wife), GREATEST(f_husb, f_wife)" .
104
-	" HAVING COUNT(f_id) > 1"
100
+    "SELECT GROUP_CONCAT(f_id) AS xrefs " .
101
+    " FROM `##families`" .
102
+    " WHERE f_file = :tree_id" .
103
+    " GROUP BY LEAST(f_husb, f_wife), GREATEST(f_husb, f_wife)" .
104
+    " HAVING COUNT(f_id) > 1"
105 105
 )->execute(array(
106
-	'tree_id' => $WT_TREE->getTreeId(),
106
+    'tree_id' => $WT_TREE->getTreeId(),
107 107
 ))->fetchAll();
108 108
 
109 109
 $families = array_map(
110
-	function (\stdClass $x) use ($WT_TREE) {
111
-		$tmp = explode(',', $x->xrefs);
110
+    function (\stdClass $x) use ($WT_TREE) {
111
+        $tmp = explode(',', $x->xrefs);
112 112
 
113
-		return array_map(function ($y) use ($WT_TREE) {
114
-			return Family::getInstance($y, $WT_TREE);
115
-		}, $tmp);
116
-	}, $families
113
+        return array_map(function ($y) use ($WT_TREE) {
114
+            return Family::getInstance($y, $WT_TREE);
115
+        }, $tmp);
116
+    }, $families
117 117
 );
118 118
 
119 119
 $media = Database::prepare(
120
-	"SELECT GROUP_CONCAT(m_id) AS xrefs " .
121
-	" FROM `##media`" .
122
-	" WHERE m_file = :tree_id" .
123
-	" GROUP BY m_titl" .
124
-	" HAVING COUNT(m_id) > 1"
120
+    "SELECT GROUP_CONCAT(m_id) AS xrefs " .
121
+    " FROM `##media`" .
122
+    " WHERE m_file = :tree_id" .
123
+    " GROUP BY m_titl" .
124
+    " HAVING COUNT(m_id) > 1"
125 125
 )->execute(array(
126
-	'tree_id' => $WT_TREE->getTreeId(),
126
+    'tree_id' => $WT_TREE->getTreeId(),
127 127
 ))->fetchAll();
128 128
 
129 129
 $media = array_map(
130
-	function (\stdClass $x) use ($WT_TREE) {
131
-		$tmp = explode(',', $x->xrefs);
130
+    function (\stdClass $x) use ($WT_TREE) {
131
+        $tmp = explode(',', $x->xrefs);
132 132
 
133
-		return array_map(function ($y) use ($WT_TREE) {
134
-			return Media::getInstance($y, $WT_TREE);
135
-		}, $tmp);
136
-	}, $media
133
+        return array_map(function ($y) use ($WT_TREE) {
134
+            return Media::getInstance($y, $WT_TREE);
135
+        }, $tmp);
136
+    }, $media
137 137
 );
138 138
 
139 139
 $all_duplicates = array(
140
-	I18N::translate('Repositories')  => $repositories,
141
-	I18N::translate('Sources')       => $sources,
142
-	I18N::translate('Individuals')   => $individuals,
143
-	I18N::translate('Families')      => $families,
144
-	I18N::translate('Media objects') => $media,
140
+    I18N::translate('Repositories')  => $repositories,
141
+    I18N::translate('Sources')       => $sources,
142
+    I18N::translate('Individuals')   => $individuals,
143
+    I18N::translate('Families')      => $families,
144
+    I18N::translate('Media objects') => $media,
145 145
 );
146 146
 
147 147
 ?>
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -177,8 +177,11 @@
 block discarded – undo
177 177
 	</li>
178 178
 <?php endforeach; ?>
179 179
 </ul>
180
-<?php else: ?>
181
-<p><?php echo I18N::translate('No duplicates have been found.'); ?></p>
180
+<?php else {
181
+    : ?>
182
+<p><?php echo I18N::translate('No duplicates have been found.');
183
+}
184
+?></p>
182 185
 <?php endif; ?>
183 186
 
184 187
 <?php endforeach; ?>
Please login to merge, or discard this patch.