Completed
Push — 1.7 ( ce7091...0d97cf )
by Greg
14:14 queued 07:41
created
app/Functions/FunctionsExport.php 1 patch
Switch Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -183,18 +183,18 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	public static function exportGedcom(Tree $tree, $gedout, $exportOptions) {
185 185
 		switch ($exportOptions['privatize']) {
186
-		case 'gedadmin':
187
-			$access_level = Auth::PRIV_NONE;
188
-			break;
189
-		case 'user':
190
-			$access_level = Auth::PRIV_USER;
191
-			break;
192
-		case 'visitor':
193
-			$access_level = Auth::PRIV_PRIVATE;
194
-			break;
195
-		case 'none':
196
-			$access_level = Auth::PRIV_HIDE;
197
-			break;
186
+		    case 'gedadmin':
187
+			    $access_level = Auth::PRIV_NONE;
188
+			    break;
189
+		    case 'user':
190
+			    $access_level = Auth::PRIV_USER;
191
+			    break;
192
+		    case 'visitor':
193
+			    $access_level = Auth::PRIV_PRIVATE;
194
+			    break;
195
+		    case 'none':
196
+			    $access_level = Auth::PRIV_HIDE;
197
+			    break;
198 198
 		}
199 199
 
200 200
 		$head = self::gedcomHeader($tree);
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
 
252 252
 		foreach ($rows as $row) {
253 253
 			switch ($row->type) {
254
-			case 'NOTE':
255
-				$record = Note::getInstance($row->xref, $tree, $row->gedcom);
256
-				break;
257
-			case 'REPO':
258
-				$record = Repository::getInstance($row->xref, $tree, $row->gedcom);
259
-				break;
260
-			default:
261
-				$record = GedcomRecord::getInstance($row->xref, $tree, $row->gedcom);
262
-				break;
254
+			    case 'NOTE':
255
+				    $record = Note::getInstance($row->xref, $tree, $row->gedcom);
256
+				    break;
257
+			    case 'REPO':
258
+				    $record = Repository::getInstance($row->xref, $tree, $row->gedcom);
259
+				    break;
260
+			    default:
261
+				    $record = GedcomRecord::getInstance($row->xref, $tree, $row->gedcom);
262
+				    break;
263 263
 			}
264 264
 
265 265
 			$rec = $record->privatizeGedcom($access_level);
Please login to merge, or discard this patch.
app/Functions/FunctionsImport.php 1 patch
Switch Indentation   +632 added lines, -632 removed lines patch added patch discarded remove patch
@@ -59,477 +59,477 @@  discard block
 block discarded – undo
59 59
 			$tag                               = strtoupper($tag); // Tags should always be upper case
60 60
 			switch ($tag) {
61 61
 				// Convert PhpGedView tags to WT
62
-			case '_PGVU':
63
-				$tag = '_WT_USER';
64
-				break;
65
-			case '_PGV_OBJS':
66
-				$tag = '_WT_OBJE_SORT';
67
-				break;
68
-				// Convert FTM-style "TAG_FORMAL_NAME" into "TAG".
69
-			case 'ABBREVIATION':
70
-				$tag = 'ABBR';
71
-				break;
72
-			case 'ADDRESS':
73
-				$tag = 'ADDR';
74
-				break;
75
-			case 'ADDRESS1':
76
-				$tag = 'ADR1';
77
-				break;
78
-			case 'ADDRESS2':
79
-				$tag = 'ADR2';
80
-				break;
81
-			case 'ADDRESS3':
82
-				$tag = 'ADR3';
83
-				break;
84
-			case 'ADOPTION':
85
-				$tag = 'ADOP';
86
-				break;
87
-			case 'ADULT_CHRISTENING':
88
-				$tag = 'CHRA';
89
-				break;
90
-			case 'AFN':
91
-				// AFN values are upper case
92
-				$data = strtoupper($data);
93
-				break;
94
-			case 'AGENCY':
95
-				$tag = 'AGNC';
96
-				break;
97
-			case 'ALIAS':
98
-				$tag = 'ALIA';
99
-				break;
100
-			case 'ANCESTORS':
101
-				$tag = 'ANCE';
102
-				break;
103
-			case 'ANCES_INTEREST':
104
-				$tag = 'ANCI';
105
-				break;
106
-			case 'ANNULMENT':
107
-				$tag = 'ANUL';
108
-				break;
109
-			case 'ASSOCIATES':
110
-				$tag = 'ASSO';
111
-				break;
112
-			case 'AUTHOR':
113
-				$tag = 'AUTH';
114
-				break;
115
-			case 'BAPTISM':
116
-				$tag = 'BAPM';
117
-				break;
118
-			case 'BAPTISM_LDS':
119
-				$tag = 'BAPL';
120
-				break;
121
-			case 'BAR_MITZVAH':
122
-				$tag = 'BARM';
123
-				break;
124
-			case 'BAS_MITZVAH':
125
-				$tag = 'BASM';
126
-				break;
127
-			case 'BIRTH':
128
-				$tag = 'BIRT';
129
-				break;
130
-			case 'BLESSING':
131
-				$tag = 'BLES';
132
-				break;
133
-			case 'BURIAL':
134
-				$tag = 'BURI';
135
-				break;
136
-			case 'CALL_NUMBER':
137
-				$tag = 'CALN';
138
-				break;
139
-			case 'CASTE':
140
-				$tag = 'CAST';
141
-				break;
142
-			case 'CAUSE':
143
-				$tag = 'CAUS';
144
-				break;
145
-			case 'CENSUS':
146
-				$tag = 'CENS';
147
-				break;
148
-			case 'CHANGE':
149
-				$tag = 'CHAN';
150
-				break;
151
-			case 'CHARACTER':
152
-				$tag = 'CHAR';
153
-				break;
154
-			case 'CHILD':
155
-				$tag = 'CHIL';
156
-				break;
157
-			case 'CHILDREN_COUNT':
158
-				$tag = 'NCHI';
159
-				break;
160
-			case 'CHRISTENING':
161
-				$tag = 'CHR';
162
-				break;
163
-			case 'CONCATENATION':
164
-				$tag = 'CONC';
165
-				break;
166
-			case 'CONFIRMATION':
167
-				$tag = 'CONF';
168
-				break;
169
-			case 'CONFIRMATION_LDS':
170
-				$tag = 'CONL';
171
-				break;
172
-			case 'CONTINUED':
173
-				$tag = 'CONT';
174
-				break;
175
-			case 'COPYRIGHT':
176
-				$tag = 'COPR';
177
-				break;
178
-			case 'CORPORATE':
179
-				$tag = 'CORP';
180
-				break;
181
-			case 'COUNTRY':
182
-				$tag = 'CTRY';
183
-				break;
184
-			case 'CREMATION':
185
-				$tag = 'CREM';
186
-				break;
187
-			case 'DATE':
188
-				// Preserve text from INT dates
189
-				if (strpos($data, '(') !== false) {
190
-					list($date, $text) = explode('(', $data, 2);
191
-					$text              = ' (' . $text;
192
-				} else {
193
-					$date = $data;
194
-					$text = '';
195
-				}
196
-				// Capitals
197
-				$date = strtoupper($date);
198
-				// Temporarily add leading/trailing spaces, to allow efficient matching below
199
-				$date = " {$date} ";
200
-				// Ensure space digits and letters
201
-				$date = preg_replace('/([A-Z])(\d)/', '$1 $2', $date);
202
-				$date = preg_replace('/(\d)([A-Z])/', '$1 $2', $date);
203
-				// Ensure space before/after calendar escapes
204
-				$date = preg_replace('/@#[^@]+@/', ' $0 ', $date);
205
-				// "BET." => "BET"
206
-				$date = preg_replace('/(\w\w)\./', '$1', $date);
207
-				// "CIR" => "ABT"
208
-				$date = str_replace(' CIR ', ' ABT ', $date);
209
-				$date = str_replace(' APX ', ' ABT ', $date);
210
-				// B.C. => BC (temporarily, to allow easier handling of ".")
211
-				$date = str_replace(' B.C. ', ' BC ', $date);
212
-				// "BET X - Y " => "BET X AND Y"
213
-				$date = preg_replace('/^(.* BET .+) - (.+)/', '$1 AND $2', $date);
214
-				$date = preg_replace('/^(.* FROM .+) - (.+)/', '$1 TO $2', $date);
215
-				// "@#ESC@ FROM X TO Y" => "FROM @#ESC@ X TO @#ESC@ Y"
216
-				$date = preg_replace('/^ +(@#[^@]+@) +FROM +(.+) +TO +(.+)/', ' FROM $1 $2 TO $1 $3', $date);
217
-				$date = preg_replace('/^ +(@#[^@]+@) +BET +(.+) +AND +(.+)/', ' BET $1 $2 AND $1 $3', $date);
218
-				// "@#ESC@ AFT X" => "AFT @#ESC@ X"
219
-				$date = preg_replace('/^ +(@#[^@]+@) +(FROM|BET|TO|AND|BEF|AFT|CAL|EST|INT|ABT) +(.+)/', ' $2 $1 $3', $date);
220
-				// Ignore any remaining punctuation, e.g. "14-MAY, 1900" => "14 MAY 1900"
221
-				// (don't change "/" - it is used in NS/OS dates)
222
-				$date = preg_replace('/[.,:;-]/', ' ', $date);
223
-				// BC => B.C.
224
-				$date = str_replace(' BC ', ' B.C. ', $date);
225
-				// Append the "INT" text
226
-				$data = $date . $text;
227
-				break;
228
-			case 'DEATH':
229
-				$tag = 'DEAT';
230
-				break;
231
-			case '_DEATH_OF_SPOUSE':
232
-				$tag = '_DETS';
233
-				break;
234
-			case '_DEGREE':
235
-				$tag = '_DEG';
236
-				break;
237
-			case 'DESCENDANTS':
238
-				$tag = 'DESC';
239
-				break;
240
-			case 'DESCENDANT_INT':
241
-				$tag = 'DESI';
242
-				break;
243
-			case 'DESTINATION':
244
-				$tag = 'DEST';
245
-				break;
246
-			case 'DIVORCE':
247
-				$tag = 'DIV';
248
-				break;
249
-			case 'DIVORCE_FILED':
250
-				$tag = 'DIVF';
251
-				break;
252
-			case 'EDUCATION':
253
-				$tag = 'EDUC';
254
-				break;
255
-			case 'EMIGRATION':
256
-				$tag = 'EMIG';
257
-				break;
258
-			case 'ENDOWMENT':
259
-				$tag = 'ENDL';
260
-				break;
261
-			case 'ENGAGEMENT':
262
-				$tag = 'ENGA';
263
-				break;
264
-			case 'EVENT':
265
-				$tag = 'EVEN';
266
-				break;
267
-			case 'FACSIMILE':
268
-				$tag = 'FAX';
269
-				break;
270
-			case 'FAMILY':
271
-				$tag = 'FAM';
272
-				break;
273
-			case 'FAMILY_CHILD':
274
-				$tag = 'FAMC';
275
-				break;
276
-			case 'FAMILY_FILE':
277
-				$tag = 'FAMF';
278
-				break;
279
-			case 'FAMILY_SPOUSE':
280
-				$tag = 'FAMS';
281
-				break;
282
-			case 'FIRST_COMMUNION':
283
-				$tag = 'FCOM';
284
-				break;
285
-			case '_FILE':
286
-				$tag = 'FILE';
287
-				break;
288
-			case 'FORMAT':
289
-				$tag = 'FORM';
290
-			case 'FORM':
291
-				// Consistent commas
292
-				$data = preg_replace('/ *, */', ', ', $data);
293
-				break;
294
-			case 'GEDCOM':
295
-				$tag = 'GEDC';
296
-				break;
297
-			case 'GIVEN_NAME':
298
-				$tag = 'GIVN';
299
-				break;
300
-			case 'GRADUATION':
301
-				$tag = 'GRAD';
302
-				break;
303
-			case 'HEADER':
304
-				$tag = 'HEAD';
305
-			case 'HEAD':
306
-				// HEAD records don't have an XREF or DATA
307
-				if ($level == '0') {
308
-					$xref = '';
309
-					$data = '';
310
-				}
311
-				break;
312
-			case 'HUSBAND':
313
-				$tag = 'HUSB';
314
-				break;
315
-			case 'IDENT_NUMBER':
316
-				$tag = 'IDNO';
317
-				break;
318
-			case 'IMMIGRATION':
319
-				$tag = 'IMMI';
320
-				break;
321
-			case 'INDIVIDUAL':
322
-				$tag = 'INDI';
323
-				break;
324
-			case 'LANGUAGE':
325
-				$tag = 'LANG';
326
-				break;
327
-			case 'LATITUDE':
328
-				$tag = 'LATI';
329
-				break;
330
-			case 'LONGITUDE':
331
-				$tag = 'LONG';
332
-				break;
333
-			case 'MARRIAGE':
334
-				$tag = 'MARR';
335
-				break;
336
-			case 'MARRIAGE_BANN':
337
-				$tag = 'MARB';
338
-				break;
339
-			case 'MARRIAGE_COUNT':
340
-				$tag = 'NMR';
341
-				break;
342
-			case 'MARRIAGE_CONTRACT':
343
-				$tag = 'MARC';
344
-				break;
345
-			case 'MARRIAGE_LICENSE':
346
-				$tag = 'MARL';
347
-				break;
348
-			case 'MARRIAGE_SETTLEMENT':
349
-				$tag = 'MARS';
350
-				break;
351
-			case 'MEDIA':
352
-				$tag = 'MEDI';
353
-				break;
354
-			case '_MEDICAL':
355
-				$tag = '_MDCL';
356
-				break;
357
-			case '_MILITARY_SERVICE':
358
-				$tag = '_MILT';
359
-				break;
360
-			case 'NAME':
361
-				// Tidy up whitespace
362
-				$data = preg_replace('/  +/', ' ', trim($data));
363
-				break;
364
-			case 'NAME_PREFIX':
365
-				$tag = 'NPFX';
366
-				break;
367
-			case 'NAME_SUFFIX':
368
-				$tag = 'NSFX';
369
-				break;
370
-			case 'NATIONALITY':
371
-				$tag = 'NATI';
372
-				break;
373
-			case 'NATURALIZATION':
374
-				$tag = 'NATU';
375
-				break;
376
-			case 'NICKNAME':
377
-				$tag = 'NICK';
378
-				break;
379
-			case 'OBJECT':
380
-				$tag = 'OBJE';
381
-				break;
382
-			case 'OCCUPATION':
383
-				$tag = 'OCCU';
384
-				break;
385
-			case 'ORDINANCE':
386
-				$tag = 'ORDI';
387
-				break;
388
-			case 'ORDINATION':
389
-				$tag = 'ORDN';
390
-				break;
391
-			case 'PEDIGREE':
392
-				$tag = 'PEDI';
393
-			case 'PEDI':
394
-				// PEDI values are lower case
395
-				$data = strtolower($data);
396
-				break;
397
-			case 'PHONE':
398
-				$tag = 'PHON';
399
-				break;
400
-			case 'PHONETIC':
401
-				$tag = 'FONE';
402
-				break;
403
-			case 'PHY_DESCRIPTION':
404
-				$tag = 'DSCR';
405
-				break;
406
-			case 'PLACE':
407
-				$tag = 'PLAC';
408
-			case 'PLAC':
409
-				// Consistent commas
410
-				$data = preg_replace('/ *(،|,) */', ', ', $data);
411
-				// The Master Genealogist stores LAT/LONG data in the PLAC field, e.g. Pennsylvania, USA, 395945N0751013W
412
-				if (preg_match('/(.*), (\d\d)(\d\d)(\d\d)([NS])(\d\d\d)(\d\d)(\d\d)([EW])$/', $data, $match)) {
413
-					$data =
414
-						$match[1] . "\n" .
415
-						($level + 1) . " MAP\n" .
416
-						($level + 2) . " LATI " . ($match[5] . (round($match[2] + ($match[3] / 60) + ($match[4] / 3600), 4))) . "\n" .
417
-						($level + 2) . " LONG " . ($match[9] . (round($match[6] + ($match[7] / 60) + ($match[8] / 3600), 4)));
418
-				}
419
-				break;
420
-			case 'POSTAL_CODE':
421
-				$tag = 'POST';
422
-				break;
423
-			case 'PROBATE':
424
-				$tag = 'PROB';
425
-				break;
426
-			case 'PROPERTY':
427
-				$tag = 'PROP';
428
-				break;
429
-			case 'PUBLICATION':
430
-				$tag = 'PUBL';
431
-				break;
432
-			case 'QUALITY_OF_DATA':
433
-				$tag = 'QUAL';
434
-				break;
435
-			case 'REC_FILE_NUMBER':
436
-				$tag = 'RFN';
437
-				break;
438
-			case 'REC_ID_NUMBER':
439
-				$tag = 'RIN';
440
-				break;
441
-			case 'REFERENCE':
442
-				$tag = 'REFN';
443
-				break;
444
-			case 'RELATIONSHIP':
445
-				$tag = 'RELA';
446
-				break;
447
-			case 'RELIGION':
448
-				$tag = 'RELI';
449
-				break;
450
-			case 'REPOSITORY':
451
-				$tag = 'REPO';
452
-				break;
453
-			case 'RESIDENCE':
454
-				$tag = 'RESI';
455
-				break;
456
-			case 'RESTRICTION':
457
-				$tag = 'RESN';
458
-			case 'RESN':
459
-				// RESN values are lower case (confidential, privacy, locked, none)
460
-				$data = strtolower($data);
461
-				if ($data == 'invisible') {
462
-					$data = 'confidential'; // From old versions of Legacy.
463
-				}
464
-				break;
465
-			case 'RETIREMENT':
466
-				$tag = 'RETI';
467
-				break;
468
-			case 'ROMANIZED':
469
-				$tag = 'ROMN';
470
-				break;
471
-			case 'SEALING_CHILD':
472
-				$tag = 'SLGC';
473
-				break;
474
-			case 'SEALING_SPOUSE':
475
-				$tag = 'SLGS';
476
-				break;
477
-			case 'SOC_SEC_NUMBER':
478
-				$tag = 'SSN';
479
-				break;
480
-			case 'SEX':
481
-				$data = strtoupper($data);
482
-				break;
483
-			case 'SOURCE':
484
-				$tag = 'SOUR';
485
-				break;
486
-			case 'STATE':
487
-				$tag = 'STAE';
488
-				break;
489
-			case 'STATUS':
490
-				$tag = 'STAT';
491
-			case 'STAT':
492
-				if ($data == 'CANCELLED') {
493
-					// PhpGedView mis-spells this tag - correct it.
494
-					$data = 'CANCELED';
495
-				}
496
-				break;
497
-			case 'SUBMISSION':
498
-				$tag = 'SUBN';
499
-				break;
500
-			case 'SUBMITTER':
501
-				$tag = 'SUBM';
502
-				break;
503
-			case 'SURNAME':
504
-				$tag = 'SURN';
505
-				break;
506
-			case 'SURN_PREFIX':
507
-				$tag = 'SPFX';
508
-				break;
509
-			case 'TEMPLE':
510
-				$tag = 'TEMP';
511
-			case 'TEMP':
512
-				// Temple codes are upper case
513
-				$data = strtoupper($data);
514
-				break;
515
-			case 'TITLE':
516
-				$tag = 'TITL';
517
-				break;
518
-			case 'TRAILER':
519
-				$tag = 'TRLR';
520
-			case 'TRLR':
521
-				// TRLR records don't have an XREF or DATA
522
-				if ($level == '0') {
523
-					$xref = '';
524
-					$data = '';
525
-				}
526
-				break;
527
-			case 'VERSION':
528
-				$tag = 'VERS';
529
-				break;
530
-			case 'WEB':
531
-				$tag = 'WWW';
532
-				break;
62
+			    case '_PGVU':
63
+				    $tag = '_WT_USER';
64
+				    break;
65
+			    case '_PGV_OBJS':
66
+				    $tag = '_WT_OBJE_SORT';
67
+				    break;
68
+				    // Convert FTM-style "TAG_FORMAL_NAME" into "TAG".
69
+			    case 'ABBREVIATION':
70
+				    $tag = 'ABBR';
71
+				    break;
72
+			    case 'ADDRESS':
73
+				    $tag = 'ADDR';
74
+				    break;
75
+			    case 'ADDRESS1':
76
+				    $tag = 'ADR1';
77
+				    break;
78
+			    case 'ADDRESS2':
79
+				    $tag = 'ADR2';
80
+				    break;
81
+			    case 'ADDRESS3':
82
+				    $tag = 'ADR3';
83
+				    break;
84
+			    case 'ADOPTION':
85
+				    $tag = 'ADOP';
86
+				    break;
87
+			    case 'ADULT_CHRISTENING':
88
+				    $tag = 'CHRA';
89
+				    break;
90
+			    case 'AFN':
91
+				    // AFN values are upper case
92
+				    $data = strtoupper($data);
93
+				    break;
94
+			    case 'AGENCY':
95
+				    $tag = 'AGNC';
96
+				    break;
97
+			    case 'ALIAS':
98
+				    $tag = 'ALIA';
99
+				    break;
100
+			    case 'ANCESTORS':
101
+				    $tag = 'ANCE';
102
+				    break;
103
+			    case 'ANCES_INTEREST':
104
+				    $tag = 'ANCI';
105
+				    break;
106
+			    case 'ANNULMENT':
107
+				    $tag = 'ANUL';
108
+				    break;
109
+			    case 'ASSOCIATES':
110
+				    $tag = 'ASSO';
111
+				    break;
112
+			    case 'AUTHOR':
113
+				    $tag = 'AUTH';
114
+				    break;
115
+			    case 'BAPTISM':
116
+				    $tag = 'BAPM';
117
+				    break;
118
+			    case 'BAPTISM_LDS':
119
+				    $tag = 'BAPL';
120
+				    break;
121
+			    case 'BAR_MITZVAH':
122
+				    $tag = 'BARM';
123
+				    break;
124
+			    case 'BAS_MITZVAH':
125
+				    $tag = 'BASM';
126
+				    break;
127
+			    case 'BIRTH':
128
+				    $tag = 'BIRT';
129
+				    break;
130
+			    case 'BLESSING':
131
+				    $tag = 'BLES';
132
+				    break;
133
+			    case 'BURIAL':
134
+				    $tag = 'BURI';
135
+				    break;
136
+			    case 'CALL_NUMBER':
137
+				    $tag = 'CALN';
138
+				    break;
139
+			    case 'CASTE':
140
+				    $tag = 'CAST';
141
+				    break;
142
+			    case 'CAUSE':
143
+				    $tag = 'CAUS';
144
+				    break;
145
+			    case 'CENSUS':
146
+				    $tag = 'CENS';
147
+				    break;
148
+			    case 'CHANGE':
149
+				    $tag = 'CHAN';
150
+				    break;
151
+			    case 'CHARACTER':
152
+				    $tag = 'CHAR';
153
+				    break;
154
+			    case 'CHILD':
155
+				    $tag = 'CHIL';
156
+				    break;
157
+			    case 'CHILDREN_COUNT':
158
+				    $tag = 'NCHI';
159
+				    break;
160
+			    case 'CHRISTENING':
161
+				    $tag = 'CHR';
162
+				    break;
163
+			    case 'CONCATENATION':
164
+				    $tag = 'CONC';
165
+				    break;
166
+			    case 'CONFIRMATION':
167
+				    $tag = 'CONF';
168
+				    break;
169
+			    case 'CONFIRMATION_LDS':
170
+				    $tag = 'CONL';
171
+				    break;
172
+			    case 'CONTINUED':
173
+				    $tag = 'CONT';
174
+				    break;
175
+			    case 'COPYRIGHT':
176
+				    $tag = 'COPR';
177
+				    break;
178
+			    case 'CORPORATE':
179
+				    $tag = 'CORP';
180
+				    break;
181
+			    case 'COUNTRY':
182
+				    $tag = 'CTRY';
183
+				    break;
184
+			    case 'CREMATION':
185
+				    $tag = 'CREM';
186
+				    break;
187
+			    case 'DATE':
188
+				    // Preserve text from INT dates
189
+				    if (strpos($data, '(') !== false) {
190
+					    list($date, $text) = explode('(', $data, 2);
191
+					    $text              = ' (' . $text;
192
+				    } else {
193
+					    $date = $data;
194
+					    $text = '';
195
+				    }
196
+				    // Capitals
197
+				    $date = strtoupper($date);
198
+				    // Temporarily add leading/trailing spaces, to allow efficient matching below
199
+				    $date = " {$date} ";
200
+				    // Ensure space digits and letters
201
+				    $date = preg_replace('/([A-Z])(\d)/', '$1 $2', $date);
202
+				    $date = preg_replace('/(\d)([A-Z])/', '$1 $2', $date);
203
+				    // Ensure space before/after calendar escapes
204
+				    $date = preg_replace('/@#[^@]+@/', ' $0 ', $date);
205
+				    // "BET." => "BET"
206
+				    $date = preg_replace('/(\w\w)\./', '$1', $date);
207
+				    // "CIR" => "ABT"
208
+				    $date = str_replace(' CIR ', ' ABT ', $date);
209
+				    $date = str_replace(' APX ', ' ABT ', $date);
210
+				    // B.C. => BC (temporarily, to allow easier handling of ".")
211
+				    $date = str_replace(' B.C. ', ' BC ', $date);
212
+				    // "BET X - Y " => "BET X AND Y"
213
+				    $date = preg_replace('/^(.* BET .+) - (.+)/', '$1 AND $2', $date);
214
+				    $date = preg_replace('/^(.* FROM .+) - (.+)/', '$1 TO $2', $date);
215
+				    // "@#ESC@ FROM X TO Y" => "FROM @#ESC@ X TO @#ESC@ Y"
216
+				    $date = preg_replace('/^ +(@#[^@]+@) +FROM +(.+) +TO +(.+)/', ' FROM $1 $2 TO $1 $3', $date);
217
+				    $date = preg_replace('/^ +(@#[^@]+@) +BET +(.+) +AND +(.+)/', ' BET $1 $2 AND $1 $3', $date);
218
+				    // "@#ESC@ AFT X" => "AFT @#ESC@ X"
219
+				    $date = preg_replace('/^ +(@#[^@]+@) +(FROM|BET|TO|AND|BEF|AFT|CAL|EST|INT|ABT) +(.+)/', ' $2 $1 $3', $date);
220
+				    // Ignore any remaining punctuation, e.g. "14-MAY, 1900" => "14 MAY 1900"
221
+				    // (don't change "/" - it is used in NS/OS dates)
222
+				    $date = preg_replace('/[.,:;-]/', ' ', $date);
223
+				    // BC => B.C.
224
+				    $date = str_replace(' BC ', ' B.C. ', $date);
225
+				    // Append the "INT" text
226
+				    $data = $date . $text;
227
+				    break;
228
+			    case 'DEATH':
229
+				    $tag = 'DEAT';
230
+				    break;
231
+			    case '_DEATH_OF_SPOUSE':
232
+				    $tag = '_DETS';
233
+				    break;
234
+			    case '_DEGREE':
235
+				    $tag = '_DEG';
236
+				    break;
237
+			    case 'DESCENDANTS':
238
+				    $tag = 'DESC';
239
+				    break;
240
+			    case 'DESCENDANT_INT':
241
+				    $tag = 'DESI';
242
+				    break;
243
+			    case 'DESTINATION':
244
+				    $tag = 'DEST';
245
+				    break;
246
+			    case 'DIVORCE':
247
+				    $tag = 'DIV';
248
+				    break;
249
+			    case 'DIVORCE_FILED':
250
+				    $tag = 'DIVF';
251
+				    break;
252
+			    case 'EDUCATION':
253
+				    $tag = 'EDUC';
254
+				    break;
255
+			    case 'EMIGRATION':
256
+				    $tag = 'EMIG';
257
+				    break;
258
+			    case 'ENDOWMENT':
259
+				    $tag = 'ENDL';
260
+				    break;
261
+			    case 'ENGAGEMENT':
262
+				    $tag = 'ENGA';
263
+				    break;
264
+			    case 'EVENT':
265
+				    $tag = 'EVEN';
266
+				    break;
267
+			    case 'FACSIMILE':
268
+				    $tag = 'FAX';
269
+				    break;
270
+			    case 'FAMILY':
271
+				    $tag = 'FAM';
272
+				    break;
273
+			    case 'FAMILY_CHILD':
274
+				    $tag = 'FAMC';
275
+				    break;
276
+			    case 'FAMILY_FILE':
277
+				    $tag = 'FAMF';
278
+				    break;
279
+			    case 'FAMILY_SPOUSE':
280
+				    $tag = 'FAMS';
281
+				    break;
282
+			    case 'FIRST_COMMUNION':
283
+				    $tag = 'FCOM';
284
+				    break;
285
+			    case '_FILE':
286
+				    $tag = 'FILE';
287
+				    break;
288
+			    case 'FORMAT':
289
+				    $tag = 'FORM';
290
+			    case 'FORM':
291
+				    // Consistent commas
292
+				    $data = preg_replace('/ *, */', ', ', $data);
293
+				    break;
294
+			    case 'GEDCOM':
295
+				    $tag = 'GEDC';
296
+				    break;
297
+			    case 'GIVEN_NAME':
298
+				    $tag = 'GIVN';
299
+				    break;
300
+			    case 'GRADUATION':
301
+				    $tag = 'GRAD';
302
+				    break;
303
+			    case 'HEADER':
304
+				    $tag = 'HEAD';
305
+			    case 'HEAD':
306
+				    // HEAD records don't have an XREF or DATA
307
+				    if ($level == '0') {
308
+					    $xref = '';
309
+					    $data = '';
310
+				    }
311
+				    break;
312
+			    case 'HUSBAND':
313
+				    $tag = 'HUSB';
314
+				    break;
315
+			    case 'IDENT_NUMBER':
316
+				    $tag = 'IDNO';
317
+				    break;
318
+			    case 'IMMIGRATION':
319
+				    $tag = 'IMMI';
320
+				    break;
321
+			    case 'INDIVIDUAL':
322
+				    $tag = 'INDI';
323
+				    break;
324
+			    case 'LANGUAGE':
325
+				    $tag = 'LANG';
326
+				    break;
327
+			    case 'LATITUDE':
328
+				    $tag = 'LATI';
329
+				    break;
330
+			    case 'LONGITUDE':
331
+				    $tag = 'LONG';
332
+				    break;
333
+			    case 'MARRIAGE':
334
+				    $tag = 'MARR';
335
+				    break;
336
+			    case 'MARRIAGE_BANN':
337
+				    $tag = 'MARB';
338
+				    break;
339
+			    case 'MARRIAGE_COUNT':
340
+				    $tag = 'NMR';
341
+				    break;
342
+			    case 'MARRIAGE_CONTRACT':
343
+				    $tag = 'MARC';
344
+				    break;
345
+			    case 'MARRIAGE_LICENSE':
346
+				    $tag = 'MARL';
347
+				    break;
348
+			    case 'MARRIAGE_SETTLEMENT':
349
+				    $tag = 'MARS';
350
+				    break;
351
+			    case 'MEDIA':
352
+				    $tag = 'MEDI';
353
+				    break;
354
+			    case '_MEDICAL':
355
+				    $tag = '_MDCL';
356
+				    break;
357
+			    case '_MILITARY_SERVICE':
358
+				    $tag = '_MILT';
359
+				    break;
360
+			    case 'NAME':
361
+				    // Tidy up whitespace
362
+				    $data = preg_replace('/  +/', ' ', trim($data));
363
+				    break;
364
+			    case 'NAME_PREFIX':
365
+				    $tag = 'NPFX';
366
+				    break;
367
+			    case 'NAME_SUFFIX':
368
+				    $tag = 'NSFX';
369
+				    break;
370
+			    case 'NATIONALITY':
371
+				    $tag = 'NATI';
372
+				    break;
373
+			    case 'NATURALIZATION':
374
+				    $tag = 'NATU';
375
+				    break;
376
+			    case 'NICKNAME':
377
+				    $tag = 'NICK';
378
+				    break;
379
+			    case 'OBJECT':
380
+				    $tag = 'OBJE';
381
+				    break;
382
+			    case 'OCCUPATION':
383
+				    $tag = 'OCCU';
384
+				    break;
385
+			    case 'ORDINANCE':
386
+				    $tag = 'ORDI';
387
+				    break;
388
+			    case 'ORDINATION':
389
+				    $tag = 'ORDN';
390
+				    break;
391
+			    case 'PEDIGREE':
392
+				    $tag = 'PEDI';
393
+			    case 'PEDI':
394
+				    // PEDI values are lower case
395
+				    $data = strtolower($data);
396
+				    break;
397
+			    case 'PHONE':
398
+				    $tag = 'PHON';
399
+				    break;
400
+			    case 'PHONETIC':
401
+				    $tag = 'FONE';
402
+				    break;
403
+			    case 'PHY_DESCRIPTION':
404
+				    $tag = 'DSCR';
405
+				    break;
406
+			    case 'PLACE':
407
+				    $tag = 'PLAC';
408
+			    case 'PLAC':
409
+				    // Consistent commas
410
+				    $data = preg_replace('/ *(،|,) */', ', ', $data);
411
+				    // The Master Genealogist stores LAT/LONG data in the PLAC field, e.g. Pennsylvania, USA, 395945N0751013W
412
+				    if (preg_match('/(.*), (\d\d)(\d\d)(\d\d)([NS])(\d\d\d)(\d\d)(\d\d)([EW])$/', $data, $match)) {
413
+					    $data =
414
+						    $match[1] . "\n" .
415
+						    ($level + 1) . " MAP\n" .
416
+						    ($level + 2) . " LATI " . ($match[5] . (round($match[2] + ($match[3] / 60) + ($match[4] / 3600), 4))) . "\n" .
417
+						    ($level + 2) . " LONG " . ($match[9] . (round($match[6] + ($match[7] / 60) + ($match[8] / 3600), 4)));
418
+				    }
419
+				    break;
420
+			    case 'POSTAL_CODE':
421
+				    $tag = 'POST';
422
+				    break;
423
+			    case 'PROBATE':
424
+				    $tag = 'PROB';
425
+				    break;
426
+			    case 'PROPERTY':
427
+				    $tag = 'PROP';
428
+				    break;
429
+			    case 'PUBLICATION':
430
+				    $tag = 'PUBL';
431
+				    break;
432
+			    case 'QUALITY_OF_DATA':
433
+				    $tag = 'QUAL';
434
+				    break;
435
+			    case 'REC_FILE_NUMBER':
436
+				    $tag = 'RFN';
437
+				    break;
438
+			    case 'REC_ID_NUMBER':
439
+				    $tag = 'RIN';
440
+				    break;
441
+			    case 'REFERENCE':
442
+				    $tag = 'REFN';
443
+				    break;
444
+			    case 'RELATIONSHIP':
445
+				    $tag = 'RELA';
446
+				    break;
447
+			    case 'RELIGION':
448
+				    $tag = 'RELI';
449
+				    break;
450
+			    case 'REPOSITORY':
451
+				    $tag = 'REPO';
452
+				    break;
453
+			    case 'RESIDENCE':
454
+				    $tag = 'RESI';
455
+				    break;
456
+			    case 'RESTRICTION':
457
+				    $tag = 'RESN';
458
+			    case 'RESN':
459
+				    // RESN values are lower case (confidential, privacy, locked, none)
460
+				    $data = strtolower($data);
461
+				    if ($data == 'invisible') {
462
+					    $data = 'confidential'; // From old versions of Legacy.
463
+				    }
464
+				    break;
465
+			    case 'RETIREMENT':
466
+				    $tag = 'RETI';
467
+				    break;
468
+			    case 'ROMANIZED':
469
+				    $tag = 'ROMN';
470
+				    break;
471
+			    case 'SEALING_CHILD':
472
+				    $tag = 'SLGC';
473
+				    break;
474
+			    case 'SEALING_SPOUSE':
475
+				    $tag = 'SLGS';
476
+				    break;
477
+			    case 'SOC_SEC_NUMBER':
478
+				    $tag = 'SSN';
479
+				    break;
480
+			    case 'SEX':
481
+				    $data = strtoupper($data);
482
+				    break;
483
+			    case 'SOURCE':
484
+				    $tag = 'SOUR';
485
+				    break;
486
+			    case 'STATE':
487
+				    $tag = 'STAE';
488
+				    break;
489
+			    case 'STATUS':
490
+				    $tag = 'STAT';
491
+			    case 'STAT':
492
+				    if ($data == 'CANCELLED') {
493
+					    // PhpGedView mis-spells this tag - correct it.
494
+					    $data = 'CANCELED';
495
+				    }
496
+				    break;
497
+			    case 'SUBMISSION':
498
+				    $tag = 'SUBN';
499
+				    break;
500
+			    case 'SUBMITTER':
501
+				    $tag = 'SUBM';
502
+				    break;
503
+			    case 'SURNAME':
504
+				    $tag = 'SURN';
505
+				    break;
506
+			    case 'SURN_PREFIX':
507
+				    $tag = 'SPFX';
508
+				    break;
509
+			    case 'TEMPLE':
510
+				    $tag = 'TEMP';
511
+			    case 'TEMP':
512
+				    // Temple codes are upper case
513
+				    $data = strtoupper($data);
514
+				    break;
515
+			    case 'TITLE':
516
+				    $tag = 'TITL';
517
+				    break;
518
+			    case 'TRAILER':
519
+				    $tag = 'TRLR';
520
+			    case 'TRLR':
521
+				    // TRLR records don't have an XREF or DATA
522
+				    if ($level == '0') {
523
+					    $xref = '';
524
+					    $data = '';
525
+				    }
526
+				    break;
527
+			    case 'VERSION':
528
+				    $tag = 'VERS';
529
+				    break;
530
+			    case 'WEB':
531
+				    $tag = 'WWW';
532
+				    break;
533 533
 			}
534 534
 			// Suppress "Y", for facts/events with a DATE or PLAC
535 535
 			if ($data == 'y') {
@@ -545,40 +545,40 @@  discard block
 block discarded – undo
545 545
 			}
546 546
 			// Reassemble components back into a single line
547 547
 			switch ($tag) {
548
-			default:
549
-				// Remove tabs and multiple/leading/trailing spaces
550
-				if (strpos($data, "\t") !== false) {
551
-					$data = str_replace("\t", ' ', $data);
552
-				}
553
-				if (substr($data, 0, 1) == ' ' || substr($data, -1, 1) == ' ') {
554
-					$data = trim($data);
555
-				}
556
-				while (strpos($data, '  ')) {
557
-					$data = str_replace('  ', ' ', $data);
558
-				}
559
-				$newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level == '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag != "NOTE" ? '' : ' ' . $data);
560
-				break;
561
-			case 'NOTE':
562
-			case 'TEXT':
563
-			case 'DATA':
564
-			case 'CONT':
565
-				$newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level == '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag != "NOTE" ? '' : ' ' . $data);
566
-				break;
567
-			case 'FILE':
568
-				// Strip off the user-defined path prefix
569
-				$GEDCOM_MEDIA_PATH = $tree->getPreference('GEDCOM_MEDIA_PATH');
570
-				if ($GEDCOM_MEDIA_PATH && strpos($data, $GEDCOM_MEDIA_PATH) === 0) {
571
-					$data = substr($data, strlen($GEDCOM_MEDIA_PATH));
572
-				}
573
-				// convert backslashes in filenames to forward slashes
574
-				$data = preg_replace("/\\\/", "/", $data);
548
+			    default:
549
+				    // Remove tabs and multiple/leading/trailing spaces
550
+				    if (strpos($data, "\t") !== false) {
551
+					    $data = str_replace("\t", ' ', $data);
552
+				    }
553
+				    if (substr($data, 0, 1) == ' ' || substr($data, -1, 1) == ' ') {
554
+					    $data = trim($data);
555
+				    }
556
+				    while (strpos($data, '  ')) {
557
+					    $data = str_replace('  ', ' ', $data);
558
+				    }
559
+				    $newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level == '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag != "NOTE" ? '' : ' ' . $data);
560
+				    break;
561
+			    case 'NOTE':
562
+			    case 'TEXT':
563
+			    case 'DATA':
564
+			    case 'CONT':
565
+				    $newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level == '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag != "NOTE" ? '' : ' ' . $data);
566
+				    break;
567
+			    case 'FILE':
568
+				    // Strip off the user-defined path prefix
569
+				    $GEDCOM_MEDIA_PATH = $tree->getPreference('GEDCOM_MEDIA_PATH');
570
+				    if ($GEDCOM_MEDIA_PATH && strpos($data, $GEDCOM_MEDIA_PATH) === 0) {
571
+					    $data = substr($data, strlen($GEDCOM_MEDIA_PATH));
572
+				    }
573
+				    // convert backslashes in filenames to forward slashes
574
+				    $data = preg_replace("/\\\/", "/", $data);
575 575
 
576
-				$newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level == '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag != "NOTE" ? '' : ' ' . $data);
577
-				break;
578
-			case 'CONC':
579
-				// Merge CONC lines, to simplify access later on.
580
-				$newrec .= ($tree->getPreference('WORD_WRAPPED_NOTES') ? ' ' : '') . $data;
581
-				break;
576
+				    $newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level == '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag != "NOTE" ? '' : ' ' . $data);
577
+				    break;
578
+			    case 'CONC':
579
+				    // Merge CONC lines, to simplify access later on.
580
+				    $newrec .= ($tree->getPreference('WORD_WRAPPED_NOTES') ? ' ' : '') . $data;
581
+				    break;
582 582
 			}
583 583
 		}
584 584
 
@@ -635,123 +635,123 @@  discard block
 block discarded – undo
635 635
 		}
636 636
 
637 637
 		switch ($type) {
638
-		case 'INDI':
639
-			// Convert inline media into media objects
640
-			$gedrec = self::convertInlineMedia($tree, $gedrec);
638
+		    case 'INDI':
639
+			    // Convert inline media into media objects
640
+			    $gedrec = self::convertInlineMedia($tree, $gedrec);
641 641
 
642
-			$record = new Individual($xref, $gedrec, null, $tree);
643
-			if (preg_match('/\n1 RIN (.+)/', $gedrec, $match)) {
644
-				$rin = $match[1];
645
-			} else {
646
-				$rin = $xref;
647
-			}
648
-			Database::prepare(
649
-				"INSERT INTO `##individuals` (i_id, i_file, i_rin, i_sex, i_gedcom) VALUES (?, ?, ?, ?, ?)"
650
-			)->execute(array(
651
-				$xref, $tree_id, $rin, $record->getSex(), $gedrec,
652
-			));
653
-			// Update the cross-reference/index tables.
654
-			self::updatePlaces($xref, $tree_id, $gedrec);
655
-			self::updateDates($xref, $tree_id, $gedrec);
656
-			self::updateLinks($xref, $tree_id, $gedrec);
657
-			self::updateNames($xref, $tree_id, $record);
658
-			break;
659
-		case 'FAM':
660
-			// Convert inline media into media objects
661
-			$gedrec = self::convertInlineMedia($tree, $gedrec);
642
+			    $record = new Individual($xref, $gedrec, null, $tree);
643
+			    if (preg_match('/\n1 RIN (.+)/', $gedrec, $match)) {
644
+				    $rin = $match[1];
645
+			    } else {
646
+				    $rin = $xref;
647
+			    }
648
+			    Database::prepare(
649
+				    "INSERT INTO `##individuals` (i_id, i_file, i_rin, i_sex, i_gedcom) VALUES (?, ?, ?, ?, ?)"
650
+			    )->execute(array(
651
+				    $xref, $tree_id, $rin, $record->getSex(), $gedrec,
652
+			    ));
653
+			    // Update the cross-reference/index tables.
654
+			    self::updatePlaces($xref, $tree_id, $gedrec);
655
+			    self::updateDates($xref, $tree_id, $gedrec);
656
+			    self::updateLinks($xref, $tree_id, $gedrec);
657
+			    self::updateNames($xref, $tree_id, $record);
658
+			    break;
659
+		    case 'FAM':
660
+			    // Convert inline media into media objects
661
+			    $gedrec = self::convertInlineMedia($tree, $gedrec);
662 662
 
663
-			if (preg_match('/\n1 HUSB @(' . WT_REGEX_XREF . ')@/', $gedrec, $match)) {
664
-				$husb = $match[1];
665
-			} else {
666
-				$husb = '';
667
-			}
668
-			if (preg_match('/\n1 WIFE @(' . WT_REGEX_XREF . ')@/', $gedrec, $match)) {
669
-				$wife = $match[1];
670
-			} else {
671
-				$wife = '';
672
-			}
673
-			$nchi = preg_match_all('/\n1 CHIL @(' . WT_REGEX_XREF . ')@/', $gedrec, $match);
674
-			if (preg_match('/\n1 NCHI (\d+)/', $gedrec, $match)) {
675
-				$nchi = max($nchi, $match[1]);
676
-			}
677
-			Database::prepare(
678
-				"INSERT INTO `##families` (f_id, f_file, f_husb, f_wife, f_gedcom, f_numchil) VALUES (?, ?, ?, ?, ?, ?)"
679
-			)->execute(array(
680
-				$xref, $tree_id, $husb, $wife, $gedrec, $nchi,
681
-			));
682
-			// Update the cross-reference/index tables.
683
-			self::updatePlaces($xref, $tree_id, $gedrec);
684
-			self::updateDates($xref, $tree_id, $gedrec);
685
-			self::updateLinks($xref, $tree_id, $gedrec);
686
-			break;
687
-		case 'SOUR':
688
-			// Convert inline media into media objects
689
-			$gedrec = self::convertInlineMedia($tree, $gedrec);
663
+			    if (preg_match('/\n1 HUSB @(' . WT_REGEX_XREF . ')@/', $gedrec, $match)) {
664
+				    $husb = $match[1];
665
+			    } else {
666
+				    $husb = '';
667
+			    }
668
+			    if (preg_match('/\n1 WIFE @(' . WT_REGEX_XREF . ')@/', $gedrec, $match)) {
669
+				    $wife = $match[1];
670
+			    } else {
671
+				    $wife = '';
672
+			    }
673
+			    $nchi = preg_match_all('/\n1 CHIL @(' . WT_REGEX_XREF . ')@/', $gedrec, $match);
674
+			    if (preg_match('/\n1 NCHI (\d+)/', $gedrec, $match)) {
675
+				    $nchi = max($nchi, $match[1]);
676
+			    }
677
+			    Database::prepare(
678
+				    "INSERT INTO `##families` (f_id, f_file, f_husb, f_wife, f_gedcom, f_numchil) VALUES (?, ?, ?, ?, ?, ?)"
679
+			    )->execute(array(
680
+				    $xref, $tree_id, $husb, $wife, $gedrec, $nchi,
681
+			    ));
682
+			    // Update the cross-reference/index tables.
683
+			    self::updatePlaces($xref, $tree_id, $gedrec);
684
+			    self::updateDates($xref, $tree_id, $gedrec);
685
+			    self::updateLinks($xref, $tree_id, $gedrec);
686
+			    break;
687
+		    case 'SOUR':
688
+			    // Convert inline media into media objects
689
+			    $gedrec = self::convertInlineMedia($tree, $gedrec);
690 690
 
691
-			$record = new Source($xref, $gedrec, null, $tree);
692
-			if (preg_match('/\n1 TITL (.+)/', $gedrec, $match)) {
693
-				$name = $match[1];
694
-			} elseif (preg_match('/\n1 ABBR (.+)/', $gedrec, $match)) {
695
-				$name = $match[1];
696
-			} else {
697
-				$name = $xref;
698
-			}
699
-			Database::prepare(
700
-				"INSERT INTO `##sources` (s_id, s_file, s_name, s_gedcom) VALUES (?, ?, LEFT(?, 255), ?)"
701
-			)->execute(array(
702
-				$xref, $tree_id, $name, $gedrec,
703
-			));
704
-			// Update the cross-reference/index tables.
705
-			self::updateLinks($xref, $tree_id, $gedrec);
706
-			self::updateNames($xref, $tree_id, $record);
707
-			break;
708
-		case 'REPO':
709
-			// Convert inline media into media objects
710
-			$gedrec = self::convertInlineMedia($tree, $gedrec);
691
+			    $record = new Source($xref, $gedrec, null, $tree);
692
+			    if (preg_match('/\n1 TITL (.+)/', $gedrec, $match)) {
693
+				    $name = $match[1];
694
+			    } elseif (preg_match('/\n1 ABBR (.+)/', $gedrec, $match)) {
695
+				    $name = $match[1];
696
+			    } else {
697
+				    $name = $xref;
698
+			    }
699
+			    Database::prepare(
700
+				    "INSERT INTO `##sources` (s_id, s_file, s_name, s_gedcom) VALUES (?, ?, LEFT(?, 255), ?)"
701
+			    )->execute(array(
702
+				    $xref, $tree_id, $name, $gedrec,
703
+			    ));
704
+			    // Update the cross-reference/index tables.
705
+			    self::updateLinks($xref, $tree_id, $gedrec);
706
+			    self::updateNames($xref, $tree_id, $record);
707
+			    break;
708
+		    case 'REPO':
709
+			    // Convert inline media into media objects
710
+			    $gedrec = self::convertInlineMedia($tree, $gedrec);
711 711
 
712
-			$record = new Repository($xref, $gedrec, null, $tree);
713
-			Database::prepare(
714
-				"INSERT INTO `##other` (o_id, o_file, o_type, o_gedcom) VALUES (?, ?, 'REPO', ?)"
715
-			)->execute(array(
716
-				$xref, $tree_id, $gedrec,
717
-			));
718
-			// Update the cross-reference/index tables.
719
-			self::updateLinks($xref, $tree_id, $gedrec);
720
-			self::updateNames($xref, $tree_id, $record);
721
-			break;
722
-		case 'NOTE':
723
-			$record = new Note($xref, $gedrec, null, $tree);
724
-			Database::prepare(
725
-				"INSERT INTO `##other` (o_id, o_file, o_type, o_gedcom) VALUES (?, ?, 'NOTE', ?)"
726
-			)->execute(array(
727
-				$xref, $tree_id, $gedrec,
728
-			));
729
-			// Update the cross-reference/index tables.
730
-			self::updateLinks($xref, $tree_id, $gedrec);
731
-			self::updateNames($xref, $tree_id, $record);
732
-			break;
733
-		case 'OBJE':
734
-			$record = new Media($xref, $gedrec, null, $tree);
735
-			Database::prepare(
736
-				"INSERT INTO `##media` (m_id, m_ext, m_type, m_titl, m_filename, m_file, m_gedcom) VALUES (?, LEFT(?, 6), LEFT(?, 60), LEFT(?, 255), left(?, 512), ?, ?)"
737
-			)->execute(array(
738
-				$xref, $record->extension(), $record->getMediaType(), $record->getTitle(), $record->getFilename(), $tree_id, $gedrec,
739
-			));
740
-			// Update the cross-reference/index tables.
741
-			self::updateLinks($xref, $tree_id, $gedrec);
742
-			self::updateNames($xref, $tree_id, $record);
743
-			break;
744
-		default: // HEAD, TRLR, SUBM, SUBN, and custom record types.
745
-			// Force HEAD records to have a creation date.
746
-			if ($type === 'HEAD' && strpos($gedrec, "\n1 DATE ") === false) {
747
-				$gedrec .= "\n1 DATE " . date('j M Y');
748
-			}
749
-			Database::prepare(
750
-				"INSERT INTO `##other` (o_id, o_file, o_type, o_gedcom) VALUES (?, ?, LEFT(?, 15), ?)"
751
-			)->execute(array($xref, $tree_id, $type, $gedrec));
752
-			// Update the cross-reference/index tables.
753
-			self::updateLinks($xref, $tree_id, $gedrec);
754
-			break;
712
+			    $record = new Repository($xref, $gedrec, null, $tree);
713
+			    Database::prepare(
714
+				    "INSERT INTO `##other` (o_id, o_file, o_type, o_gedcom) VALUES (?, ?, 'REPO', ?)"
715
+			    )->execute(array(
716
+				    $xref, $tree_id, $gedrec,
717
+			    ));
718
+			    // Update the cross-reference/index tables.
719
+			    self::updateLinks($xref, $tree_id, $gedrec);
720
+			    self::updateNames($xref, $tree_id, $record);
721
+			    break;
722
+		    case 'NOTE':
723
+			    $record = new Note($xref, $gedrec, null, $tree);
724
+			    Database::prepare(
725
+				    "INSERT INTO `##other` (o_id, o_file, o_type, o_gedcom) VALUES (?, ?, 'NOTE', ?)"
726
+			    )->execute(array(
727
+				    $xref, $tree_id, $gedrec,
728
+			    ));
729
+			    // Update the cross-reference/index tables.
730
+			    self::updateLinks($xref, $tree_id, $gedrec);
731
+			    self::updateNames($xref, $tree_id, $record);
732
+			    break;
733
+		    case 'OBJE':
734
+			    $record = new Media($xref, $gedrec, null, $tree);
735
+			    Database::prepare(
736
+				    "INSERT INTO `##media` (m_id, m_ext, m_type, m_titl, m_filename, m_file, m_gedcom) VALUES (?, LEFT(?, 6), LEFT(?, 60), LEFT(?, 255), left(?, 512), ?, ?)"
737
+			    )->execute(array(
738
+				    $xref, $record->extension(), $record->getMediaType(), $record->getTitle(), $record->getFilename(), $tree_id, $gedrec,
739
+			    ));
740
+			    // Update the cross-reference/index tables.
741
+			    self::updateLinks($xref, $tree_id, $gedrec);
742
+			    self::updateNames($xref, $tree_id, $record);
743
+			    break;
744
+		    default: // HEAD, TRLR, SUBM, SUBN, and custom record types.
745
+			    // Force HEAD records to have a creation date.
746
+			    if ($type === 'HEAD' && strpos($gedrec, "\n1 DATE ") === false) {
747
+				    $gedrec .= "\n1 DATE " . date('j M Y');
748
+			    }
749
+			    Database::prepare(
750
+				    "INSERT INTO `##other` (o_id, o_file, o_type, o_gedcom) VALUES (?, ?, LEFT(?, 15), ?)"
751
+			    )->execute(array($xref, $tree_id, $type, $gedrec));
752
+			    // Update the cross-reference/index tables.
753
+			    self::updateLinks($xref, $tree_id, $gedrec);
754
+			    break;
755 755
 		}
756 756
 	}
757 757
 
@@ -1130,21 +1130,21 @@  discard block
 block discarded – undo
1130 1130
 		Database::prepare("DELETE FROM `##link` WHERE l_from=? AND l_file=?")->execute(array($gid, $ged_id));
1131 1131
 
1132 1132
 		switch ($type) {
1133
-		case 'INDI':
1134
-			Database::prepare("DELETE FROM `##individuals` WHERE i_id=? AND i_file=?")->execute(array($gid, $ged_id));
1135
-			break;
1136
-		case 'FAM':
1137
-			Database::prepare("DELETE FROM `##families` WHERE f_id=? AND f_file=?")->execute(array($gid, $ged_id));
1138
-			break;
1139
-		case 'SOUR':
1140
-			Database::prepare("DELETE FROM `##sources` WHERE s_id=? AND s_file=?")->execute(array($gid, $ged_id));
1141
-			break;
1142
-		case 'OBJE':
1143
-			Database::prepare("DELETE FROM `##media` WHERE m_id=? AND m_file=?")->execute(array($gid, $ged_id));
1144
-			break;
1145
-		default:
1146
-			Database::prepare("DELETE FROM `##other` WHERE o_id=? AND o_file=?")->execute(array($gid, $ged_id));
1147
-			break;
1133
+		    case 'INDI':
1134
+			    Database::prepare("DELETE FROM `##individuals` WHERE i_id=? AND i_file=?")->execute(array($gid, $ged_id));
1135
+			    break;
1136
+		    case 'FAM':
1137
+			    Database::prepare("DELETE FROM `##families` WHERE f_id=? AND f_file=?")->execute(array($gid, $ged_id));
1138
+			    break;
1139
+		    case 'SOUR':
1140
+			    Database::prepare("DELETE FROM `##sources` WHERE s_id=? AND s_file=?")->execute(array($gid, $ged_id));
1141
+			    break;
1142
+		    case 'OBJE':
1143
+			    Database::prepare("DELETE FROM `##media` WHERE m_id=? AND m_file=?")->execute(array($gid, $ged_id));
1144
+			    break;
1145
+		    default:
1146
+			    Database::prepare("DELETE FROM `##other` WHERE o_id=? AND o_file=?")->execute(array($gid, $ged_id));
1147
+			    break;
1148 1148
 		}
1149 1149
 
1150 1150
 		if (!$delete) {
Please login to merge, or discard this patch.
app/Functions/FunctionsPrintFacts.php 1 patch
Switch Indentation   +306 added lines, -306 removed lines patch added patch discarded remove patch
@@ -60,34 +60,34 @@  discard block
 block discarded – undo
60 60
 
61 61
 		// Some facts don't get printed here ...
62 62
 		switch ($fact->getTag()) {
63
-		case 'NOTE':
64
-			self::printMainNotes($fact, 1);
65
-
66
-			return;
67
-		case 'SOUR':
68
-			self::printMainSources($fact, 1);
69
-
70
-			return;
71
-		case 'OBJE':
72
-			self::printMainMedia($fact, 1);
73
-
74
-			return;
75
-		case 'FAMC':
76
-		case 'FAMS':
77
-		case 'CHIL':
78
-		case 'HUSB':
79
-		case 'WIFE':
80
-			// These are internal links, not facts
81
-			return;
82
-		case '_WT_OBJE_SORT':
83
-			// These links are used internally to record the sort order.
84
-			return;
85
-		default:
86
-			// Hide unrecognized/custom tags?
87
-			if ($fact->getParent()->getTree()->getPreference('HIDE_GEDCOM_ERRORS') === '0' && !GedcomTag::isTag($fact->getTag())) {
88
-				return;
89
-			}
90
-			break;
63
+		    case 'NOTE':
64
+			    self::printMainNotes($fact, 1);
65
+
66
+			    return;
67
+		    case 'SOUR':
68
+			    self::printMainSources($fact, 1);
69
+
70
+			    return;
71
+		    case 'OBJE':
72
+			    self::printMainMedia($fact, 1);
73
+
74
+			    return;
75
+		    case 'FAMC':
76
+		    case 'FAMS':
77
+		    case 'CHIL':
78
+		    case 'HUSB':
79
+		    case 'WIFE':
80
+			    // These are internal links, not facts
81
+			    return;
82
+		    case '_WT_OBJE_SORT':
83
+			    // These links are used internally to record the sort order.
84
+			    return;
85
+		    default:
86
+			    // Hide unrecognized/custom tags?
87
+			    if ($fact->getParent()->getTree()->getPreference('HIDE_GEDCOM_ERRORS') === '0' && !GedcomTag::isTag($fact->getTag())) {
88
+				    return;
89
+			    }
90
+			    break;
91 91
 		}
92 92
 
93 93
 		// Who is this fact about? Need it to translate fact label correctly
@@ -131,35 +131,35 @@  discard block
 block discarded – undo
131 131
 		}
132 132
 
133 133
 		switch ($fact->getTag()) {
134
-		case 'EVEN':
135
-		case 'FACT':
136
-			if (GedcomTag::isTag($type)) {
137
-				// Some users (just Meliza?) use "1 EVEN/2 TYPE BIRT". Translate the TYPE.
138
-				$label = GedcomTag::getLabel($type, $label_person);
139
-				$type  = ''; // Do not print this again
140
-			} elseif ($type) {
141
-				// We don't have a translation for $type - but a custom translation might exist.
142
-				$label = I18N::translate(Filter::escapeHtml($type));
143
-				$type  = ''; // Do not print this again
144
-			} else {
145
-				// An unspecified fact/event
146
-				$label = $fact->getLabel();
147
-			}
148
-			break;
149
-		case 'MARR':
150
-			// This is a hack for a proprietory extension. Is it still used/needed?
151
-			$utype = strtoupper($type);
152
-			if ($utype == 'CIVIL' || $utype == 'PARTNERS' || $utype == 'RELIGIOUS') {
153
-				$label = GedcomTag::getLabel('MARR_' . $utype, $label_person);
154
-				$type  = ''; // Do not print this again
155
-			} else {
156
-				$label = $fact->getLabel();
157
-			}
158
-			break;
159
-		default:
160
-			// Normal fact/event
161
-			$label = $fact->getLabel();
162
-			break;
134
+		    case 'EVEN':
135
+		    case 'FACT':
136
+			    if (GedcomTag::isTag($type)) {
137
+				    // Some users (just Meliza?) use "1 EVEN/2 TYPE BIRT". Translate the TYPE.
138
+				    $label = GedcomTag::getLabel($type, $label_person);
139
+				    $type  = ''; // Do not print this again
140
+			    } elseif ($type) {
141
+				    // We don't have a translation for $type - but a custom translation might exist.
142
+				    $label = I18N::translate(Filter::escapeHtml($type));
143
+				    $type  = ''; // Do not print this again
144
+			    } else {
145
+				    // An unspecified fact/event
146
+				    $label = $fact->getLabel();
147
+			    }
148
+			    break;
149
+		    case 'MARR':
150
+			    // This is a hack for a proprietory extension. Is it still used/needed?
151
+			    $utype = strtoupper($type);
152
+			    if ($utype == 'CIVIL' || $utype == 'PARTNERS' || $utype == 'RELIGIOUS') {
153
+				    $label = GedcomTag::getLabel('MARR_' . $utype, $label_person);
154
+				    $type  = ''; // Do not print this again
155
+			    } else {
156
+				    $label = $fact->getLabel();
157
+			    }
158
+			    break;
159
+		    default:
160
+			    // Normal fact/event
161
+			    $label = $fact->getLabel();
162
+			    break;
163 163
 		}
164 164
 
165 165
 		echo '<tr class="', $styleadd, '">';
@@ -208,15 +208,15 @@  discard block
 block discarded – undo
208 208
 		}
209 209
 
210 210
 		switch ($fact->getTag()) {
211
-		case '_BIRT_CHIL':
212
-			echo '<br>', /* I18N: Abbreviation for "number %s" */
213
-			I18N::translate('#%s', ++$n_chil);
214
-			break;
215
-		case '_BIRT_GCHI':
216
-		case '_BIRT_GCH1':
217
-		case '_BIRT_GCH2':
218
-			echo '<br>', I18N::translate('#%s', ++$n_gchi);
219
-			break;
211
+		    case '_BIRT_CHIL':
212
+			    echo '<br>', /* I18N: Abbreviation for "number %s" */
213
+			    I18N::translate('#%s', ++$n_chil);
214
+			    break;
215
+		    case '_BIRT_GCHI':
216
+		    case '_BIRT_GCH1':
217
+		    case '_BIRT_GCH2':
218
+			    echo '<br>', I18N::translate('#%s', ++$n_gchi);
219
+			    break;
220 220
 		}
221 221
 
222 222
 		echo '</td><td class="optionbox ', $styleadd, ' wrap">';
@@ -237,92 +237,92 @@  discard block
 block discarded – undo
237 237
 
238 238
 		// Print the value of this fact/event
239 239
 		switch ($fact->getTag()) {
240
-		case 'ADDR':
241
-			echo $fact->getValue();
242
-			break;
243
-		case 'AFN':
244
-			echo '<div class="field"><a href="https://familysearch.org/search/tree/results#count=20&query=afn:', Filter::escapeUrl($fact->getValue()), '">', Filter::escapeHtml($fact->getValue()), '</a></div>';
245
-			break;
246
-		case 'ASSO':
247
-			// we handle this later, in format_asso_rela_record()
248
-			break;
249
-		case 'EMAIL':
250
-		case 'EMAI':
251
-		case '_EMAIL':
252
-			echo '<div class="field"><a href="mailto:', Filter::escapeHtml($fact->getValue()), '">', Filter::escapeHtml($fact->getValue()), '</a></div>';
253
-			break;
254
-		case 'FILE':
255
-			if (Auth::isEditor($fact->getParent()->getTree())) {
256
-				echo '<div class="field">', Filter::escapeHtml($fact->getValue()), '</div>';
257
-			}
258
-			break;
259
-		case 'RESN':
260
-			echo '<div class="field">';
261
-			switch ($fact->getValue()) {
262
-			case 'none':
263
-			// Note: "1 RESN none" is not valid gedcom.
264
-			// However, webtrees privacy rules will interpret it as "show an otherwise private record to public".
265
-			echo '<i class="icon-resn-none"></i> ', I18N::translate('Show to visitors');
266
-			break;
267
-			case 'privacy':
268
-			echo '<i class="icon-class-none"></i> ', I18N::translate('Show to members');
269
-			break;
270
-			case 'confidential':
271
-			echo '<i class="icon-confidential-none"></i> ', I18N::translate('Show to managers');
272
-			break;
273
-			case 'locked':
274
-			echo '<i class="icon-locked-none"></i> ', I18N::translate('Only managers can edit');
275
-			break;
276
-			default:
277
-			echo Filter::escapeHtml($fact->getValue());
278
-			break;
279
-			}
240
+		    case 'ADDR':
241
+			    echo $fact->getValue();
242
+			    break;
243
+		    case 'AFN':
244
+			    echo '<div class="field"><a href="https://familysearch.org/search/tree/results#count=20&query=afn:', Filter::escapeUrl($fact->getValue()), '">', Filter::escapeHtml($fact->getValue()), '</a></div>';
245
+			    break;
246
+		    case 'ASSO':
247
+			    // we handle this later, in format_asso_rela_record()
248
+			    break;
249
+		    case 'EMAIL':
250
+		    case 'EMAI':
251
+		    case '_EMAIL':
252
+			    echo '<div class="field"><a href="mailto:', Filter::escapeHtml($fact->getValue()), '">', Filter::escapeHtml($fact->getValue()), '</a></div>';
253
+			    break;
254
+		    case 'FILE':
255
+			    if (Auth::isEditor($fact->getParent()->getTree())) {
256
+				    echo '<div class="field">', Filter::escapeHtml($fact->getValue()), '</div>';
257
+			    }
258
+			    break;
259
+		    case 'RESN':
260
+			    echo '<div class="field">';
261
+			    switch ($fact->getValue()) {
262
+			        case 'none':
263
+			        // Note: "1 RESN none" is not valid gedcom.
264
+			        // However, webtrees privacy rules will interpret it as "show an otherwise private record to public".
265
+			        echo '<i class="icon-resn-none"></i> ', I18N::translate('Show to visitors');
266
+			        break;
267
+			        case 'privacy':
268
+			        echo '<i class="icon-class-none"></i> ', I18N::translate('Show to members');
269
+			        break;
270
+			        case 'confidential':
271
+			        echo '<i class="icon-confidential-none"></i> ', I18N::translate('Show to managers');
272
+			        break;
273
+			        case 'locked':
274
+			        echo '<i class="icon-locked-none"></i> ', I18N::translate('Only managers can edit');
275
+			        break;
276
+			        default:
277
+			        echo Filter::escapeHtml($fact->getValue());
278
+			        break;
279
+			    }
280 280
 				echo '</div>';
281 281
 				break;
282
-		case 'PUBL': // Publication details might contain URLs.
283
-			echo '<div class="field">', Filter::expandUrls($fact->getValue()), '</div>';
284
-			break;
285
-		case 'REPO':
286
-			if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $fact->getValue(), $match)) {
287
-				self::printRepositoryRecord($match[1]);
288
-			} else {
289
-				echo '<div class="error">', Filter::escapeHtml($fact->getValue()), '</div>';
290
-			}
291
-			break;
292
-		case 'URL':
293
-		case '_URL':
294
-		case 'WWW':
295
-			echo '<div class="field"><a href="', Filter::escapeHtml($fact->getValue()), '">', Filter::escapeHtml($fact->getValue()), '</a></div>';
296
-			break;
297
-		case 'TEXT': // 0 SOUR / 1 TEXT
298
-			echo '<div class="field">', nl2br(Filter::escapeHtml($fact->getValue()), false), '</div>';
299
-			break;
300
-		default:
301
-			// Display the value for all other facts/events
302
-			switch ($fact->getValue()) {
303
-			case '':
304
-			// Nothing to display
305
-			break;
306
-			case 'N':
307
-			// Not valid GEDCOM
308
-			echo '<div class="field">', I18N::translate('No'), '</div>';
309
-			break;
310
-			case 'Y':
311
-			// Do not display "Yes".
312
-			break;
313
-			default:
314
-			if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $fact->getValue(), $match)) {
315
-			$target = GedcomRecord::getInstance($match[1], $fact->getParent()->getTree());
316
-			if ($target) {
317
-				echo '<div><a href="', $target->getHtmlUrl(), '">', $target->getFullName(), '</a></div>';
318
-			} else {
319
-				echo '<div class="error">', Filter::escapeHtml($fact->getValue()), '</div>';
320
-			}
321
-			} else {
322
-			echo '<div class="field"><span dir="auto">', Filter::escapeHtml($fact->getValue()), '</span></div>';
323
-			}
324
-			break;
325
-			}
282
+		    case 'PUBL': // Publication details might contain URLs.
283
+			    echo '<div class="field">', Filter::expandUrls($fact->getValue()), '</div>';
284
+			    break;
285
+		    case 'REPO':
286
+			    if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $fact->getValue(), $match)) {
287
+				    self::printRepositoryRecord($match[1]);
288
+			    } else {
289
+				    echo '<div class="error">', Filter::escapeHtml($fact->getValue()), '</div>';
290
+			    }
291
+			    break;
292
+		    case 'URL':
293
+		    case '_URL':
294
+		    case 'WWW':
295
+			    echo '<div class="field"><a href="', Filter::escapeHtml($fact->getValue()), '">', Filter::escapeHtml($fact->getValue()), '</a></div>';
296
+			    break;
297
+		    case 'TEXT': // 0 SOUR / 1 TEXT
298
+			    echo '<div class="field">', nl2br(Filter::escapeHtml($fact->getValue()), false), '</div>';
299
+			    break;
300
+		    default:
301
+			    // Display the value for all other facts/events
302
+			    switch ($fact->getValue()) {
303
+			        case '':
304
+			        // Nothing to display
305
+			        break;
306
+			        case 'N':
307
+			        // Not valid GEDCOM
308
+			        echo '<div class="field">', I18N::translate('No'), '</div>';
309
+			        break;
310
+			        case 'Y':
311
+			        // Do not display "Yes".
312
+			        break;
313
+			        default:
314
+			        if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $fact->getValue(), $match)) {
315
+			        $target = GedcomRecord::getInstance($match[1], $fact->getParent()->getTree());
316
+			        if ($target) {
317
+				        echo '<div><a href="', $target->getHtmlUrl(), '">', $target->getFullName(), '</a></div>';
318
+			        } else {
319
+				        echo '<div class="error">', Filter::escapeHtml($fact->getValue()), '</div>';
320
+			        }
321
+			        } else {
322
+			        echo '<div class="field"><span dir="auto">', Filter::escapeHtml($fact->getValue()), '</span></div>';
323
+			        }
324
+			        break;
325
+			    }
326 326
 				break;
327 327
 		}
328 328
 
@@ -362,123 +362,123 @@  discard block
 block discarded – undo
362 362
 		preg_match_all('/\n2 (' . WT_REGEX_TAG . ') (.+)/', $fact->getGedcom(), $matches, PREG_SET_ORDER);
363 363
 		foreach ($matches as $match) {
364 364
 			switch ($match[1]) {
365
-			case 'DATE':
366
-			case 'TIME':
367
-			case 'AGE':
368
-			case 'PLAC':
369
-			case 'ADDR':
370
-			case 'ALIA':
371
-			case 'ASSO':
372
-			case '_ASSO':
373
-			case 'DESC':
374
-			case 'RELA':
375
-			case 'STAT':
376
-			case 'TEMP':
377
-			case 'TYPE':
378
-			case 'FAMS':
379
-			case 'CONT':
380
-				// These were already shown at the beginning
381
-				break;
382
-			case 'NOTE':
383
-			case 'OBJE':
384
-			case 'SOUR':
385
-				// These will be shown at the end
386
-				break;
387
-			case '_UID':
388
-			case 'RIN':
389
-				// These don't belong at level 2, so do not display them.
390
-				// They are only shown when editing.
391
-				break;
392
-			case 'EVEN': // 0 SOUR / 1 DATA / 2 EVEN / 3 DATE / 3 PLAC
393
-				$events = array();
394
-				foreach (preg_split('/ *, */', $match[2]) as $event) {
395
-					$events[] = GedcomTag::getLabel($event);
396
-				}
397
-				if (count($events) == 1) {
398
-					echo GedcomTag::getLabelValue('EVEN', $event);
399
-				} else {
400
-					echo GedcomTag::getLabelValue('EVEN', implode(I18N::$list_separator, $events));
401
-				}
402
-				if (preg_match('/\n3 DATE (.+)/', $fact->getGedcom(), $date_match)) {
403
-					$date = new Date($date_match[1]);
404
-					echo GedcomTag::getLabelValue('DATE', $date->display());
405
-				}
406
-				if (preg_match('/\n3 PLAC (.+)/', $fact->getGedcom(), $plac_match)) {
407
-					echo GedcomTag::getLabelValue('PLAC', $plac_match[1]);
408
-				}
409
-				break;
410
-			case 'FAMC': // 0 INDI / 1 ADOP / 2 FAMC / 3 ADOP
411
-				$family = Family::getInstance(str_replace('@', '', $match[2]), $fact->getParent()->getTree());
412
-				if ($family) {
413
-					echo GedcomTag::getLabelValue('FAM', '<a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . '</a>');
414
-					if (preg_match('/\n3 ADOP (HUSB|WIFE|BOTH)/', $fact->getGedcom(), $match)) {
415
-						echo GedcomTag::getLabelValue('ADOP', GedcomCodeAdop::getValue($match[1], $label_person));
416
-					}
417
-				} else {
418
-					echo GedcomTag::getLabelValue('FAM', '<span class="error">' . $match[2] . '</span>');
419
-				}
420
-				break;
421
-			case '_WT_USER':
422
-				$user = User::findByIdentifier($match[2]); // may not exist
423
-				if ($user) {
424
-					echo GedcomTag::getLabelValue('_WT_USER', $user->getRealNameHtml());
425
-				} else {
426
-					echo GedcomTag::getLabelValue('_WT_USER', Filter::escapeHtml($match[2]));
427
-				}
428
-				break;
429
-			case 'RESN':
430
-				switch ($match[2]) {
431
-				case 'none':
432
-				// Note: "2 RESN none" is not valid gedcom.
433
-				// However, webtrees privacy rules will interpret it as "show an otherwise private fact to public".
434
-				echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-none"></i> ' . I18N::translate('Show to visitors'));
435
-				break;
436
-				case 'privacy':
437
-				echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-privacy"></i> ' . I18N::translate('Show to members'));
438
-				break;
439
-				case 'confidential':
440
-				echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-confidential"></i> ' . I18N::translate('Show to managers'));
441
-				break;
442
-				case 'locked':
443
-				echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-locked"></i> ' . I18N::translate('Only managers can edit'));
444
-				break;
445
-				default:
446
-				echo GedcomTag::getLabelValue('RESN', Filter::escapeHtml($match[2]));
447
-				break;
448
-				}
365
+			    case 'DATE':
366
+			    case 'TIME':
367
+			    case 'AGE':
368
+			    case 'PLAC':
369
+			    case 'ADDR':
370
+			    case 'ALIA':
371
+			    case 'ASSO':
372
+			    case '_ASSO':
373
+			    case 'DESC':
374
+			    case 'RELA':
375
+			    case 'STAT':
376
+			    case 'TEMP':
377
+			    case 'TYPE':
378
+			    case 'FAMS':
379
+			    case 'CONT':
380
+				    // These were already shown at the beginning
381
+				    break;
382
+			    case 'NOTE':
383
+			    case 'OBJE':
384
+			    case 'SOUR':
385
+				    // These will be shown at the end
386
+				    break;
387
+			    case '_UID':
388
+			    case 'RIN':
389
+				    // These don't belong at level 2, so do not display them.
390
+				    // They are only shown when editing.
391
+				    break;
392
+			    case 'EVEN': // 0 SOUR / 1 DATA / 2 EVEN / 3 DATE / 3 PLAC
393
+				    $events = array();
394
+				    foreach (preg_split('/ *, */', $match[2]) as $event) {
395
+					    $events[] = GedcomTag::getLabel($event);
396
+				    }
397
+				    if (count($events) == 1) {
398
+					    echo GedcomTag::getLabelValue('EVEN', $event);
399
+				    } else {
400
+					    echo GedcomTag::getLabelValue('EVEN', implode(I18N::$list_separator, $events));
401
+				    }
402
+				    if (preg_match('/\n3 DATE (.+)/', $fact->getGedcom(), $date_match)) {
403
+					    $date = new Date($date_match[1]);
404
+					    echo GedcomTag::getLabelValue('DATE', $date->display());
405
+				    }
406
+				    if (preg_match('/\n3 PLAC (.+)/', $fact->getGedcom(), $plac_match)) {
407
+					    echo GedcomTag::getLabelValue('PLAC', $plac_match[1]);
408
+				    }
409
+				    break;
410
+			    case 'FAMC': // 0 INDI / 1 ADOP / 2 FAMC / 3 ADOP
411
+				    $family = Family::getInstance(str_replace('@', '', $match[2]), $fact->getParent()->getTree());
412
+				    if ($family) {
413
+					    echo GedcomTag::getLabelValue('FAM', '<a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . '</a>');
414
+					    if (preg_match('/\n3 ADOP (HUSB|WIFE|BOTH)/', $fact->getGedcom(), $match)) {
415
+						    echo GedcomTag::getLabelValue('ADOP', GedcomCodeAdop::getValue($match[1], $label_person));
416
+					    }
417
+				    } else {
418
+					    echo GedcomTag::getLabelValue('FAM', '<span class="error">' . $match[2] . '</span>');
419
+				    }
420
+				    break;
421
+			    case '_WT_USER':
422
+				    $user = User::findByIdentifier($match[2]); // may not exist
423
+				    if ($user) {
424
+					    echo GedcomTag::getLabelValue('_WT_USER', $user->getRealNameHtml());
425
+				    } else {
426
+					    echo GedcomTag::getLabelValue('_WT_USER', Filter::escapeHtml($match[2]));
427
+				    }
428
+				    break;
429
+			    case 'RESN':
430
+				    switch ($match[2]) {
431
+				        case 'none':
432
+				        // Note: "2 RESN none" is not valid gedcom.
433
+				        // However, webtrees privacy rules will interpret it as "show an otherwise private fact to public".
434
+				        echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-none"></i> ' . I18N::translate('Show to visitors'));
435
+				        break;
436
+				        case 'privacy':
437
+				        echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-privacy"></i> ' . I18N::translate('Show to members'));
438
+				        break;
439
+				        case 'confidential':
440
+				        echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-confidential"></i> ' . I18N::translate('Show to managers'));
441
+				        break;
442
+				        case 'locked':
443
+				        echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-locked"></i> ' . I18N::translate('Only managers can edit'));
444
+				        break;
445
+				        default:
446
+				        echo GedcomTag::getLabelValue('RESN', Filter::escapeHtml($match[2]));
447
+				        break;
448
+				    }
449 449
 					break;
450
-			case 'CALN':
451
-				echo GedcomTag::getLabelValue('CALN', Filter::expandUrls($match[2]));
452
-				break;
453
-			case 'FORM': // 0 OBJE / 1 FILE / 2 FORM / 3 TYPE
454
-				echo GedcomTag::getLabelValue('FORM', $match[2]);
455
-				if (preg_match('/\n3 TYPE (.+)/', $fact->getGedcom(), $type_match)) {
456
-					echo GedcomTag::getLabelValue('TYPE', GedcomTag::getFileFormTypeValue($type_match[1]));
457
-				}
458
-				break;
459
-			case 'URL':
460
-			case '_URL':
461
-			case 'WWW':
462
-				$link = '<a href="' . Filter::escapeHtml($match[2]) . '">' . Filter::escapeHtml($match[2]) . '</a>';
463
-				echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], $link);
464
-				break;
465
-			default:
466
-				if ($fact->getParent()->getTree()->getPreference('HIDE_GEDCOM_ERRORS') === '1' || GedcomTag::isTag($match[1])) {
467
-					if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $match[2], $xmatch)) {
468
-						// Links
469
-						$linked_record = GedcomRecord::getInstance($xmatch[1], $fact->getParent()->getTree());
470
-						if ($linked_record) {
471
-							$link = '<a href="' . $linked_record->getHtmlUrl() . '">' . $linked_record->getFullName() . '</a>';
472
-							echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], $link);
473
-						} else {
474
-							echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], Filter::escapeHtml($match[2]));
475
-						}
476
-					} else {
477
-						// Non links
478
-						echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], Filter::escapeHtml($match[2]));
479
-					}
480
-				}
481
-				break;
450
+			    case 'CALN':
451
+				    echo GedcomTag::getLabelValue('CALN', Filter::expandUrls($match[2]));
452
+				    break;
453
+			    case 'FORM': // 0 OBJE / 1 FILE / 2 FORM / 3 TYPE
454
+				    echo GedcomTag::getLabelValue('FORM', $match[2]);
455
+				    if (preg_match('/\n3 TYPE (.+)/', $fact->getGedcom(), $type_match)) {
456
+					    echo GedcomTag::getLabelValue('TYPE', GedcomTag::getFileFormTypeValue($type_match[1]));
457
+				    }
458
+				    break;
459
+			    case 'URL':
460
+			    case '_URL':
461
+			    case 'WWW':
462
+				    $link = '<a href="' . Filter::escapeHtml($match[2]) . '">' . Filter::escapeHtml($match[2]) . '</a>';
463
+				    echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], $link);
464
+				    break;
465
+			    default:
466
+				    if ($fact->getParent()->getTree()->getPreference('HIDE_GEDCOM_ERRORS') === '1' || GedcomTag::isTag($match[1])) {
467
+					    if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $match[2], $xmatch)) {
468
+						    // Links
469
+						    $linked_record = GedcomRecord::getInstance($xmatch[1], $fact->getParent()->getTree());
470
+						    if ($linked_record) {
471
+							    $link = '<a href="' . $linked_record->getHtmlUrl() . '">' . $linked_record->getFullName() . '</a>';
472
+							    echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], $link);
473
+						    } else {
474
+							    echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], Filter::escapeHtml($match[2]));
475
+						    }
476
+					    } else {
477
+						    // Non links
478
+						    echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], Filter::escapeHtml($match[2]));
479
+					    }
480
+				    }
481
+				    break;
482 482
 			}
483 483
 		}
484 484
 		echo self::printFactSources($fact->getGedcom(), 2);
@@ -824,23 +824,23 @@  discard block
 block discarded – undo
824 824
 						foreach ($rmatches[1] as $rmatch) {
825 825
 							echo '<br><span class="label">', GedcomTag::getLabel('RESN'), ':</span> <span class="field">';
826 826
 							switch ($rmatch) {
827
-							case 'none':
828
-								// Note: "2 RESN none" is not valid gedcom, and the GUI will not let you add it.
829
-								// However, webtrees privacy rules will interpret it as "show an otherwise private fact to public".
830
-								echo '<i class="icon-resn-none"></i> ', I18N::translate('Show to visitors');
831
-								break;
832
-							case 'privacy':
833
-								echo '<i class="icon-resn-privacy"></i> ', I18N::translate('Show to members');
834
-								break;
835
-							case 'confidential':
836
-								echo '<i class="icon-resn-confidential"></i> ', I18N::translate('Show to managers');
837
-								break;
838
-							case 'locked':
839
-								echo '<i class="icon-resn-locked"></i> ', I18N::translate('Only managers can edit');
840
-								break;
841
-							default:
842
-								echo $rmatch;
843
-								break;
827
+							    case 'none':
828
+								    // Note: "2 RESN none" is not valid gedcom, and the GUI will not let you add it.
829
+								    // However, webtrees privacy rules will interpret it as "show an otherwise private fact to public".
830
+								    echo '<i class="icon-resn-none"></i> ', I18N::translate('Show to visitors');
831
+								    break;
832
+							    case 'privacy':
833
+								    echo '<i class="icon-resn-privacy"></i> ', I18N::translate('Show to members');
834
+								    break;
835
+							    case 'confidential':
836
+								    echo '<i class="icon-resn-confidential"></i> ', I18N::translate('Show to managers');
837
+								    break;
838
+							    case 'locked':
839
+								    echo '<i class="icon-resn-locked"></i> ', I18N::translate('Only managers can edit');
840
+								    break;
841
+							    default:
842
+								    echo $rmatch;
843
+								    break;
844 844
 							}
845 845
 							echo '</span>';
846 846
 						}
@@ -1090,23 +1090,23 @@  discard block
 block discarded – undo
1090 1090
 				foreach ($matches[1] as $match) {
1091 1091
 					echo '<br><span class="label">', GedcomTag::getLabel('RESN'), ':</span> <span class="field">';
1092 1092
 					switch ($match) {
1093
-					case 'none':
1094
-						// Note: "2 RESN none" is not valid gedcom, and the GUI will not let you add it.
1095
-						// However, webtrees privacy rules will interpret it as "show an otherwise private fact to public".
1096
-						echo '<i class="icon-resn-none"></i> ', I18N::translate('Show to visitors');
1097
-						break;
1098
-					case 'privacy':
1099
-						echo '<i class="icon-resn-privacy"></i> ', I18N::translate('Show to members');
1100
-						break;
1101
-					case 'confidential':
1102
-						echo '<i class="icon-resn-confidential"></i> ', I18N::translate('Show to managers');
1103
-						break;
1104
-					case 'locked':
1105
-						echo '<i class="icon-resn-locked"></i> ', I18N::translate('Only managers can edit');
1106
-						break;
1107
-					default:
1108
-						echo $match;
1109
-						break;
1093
+					    case 'none':
1094
+						    // Note: "2 RESN none" is not valid gedcom, and the GUI will not let you add it.
1095
+						    // However, webtrees privacy rules will interpret it as "show an otherwise private fact to public".
1096
+						    echo '<i class="icon-resn-none"></i> ', I18N::translate('Show to visitors');
1097
+						    break;
1098
+					    case 'privacy':
1099
+						    echo '<i class="icon-resn-privacy"></i> ', I18N::translate('Show to members');
1100
+						    break;
1101
+					    case 'confidential':
1102
+						    echo '<i class="icon-resn-confidential"></i> ', I18N::translate('Show to managers');
1103
+						    break;
1104
+					    case 'locked':
1105
+						    echo '<i class="icon-resn-locked"></i> ', I18N::translate('Only managers can edit');
1106
+						    break;
1107
+					    default:
1108
+						    echo $match;
1109
+						    break;
1110 1110
 					}
1111 1111
 					echo '</span>';
1112 1112
 				}
@@ -1207,12 +1207,12 @@  discard block
 block discarded – undo
1207 1207
 					}
1208 1208
 
1209 1209
 					switch ($media->isPrimary()) {
1210
-					case 'Y':
1211
-						echo GedcomTag::getLabelValue('_PRIM', I18N::translate('yes'));
1212
-						break;
1213
-					case 'N':
1214
-						echo GedcomTag::getLabelValue('_PRIM', I18N::translate('no'));
1215
-						break;
1210
+					    case 'Y':
1211
+						    echo GedcomTag::getLabelValue('_PRIM', I18N::translate('yes'));
1212
+						    break;
1213
+					    case 'N':
1214
+						    echo GedcomTag::getLabelValue('_PRIM', I18N::translate('no'));
1215
+						    break;
1216 1216
 					}
1217 1217
 					echo FunctionsPrint::printFactNotes($media->getGedcom(), 1);
1218 1218
 					echo self::printFactSources($media->getGedcom(), 1);
Please login to merge, or discard this patch.
app/Functions/FunctionsMedia.php 1 patch
Switch Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -34,17 +34,17 @@
 block discarded – undo
34 34
 			$val = -1;
35 35
 		}
36 36
 		switch (substr($val, -1)) {
37
-		case 'g':
38
-		case 'G':
39
-			return (int) $val * 1024 * 1024 * 1024;
40
-		case 'm':
41
-		case 'M':
42
-			return (int) $val * 1024 * 1024;
43
-		case 'k':
44
-		case 'K':
45
-			return (int) $val * 1024;
46
-		default:
47
-			return (int) $val;
37
+		    case 'g':
38
+		    case 'G':
39
+			    return (int) $val * 1024 * 1024 * 1024;
40
+		    case 'm':
41
+		    case 'M':
42
+			    return (int) $val * 1024 * 1024;
43
+		    case 'k':
44
+		    case 'K':
45
+			    return (int) $val * 1024;
46
+		    default:
47
+			    return (int) $val;
48 48
 		}
49 49
 	}
50 50
 
Please login to merge, or discard this patch.
app/Functions/FunctionsRtl.php 1 patch
Switch Indentation   +249 added lines, -249 removed lines patch added patch discarded remove patch
@@ -124,227 +124,227 @@  discard block
 block discarded – undo
124 124
 			$closeParIndex = strpos(self::CLOSE_PARENTHESES, $currentLetter); // Which closing parenthesis is this?
125 125
 
126 126
 			switch ($currentLetter) {
127
-			case '<':
128
-				// Assume this '<' starts an HTML element
129
-				$endPos = strpos($workingText, '>'); // look for the terminating '>'
130
-				if ($endPos === false) {
131
-					$endPos = 0;
132
-				}
133
-				$currentLen += $endPos;
134
-				$element = substr($workingText, 0, $currentLen);
135
-				$temp    = strtolower(substr($element, 0, 3));
136
-				if (strlen($element) < 7 && $temp == '<br') {
137
-					if ($numberState) {
138
-						$numberState = false;
139
-						if (self::$currentState == 'RTL') {
140
-							self::$waitingText .= WT_UTF8_PDF;
141
-						}
142
-					}
143
-					self::breakCurrentSpan($result);
144
-				} elseif (self::$waitingText == '') {
145
-					$result .= $element;
146
-				} else {
147
-					self::$waitingText .= $element;
148
-				}
149
-				$workingText = substr($workingText, $currentLen);
150
-				break;
151
-			case '&':
152
-				// Assume this '&' starts an HTML entity
153
-				$endPos = strpos($workingText, ';'); // look for the terminating ';'
154
-				if ($endPos === false) {
155
-					$endPos = 0;
156
-				}
157
-				$currentLen += $endPos;
158
-				$entity = substr($workingText, 0, $currentLen);
159
-				if (strtolower($entity) == '&nbsp;') {
160
-					$entity .= '&nbsp;'; // Ensure consistent case for this entity
161
-				}
162
-				if (self::$waitingText == '') {
163
-					$result .= $entity;
164
-				} else {
165
-					self::$waitingText .= $entity;
166
-				}
167
-				$workingText = substr($workingText, $currentLen);
168
-				break;
169
-			case '{':
170
-				if (substr($workingText, 1, 1) == '{') {
171
-					// Assume this '{{' starts a TCPDF directive
172
-					$endPos = strpos($workingText, '}}'); // look for the terminating '}}'
173
-					if ($endPos === false) {
174
-						$endPos = 0;
175
-					}
176
-					$currentLen        = $endPos + 2;
177
-					$directive         = substr($workingText, 0, $currentLen);
178
-					$workingText       = substr($workingText, $currentLen);
179
-					$result            = $result . self::$waitingText . $directive;
180
-					self::$waitingText = '';
181
-					break;
182
-				}
183
-			default:
184
-				// Look for strings of numbers with optional leading or trailing + or -
185
-				// and with optional embedded numeric punctuation
186
-				if ($numberState) {
187
-					// If we're inside a numeric string, look for reasons to end it
188
-					$offset    = 0; // Be sure to look at the current character first
189
-					$charArray = self::getChar($workingText . "\n", $offset);
190
-					if (strpos(self::NUMBERS, $charArray['letter']) === false) {
191
-						// This is not a digit. Is it numeric punctuation?
192
-						if (substr($workingText . "\n", $offset, 6) == '&nbsp;') {
193
-							$offset += 6; // This could be numeric punctuation
194
-						} elseif (strpos(self::NUMBER_PUNCTUATION, $charArray['letter']) !== false) {
195
-							$offset += $charArray['length']; // This could be numeric punctuation
196
-						}
197
-						// If the next character is a digit, the current character is numeric punctuation
198
-						$charArray = self::getChar($workingText . "\n", $offset);
199
-						if (strpos(self::NUMBERS, $charArray['letter']) === false) {
200
-							// This is not a digit. End the run of digits and punctuation.
201
-							$numberState = false;
202
-							if (self::$currentState == 'RTL') {
203
-								if (strpos(self::NUMBER_PREFIX, $currentLetter) === false) {
204
-									$currentLetter = WT_UTF8_PDF . $currentLetter;
205
-								} else {
206
-									$currentLetter = $currentLetter . WT_UTF8_PDF; // Include a trailing + or - in the run
207
-								}
208
-							}
209
-						}
210
-					}
211
-				} else {
212
-					// If we're outside a numeric string, look for reasons to start it
213
-					if (strpos(self::NUMBER_PREFIX, $currentLetter) !== false) {
214
-						// This might be a number lead-in
215
-						$offset   = $currentLen;
216
-						$nextChar = substr($workingText . "\n", $offset, 1);
217
-						if (strpos(self::NUMBERS, $nextChar) !== false) {
218
-							$numberState = true; // We found a digit: the lead-in is therefore numeric
219
-							if (self::$currentState == 'RTL') {
220
-								$currentLetter = WT_UTF8_LRE . $currentLetter;
221
-							}
222
-						}
223
-					} elseif (strpos(self::NUMBERS, $currentLetter) !== false) {
224
-						$numberState = true; // The current letter is a digit
225
-						if (self::$currentState == 'RTL') {
226
-							$currentLetter = WT_UTF8_LRE . $currentLetter;
227
-						}
228
-					}
229
-				}
230
-
231
-				// Determine the directionality of the current UTF-8 character
232
-				$newState = self::$currentState;
233
-				while (true) {
234
-					if (I18N::scriptDirection(I18N::textScript($currentLetter)) === 'rtl') {
235
-						if (self::$currentState == '') {
236
-							$newState = 'RTL';
237
-							break;
238
-						}
239
-
240
-						if (self::$currentState == 'RTL') {
241
-							break;
242
-						}
243
-						// Switch to RTL only if this isn't a solitary RTL letter
244
-						$tempText = substr($workingText, $currentLen);
245
-						while ($tempText != '') {
246
-							$nextCharArray = self::getChar($tempText, 0);
247
-							$nextLetter    = $nextCharArray['letter'];
248
-							$nextLen       = $nextCharArray['length'];
249
-							$tempText      = substr($tempText, $nextLen);
250
-
251
-							if (I18N::scriptDirection(I18N::textScript($nextLetter)) === 'rtl') {
252
-								$newState = 'RTL';
253
-								break 2;
254
-							}
255
-
256
-							if (strpos(self::PUNCTUATION, $nextLetter) !== false || strpos(self::OPEN_PARENTHESES, $nextLetter) !== false) {
257
-								$newState = 'RTL';
258
-								break 2;
259
-							}
260
-
261
-							if ($nextLetter === ' ') {
262
-								break;
263
-							}
264
-							$nextLetter .= substr($tempText . "\n", 0, 5);
265
-							if ($nextLetter === '&nbsp;') {
266
-								break;
267
-							}
268
-						}
269
-						// This is a solitary RTL letter : wrap it in UTF8 control codes to force LTR directionality
270
-						$currentLetter = WT_UTF8_LRO . $currentLetter . WT_UTF8_PDF;
271
-						$newState      = 'LTR';
272
-						break;
273
-					}
274
-					if (($currentLen != 1) || ($currentLetter >= 'A' && $currentLetter <= 'Z') || ($currentLetter >= 'a' && $currentLetter <= 'z')) {
275
-						// Since it’s neither Hebrew nor Arabic, this UTF-8 character or ASCII letter must be LTR
276
-						$newState = 'LTR';
277
-						break;
278
-					}
279
-					if ($closeParIndex !== false) {
280
-						// This closing parenthesis has to inherit the matching opening parenthesis' directionality
281
-						if (!empty($openParDirection[$closeParIndex]) && $openParDirection[$closeParIndex] != '?') {
282
-							$newState = $openParDirection[$closeParIndex];
283
-						}
284
-						$openParDirection[$closeParIndex] = '';
285
-						break;
286
-					}
287
-					if ($openParIndex !== false) {
288
-						// Opening parentheses always inherit the following directionality
289
-						self::$waitingText .= $currentLetter;
290
-						$workingText = substr($workingText, $currentLen);
291
-						while (true) {
292
-							if ($workingText === '') {
293
-								break;
294
-							}
295
-							if (substr($workingText, 0, 1) === ' ') {
296
-								// Spaces following this left parenthesis inherit the following directionality too
297
-								self::$waitingText .= ' ';
298
-								$workingText = substr($workingText, 1);
299
-								continue;
300
-							}
301
-							if (substr($workingText, 0, 6) === '&nbsp;') {
302
-								// Spaces following this left parenthesis inherit the following directionality too
303
-								self::$waitingText .= '&nbsp;';
304
-								$workingText = substr($workingText, 6);
305
-								continue;
306
-							}
307
-							break;
308
-						}
309
-						$openParDirection[$openParIndex] = '?';
310
-						break 2; // double break because we're waiting for more information
311
-					}
312
-
313
-					// We have a digit or a "normal" special character.
314
-					//
315
-					// When this character is not at the start of the input string, it inherits the preceding directionality;
316
-					// at the start of the input string, it assumes the following directionality.
317
-					//
318
-					// Exceptions to this rule will be handled later during final clean-up.
319
-					//
320
-					self::$waitingText .= $currentLetter;
321
-					$workingText = substr($workingText, $currentLen);
322
-					if (self::$currentState != '') {
323
-						$result .= self::$waitingText;
324
-						self::$waitingText = '';
325
-					}
326
-					break 2; // double break because we're waiting for more information
327
-				}
328
-				if ($newState != self::$currentState) {
329
-					// A direction change has occurred
330
-					self::finishCurrentSpan($result, false);
331
-					self::$previousState = self::$currentState;
332
-					self::$currentState  = $newState;
333
-					self::beginCurrentSpan($result);
334
-				}
335
-				self::$waitingText .= $currentLetter;
336
-				$workingText = substr($workingText, $currentLen);
337
-				$result .= self::$waitingText;
338
-				self::$waitingText = '';
339
-
340
-				foreach ($openParDirection as $index => $value) {
341
-					// Since we now know the proper direction, remember it for all waiting opening parentheses
342
-					if ($value === '?') {
343
-						$openParDirection[$index] = self::$currentState;
344
-					}
345
-				}
346
-
347
-				break;
127
+			    case '<':
128
+				    // Assume this '<' starts an HTML element
129
+				    $endPos = strpos($workingText, '>'); // look for the terminating '>'
130
+				    if ($endPos === false) {
131
+					    $endPos = 0;
132
+				    }
133
+				    $currentLen += $endPos;
134
+				    $element = substr($workingText, 0, $currentLen);
135
+				    $temp    = strtolower(substr($element, 0, 3));
136
+				    if (strlen($element) < 7 && $temp == '<br') {
137
+					    if ($numberState) {
138
+						    $numberState = false;
139
+						    if (self::$currentState == 'RTL') {
140
+							    self::$waitingText .= WT_UTF8_PDF;
141
+						    }
142
+					    }
143
+					    self::breakCurrentSpan($result);
144
+				    } elseif (self::$waitingText == '') {
145
+					    $result .= $element;
146
+				    } else {
147
+					    self::$waitingText .= $element;
148
+				    }
149
+				    $workingText = substr($workingText, $currentLen);
150
+				    break;
151
+			    case '&':
152
+				    // Assume this '&' starts an HTML entity
153
+				    $endPos = strpos($workingText, ';'); // look for the terminating ';'
154
+				    if ($endPos === false) {
155
+					    $endPos = 0;
156
+				    }
157
+				    $currentLen += $endPos;
158
+				    $entity = substr($workingText, 0, $currentLen);
159
+				    if (strtolower($entity) == '&nbsp;') {
160
+					    $entity .= '&nbsp;'; // Ensure consistent case for this entity
161
+				    }
162
+				    if (self::$waitingText == '') {
163
+					    $result .= $entity;
164
+				    } else {
165
+					    self::$waitingText .= $entity;
166
+				    }
167
+				    $workingText = substr($workingText, $currentLen);
168
+				    break;
169
+			    case '{':
170
+				    if (substr($workingText, 1, 1) == '{') {
171
+					    // Assume this '{{' starts a TCPDF directive
172
+					    $endPos = strpos($workingText, '}}'); // look for the terminating '}}'
173
+					    if ($endPos === false) {
174
+						    $endPos = 0;
175
+					    }
176
+					    $currentLen        = $endPos + 2;
177
+					    $directive         = substr($workingText, 0, $currentLen);
178
+					    $workingText       = substr($workingText, $currentLen);
179
+					    $result            = $result . self::$waitingText . $directive;
180
+					    self::$waitingText = '';
181
+					    break;
182
+				    }
183
+			    default:
184
+				    // Look for strings of numbers with optional leading or trailing + or -
185
+				    // and with optional embedded numeric punctuation
186
+				    if ($numberState) {
187
+					    // If we're inside a numeric string, look for reasons to end it
188
+					    $offset    = 0; // Be sure to look at the current character first
189
+					    $charArray = self::getChar($workingText . "\n", $offset);
190
+					    if (strpos(self::NUMBERS, $charArray['letter']) === false) {
191
+						    // This is not a digit. Is it numeric punctuation?
192
+						    if (substr($workingText . "\n", $offset, 6) == '&nbsp;') {
193
+							    $offset += 6; // This could be numeric punctuation
194
+						    } elseif (strpos(self::NUMBER_PUNCTUATION, $charArray['letter']) !== false) {
195
+							    $offset += $charArray['length']; // This could be numeric punctuation
196
+						    }
197
+						    // If the next character is a digit, the current character is numeric punctuation
198
+						    $charArray = self::getChar($workingText . "\n", $offset);
199
+						    if (strpos(self::NUMBERS, $charArray['letter']) === false) {
200
+							    // This is not a digit. End the run of digits and punctuation.
201
+							    $numberState = false;
202
+							    if (self::$currentState == 'RTL') {
203
+								    if (strpos(self::NUMBER_PREFIX, $currentLetter) === false) {
204
+									    $currentLetter = WT_UTF8_PDF . $currentLetter;
205
+								    } else {
206
+									    $currentLetter = $currentLetter . WT_UTF8_PDF; // Include a trailing + or - in the run
207
+								    }
208
+							    }
209
+						    }
210
+					    }
211
+				    } else {
212
+					    // If we're outside a numeric string, look for reasons to start it
213
+					    if (strpos(self::NUMBER_PREFIX, $currentLetter) !== false) {
214
+						    // This might be a number lead-in
215
+						    $offset   = $currentLen;
216
+						    $nextChar = substr($workingText . "\n", $offset, 1);
217
+						    if (strpos(self::NUMBERS, $nextChar) !== false) {
218
+							    $numberState = true; // We found a digit: the lead-in is therefore numeric
219
+							    if (self::$currentState == 'RTL') {
220
+								    $currentLetter = WT_UTF8_LRE . $currentLetter;
221
+							    }
222
+						    }
223
+					    } elseif (strpos(self::NUMBERS, $currentLetter) !== false) {
224
+						    $numberState = true; // The current letter is a digit
225
+						    if (self::$currentState == 'RTL') {
226
+							    $currentLetter = WT_UTF8_LRE . $currentLetter;
227
+						    }
228
+					    }
229
+				    }
230
+
231
+				    // Determine the directionality of the current UTF-8 character
232
+				    $newState = self::$currentState;
233
+				    while (true) {
234
+					    if (I18N::scriptDirection(I18N::textScript($currentLetter)) === 'rtl') {
235
+						    if (self::$currentState == '') {
236
+							    $newState = 'RTL';
237
+							    break;
238
+						    }
239
+
240
+						    if (self::$currentState == 'RTL') {
241
+							    break;
242
+						    }
243
+						    // Switch to RTL only if this isn't a solitary RTL letter
244
+						    $tempText = substr($workingText, $currentLen);
245
+						    while ($tempText != '') {
246
+							    $nextCharArray = self::getChar($tempText, 0);
247
+							    $nextLetter    = $nextCharArray['letter'];
248
+							    $nextLen       = $nextCharArray['length'];
249
+							    $tempText      = substr($tempText, $nextLen);
250
+
251
+							    if (I18N::scriptDirection(I18N::textScript($nextLetter)) === 'rtl') {
252
+								    $newState = 'RTL';
253
+								    break 2;
254
+							    }
255
+
256
+							    if (strpos(self::PUNCTUATION, $nextLetter) !== false || strpos(self::OPEN_PARENTHESES, $nextLetter) !== false) {
257
+								    $newState = 'RTL';
258
+								    break 2;
259
+							    }
260
+
261
+							    if ($nextLetter === ' ') {
262
+								    break;
263
+							    }
264
+							    $nextLetter .= substr($tempText . "\n", 0, 5);
265
+							    if ($nextLetter === '&nbsp;') {
266
+								    break;
267
+							    }
268
+						    }
269
+						    // This is a solitary RTL letter : wrap it in UTF8 control codes to force LTR directionality
270
+						    $currentLetter = WT_UTF8_LRO . $currentLetter . WT_UTF8_PDF;
271
+						    $newState      = 'LTR';
272
+						    break;
273
+					    }
274
+					    if (($currentLen != 1) || ($currentLetter >= 'A' && $currentLetter <= 'Z') || ($currentLetter >= 'a' && $currentLetter <= 'z')) {
275
+						    // Since it’s neither Hebrew nor Arabic, this UTF-8 character or ASCII letter must be LTR
276
+						    $newState = 'LTR';
277
+						    break;
278
+					    }
279
+					    if ($closeParIndex !== false) {
280
+						    // This closing parenthesis has to inherit the matching opening parenthesis' directionality
281
+						    if (!empty($openParDirection[$closeParIndex]) && $openParDirection[$closeParIndex] != '?') {
282
+							    $newState = $openParDirection[$closeParIndex];
283
+						    }
284
+						    $openParDirection[$closeParIndex] = '';
285
+						    break;
286
+					    }
287
+					    if ($openParIndex !== false) {
288
+						    // Opening parentheses always inherit the following directionality
289
+						    self::$waitingText .= $currentLetter;
290
+						    $workingText = substr($workingText, $currentLen);
291
+						    while (true) {
292
+							    if ($workingText === '') {
293
+								    break;
294
+							    }
295
+							    if (substr($workingText, 0, 1) === ' ') {
296
+								    // Spaces following this left parenthesis inherit the following directionality too
297
+								    self::$waitingText .= ' ';
298
+								    $workingText = substr($workingText, 1);
299
+								    continue;
300
+							    }
301
+							    if (substr($workingText, 0, 6) === '&nbsp;') {
302
+								    // Spaces following this left parenthesis inherit the following directionality too
303
+								    self::$waitingText .= '&nbsp;';
304
+								    $workingText = substr($workingText, 6);
305
+								    continue;
306
+							    }
307
+							    break;
308
+						    }
309
+						    $openParDirection[$openParIndex] = '?';
310
+						    break 2; // double break because we're waiting for more information
311
+					    }
312
+
313
+					    // We have a digit or a "normal" special character.
314
+					    //
315
+					    // When this character is not at the start of the input string, it inherits the preceding directionality;
316
+					    // at the start of the input string, it assumes the following directionality.
317
+					    //
318
+					    // Exceptions to this rule will be handled later during final clean-up.
319
+					    //
320
+					    self::$waitingText .= $currentLetter;
321
+					    $workingText = substr($workingText, $currentLen);
322
+					    if (self::$currentState != '') {
323
+						    $result .= self::$waitingText;
324
+						    self::$waitingText = '';
325
+					    }
326
+					    break 2; // double break because we're waiting for more information
327
+				    }
328
+				    if ($newState != self::$currentState) {
329
+					    // A direction change has occurred
330
+					    self::finishCurrentSpan($result, false);
331
+					    self::$previousState = self::$currentState;
332
+					    self::$currentState  = $newState;
333
+					    self::beginCurrentSpan($result);
334
+				    }
335
+				    self::$waitingText .= $currentLetter;
336
+				    $workingText = substr($workingText, $currentLen);
337
+				    $result .= self::$waitingText;
338
+				    self::$waitingText = '';
339
+
340
+				    foreach ($openParDirection as $index => $value) {
341
+					    // Since we now know the proper direction, remember it for all waiting opening parentheses
342
+					    if ($value === '?') {
343
+						    $openParDirection[$index] = self::$currentState;
344
+					    }
345
+				    }
346
+
347
+				    break;
348 348
 			}
349 349
 		}
350 350
 
@@ -461,34 +461,34 @@  discard block
 block discarded – undo
461 461
 
462 462
 		// Finally, correct '<LTR>', '</LTR>', '<RTL>', and '</RTL>'
463 463
 		switch ($direction) {
464
-		case 'BOTH':
465
-		case 'both':
466
-			// LTR text: <span dir="ltr"> text </span>
467
-			// RTL text: <span dir="rtl"> text </span>
468
-			$sLTR = '<span dir="ltr" ' . $class . '>' . $nothing;
469
-			$eLTR = $nothing . '</span>';
470
-			$sRTL = '<span dir="rtl" ' . $class . '>' . $nothing;
471
-			$eRTL = $nothing . '</span>';
472
-			break;
473
-		case 'LTR':
474
-		case 'ltr':
475
-			// LTR text: <span dir="ltr"> text </span>
476
-			// RTL text: text
477
-			$sLTR = '<span dir="ltr" ' . $class . '>' . $nothing;
478
-			$eLTR = $nothing . '</span>';
479
-			$sRTL = '';
480
-			$eRTL = '';
481
-			break;
482
-		case 'RTL':
483
-		case 'rtl':
484
-		default:
485
-			// LTR text: text
486
-			// RTL text: <span dir="rtl"> text </span>
487
-			$sLTR = '';
488
-			$eLTR = '';
489
-			$sRTL = '<span dir="rtl" ' . $class . '>' . $nothing;
490
-			$eRTL = $nothing . '</span>';
491
-			break;
464
+		    case 'BOTH':
465
+		    case 'both':
466
+			    // LTR text: <span dir="ltr"> text </span>
467
+			    // RTL text: <span dir="rtl"> text </span>
468
+			    $sLTR = '<span dir="ltr" ' . $class . '>' . $nothing;
469
+			    $eLTR = $nothing . '</span>';
470
+			    $sRTL = '<span dir="rtl" ' . $class . '>' . $nothing;
471
+			    $eRTL = $nothing . '</span>';
472
+			    break;
473
+		    case 'LTR':
474
+		    case 'ltr':
475
+			    // LTR text: <span dir="ltr"> text </span>
476
+			    // RTL text: text
477
+			    $sLTR = '<span dir="ltr" ' . $class . '>' . $nothing;
478
+			    $eLTR = $nothing . '</span>';
479
+			    $sRTL = '';
480
+			    $eRTL = '';
481
+			    break;
482
+		    case 'RTL':
483
+		    case 'rtl':
484
+		    default:
485
+			    // LTR text: text
486
+			    // RTL text: <span dir="rtl"> text </span>
487
+			    $sLTR = '';
488
+			    $eLTR = '';
489
+			    $sRTL = '<span dir="rtl" ' . $class . '>' . $nothing;
490
+			    $eRTL = $nothing . '</span>';
491
+			    break;
492 492
 		}
493 493
 		$result = str_replace(array(self::$startLTR, self::$endLTR, self::$startRTL, self::$endRTL), array($sLTR, $eLTR, $sRTL, $eRTL), $result);
494 494
 
Please login to merge, or discard this patch.
app/Functions/FunctionsPrint.php 1 patch
Switch Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -51,20 +51,20 @@  discard block
 block discarded – undo
51 51
 	public static function printPedigreePerson(Individual $person = null, $show_full = 1) {
52 52
 
53 53
 		switch ($show_full) {
54
-		case 0:
55
-			if ($person) {
56
-				echo Theme::theme()->individualBoxSmall($person);
57
-			} else {
58
-				echo Theme::theme()->individualBoxSmallEmpty();
59
-			}
60
-			break;
61
-		case 1:
62
-			if ($person) {
63
-				echo Theme::theme()->individualBox($person);
64
-			} else {
65
-				echo Theme::theme()->individualBoxEmpty();
66
-			}
67
-			break;
54
+		    case 0:
55
+			    if ($person) {
56
+				    echo Theme::theme()->individualBoxSmall($person);
57
+			    } else {
58
+				    echo Theme::theme()->individualBoxSmallEmpty();
59
+			    }
60
+			    break;
61
+		    case 1:
62
+			    if ($person) {
63
+				    echo Theme::theme()->individualBox($person);
64
+			    } else {
65
+				    echo Theme::theme()->individualBoxEmpty();
66
+			    }
67
+			    break;
68 68
 		}
69 69
 	}
70 70
 
@@ -260,25 +260,25 @@  discard block
 block discarded – undo
260 260
 					$age      = Date::getAge($parent->getBirthDate(), $birth_date, 2);
261 261
 					$deatdate = $parent->getDeathDate();
262 262
 					switch ($parent->getSex()) {
263
-					case 'F':
264
-						// Highlight mothers who die in childbirth or shortly afterwards
265
-						if ($deatdate->isOK() && $deatdate->maximumJulianDay() < $birth_date->minimumJulianDay() + 90) {
266
-							$html .= ' <span title="' . GedcomTag::getLabel('_DEAT_PARE', $parent) . '" class="parentdeath">' . $sex . $age . '</span>';
267
-						} else {
268
-							$html .= ' <span title="' . I18N::translate('Mother’s age') . '">' . $sex . $age . '</span>';
269
-						}
270
-						break;
271
-					case 'M':
272
-						// Highlight fathers who die before the birth
273
-						if ($deatdate->isOK() && $deatdate->maximumJulianDay() < $birth_date->minimumJulianDay()) {
274
-							$html .= ' <span title="' . GedcomTag::getLabel('_DEAT_PARE', $parent) . '" class="parentdeath">' . $sex . $age . '</span>';
275
-						} else {
276
-							$html .= ' <span title="' . I18N::translate('Father’s age') . '">' . $sex . $age . '</span>';
277
-						}
278
-						break;
279
-					default:
280
-						$html .= ' <span title="' . I18N::translate('Parent’s age') . '">' . $sex . $age . '</span>';
281
-						break;
263
+					    case 'F':
264
+						    // Highlight mothers who die in childbirth or shortly afterwards
265
+						    if ($deatdate->isOK() && $deatdate->maximumJulianDay() < $birth_date->minimumJulianDay() + 90) {
266
+							    $html .= ' <span title="' . GedcomTag::getLabel('_DEAT_PARE', $parent) . '" class="parentdeath">' . $sex . $age . '</span>';
267
+						    } else {
268
+							    $html .= ' <span title="' . I18N::translate('Mother’s age') . '">' . $sex . $age . '</span>';
269
+						    }
270
+						    break;
271
+					    case 'M':
272
+						    // Highlight fathers who die before the birth
273
+						    if ($deatdate->isOK() && $deatdate->maximumJulianDay() < $birth_date->minimumJulianDay()) {
274
+							    $html .= ' <span title="' . GedcomTag::getLabel('_DEAT_PARE', $parent) . '" class="parentdeath">' . $sex . $age . '</span>';
275
+						    } else {
276
+							    $html .= ' <span title="' . I18N::translate('Father’s age') . '">' . $sex . $age . '</span>';
277
+						    }
278
+						    break;
279
+					    default:
280
+						    $html .= ' <span title="' . I18N::translate('Parent’s age') . '">' . $sex . $age . '</span>';
281
+						    break;
282 282
 					}
283 283
 				}
284 284
 			}
@@ -573,33 +573,33 @@  discard block
 block discarded – undo
573 573
 
574 574
 		// -- Add from pick list
575 575
 		switch ($type) {
576
-		case "INDI":
577
-			$addfacts    = preg_split("/[, ;:]+/", $WT_TREE->getPreference('INDI_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY);
578
-			$uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('INDI_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY);
579
-			$quickfacts  = preg_split("/[, ;:]+/", $WT_TREE->getPreference('INDI_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY);
580
-			break;
581
-		case "FAM":
582
-			$addfacts    = preg_split("/[, ;:]+/", $WT_TREE->getPreference('FAM_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY);
583
-			$uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('FAM_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY);
584
-			$quickfacts  = preg_split("/[, ;:]+/", $WT_TREE->getPreference('FAM_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY);
585
-			break;
586
-		case "SOUR":
587
-			$addfacts    = preg_split("/[, ;:]+/", $WT_TREE->getPreference('SOUR_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY);
588
-			$uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('SOUR_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY);
589
-			$quickfacts  = preg_split("/[, ;:]+/", $WT_TREE->getPreference('SOUR_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY);
590
-			break;
591
-		case "NOTE":
592
-			$addfacts    = preg_split("/[, ;:]+/", $WT_TREE->getPreference('NOTE_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY);
593
-			$uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('NOTE_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY);
594
-			$quickfacts  = preg_split("/[, ;:]+/", $WT_TREE->getPreference('NOTE_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY);
595
-			break;
596
-		case "REPO":
597
-			$addfacts    = preg_split("/[, ;:]+/", $WT_TREE->getPreference('REPO_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY);
598
-			$uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('REPO_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY);
599
-			$quickfacts  = preg_split("/[, ;:]+/", $WT_TREE->getPreference('REPO_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY);
600
-			break;
601
-		default:
602
-			return;
576
+		    case "INDI":
577
+			    $addfacts    = preg_split("/[, ;:]+/", $WT_TREE->getPreference('INDI_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY);
578
+			    $uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('INDI_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY);
579
+			    $quickfacts  = preg_split("/[, ;:]+/", $WT_TREE->getPreference('INDI_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY);
580
+			    break;
581
+		    case "FAM":
582
+			    $addfacts    = preg_split("/[, ;:]+/", $WT_TREE->getPreference('FAM_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY);
583
+			    $uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('FAM_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY);
584
+			    $quickfacts  = preg_split("/[, ;:]+/", $WT_TREE->getPreference('FAM_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY);
585
+			    break;
586
+		    case "SOUR":
587
+			    $addfacts    = preg_split("/[, ;:]+/", $WT_TREE->getPreference('SOUR_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY);
588
+			    $uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('SOUR_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY);
589
+			    $quickfacts  = preg_split("/[, ;:]+/", $WT_TREE->getPreference('SOUR_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY);
590
+			    break;
591
+		    case "NOTE":
592
+			    $addfacts    = preg_split("/[, ;:]+/", $WT_TREE->getPreference('NOTE_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY);
593
+			    $uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('NOTE_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY);
594
+			    $quickfacts  = preg_split("/[, ;:]+/", $WT_TREE->getPreference('NOTE_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY);
595
+			    break;
596
+		    case "REPO":
597
+			    $addfacts    = preg_split("/[, ;:]+/", $WT_TREE->getPreference('REPO_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY);
598
+			    $uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('REPO_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY);
599
+			    $quickfacts  = preg_split("/[, ;:]+/", $WT_TREE->getPreference('REPO_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY);
600
+			    break;
601
+		    default:
602
+			    return;
603 603
 		}
604 604
 		$addfacts            = array_merge(self::checkFactUnique($uniquefacts, $usedfacts, $type), $addfacts);
605 605
 		$quickfacts          = array_intersect($quickfacts, $addfacts);
Please login to merge, or discard this patch.
app/Functions/FunctionsEdit.php 1 patch
Switch Indentation   +302 added lines, -302 removed lines patch added patch discarded remove patch
@@ -559,19 +559,19 @@  discard block
 block discarded – undo
559 559
 		} else {
560 560
 			// Not all facts have help text.
561 561
 			switch ($fact) {
562
-			case 'NAME':
563
-				if ($upperlevel !== 'REPO' && $upperlevel !== 'UNKNOWN') {
564
-					echo FunctionsPrint::helpLink($fact);
565
-				}
566
-				break;
567
-			case 'DATE':
568
-			case 'PLAC':
569
-			case 'RESN':
570
-			case 'ROMN':
571
-			case 'SURN':
572
-			case '_HEB':
573
-				echo FunctionsPrint::helpLink($fact);
574
-				break;
562
+			    case 'NAME':
563
+				    if ($upperlevel !== 'REPO' && $upperlevel !== 'UNKNOWN') {
564
+					    echo FunctionsPrint::helpLink($fact);
565
+				    }
566
+				    break;
567
+			    case 'DATE':
568
+			    case 'PLAC':
569
+			    case 'RESN':
570
+			    case 'ROMN':
571
+			    case 'SURN':
572
+			    case '_HEB':
573
+				    echo FunctionsPrint::helpLink($fact);
574
+				    break;
575 575
 			}
576 576
 		}
577 577
 		// tag level
@@ -716,51 +716,51 @@  discard block
 block discarded – undo
716 716
 
717 717
 				// Extra markup for specific fact types
718 718
 				switch ($fact) {
719
-				case 'ALIA':
720
-				case 'ASSO':
721
-				case '_ASSO':
722
-					echo ' data-autocomplete-type="ASSO" data-autocomplete-extra="input.DATE"';
723
-					break;
724
-				case 'DATE':
725
-					echo ' onblur="valid_date(this);" onmouseout="valid_date(this);"';
726
-					break;
727
-				case 'GIVN':
728
-					echo ' autofocus data-autocomplete-type="GIVN"';
729
-					break;
730
-				case 'LATI':
731
-					echo ' onblur="valid_lati_long(this, \'N\', \'S\');" onmouseout="valid_lati_long(this, \'N\', \'S\');"';
732
-					break;
733
-				case 'LONG':
734
-					echo ' onblur="valid_lati_long(this, \'E\', \'W\');" onmouseout="valid_lati_long(this, \'E\', \'W\');"';
735
-					break;
736
-				case 'NOTE':
737
-					// Shared notes. Inline notes are handled elsewhere.
738
-					echo ' data-autocomplete-type="NOTE"';
739
-					break;
740
-				case 'OBJE':
741
-					echo ' data-autocomplete-type="OBJE"';
742
-					break;
743
-				case 'PAGE':
744
-					echo ' data-autocomplete-type="PAGE" data-autocomplete-extra="#' . $source_element_id . '"';
745
-					break;
746
-				case 'PLAC':
747
-					echo ' data-autocomplete-type="PLAC"';
748
-					break;
749
-				case 'REPO':
750
-					echo ' data-autocomplete-type="REPO"';
751
-					break;
752
-				case 'SOUR':
753
-					$source_element_id = $element_id;
754
-					echo ' data-autocomplete-type="SOUR"';
755
-					break;
756
-				case 'SURN':
757
-				case '_MARNM_SURN':
758
-					echo ' data-autocomplete-type="SURN"';
759
-					break;
760
-				case 'TIME':
761
-					echo ' pattern="([0-1][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?" dir="ltr" placeholder="' . /* I18N: Examples of valid time formats (hours:minutes:seconds) */
762
-						I18N::translate('hh:mm or hh:mm:ss') . '"';
763
-					break;
719
+				    case 'ALIA':
720
+				    case 'ASSO':
721
+				    case '_ASSO':
722
+					    echo ' data-autocomplete-type="ASSO" data-autocomplete-extra="input.DATE"';
723
+					    break;
724
+				    case 'DATE':
725
+					    echo ' onblur="valid_date(this);" onmouseout="valid_date(this);"';
726
+					    break;
727
+				    case 'GIVN':
728
+					    echo ' autofocus data-autocomplete-type="GIVN"';
729
+					    break;
730
+				    case 'LATI':
731
+					    echo ' onblur="valid_lati_long(this, \'N\', \'S\');" onmouseout="valid_lati_long(this, \'N\', \'S\');"';
732
+					    break;
733
+				    case 'LONG':
734
+					    echo ' onblur="valid_lati_long(this, \'E\', \'W\');" onmouseout="valid_lati_long(this, \'E\', \'W\');"';
735
+					    break;
736
+				    case 'NOTE':
737
+					    // Shared notes. Inline notes are handled elsewhere.
738
+					    echo ' data-autocomplete-type="NOTE"';
739
+					    break;
740
+				    case 'OBJE':
741
+					    echo ' data-autocomplete-type="OBJE"';
742
+					    break;
743
+				    case 'PAGE':
744
+					    echo ' data-autocomplete-type="PAGE" data-autocomplete-extra="#' . $source_element_id . '"';
745
+					    break;
746
+				    case 'PLAC':
747
+					    echo ' data-autocomplete-type="PLAC"';
748
+					    break;
749
+				    case 'REPO':
750
+					    echo ' data-autocomplete-type="REPO"';
751
+					    break;
752
+				    case 'SOUR':
753
+					    $source_element_id = $element_id;
754
+					    echo ' data-autocomplete-type="SOUR"';
755
+					    break;
756
+				    case 'SURN':
757
+				    case '_MARNM_SURN':
758
+					    echo ' data-autocomplete-type="SURN"';
759
+					    break;
760
+				    case 'TIME':
761
+					    echo ' pattern="([0-1][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?" dir="ltr" placeholder="' . /* I18N: Examples of valid time formats (hours:minutes:seconds) */
762
+						    I18N::translate('hh:mm or hh:mm:ss') . '"';
763
+					    break;
764 764
 				}
765 765
 				echo '>';
766 766
 			}
@@ -810,41 +810,41 @@  discard block
 block discarded – undo
810 810
 
811 811
 		// popup links
812 812
 		switch ($fact) {
813
-		case 'DATE':
814
-			echo self::printCalendarPopup($element_id);
815
-			break;
816
-		case 'FAMC':
817
-		case 'FAMS':
818
-			echo FunctionsPrint::printFindFamilyLink($element_id);
819
-			break;
820
-		case 'ALIA':
821
-		case 'ASSO':
822
-		case '_ASSO':
823
-			echo FunctionsPrint::printFindIndividualLink($element_id, $element_id . '_description');
824
-			break;
825
-		case 'FILE':
826
-			FunctionsPrint::printFindMediaLink($element_id, '0file');
827
-			break;
828
-		case 'SOUR':
829
-			echo FunctionsPrint::printFindSourceLink($element_id, $element_id . '_description'), ' ', self::printAddNewSourceLink($element_id);
830
-			//-- checkboxes to apply '1 SOUR' to BIRT/MARR/DEAT as '2 SOUR'
831
-			if ($level === 1) {
832
-				echo '<br>';
833
-				switch ($WT_TREE->getPreference('PREFER_LEVEL2_SOURCES')) {
834
-				case '2': // records
835
-				$level1_checked = 'checked';
836
-				$level2_checked = '';
837
-				break;
838
-				case '1': // facts
839
-				$level1_checked = '';
840
-				$level2_checked = 'checked';
841
-				break;
842
-				case '0': // none
843
-				default:
844
-				$level1_checked = '';
845
-				$level2_checked = '';
846
-				break;
847
-				}
813
+		    case 'DATE':
814
+			    echo self::printCalendarPopup($element_id);
815
+			    break;
816
+		    case 'FAMC':
817
+		    case 'FAMS':
818
+			    echo FunctionsPrint::printFindFamilyLink($element_id);
819
+			    break;
820
+		    case 'ALIA':
821
+		    case 'ASSO':
822
+		    case '_ASSO':
823
+			    echo FunctionsPrint::printFindIndividualLink($element_id, $element_id . '_description');
824
+			    break;
825
+		    case 'FILE':
826
+			    FunctionsPrint::printFindMediaLink($element_id, '0file');
827
+			    break;
828
+		    case 'SOUR':
829
+			    echo FunctionsPrint::printFindSourceLink($element_id, $element_id . '_description'), ' ', self::printAddNewSourceLink($element_id);
830
+			    //-- checkboxes to apply '1 SOUR' to BIRT/MARR/DEAT as '2 SOUR'
831
+			    if ($level === 1) {
832
+				    echo '<br>';
833
+				    switch ($WT_TREE->getPreference('PREFER_LEVEL2_SOURCES')) {
834
+				        case '2': // records
835
+				        $level1_checked = 'checked';
836
+				        $level2_checked = '';
837
+				        break;
838
+				        case '1': // facts
839
+				        $level1_checked = '';
840
+				        $level2_checked = 'checked';
841
+				        break;
842
+				        case '0': // none
843
+				        default:
844
+				        $level1_checked = '';
845
+				        $level2_checked = '';
846
+				        break;
847
+				    }
848 848
 					if (strpos($bdm, 'B') !== false) {
849 849
 						echo ' <label><input type="checkbox" name="SOUR_INDI" ', $level1_checked, ' value="1">', I18N::translate('Individual'), '</label>';
850 850
 						if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
@@ -874,26 +874,26 @@  discard block
 block discarded – undo
874 874
 					}
875 875
 				}
876 876
 				break;
877
-		case 'REPO':
878
-			echo FunctionsPrint::printFindRepositoryLink($element_id), ' ', self::printAddNewRepositoryLink($element_id);
879
-			break;
880
-		case 'NOTE':
881
-			// Shared Notes Icons ========================================
882
-			if ($islink) {
883
-				// Print regular Shared Note icons ---------------------------
884
-				echo ' ', FunctionsPrint::printFindNoteLink($element_id, $element_id . '_description'), ' ', self::printAddNewNoteLink($element_id);
885
-				if ($value) {
886
-					echo ' ', self::printEditNoteLink($value);
887
-				}
888
-			}
889
-			break;
890
-		case 'OBJE':
891
-			echo FunctionsPrint::printFindMediaLink($element_id, '1media');
892
-			if (!$value) {
893
-				echo ' ', self::printAddNewMediaLink($element_id);
894
-				$value = 'new';
895
-			}
896
-			break;
877
+		    case 'REPO':
878
+			    echo FunctionsPrint::printFindRepositoryLink($element_id), ' ', self::printAddNewRepositoryLink($element_id);
879
+			    break;
880
+		    case 'NOTE':
881
+			    // Shared Notes Icons ========================================
882
+			    if ($islink) {
883
+				    // Print regular Shared Note icons ---------------------------
884
+				    echo ' ', FunctionsPrint::printFindNoteLink($element_id, $element_id . '_description'), ' ', self::printAddNewNoteLink($element_id);
885
+				    if ($value) {
886
+					    echo ' ', self::printEditNoteLink($value);
887
+				    }
888
+			    }
889
+			    break;
890
+		    case 'OBJE':
891
+			    echo FunctionsPrint::printFindMediaLink($element_id, '1media');
892
+			    if (!$value) {
893
+				    echo ' ', self::printAddNewMediaLink($element_id);
894
+				    $value = 'new';
895
+			    }
896
+			    break;
897 897
 		}
898 898
 
899 899
 		echo '<div id="' . $element_id . '_description">';
@@ -913,38 +913,38 @@  discard block
 block discarded – undo
913 913
 
914 914
 		if ($value && $value !== 'new' && $islink) {
915 915
 			switch ($fact) {
916
-			case 'ALIA':
917
-			case 'ASSO':
918
-			case '_ASSO':
919
-				$tmp = Individual::getInstance($value, $WT_TREE);
920
-				if ($tmp) {
921
-					echo ' ', $tmp->getFullName();
922
-				}
923
-				break;
924
-			case 'SOUR':
925
-				$tmp = Source::getInstance($value, $WT_TREE);
926
-				if ($tmp) {
927
-					echo ' ', $tmp->getFullName();
928
-				}
929
-				break;
930
-			case 'NOTE':
931
-				$tmp = Note::getInstance($value, $WT_TREE);
932
-				if ($tmp) {
933
-					echo ' ', $tmp->getFullName();
934
-				}
935
-				break;
936
-			case 'OBJE':
937
-				$tmp = Media::getInstance($value, $WT_TREE);
938
-				if ($tmp) {
939
-					echo ' ', $tmp->getFullName();
940
-				}
941
-				break;
942
-			case 'REPO':
943
-				$tmp = Repository::getInstance($value, $WT_TREE);
944
-				if ($tmp) {
945
-					echo ' ', $tmp->getFullName();
946
-				}
947
-				break;
916
+			    case 'ALIA':
917
+			    case 'ASSO':
918
+			    case '_ASSO':
919
+				    $tmp = Individual::getInstance($value, $WT_TREE);
920
+				    if ($tmp) {
921
+					    echo ' ', $tmp->getFullName();
922
+				    }
923
+				    break;
924
+			    case 'SOUR':
925
+				    $tmp = Source::getInstance($value, $WT_TREE);
926
+				    if ($tmp) {
927
+					    echo ' ', $tmp->getFullName();
928
+				    }
929
+				    break;
930
+			    case 'NOTE':
931
+				    $tmp = Note::getInstance($value, $WT_TREE);
932
+				    if ($tmp) {
933
+					    echo ' ', $tmp->getFullName();
934
+				    }
935
+				    break;
936
+			    case 'OBJE':
937
+				    $tmp = Media::getInstance($value, $WT_TREE);
938
+				    if ($tmp) {
939
+					    echo ' ', $tmp->getFullName();
940
+				    }
941
+				    break;
942
+			    case 'REPO':
943
+				    $tmp = Repository::getInstance($value, $WT_TREE);
944
+				    if ($tmp) {
945
+					    echo ' ', $tmp->getFullName();
946
+				    }
947
+				    break;
948 948
 			}
949 949
 		}
950 950
 
@@ -969,29 +969,29 @@  discard block
 block discarded – undo
969 969
 
970 970
 		// Show more likely census details at the top of the list.
971 971
 		switch (WT_LOCALE) {
972
-		case 'cs':
973
-			$census_places = array(new CensusOfCzechRepublic);
974
-			break;
975
-		case 'en-AU':
976
-		case 'en-GB':
977
-			$census_places = array(new CensusOfEngland, new CensusOfWales, new CensusOfScotland);
978
-			break;
979
-		case 'en-US':
980
-			$census_places = array(new CensusOfUnitedStates);
981
-			break;
982
-		case 'fr':
983
-		case 'fr-CA':
984
-			$census_places = array(new CensusOfFrance);
985
-			break;
986
-		case 'da':
987
-			$census_places = array(new CensusOfDenmark);
988
-			break;
989
-		case 'de':
990
-			$census_places = array(new CensusOfDeutschland);
991
-			break;
992
-		default:
993
-			$census_places = array();
994
-			break;
972
+		    case 'cs':
973
+			    $census_places = array(new CensusOfCzechRepublic);
974
+			    break;
975
+		    case 'en-AU':
976
+		    case 'en-GB':
977
+			    $census_places = array(new CensusOfEngland, new CensusOfWales, new CensusOfScotland);
978
+			    break;
979
+		    case 'en-US':
980
+			    $census_places = array(new CensusOfUnitedStates);
981
+			    break;
982
+		    case 'fr':
983
+		    case 'fr-CA':
984
+			    $census_places = array(new CensusOfFrance);
985
+			    break;
986
+		    case 'da':
987
+			    $census_places = array(new CensusOfDenmark);
988
+			    break;
989
+		    case 'de':
990
+			    $census_places = array(new CensusOfDeutschland);
991
+			    break;
992
+		    default:
993
+			    $census_places = array();
994
+			    break;
995 995
 		}
996 996
 		foreach (Census::allCensusPlaces() as $census_place) {
997 997
 			if (!in_array($census_place, $census_places)) {
@@ -1053,97 +1053,97 @@  discard block
 block discarded – undo
1053 1053
 		global $WT_TREE;
1054 1054
 
1055 1055
 		switch ($tag) {
1056
-		case 'SOUR':
1057
-			echo '<a href="#" onclick="return expand_layer(\'newsource\');"><i id="newsource_img" class="icon-plus"></i> ', I18N::translate('Add a source citation'), '</a>';
1058
-			echo '<br>';
1059
-			echo '<div id="newsource" style="display: none;">';
1060
-			echo '<table class="facts_table">';
1061
-			// 2 SOUR
1062
-			self::addSimpleTag($level . ' SOUR @');
1063
-			// 3 PAGE
1064
-			self::addSimpleTag(($level + 1) . ' PAGE');
1065
-			// 3 DATA
1066
-			self::addSimpleTag(($level + 1) . ' DATA');
1067
-			// 4 TEXT
1068
-			self::addSimpleTag(($level + 2) . ' TEXT');
1069
-			if ($WT_TREE->getPreference('FULL_SOURCES')) {
1070
-				// 4 DATE
1071
-				self::addSimpleTag(($level + 2) . ' DATE', '', GedcomTag::getLabel('DATA:DATE'));
1072
-				// 3 QUAY
1073
-				self::addSimpleTag(($level + 1) . ' QUAY');
1074
-			}
1075
-			// 3 OBJE
1076
-			self::addSimpleTag(($level + 1) . ' OBJE');
1077
-			// 3 SHARED_NOTE
1078
-			self::addSimpleTag(($level + 1) . ' SHARED_NOTE');
1079
-			echo '</table></div>';
1080
-			break;
1081
-
1082
-		case 'ASSO':
1083
-		case 'ASSO2':
1084
-			//-- Add a new ASSOciate
1085
-			if ($tag === 'ASSO') {
1086
-				echo "<a href=\"#\" onclick=\"return expand_layer('newasso');\"><i id=\"newasso_img\" class=\"icon-plus\"></i> ", I18N::translate('Add an associate'), '</a>';
1087
-				echo '<br>';
1088
-				echo '<div id="newasso" style="display: none;">';
1089
-			} else {
1090
-				echo "<a href=\"#\" onclick=\"return expand_layer('newasso2');\"><i id=\"newasso2_img\" class=\"icon-plus\"></i> ", I18N::translate('Add an associate'), '</a>';
1091
-				echo '<br>';
1092
-				echo '<div id="newasso2" style="display: none;">';
1093
-			}
1094
-			echo '<table class="facts_table">';
1095
-			// 2 ASSO
1096
-			self::addSimpleTag($level . ' _ASSO @');
1097
-			// 3 RELA
1098
-			self::addSimpleTag(($level + 1) . ' RELA');
1099
-			// 3 NOTE
1100
-			self::addSimpleTag(($level + 1) . ' NOTE');
1101
-			// 3 SHARED_NOTE
1102
-			self::addSimpleTag(($level + 1) . ' SHARED_NOTE');
1103
-			echo '</table></div>';
1104
-			break;
1105
-
1106
-		case 'NOTE':
1107
-			//-- Retrieve existing note or add new note to fact
1108
-			echo "<a href=\"#\" onclick=\"return expand_layer('newnote');\"><i id=\"newnote_img\" class=\"icon-plus\"></i> ", I18N::translate('Add a note'), '</a>';
1109
-			echo '<br>';
1110
-			echo '<div id="newnote" style="display: none;">';
1111
-			echo '<table class="facts_table">';
1112
-			// 2 NOTE
1113
-			self::addSimpleTag($level . ' NOTE');
1114
-			echo '</table></div>';
1115
-			break;
1116
-
1117
-		case 'SHARED_NOTE':
1118
-			echo "<a href=\"#\" onclick=\"return expand_layer('newshared_note');\"><i id=\"newshared_note_img\" class=\"icon-plus\"></i> ", I18N::translate('Add a shared note'), '</a>';
1119
-			echo '<br>';
1120
-			echo '<div id="newshared_note" style="display: none;">';
1121
-			echo '<table class="facts_table">';
1122
-			// 2 SHARED NOTE
1123
-			self::addSimpleTag($level . ' SHARED_NOTE', $parent_tag);
1124
-			echo '</table></div>';
1125
-			break;
1126
-
1127
-		case 'OBJE':
1128
-			if ($WT_TREE->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($WT_TREE)) {
1129
-				echo "<a href=\"#\" onclick=\"return expand_layer('newobje');\"><i id=\"newobje_img\" class=\"icon-plus\"></i> ", I18N::translate('Add a media object'), '</a>';
1130
-				echo '<br>';
1131
-				echo '<div id="newobje" style="display: none;">';
1132
-				echo '<table class="facts_table">';
1133
-				self::addSimpleTag($level . ' OBJE');
1134
-				echo '</table></div>';
1135
-			}
1136
-			break;
1137
-
1138
-		case 'RESN':
1139
-			echo "<a href=\"#\" onclick=\"return expand_layer('newresn');\"><i id=\"newresn_img\" class=\"icon-plus\"></i> ", I18N::translate('Add a restriction'), '</a>';
1140
-			echo '<br>';
1141
-			echo '<div id="newresn" style="display: none;">';
1142
-			echo '<table class="facts_table">';
1143
-			// 2 RESN
1144
-			self::addSimpleTag($level . ' RESN');
1145
-			echo '</table></div>';
1146
-			break;
1056
+		    case 'SOUR':
1057
+			    echo '<a href="#" onclick="return expand_layer(\'newsource\');"><i id="newsource_img" class="icon-plus"></i> ', I18N::translate('Add a source citation'), '</a>';
1058
+			    echo '<br>';
1059
+			    echo '<div id="newsource" style="display: none;">';
1060
+			    echo '<table class="facts_table">';
1061
+			    // 2 SOUR
1062
+			    self::addSimpleTag($level . ' SOUR @');
1063
+			    // 3 PAGE
1064
+			    self::addSimpleTag(($level + 1) . ' PAGE');
1065
+			    // 3 DATA
1066
+			    self::addSimpleTag(($level + 1) . ' DATA');
1067
+			    // 4 TEXT
1068
+			    self::addSimpleTag(($level + 2) . ' TEXT');
1069
+			    if ($WT_TREE->getPreference('FULL_SOURCES')) {
1070
+				    // 4 DATE
1071
+				    self::addSimpleTag(($level + 2) . ' DATE', '', GedcomTag::getLabel('DATA:DATE'));
1072
+				    // 3 QUAY
1073
+				    self::addSimpleTag(($level + 1) . ' QUAY');
1074
+			    }
1075
+			    // 3 OBJE
1076
+			    self::addSimpleTag(($level + 1) . ' OBJE');
1077
+			    // 3 SHARED_NOTE
1078
+			    self::addSimpleTag(($level + 1) . ' SHARED_NOTE');
1079
+			    echo '</table></div>';
1080
+			    break;
1081
+
1082
+		    case 'ASSO':
1083
+		    case 'ASSO2':
1084
+			    //-- Add a new ASSOciate
1085
+			    if ($tag === 'ASSO') {
1086
+				    echo "<a href=\"#\" onclick=\"return expand_layer('newasso');\"><i id=\"newasso_img\" class=\"icon-plus\"></i> ", I18N::translate('Add an associate'), '</a>';
1087
+				    echo '<br>';
1088
+				    echo '<div id="newasso" style="display: none;">';
1089
+			    } else {
1090
+				    echo "<a href=\"#\" onclick=\"return expand_layer('newasso2');\"><i id=\"newasso2_img\" class=\"icon-plus\"></i> ", I18N::translate('Add an associate'), '</a>';
1091
+				    echo '<br>';
1092
+				    echo '<div id="newasso2" style="display: none;">';
1093
+			    }
1094
+			    echo '<table class="facts_table">';
1095
+			    // 2 ASSO
1096
+			    self::addSimpleTag($level . ' _ASSO @');
1097
+			    // 3 RELA
1098
+			    self::addSimpleTag(($level + 1) . ' RELA');
1099
+			    // 3 NOTE
1100
+			    self::addSimpleTag(($level + 1) . ' NOTE');
1101
+			    // 3 SHARED_NOTE
1102
+			    self::addSimpleTag(($level + 1) . ' SHARED_NOTE');
1103
+			    echo '</table></div>';
1104
+			    break;
1105
+
1106
+		    case 'NOTE':
1107
+			    //-- Retrieve existing note or add new note to fact
1108
+			    echo "<a href=\"#\" onclick=\"return expand_layer('newnote');\"><i id=\"newnote_img\" class=\"icon-plus\"></i> ", I18N::translate('Add a note'), '</a>';
1109
+			    echo '<br>';
1110
+			    echo '<div id="newnote" style="display: none;">';
1111
+			    echo '<table class="facts_table">';
1112
+			    // 2 NOTE
1113
+			    self::addSimpleTag($level . ' NOTE');
1114
+			    echo '</table></div>';
1115
+			    break;
1116
+
1117
+		    case 'SHARED_NOTE':
1118
+			    echo "<a href=\"#\" onclick=\"return expand_layer('newshared_note');\"><i id=\"newshared_note_img\" class=\"icon-plus\"></i> ", I18N::translate('Add a shared note'), '</a>';
1119
+			    echo '<br>';
1120
+			    echo '<div id="newshared_note" style="display: none;">';
1121
+			    echo '<table class="facts_table">';
1122
+			    // 2 SHARED NOTE
1123
+			    self::addSimpleTag($level . ' SHARED_NOTE', $parent_tag);
1124
+			    echo '</table></div>';
1125
+			    break;
1126
+
1127
+		    case 'OBJE':
1128
+			    if ($WT_TREE->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($WT_TREE)) {
1129
+				    echo "<a href=\"#\" onclick=\"return expand_layer('newobje');\"><i id=\"newobje_img\" class=\"icon-plus\"></i> ", I18N::translate('Add a media object'), '</a>';
1130
+				    echo '<br>';
1131
+				    echo '<div id="newobje" style="display: none;">';
1132
+				    echo '<table class="facts_table">';
1133
+				    self::addSimpleTag($level . ' OBJE');
1134
+				    echo '</table></div>';
1135
+			    }
1136
+			    break;
1137
+
1138
+		    case 'RESN':
1139
+			    echo "<a href=\"#\" onclick=\"return expand_layer('newresn');\"><i id=\"newresn_img\" class=\"icon-plus\"></i> ", I18N::translate('Add a restriction'), '</a>';
1140
+			    echo '<br>';
1141
+			    echo '<div id="newresn" style="display: none;">';
1142
+			    echo '<table class="facts_table">';
1143
+			    // 2 RESN
1144
+			    self::addSimpleTag($level . ' RESN');
1145
+			    echo '</table></div>';
1146
+			    break;
1147 1147
 		}
1148 1148
 	}
1149 1149
 
@@ -1219,12 +1219,12 @@  discard block
 block discarded – undo
1219 1219
 	 */
1220 1220
 	public static function addNewSex() {
1221 1221
 		switch (Filter::post('SEX', '[MF]', 'U')) {
1222
-		case 'M':
1223
-			return "\n1 SEX M";
1224
-		case 'F':
1225
-			return "\n1 SEX F";
1226
-		default:
1227
-			return "\n1 SEX U";
1222
+		    case 'M':
1223
+			    return "\n1 SEX M";
1224
+		    case 'F':
1225
+			    return "\n1 SEX F";
1226
+		    default:
1227
+			    return "\n1 SEX U";
1228 1228
 		}
1229 1229
 	}
1230 1230
 
@@ -1750,43 +1750,43 @@  discard block
 block discarded – undo
1750 1750
 				}
1751 1751
 				// Add level 3/4 tags as appropriate
1752 1752
 				switch ($key) {
1753
-				case 'PLAC':
1754
-					if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
1755
-						foreach ($match[1] as $tag) {
1756
-							self::addSimpleTag('3 ' . $tag, '', GedcomTag::getLabel($level1tag . ':PLAC:' . $tag));
1757
-						}
1758
-					}
1759
-					self::addSimpleTag('3 MAP');
1760
-					self::addSimpleTag('4 LATI');
1761
-					self::addSimpleTag('4 LONG');
1762
-					break;
1763
-				case 'FILE':
1764
-					self::addSimpleTag('3 FORM');
1765
-					break;
1766
-				case 'EVEN':
1767
-					self::addSimpleTag('3 DATE');
1768
-					self::addSimpleTag('3 PLAC');
1769
-					break;
1770
-				case 'STAT':
1771
-					if (GedcomCodeTemp::isTagLDS($level1tag)) {
1772
-						self::addSimpleTag('3 DATE', '', GedcomTag::getLabel('STAT:DATE'));
1773
-					}
1774
-					break;
1775
-				case 'DATE':
1776
-					// TIME is NOT a valid 5.5.1 tag
1777
-					if (in_array($level1tag, Config::dateAndTime())) {
1778
-						self::addSimpleTag('3 TIME');
1779
-					}
1780
-					break;
1781
-				case 'HUSB':
1782
-				case 'WIFE':
1783
-					self::addSimpleTag('3 AGE');
1784
-					break;
1785
-				case 'FAMC':
1786
-					if ($level1tag === 'ADOP') {
1787
-						self::addSimpleTag('3 ADOP BOTH');
1788
-					}
1789
-					break;
1753
+				    case 'PLAC':
1754
+					    if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
1755
+						    foreach ($match[1] as $tag) {
1756
+							    self::addSimpleTag('3 ' . $tag, '', GedcomTag::getLabel($level1tag . ':PLAC:' . $tag));
1757
+						    }
1758
+					    }
1759
+					    self::addSimpleTag('3 MAP');
1760
+					    self::addSimpleTag('4 LATI');
1761
+					    self::addSimpleTag('4 LONG');
1762
+					    break;
1763
+				    case 'FILE':
1764
+					    self::addSimpleTag('3 FORM');
1765
+					    break;
1766
+				    case 'EVEN':
1767
+					    self::addSimpleTag('3 DATE');
1768
+					    self::addSimpleTag('3 PLAC');
1769
+					    break;
1770
+				    case 'STAT':
1771
+					    if (GedcomCodeTemp::isTagLDS($level1tag)) {
1772
+						    self::addSimpleTag('3 DATE', '', GedcomTag::getLabel('STAT:DATE'));
1773
+					    }
1774
+					    break;
1775
+				    case 'DATE':
1776
+					    // TIME is NOT a valid 5.5.1 tag
1777
+					    if (in_array($level1tag, Config::dateAndTime())) {
1778
+						    self::addSimpleTag('3 TIME');
1779
+					    }
1780
+					    break;
1781
+				    case 'HUSB':
1782
+				    case 'WIFE':
1783
+					    self::addSimpleTag('3 AGE');
1784
+					    break;
1785
+				    case 'FAMC':
1786
+					    if ($level1tag === 'ADOP') {
1787
+						    self::addSimpleTag('3 ADOP BOTH');
1788
+					    }
1789
+					    break;
1790 1790
 				}
1791 1791
 			} elseif ($key === 'DATE' && $add_date) {
1792 1792
 				self::addSimpleTag('2 DATE', $level1tag, GedcomTag::getLabel($level1tag . ':DATE'));
Please login to merge, or discard this patch.
app/Tree.php 1 patch
Switch Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -466,25 +466,25 @@
 block discarded – undo
466 466
 		$tree->setPreference('WEBMASTER_USER_ID', Auth::id());
467 467
 		$tree->setPreference('LANGUAGE', WT_LOCALE); // Default to the current admin’s language
468 468
 		switch (WT_LOCALE) {
469
-		case 'es':
470
-			$tree->setPreference('SURNAME_TRADITION', 'spanish');
471
-			break;
472
-		case 'is':
473
-			$tree->setPreference('SURNAME_TRADITION', 'icelandic');
474
-			break;
475
-		case 'lt':
476
-			$tree->setPreference('SURNAME_TRADITION', 'lithuanian');
477
-			break;
478
-		case 'pl':
479
-			$tree->setPreference('SURNAME_TRADITION', 'polish');
480
-			break;
481
-		case 'pt':
482
-		case 'pt-BR':
483
-			$tree->setPreference('SURNAME_TRADITION', 'portuguese');
484
-			break;
485
-		default:
486
-			$tree->setPreference('SURNAME_TRADITION', 'paternal');
487
-			break;
469
+		    case 'es':
470
+			    $tree->setPreference('SURNAME_TRADITION', 'spanish');
471
+			    break;
472
+		    case 'is':
473
+			    $tree->setPreference('SURNAME_TRADITION', 'icelandic');
474
+			    break;
475
+		    case 'lt':
476
+			    $tree->setPreference('SURNAME_TRADITION', 'lithuanian');
477
+			    break;
478
+		    case 'pl':
479
+			    $tree->setPreference('SURNAME_TRADITION', 'polish');
480
+			    break;
481
+		    case 'pt':
482
+		    case 'pt-BR':
483
+			    $tree->setPreference('SURNAME_TRADITION', 'portuguese');
484
+			    break;
485
+		    default:
486
+			    $tree->setPreference('SURNAME_TRADITION', 'paternal');
487
+			    break;
488 488
 		}
489 489
 
490 490
 		// Genealogy data
Please login to merge, or discard this patch.
app/SurnameTradition/SpanishSurnameTradition.php 1 patch
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -62,16 +62,16 @@
 block discarded – undo
62 62
 	public function newParentNames($child_name, $parent_sex) {
63 63
 		if (preg_match(self::REGEX_SURNS, $child_name, $match)) {
64 64
 			switch ($parent_sex) {
65
-			case 'M':
66
-				return array(
67
-					'NAME' => '/' . $match['SURN1'] . '/ //',
68
-					'SURN' => $match['SURN1'],
69
-				);
70
-			case 'F':
71
-				return array(
72
-					'NAME' => '/' . $match['SURN2'] . '/ //',
73
-					'SURN' => $match['SURN2'],
74
-				);
65
+			    case 'M':
66
+				    return array(
67
+					    'NAME' => '/' . $match['SURN1'] . '/ //',
68
+					    'SURN' => $match['SURN1'],
69
+				    );
70
+			    case 'F':
71
+				    return array(
72
+					    'NAME' => '/' . $match['SURN2'] . '/ //',
73
+					    'SURN' => $match['SURN2'],
74
+				    );
75 75
 			}
76 76
 		}
77 77
 
Please login to merge, or discard this patch.