|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* webtrees: online genealogy |
|
4
|
|
|
* Copyright (C) 2019 webtrees development team |
|
5
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
6
|
|
|
* it under the terms of the GNU General Public License as published by |
|
7
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
8
|
|
|
* (at your option) any later version. |
|
9
|
|
|
* This program is distributed in the hope that it will be useful, |
|
10
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12
|
|
|
* GNU General Public License for more details. |
|
13
|
|
|
* You should have received a copy of the GNU General Public License |
|
14
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15
|
|
|
*/ |
|
16
|
|
|
namespace Fisharebest\Webtrees\Functions; |
|
17
|
|
|
|
|
18
|
|
|
use Fisharebest\Webtrees\Auth; |
|
19
|
|
|
use Fisharebest\Webtrees\Date; |
|
20
|
|
|
use Fisharebest\Webtrees\Fact; |
|
21
|
|
|
use Fisharebest\Webtrees\Family; |
|
22
|
|
|
use Fisharebest\Webtrees\Filter; |
|
23
|
|
|
use Fisharebest\Webtrees\GedcomCode\GedcomCodeAdop; |
|
24
|
|
|
use Fisharebest\Webtrees\GedcomCode\GedcomCodeQuay; |
|
25
|
|
|
use Fisharebest\Webtrees\GedcomCode\GedcomCodeRela; |
|
26
|
|
|
use Fisharebest\Webtrees\GedcomRecord; |
|
27
|
|
|
use Fisharebest\Webtrees\GedcomTag; |
|
28
|
|
|
use Fisharebest\Webtrees\I18N; |
|
29
|
|
|
use Fisharebest\Webtrees\Individual; |
|
30
|
|
|
use Fisharebest\Webtrees\Media; |
|
31
|
|
|
use Fisharebest\Webtrees\Module; |
|
32
|
|
|
use Fisharebest\Webtrees\Module\CensusAssistantModule; |
|
33
|
|
|
use Fisharebest\Webtrees\Note; |
|
34
|
|
|
use Fisharebest\Webtrees\Repository; |
|
35
|
|
|
use Fisharebest\Webtrees\Source; |
|
36
|
|
|
use Fisharebest\Webtrees\Theme; |
|
37
|
|
|
use Fisharebest\Webtrees\User; |
|
38
|
|
|
use Rhumsaa\Uuid\Uuid; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Class FunctionsPrintFacts - common functions |
|
42
|
|
|
*/ |
|
43
|
|
|
class FunctionsPrintFacts |
|
44
|
|
|
{ |
|
45
|
|
|
/** |
|
46
|
|
|
* Print a fact record, for the individual/family/source/repository/etc. pages. |
|
47
|
|
|
* |
|
48
|
|
|
* Although a Fact has a parent object, we also need to know |
|
49
|
|
|
* the GedcomRecord for which we are printing it. For example, |
|
50
|
|
|
* we can show the death of X on the page of Y, or the marriage |
|
51
|
|
|
* of X+Y on the page of Z. We need to know both records to |
|
52
|
|
|
* calculate ages, relationships, etc. |
|
53
|
|
|
* |
|
54
|
|
|
* @param Fact $fact |
|
55
|
|
|
* @param GedcomRecord $record |
|
56
|
|
|
*/ |
|
57
|
|
|
public static function printFact(Fact $fact, GedcomRecord $record) |
|
58
|
|
|
{ |
|
59
|
|
|
static $n_chil = 0, $n_gchi = 0; |
|
60
|
|
|
|
|
61
|
|
|
$parent = $fact->getParent(); |
|
62
|
|
|
|
|
63
|
|
|
// Some facts don't get printed here ... |
|
64
|
|
|
switch ($fact->getTag()) { |
|
65
|
|
|
case 'NOTE': |
|
66
|
|
|
self::printMainNotes($fact, 1); |
|
67
|
|
|
|
|
68
|
|
|
return; |
|
69
|
|
|
case 'SOUR': |
|
70
|
|
|
self::printMainSources($fact, 1); |
|
71
|
|
|
|
|
72
|
|
|
return; |
|
73
|
|
|
case 'OBJE': |
|
74
|
|
|
self::printMainMedia($fact, 1); |
|
75
|
|
|
|
|
76
|
|
|
return; |
|
77
|
|
|
case 'FAMC': |
|
78
|
|
|
case 'FAMS': |
|
79
|
|
|
case 'CHIL': |
|
80
|
|
|
case 'HUSB': |
|
81
|
|
|
case 'WIFE': |
|
82
|
|
|
// These are internal links, not facts |
|
83
|
|
|
return; |
|
84
|
|
|
case '_WT_OBJE_SORT': |
|
85
|
|
|
// These links are used internally to record the sort order. |
|
86
|
|
|
return; |
|
87
|
|
|
default: |
|
88
|
|
|
// Hide unrecognized/custom tags? |
|
89
|
|
|
if ($fact->getParent()->getTree()->getPreference('HIDE_GEDCOM_ERRORS') === '0' && !GedcomTag::isTag($fact->getTag())) { |
|
90
|
|
|
return; |
|
91
|
|
|
} |
|
92
|
|
|
break; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
// Who is this fact about? Need it to translate fact label correctly |
|
96
|
|
|
if ($parent instanceof Family && $record instanceof Individual) { |
|
97
|
|
|
// Family event |
|
98
|
|
|
$label_person = $fact->getParent()->getSpouse($record); |
|
|
|
|
|
|
99
|
|
|
} else { |
|
100
|
|
|
// Individual event |
|
101
|
|
|
$label_person = $parent; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
// New or deleted facts need different styling |
|
105
|
|
|
$styleadd = ''; |
|
106
|
|
|
if ($fact->isPendingAddition()) { |
|
107
|
|
|
$styleadd = 'new'; |
|
108
|
|
|
} |
|
109
|
|
|
if ($fact->isPendingDeletion()) { |
|
110
|
|
|
$styleadd = 'old'; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
// Event of close relative |
|
114
|
|
|
if (preg_match('/^_[A-Z_]{3,5}_[A-Z0-9]{4}$/', $fact->getTag())) { |
|
115
|
|
|
$styleadd = trim($styleadd . ' rela'); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
// Event of close associates |
|
119
|
|
|
if ($fact->getFactId() == 'asso') { |
|
120
|
|
|
$styleadd = trim($styleadd . ' rela'); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
// historical facts |
|
124
|
|
|
if ($fact->getFactId() == 'histo') { |
|
125
|
|
|
$styleadd = trim($styleadd . ' histo'); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
// Does this fact have a type? |
|
129
|
|
|
if (preg_match('/\n2 TYPE (.+)/', $fact->getGedcom(), $match)) { |
|
130
|
|
|
$type = $match[1]; |
|
131
|
|
|
} else { |
|
132
|
|
|
$type = ''; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
switch ($fact->getTag()) { |
|
136
|
|
|
case 'EVEN': |
|
137
|
|
|
case 'FACT': |
|
138
|
|
|
if (GedcomTag::isTag($type)) { |
|
139
|
|
|
// Some users (just Meliza?) use "1 EVEN/2 TYPE BIRT". Translate the TYPE. |
|
140
|
|
|
$label = GedcomTag::getLabel($type, $label_person); |
|
141
|
|
|
$type = ''; // Do not print this again |
|
142
|
|
|
} elseif ($type) { |
|
143
|
|
|
// We don't have a translation for $type - but a custom translation might exist. |
|
144
|
|
|
$label = I18N::translate(Filter::escapeHtml($type)); |
|
145
|
|
|
$type = ''; // Do not print this again |
|
146
|
|
|
} else { |
|
147
|
|
|
// An unspecified fact/event |
|
148
|
|
|
$label = $fact->getLabel(); |
|
149
|
|
|
} |
|
150
|
|
|
break; |
|
151
|
|
|
case 'MARR': |
|
152
|
|
|
// This is a hack for a proprietory extension. Is it still used/needed? |
|
153
|
|
|
$utype = strtoupper($type); |
|
154
|
|
|
if ($utype == 'CIVIL' || $utype == 'PARTNERS' || $utype == 'RELIGIOUS') { |
|
155
|
|
|
$label = GedcomTag::getLabel('MARR_' . $utype, $label_person); |
|
156
|
|
|
$type = ''; // Do not print this again |
|
157
|
|
|
} else { |
|
158
|
|
|
$label = $fact->getLabel(); |
|
159
|
|
|
} |
|
160
|
|
|
break; |
|
161
|
|
|
default: |
|
162
|
|
|
// Normal fact/event |
|
163
|
|
|
$label = $fact->getLabel(); |
|
164
|
|
|
break; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
echo '<tr class="', $styleadd, '">'; |
|
168
|
|
|
echo '<td class="descriptionbox width20">'; |
|
169
|
|
|
|
|
170
|
|
|
if ($fact->getParent()->getTree()->getPreference('SHOW_FACT_ICONS')) { |
|
171
|
|
|
echo Theme::theme()->icon($fact), ' '; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
if ($fact->getFactId() != 'histo' && $fact->canEdit()) { |
|
175
|
|
|
?> |
|
176
|
|
|
<a |
|
177
|
|
|
href="#" |
|
178
|
|
|
title="<?php echo I18N::translate('Edit'); ?>" |
|
179
|
|
|
onclick="return edit_record('<?php echo $parent->getXref(); ?>', '<?php echo $fact->getFactId(); ?>');" |
|
180
|
|
|
><?php echo $label; ?></a> |
|
181
|
|
|
<div class="editfacts"> |
|
182
|
|
|
<div class="editlink"> |
|
183
|
|
|
<a |
|
184
|
|
|
href="#" |
|
185
|
|
|
title="<?php echo I18N::translate('Edit'); ?>" |
|
186
|
|
|
class="editicon" |
|
187
|
|
|
onclick="return edit_record('<?php echo $parent->getXref(); ?>', '<?php echo $fact->getFactId(); ?>');" |
|
188
|
|
|
><span class="link_text"><?php echo I18N::translate('Edit'); ?></span></a> |
|
189
|
|
|
</div> |
|
190
|
|
|
<div class="copylink"> |
|
191
|
|
|
<a |
|
192
|
|
|
href="#" |
|
193
|
|
|
title="<?php echo I18N::translate('Copy'); ?>" |
|
194
|
|
|
class="copyicon" |
|
195
|
|
|
onclick="return copy_fact('<?php echo $parent->getXref(); ?>', '<?php echo $fact->getFactId(); ?>');" |
|
196
|
|
|
><span class="link_text"><?php echo I18N::translate('Copy'); ?></span></a> |
|
197
|
|
|
</div> |
|
198
|
|
|
<div class="deletelink"> |
|
199
|
|
|
<a |
|
200
|
|
|
href="#" |
|
201
|
|
|
title="<?php echo I18N::translate('Delete'); ?>" |
|
202
|
|
|
class="deleteicon" |
|
203
|
|
|
onclick="return delete_fact('<?php echo I18N::translate('Are you sure you want to delete this fact?'); ?>', '<?php echo $parent->getXref(); ?>', '<?php echo $fact->getFactId(); ?>');" |
|
204
|
|
|
><span class="link_text"><?php echo I18N::translate('Delete'); ?></span></a> |
|
205
|
|
|
</div> |
|
206
|
|
|
</div> |
|
207
|
|
|
<?php |
|
208
|
|
|
} else { |
|
209
|
|
|
echo $label; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
switch ($fact->getTag()) { |
|
213
|
|
|
case '_BIRT_CHIL': |
|
214
|
|
|
echo '<br>', /* I18N: Abbreviation for "number %s" */ |
|
215
|
|
|
I18N::translate('#%s', ++$n_chil); |
|
216
|
|
|
break; |
|
217
|
|
|
case '_BIRT_GCHI': |
|
218
|
|
|
case '_BIRT_GCH1': |
|
219
|
|
|
case '_BIRT_GCH2': |
|
220
|
|
|
echo '<br>', I18N::translate('#%s', ++$n_gchi); |
|
221
|
|
|
break; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
echo '</td><td class="optionbox ', $styleadd, ' wrap">'; |
|
225
|
|
|
|
|
226
|
|
|
// Event from another record? |
|
227
|
|
|
if ($parent !== $record) { |
|
228
|
|
|
if ($parent instanceof Family) { |
|
229
|
|
|
foreach ($parent->getSpouses() as $spouse) { |
|
230
|
|
|
if ($record !== $spouse) { |
|
231
|
|
|
echo '<a href="', $spouse->getHtmlUrl(), '">', $spouse->getFullName(), '</a> — '; |
|
232
|
|
|
} |
|
233
|
|
|
} |
|
234
|
|
|
echo '<a href="', $parent->getHtmlUrl(), '">', I18N::translate('View this family'), '</a><br>'; |
|
235
|
|
|
} elseif ($parent instanceof Individual) { |
|
236
|
|
|
echo '<a href="', $parent->getHtmlUrl(), '">', $parent->getFullName(), '</a><br>'; |
|
237
|
|
|
} |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
// Print the value of this fact/event |
|
241
|
|
|
switch ($fact->getTag()) { |
|
242
|
|
|
case 'ADDR': |
|
243
|
|
|
echo Filter::escapeUrl($fact->getValue()); |
|
244
|
|
|
break; |
|
245
|
|
|
case 'AFN': |
|
246
|
|
|
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>'; |
|
247
|
|
|
break; |
|
248
|
|
|
case 'ASSO': |
|
249
|
|
|
// we handle this later, in format_asso_rela_record() |
|
250
|
|
|
break; |
|
251
|
|
|
case 'EMAIL': |
|
252
|
|
|
case 'EMAI': |
|
253
|
|
|
case '_EMAIL': |
|
254
|
|
|
echo '<div class="field"><a href="mailto:', Filter::escapeHtml($fact->getValue()), '">', Filter::escapeHtml($fact->getValue()), '</a></div>'; |
|
255
|
|
|
break; |
|
256
|
|
|
case 'FILE': |
|
257
|
|
|
if (Auth::isEditor($fact->getParent()->getTree())) { |
|
258
|
|
|
echo '<div class="field">', Filter::escapeHtml($fact->getValue()), '</div>'; |
|
259
|
|
|
} |
|
260
|
|
|
break; |
|
261
|
|
|
case 'RESN': |
|
262
|
|
|
echo '<div class="field">'; |
|
263
|
|
|
switch ($fact->getValue()) { |
|
264
|
|
|
case 'none': |
|
265
|
|
|
// Note: "1 RESN none" is not valid gedcom. |
|
266
|
|
|
// However, webtrees privacy rules will interpret it as "show an otherwise private record to public". |
|
267
|
|
|
echo '<i class="icon-resn-none"></i> ', I18N::translate('Show to visitors'); |
|
268
|
|
|
break; |
|
269
|
|
|
case 'privacy': |
|
270
|
|
|
echo '<i class="icon-class-none"></i> ', I18N::translate('Show to members'); |
|
271
|
|
|
break; |
|
272
|
|
|
case 'confidential': |
|
273
|
|
|
echo '<i class="icon-confidential-none"></i> ', I18N::translate('Show to managers'); |
|
274
|
|
|
break; |
|
275
|
|
|
case 'locked': |
|
276
|
|
|
echo '<i class="icon-locked-none"></i> ', I18N::translate('Only managers can edit'); |
|
277
|
|
|
break; |
|
278
|
|
|
default: |
|
279
|
|
|
echo Filter::escapeHtml($fact->getValue()); |
|
280
|
|
|
break; |
|
281
|
|
|
} |
|
282
|
|
|
echo '</div>'; |
|
283
|
|
|
break; |
|
284
|
|
|
case 'PUBL': // Publication details might contain URLs. |
|
285
|
|
|
echo '<div class="field">', Filter::expandUrls($fact->getValue()), '</div>'; |
|
286
|
|
|
break; |
|
287
|
|
|
case 'REPO': |
|
288
|
|
|
if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $fact->getValue(), $match)) { |
|
|
|
|
|
|
289
|
|
|
self::printRepositoryRecord($match[1]); |
|
290
|
|
|
} else { |
|
291
|
|
|
echo '<div class="error">', Filter::escapeHtml($fact->getValue()), '</div>'; |
|
292
|
|
|
} |
|
293
|
|
|
break; |
|
294
|
|
|
case 'URL': |
|
295
|
|
|
case '_URL': |
|
296
|
|
|
case 'WWW': |
|
297
|
|
|
echo '<div class="field"><a href="', Filter::escapeHtml($fact->getValue()), '">', Filter::escapeHtml($fact->getValue()), '</a></div>'; |
|
298
|
|
|
break; |
|
299
|
|
|
case 'TEXT': // 0 SOUR / 1 TEXT |
|
300
|
|
|
echo '<div class="field">', nl2br(Filter::escapeHtml($fact->getValue()), false), '</div>'; |
|
301
|
|
|
break; |
|
302
|
|
|
default: |
|
303
|
|
|
// Display the value for all other facts/events |
|
304
|
|
|
switch ($fact->getValue()) { |
|
305
|
|
|
case '': |
|
306
|
|
|
// Nothing to display |
|
307
|
|
|
break; |
|
308
|
|
|
case 'N': |
|
309
|
|
|
// Not valid GEDCOM |
|
310
|
|
|
echo '<div class="field">', I18N::translate('No'), '</div>'; |
|
311
|
|
|
break; |
|
312
|
|
|
case 'Y': |
|
313
|
|
|
// Do not display "Yes". |
|
314
|
|
|
break; |
|
315
|
|
|
default: |
|
316
|
|
|
if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $fact->getValue(), $match)) { |
|
317
|
|
|
$target = GedcomRecord::getInstance($match[1], $fact->getParent()->getTree()); |
|
318
|
|
|
if ($target) { |
|
319
|
|
|
echo '<div><a href="', $target->getHtmlUrl(), '">', $target->getFullName(), '</a></div>'; |
|
320
|
|
|
} else { |
|
321
|
|
|
echo '<div class="error">', Filter::escapeHtml($fact->getValue()), '</div>'; |
|
322
|
|
|
} |
|
323
|
|
|
} else { |
|
324
|
|
|
echo '<div class="field"><span dir="auto">', Filter::escapeHtml($fact->getValue()), '</span></div>'; |
|
325
|
|
|
} |
|
326
|
|
|
break; |
|
327
|
|
|
} |
|
328
|
|
|
break; |
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
|
// Print the type of this fact/event |
|
332
|
|
|
if ($type) { |
|
333
|
|
|
$utype = strtoupper($type); |
|
334
|
|
|
// Events of close relatives, e.g. _MARR_CHIL |
|
335
|
|
|
if (substr($fact->getTag(), 0, 6) == '_MARR_' && ($utype == 'CIVIL' || $utype == 'PARTNERS' || $utype == 'RELIGIOUS')) { |
|
336
|
|
|
// Translate MARR/TYPE using the code that supports MARR_CIVIL, etc. tags |
|
337
|
|
|
$type = GedcomTag::getLabel('MARR_' . $utype); |
|
338
|
|
|
} else { |
|
339
|
|
|
// Allow (custom) translations for other types |
|
340
|
|
|
$type = I18N::translate($type); |
|
341
|
|
|
} |
|
342
|
|
|
echo GedcomTag::getLabelValue('TYPE', Filter::escapeHtml($type)); |
|
343
|
|
|
} |
|
344
|
|
|
|
|
345
|
|
|
// Print the date of this fact/event |
|
346
|
|
|
echo FunctionsPrint::formatFactDate($fact, $record, true, true); |
|
347
|
|
|
|
|
348
|
|
|
// Print the place of this fact/event |
|
349
|
|
|
echo '<div class="place">', FunctionsPrint::formatFactPlace($fact, true, true, true), '</div>'; |
|
350
|
|
|
// A blank line between the primary attributes (value, date, place) and the secondary ones |
|
351
|
|
|
echo '<br>'; |
|
352
|
|
|
|
|
353
|
|
|
$addr = $fact->getAttribute('ADDR'); |
|
354
|
|
|
if ($addr) { |
|
355
|
|
|
echo GedcomTag::getLabelValue('ADDR', $addr); |
|
356
|
|
|
} |
|
357
|
|
|
|
|
358
|
|
|
// Print the associates of this fact/event |
|
359
|
|
|
if ($fact->getFactId() !== 'asso') { |
|
360
|
|
|
echo self::formatAssociateRelationship($fact); |
|
361
|
|
|
} |
|
362
|
|
|
|
|
363
|
|
|
// Print any other "2 XXXX" attributes, in the order in which they appear. |
|
364
|
|
|
preg_match_all('/\n2 (' . WT_REGEX_TAG . ') (.+)/', $fact->getGedcom(), $matches, PREG_SET_ORDER); |
|
365
|
|
|
foreach ($matches as $match) { |
|
366
|
|
|
switch ($match[1]) { |
|
367
|
|
|
case 'DATE': |
|
368
|
|
|
case 'TIME': |
|
369
|
|
|
case 'AGE': |
|
370
|
|
|
case 'PLAC': |
|
371
|
|
|
case 'ADDR': |
|
372
|
|
|
case 'ALIA': |
|
373
|
|
|
case 'ASSO': |
|
374
|
|
|
case '_ASSO': |
|
375
|
|
|
case 'DESC': |
|
376
|
|
|
case 'RELA': |
|
377
|
|
|
case 'STAT': |
|
378
|
|
|
case 'TEMP': |
|
379
|
|
|
case 'TYPE': |
|
380
|
|
|
case 'FAMS': |
|
381
|
|
|
case 'CONT': |
|
382
|
|
|
// These were already shown at the beginning |
|
383
|
|
|
break; |
|
384
|
|
|
case 'NOTE': |
|
385
|
|
|
case 'OBJE': |
|
386
|
|
|
case 'SOUR': |
|
387
|
|
|
// These will be shown at the end |
|
388
|
|
|
break; |
|
389
|
|
|
case '_UID': |
|
390
|
|
|
case 'RIN': |
|
391
|
|
|
// These don't belong at level 2, so do not display them. |
|
392
|
|
|
// They are only shown when editing. |
|
393
|
|
|
break; |
|
394
|
|
|
case 'EVEN': // 0 SOUR / 1 DATA / 2 EVEN / 3 DATE / 3 PLAC |
|
395
|
|
|
$events = array(); |
|
396
|
|
|
foreach (preg_split('/ *, */', $match[2]) as $event) { |
|
397
|
|
|
$events[] = GedcomTag::getLabel($event); |
|
398
|
|
|
} |
|
399
|
|
|
if (count($events) == 1) { |
|
400
|
|
|
echo GedcomTag::getLabelValue('EVEN', $event); |
|
|
|
|
|
|
401
|
|
|
} else { |
|
402
|
|
|
echo GedcomTag::getLabelValue('EVEN', implode(I18N::$list_separator, $events)); |
|
403
|
|
|
} |
|
404
|
|
|
if (preg_match('/\n3 DATE (.+)/', $fact->getGedcom(), $date_match)) { |
|
405
|
|
|
$date = new Date($date_match[1]); |
|
406
|
|
|
echo GedcomTag::getLabelValue('DATE', $date->display()); |
|
407
|
|
|
} |
|
408
|
|
|
if (preg_match('/\n3 PLAC (.+)/', $fact->getGedcom(), $plac_match)) { |
|
409
|
|
|
echo GedcomTag::getLabelValue('PLAC', $plac_match[1]); |
|
410
|
|
|
} |
|
411
|
|
|
break; |
|
412
|
|
|
case 'FAMC': // 0 INDI / 1 ADOP / 2 FAMC / 3 ADOP |
|
413
|
|
|
$family = Family::getInstance(str_replace('@', '', $match[2]), $fact->getParent()->getTree()); |
|
414
|
|
|
if ($family) { |
|
415
|
|
|
echo GedcomTag::getLabelValue('FAM', '<a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . '</a>'); |
|
416
|
|
|
if (preg_match('/\n3 ADOP (HUSB|WIFE|BOTH)/', $fact->getGedcom(), $match)) { |
|
417
|
|
|
echo GedcomTag::getLabelValue('ADOP', GedcomCodeAdop::getValue($match[1], $label_person)); |
|
418
|
|
|
} |
|
419
|
|
|
} else { |
|
420
|
|
|
echo GedcomTag::getLabelValue('FAM', '<span class="error">' . $match[2] . '</span>'); |
|
421
|
|
|
} |
|
422
|
|
|
break; |
|
423
|
|
|
case '_WT_USER': |
|
424
|
|
|
$user = User::findByIdentifier($match[2]); // may not exist |
|
425
|
|
|
if ($user) { |
|
426
|
|
|
echo GedcomTag::getLabelValue('_WT_USER', $user->getRealNameHtml()); |
|
427
|
|
|
} else { |
|
428
|
|
|
echo GedcomTag::getLabelValue('_WT_USER', Filter::escapeHtml($match[2])); |
|
429
|
|
|
} |
|
430
|
|
|
break; |
|
431
|
|
|
case 'RESN': |
|
432
|
|
|
switch ($match[2]) { |
|
433
|
|
|
case 'none': |
|
434
|
|
|
// Note: "2 RESN none" is not valid gedcom. |
|
435
|
|
|
// However, webtrees privacy rules will interpret it as "show an otherwise private fact to public". |
|
436
|
|
|
echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-none"></i> ' . I18N::translate('Show to visitors')); |
|
437
|
|
|
break; |
|
438
|
|
|
case 'privacy': |
|
439
|
|
|
echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-privacy"></i> ' . I18N::translate('Show to members')); |
|
440
|
|
|
break; |
|
441
|
|
|
case 'confidential': |
|
442
|
|
|
echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-confidential"></i> ' . I18N::translate('Show to managers')); |
|
443
|
|
|
break; |
|
444
|
|
|
case 'locked': |
|
445
|
|
|
echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-locked"></i> ' . I18N::translate('Only managers can edit')); |
|
446
|
|
|
break; |
|
447
|
|
|
default: |
|
448
|
|
|
echo GedcomTag::getLabelValue('RESN', Filter::escapeHtml($match[2])); |
|
449
|
|
|
break; |
|
450
|
|
|
} |
|
451
|
|
|
break; |
|
452
|
|
|
case 'CALN': |
|
453
|
|
|
echo GedcomTag::getLabelValue('CALN', Filter::expandUrls($match[2])); |
|
454
|
|
|
break; |
|
455
|
|
|
case 'FORM': // 0 OBJE / 1 FILE / 2 FORM / 3 TYPE |
|
456
|
|
|
echo GedcomTag::getLabelValue('FORM', $match[2]); |
|
457
|
|
|
if (preg_match('/\n3 TYPE (.+)/', $fact->getGedcom(), $type_match)) { |
|
458
|
|
|
echo GedcomTag::getLabelValue('TYPE', GedcomTag::getFileFormTypeValue($type_match[1])); |
|
459
|
|
|
} |
|
460
|
|
|
break; |
|
461
|
|
|
case 'URL': |
|
462
|
|
|
case '_URL': |
|
463
|
|
|
case 'WWW': |
|
464
|
|
|
$link = '<a href="' . Filter::escapeHtml($match[2]) . '">' . Filter::escapeHtml($match[2]) . '</a>'; |
|
465
|
|
|
echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], $link); |
|
466
|
|
|
break; |
|
467
|
|
|
default: |
|
468
|
|
|
if ($fact->getParent()->getTree()->getPreference('HIDE_GEDCOM_ERRORS') === '1' || GedcomTag::isTag($match[1])) { |
|
469
|
|
|
if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $match[2], $xmatch)) { |
|
470
|
|
|
// Links |
|
471
|
|
|
$linked_record = GedcomRecord::getInstance($xmatch[1], $fact->getParent()->getTree()); |
|
472
|
|
|
if ($linked_record) { |
|
473
|
|
|
$link = '<a href="' . $linked_record->getHtmlUrl() . '">' . $linked_record->getFullName() . '</a>'; |
|
474
|
|
|
echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], $link); |
|
475
|
|
|
} else { |
|
476
|
|
|
echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], Filter::escapeHtml($match[2])); |
|
477
|
|
|
} |
|
478
|
|
|
} else { |
|
479
|
|
|
// Non links |
|
480
|
|
|
echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], Filter::escapeHtml($match[2])); |
|
481
|
|
|
} |
|
482
|
|
|
} |
|
483
|
|
|
break; |
|
484
|
|
|
} |
|
485
|
|
|
} |
|
486
|
|
|
echo self::printFactSources($fact->getGedcom(), 2); |
|
487
|
|
|
echo FunctionsPrint::printFactNotes($fact->getGedcom(), 2); |
|
488
|
|
|
self::printMediaLinks($fact->getGedcom(), 2); |
|
489
|
|
|
echo '</td></tr>'; |
|
490
|
|
|
} |
|
491
|
|
|
|
|
492
|
|
|
/** |
|
493
|
|
|
* Print the associations from the associated individuals in $event to the individuals in $record |
|
494
|
|
|
* |
|
495
|
|
|
* @param Fact $event |
|
496
|
|
|
* |
|
497
|
|
|
* @return string |
|
498
|
|
|
*/ |
|
499
|
|
|
private static function formatAssociateRelationship(Fact $event) |
|
500
|
|
|
{ |
|
501
|
|
|
$parent = $event->getParent(); |
|
502
|
|
|
// To whom is this record an assocate? |
|
503
|
|
|
if ($parent instanceof Individual) { |
|
504
|
|
|
// On an individual page, we just show links to the person |
|
505
|
|
|
$associates = array($parent); |
|
506
|
|
|
} elseif ($parent instanceof Family) { |
|
507
|
|
|
// On a family page, we show links to both spouses |
|
508
|
|
|
$associates = $parent->getSpouses(); |
|
509
|
|
|
} else { |
|
510
|
|
|
// On other pages, it does not make sense to show associates |
|
511
|
|
|
return ''; |
|
512
|
|
|
} |
|
513
|
|
|
|
|
514
|
|
|
preg_match_all('/^1 ASSO @(' . WT_REGEX_XREF . ')@((\n[2-9].*)*)/', $event->getGedcom(), $amatches1, PREG_SET_ORDER); |
|
515
|
|
|
preg_match_all('/\n2 _?ASSO @(' . WT_REGEX_XREF . ')@((\n[3-9].*)*)/', $event->getGedcom(), $amatches2, PREG_SET_ORDER); |
|
516
|
|
|
|
|
517
|
|
|
$html = ''; |
|
518
|
|
|
// For each ASSO record |
|
519
|
|
|
foreach (array_merge($amatches1, $amatches2) as $amatch) { |
|
520
|
|
|
$person = Individual::getInstance($amatch[1], $event->getParent()->getTree()); |
|
521
|
|
|
if ($person && $person->canShowName()) { |
|
522
|
|
|
// Is there a "RELA" tag |
|
523
|
|
|
if (preg_match('/\n[23] RELA (.+)/', $amatch[2], $rmatch)) { |
|
524
|
|
|
// Use the supplied relationship as a label |
|
525
|
|
|
$label = GedcomCodeRela::getValue($rmatch[1], $person); |
|
526
|
|
|
} else { |
|
527
|
|
|
// Use a default label |
|
528
|
|
|
$label = GedcomTag::getLabel('ASSO', $person); |
|
529
|
|
|
} |
|
530
|
|
|
|
|
531
|
|
|
$values = array('<a href="' . $person->getHtmlUrl() . '">' . $person->getFullName() . '</a>'); |
|
532
|
|
|
foreach ($associates as $associate) { |
|
533
|
|
|
$relationship_name = Functions::getAssociateRelationshipName($associate, $person); |
|
|
|
|
|
|
534
|
|
|
if (!$relationship_name) { |
|
535
|
|
|
$relationship_name = GedcomTag::getLabel('RELA'); |
|
536
|
|
|
} |
|
537
|
|
|
|
|
538
|
|
|
if ($parent instanceof Family) { |
|
539
|
|
|
// For family ASSO records (e.g. MARR), identify the spouse with a sex icon |
|
540
|
|
|
$relationship_name .= $associate->getSexImage(); |
|
541
|
|
|
} |
|
542
|
|
|
|
|
543
|
|
|
$values[] = '<a href="relationship.php?pid1=' . $associate->getXref() . '&pid2=' . $person->getXref() . '&ged=' . $associate->getTree()->getNameUrl() . '" rel="nofollow">' . $relationship_name . '</a>'; |
|
544
|
|
|
} |
|
545
|
|
|
$value = implode(' — ', $values); |
|
546
|
|
|
|
|
547
|
|
|
// Use same markup as GedcomTag::getLabelValue() |
|
548
|
|
|
$asso = I18N::translate('<span class="label">%1$s:</span> <span class="field" dir="auto">%2$s</span>', $label, $value); |
|
549
|
|
|
} elseif (!$person && Auth::isEditor($event->getParent()->getTree())) { |
|
550
|
|
|
$asso = GedcomTag::getLabelValue('ASSO', '<span class="error">' . $amatch[1] . '</span>'); |
|
551
|
|
|
} else { |
|
552
|
|
|
$asso = ''; |
|
553
|
|
|
} |
|
554
|
|
|
$html .= '<div class="fact_ASSO">' . $asso . '</div>'; |
|
555
|
|
|
} |
|
556
|
|
|
|
|
557
|
|
|
return $html; |
|
558
|
|
|
} |
|
559
|
|
|
|
|
560
|
|
|
/** |
|
561
|
|
|
* print a repository record |
|
562
|
|
|
* |
|
563
|
|
|
* find and print repository information attached to a source |
|
564
|
|
|
* |
|
565
|
|
|
* @param string $xref the Gedcom Xref ID of the repository to print |
|
566
|
|
|
*/ |
|
567
|
|
|
public static function printRepositoryRecord($xref) |
|
568
|
|
|
{ |
|
569
|
|
|
global $WT_TREE; |
|
570
|
|
|
|
|
571
|
|
|
$repository = Repository::getInstance($xref, $WT_TREE); |
|
572
|
|
|
if ($repository && $repository->canShow()) { |
|
573
|
|
|
echo '<a class="field" href="', $repository->getHtmlUrl(), '">', $repository->getFullName(), '</a><br>'; |
|
574
|
|
|
echo '<br>'; |
|
575
|
|
|
echo FunctionsPrint::printFactNotes($repository->getGedcom(), 1); |
|
576
|
|
|
} |
|
577
|
|
|
} |
|
578
|
|
|
|
|
579
|
|
|
/** |
|
580
|
|
|
* print a source linked to a fact (2 SOUR) |
|
581
|
|
|
* |
|
582
|
|
|
* this function is called by the FunctionsPrintFacts::print_fact function and other functions to |
|
583
|
|
|
* print any source information attached to the fact |
|
584
|
|
|
* |
|
585
|
|
|
* @param string $factrec The fact record to look for sources in |
|
586
|
|
|
* @param int $level The level to look for sources at |
|
587
|
|
|
* |
|
588
|
|
|
* @return string HTML text |
|
589
|
|
|
*/ |
|
590
|
|
|
public static function printFactSources($factrec, $level) |
|
591
|
|
|
{ |
|
592
|
|
|
global $WT_TREE; |
|
593
|
|
|
|
|
594
|
|
|
$data = ''; |
|
595
|
|
|
$nlevel = $level + 1; |
|
596
|
|
|
|
|
597
|
|
|
// Systems not using source records |
|
598
|
|
|
// The old style is not supported when entering or editing sources, but may be found in imported trees. |
|
599
|
|
|
// Also, the old style sources allow histo.* files to use tree independent source citations, which |
|
600
|
|
|
// will display nicely when markdown is used. |
|
601
|
|
|
$ct = preg_match_all('/' . $level . ' SOUR (.*)((?:\n\d CONT.*)*)/', $factrec, $match, PREG_SET_ORDER); |
|
602
|
|
|
for ($j = 0; $j < $ct; $j++) { |
|
603
|
|
|
if (strpos($match[$j][1], '@') === false) { |
|
604
|
|
|
$source = Filter::escapeHtml($match[$j][1] . preg_replace('/\n\d CONT ?/', "\n", $match[$j][2])); |
|
605
|
|
|
$data .= '<div class="fact_SOUR"><span class="label">' . I18N::translate('Source') . ':</span> <span class="field" dir="auto">' . Filter::formatText($source, $WT_TREE) . '</span></div>'; |
|
606
|
|
|
} |
|
607
|
|
|
} |
|
608
|
|
|
// Find source for each fact |
|
609
|
|
|
$ct = preg_match_all("/$level SOUR @(.*)@/", $factrec, $match, PREG_SET_ORDER); |
|
610
|
|
|
$spos2 = 0; |
|
611
|
|
|
for ($j = 0; $j < $ct; $j++) { |
|
612
|
|
|
$sid = $match[$j][1]; |
|
613
|
|
|
$source = Source::getInstance($sid, $WT_TREE); |
|
614
|
|
|
if ($source) { |
|
615
|
|
|
if ($source->canShow()) { |
|
616
|
|
|
$spos1 = strpos($factrec, "$level SOUR @" . $sid . "@", $spos2); |
|
617
|
|
|
$spos2 = strpos($factrec, "\n$level", $spos1); |
|
618
|
|
|
if (!$spos2) { |
|
619
|
|
|
$spos2 = strlen($factrec); |
|
620
|
|
|
} |
|
621
|
|
|
$srec = substr($factrec, $spos1, $spos2 - $spos1); |
|
622
|
|
|
$lt = preg_match_all("/$nlevel \w+/", $srec, $matches); |
|
623
|
|
|
$data .= '<div class="fact_SOUR">'; |
|
624
|
|
|
$elementID = Uuid::uuid4(); |
|
625
|
|
|
if ($WT_TREE->getPreference('EXPAND_SOURCES')) { |
|
626
|
|
|
$plusminus = 'icon-minus'; |
|
627
|
|
|
} else { |
|
628
|
|
|
$plusminus = 'icon-plus'; |
|
629
|
|
|
} |
|
630
|
|
|
if ($lt > 0) { |
|
631
|
|
|
$data .= '<a href="#" onclick="return expand_layer(\'' . $elementID . '\');"><i id="' . $elementID . '_img" class="' . $plusminus . '"></i></a> '; |
|
632
|
|
|
} |
|
633
|
|
|
$data .= GedcomTag::getLabelValue('SOUR', '<a href="' . $source->getHtmlUrl() . '">' . $source->getFullName() . '</a>', null, 'span'); |
|
634
|
|
|
$data .= '</div>'; |
|
635
|
|
|
|
|
636
|
|
|
$data .= "<div id=\"$elementID\""; |
|
637
|
|
|
if ($WT_TREE->getPreference('EXPAND_SOURCES')) { |
|
638
|
|
|
$data .= ' style="display:block"'; |
|
639
|
|
|
} |
|
640
|
|
|
$data .= ' class="source_citations">'; |
|
641
|
|
|
// PUBL |
|
642
|
|
|
$publ = $source->getFirstFact('PUBL'); |
|
643
|
|
|
if ($publ) { |
|
644
|
|
|
$data .= GedcomTag::getLabelValue('PUBL', $publ->getValue()); |
|
645
|
|
|
} |
|
646
|
|
|
$data .= self::printSourceStructure(self::getSourceStructure($srec)); |
|
647
|
|
|
$data .= '<div class="indent">'; |
|
648
|
|
|
ob_start(); |
|
649
|
|
|
self::printMediaLinks($srec, $nlevel); |
|
650
|
|
|
$data .= ob_get_clean(); |
|
651
|
|
|
$data .= FunctionsPrint::printFactNotes($srec, $nlevel, false); |
|
652
|
|
|
$data .= '</div>'; |
|
653
|
|
|
$data .= '</div>'; |
|
654
|
|
|
} else { |
|
655
|
|
|
// Here we could show that we do actually have sources for this data, |
|
656
|
|
|
// but not the details. For example “Sources: ”. |
|
657
|
|
|
// But not by default, based on user feedback. |
|
658
|
|
|
// https://webtrees.net/index.php/en/forum/3-help-for-beta-and-svn-versions/27002-source-media-privacy-issue |
|
659
|
|
|
} |
|
660
|
|
|
} else { |
|
661
|
|
|
$data .= GedcomTag::getLabelValue('SOUR', '<span class="error">' . $sid . '</span>'); |
|
662
|
|
|
} |
|
663
|
|
|
} |
|
664
|
|
|
|
|
665
|
|
|
return $data; |
|
666
|
|
|
} |
|
667
|
|
|
|
|
668
|
|
|
/** |
|
669
|
|
|
* Print the links to media objects |
|
670
|
|
|
* |
|
671
|
|
|
* @param string $factrec |
|
672
|
|
|
* @param int $level |
|
673
|
|
|
*/ |
|
674
|
|
|
public static function printMediaLinks($factrec, $level) |
|
675
|
|
|
{ |
|
676
|
|
|
global $WT_TREE; |
|
677
|
|
|
|
|
678
|
|
|
$nlevel = $level + 1; |
|
679
|
|
|
if (preg_match_all("/$level OBJE @(.*)@/", $factrec, $omatch, PREG_SET_ORDER) == 0) { |
|
|
|
|
|
|
680
|
|
|
return; |
|
681
|
|
|
} |
|
682
|
|
|
$objectNum = 0; |
|
683
|
|
|
while ($objectNum < count($omatch)) { |
|
684
|
|
|
$media_id = $omatch[$objectNum][1]; |
|
685
|
|
|
$media = Media::getInstance($media_id, $WT_TREE); |
|
686
|
|
|
if ($media) { |
|
687
|
|
|
if ($media->canShow()) { |
|
688
|
|
|
if ($objectNum > 0) { |
|
689
|
|
|
echo '<br class="media-separator" style="clear:both;">'; |
|
690
|
|
|
} |
|
691
|
|
|
echo '<div class="media-display"><div class="media-display-image">'; |
|
692
|
|
|
echo $media->displayImage(); |
|
|
|
|
|
|
693
|
|
|
echo '</div>'; |
|
694
|
|
|
echo '<div class="media-display-title">'; |
|
695
|
|
|
echo '<a href="', $media->getHtmlUrl(), '">', $media->getFullName(), '</a>'; |
|
696
|
|
|
// NOTE: echo the notes of the media |
|
697
|
|
|
echo '<p>'; |
|
698
|
|
|
echo FunctionsPrint::printFactNotes($media->getGedcom(), 1); |
|
699
|
|
|
$ttype = preg_match("/" . ($nlevel + 1) . " TYPE (.*)/", $media->getGedcom(), $match); |
|
700
|
|
|
if ($ttype > 0) { |
|
701
|
|
|
$mediaType = GedcomTag::getFileFormTypeValue($match[1]); |
|
702
|
|
|
echo '<p class="label">', I18N::translate('Type'), ': </span> <span class="field">', $mediaType, '</p>'; |
|
703
|
|
|
} |
|
704
|
|
|
echo '</p>'; |
|
705
|
|
|
//-- print spouse name for marriage events |
|
706
|
|
|
$ct = preg_match("/WT_SPOUSE: (.*)/", $factrec, $match); |
|
707
|
|
|
if ($ct > 0) { |
|
708
|
|
|
$spouse = Individual::getInstance($match[1], $media->getTree()); |
|
709
|
|
|
if ($spouse) { |
|
710
|
|
|
echo '<a href="', $spouse->getHtmlUrl(), '">'; |
|
711
|
|
|
echo $spouse->getFullName(); |
|
712
|
|
|
echo '</a>'; |
|
713
|
|
|
} |
|
714
|
|
|
$ct = preg_match("/WT_FAMILY_ID: (.*)/", $factrec, $match); |
|
715
|
|
|
if ($ct > 0) { |
|
716
|
|
|
$famid = trim($match[1]); |
|
717
|
|
|
$family = Family::getInstance($famid, $spouse->getTree()); |
|
718
|
|
|
if ($family) { |
|
719
|
|
|
if ($spouse) { |
|
720
|
|
|
echo " - "; |
|
721
|
|
|
} |
|
722
|
|
|
echo '<a href="', $family->getHtmlUrl(), '">', I18N::translate('View this family'), '</a>'; |
|
723
|
|
|
} |
|
724
|
|
|
} |
|
725
|
|
|
} |
|
726
|
|
|
echo FunctionsPrint::printFactNotes($media->getGedcom(), $nlevel); |
|
727
|
|
|
echo self::printFactSources($media->getGedcom(), $nlevel); |
|
728
|
|
|
echo '</div>'; //close div "media-display-title" |
|
729
|
|
|
echo '</div>'; //close div "media-display" |
|
730
|
|
|
} |
|
731
|
|
|
} elseif ($WT_TREE->getPreference('HIDE_GEDCOM_ERRORS') === '1') { |
|
732
|
|
|
echo '<p class="ui-state-error">', $media_id, '</p>'; |
|
733
|
|
|
} |
|
734
|
|
|
$objectNum++; |
|
735
|
|
|
} |
|
736
|
|
|
} |
|
737
|
|
|
|
|
738
|
|
|
/** |
|
739
|
|
|
* Print a row for the sources tab on the individual page. |
|
740
|
|
|
* |
|
741
|
|
|
* @param Fact $fact |
|
742
|
|
|
* @param int $level |
|
743
|
|
|
*/ |
|
744
|
|
|
public static function printMainSources(Fact $fact, $level) |
|
745
|
|
|
{ |
|
746
|
|
|
$factrec = $fact->getGedcom(); |
|
747
|
|
|
$fact_id = $fact->getFactId(); |
|
748
|
|
|
$parent = $fact->getParent(); |
|
749
|
|
|
$pid = $parent->getXref(); |
|
750
|
|
|
|
|
751
|
|
|
$nlevel = $level + 1; |
|
752
|
|
|
if ($fact->isPendingAddition()) { |
|
753
|
|
|
$styleadd = 'new'; |
|
754
|
|
|
$can_edit = $level == 1 && $fact->canEdit(); |
|
755
|
|
|
} elseif ($fact->isPendingDeletion()) { |
|
756
|
|
|
$styleadd = 'old'; |
|
757
|
|
|
$can_edit = false; |
|
758
|
|
|
} else { |
|
759
|
|
|
$styleadd = ''; |
|
760
|
|
|
$can_edit = $level == 1 && $fact->canEdit(); |
|
761
|
|
|
} |
|
762
|
|
|
|
|
763
|
|
|
// -- find source for each fact |
|
764
|
|
|
$ct = preg_match_all("/($level SOUR (.+))/", $factrec, $match, PREG_SET_ORDER); |
|
765
|
|
|
$spos2 = 0; |
|
766
|
|
|
for ($j = 0; $j < $ct; $j++) { |
|
767
|
|
|
$sid = trim($match[$j][2], '@'); |
|
768
|
|
|
$spos1 = strpos($factrec, $match[$j][1], $spos2); |
|
769
|
|
|
$spos2 = strpos($factrec, "\n$level", $spos1); |
|
770
|
|
|
if (!$spos2) { |
|
771
|
|
|
$spos2 = strlen($factrec); |
|
772
|
|
|
} |
|
773
|
|
|
$srec = substr($factrec, $spos1, $spos2 - $spos1); |
|
774
|
|
|
$source = Source::getInstance($sid, $fact->getParent()->getTree()); |
|
775
|
|
|
// Allow access to "1 SOUR @non_existent_source@", so it can be corrected/deleted |
|
776
|
|
|
if (!$source || $source->canShow()) { |
|
777
|
|
|
if ($level > 1) { |
|
778
|
|
|
echo '<tr class="row_sour2">'; |
|
779
|
|
|
} else { |
|
780
|
|
|
echo '<tr>'; |
|
781
|
|
|
} |
|
782
|
|
|
echo '<td class="descriptionbox'; |
|
783
|
|
|
if ($level > 1) { |
|
784
|
|
|
echo ' rela'; |
|
785
|
|
|
} |
|
786
|
|
|
echo ' ', $styleadd, ' width20">'; |
|
787
|
|
|
$factlines = explode("\n", $factrec); // 1 BIRT Y\n2 SOUR ... |
|
788
|
|
|
$factwords = explode(" ", $factlines[0]); // 1 BIRT Y |
|
789
|
|
|
$factname = $factwords[1]; // BIRT |
|
790
|
|
|
if ($factname == 'EVEN' || $factname == 'FACT') { |
|
791
|
|
|
// Add ' EVEN' to provide sensible output for an event with an empty TYPE record |
|
792
|
|
|
$ct = preg_match("/2 TYPE (.*)/", $factrec, $ematch); |
|
793
|
|
|
if ($ct > 0) { |
|
794
|
|
|
$factname = trim($ematch[1]); |
|
795
|
|
|
echo $factname; |
|
796
|
|
|
} else { |
|
797
|
|
|
echo GedcomTag::getLabel($factname, $parent); |
|
798
|
|
|
} |
|
799
|
|
|
} elseif ($can_edit) { |
|
800
|
|
|
echo "<a onclick=\"return edit_record('$pid', '$fact_id');\" href=\"#\" title=\"", I18N::translate('Edit'), '">'; |
|
801
|
|
|
if ($fact->getParent()->getTree()->getPreference('SHOW_FACT_ICONS')) { |
|
802
|
|
|
if ($level == 1) { |
|
803
|
|
|
echo '<i class="icon-source"></i> '; |
|
804
|
|
|
} |
|
805
|
|
|
} |
|
806
|
|
|
echo GedcomTag::getLabel($factname, $parent), '</a>'; |
|
807
|
|
|
echo '<div class="editfacts">'; |
|
808
|
|
|
if (preg_match('/^@.+@$/', $match[$j][2])) { |
|
809
|
|
|
// Inline sources can't be edited. Attempting to save one will convert it |
|
810
|
|
|
// into a link, and delete it. |
|
811
|
|
|
// e.g. "1 SOUR my source" becomes "1 SOUR @my source@" which does not exist. |
|
812
|
|
|
echo "<div class=\"editlink\"><a class=\"editicon\" onclick=\"return edit_record('$pid', '$fact_id');\" href=\"#\" title=\"" . I18N::translate('Edit') . "\"><span class=\"link_text\">" . I18N::translate('Edit') . "</span></a></div>"; |
|
813
|
|
|
echo '<div class="copylink"><a class="copyicon" href="#" onclick="return copy_fact(\'', $pid, '\', \'', $fact_id, '\');" title="' . I18N::translate('Copy') . '"><span class="link_text">' . I18N::translate('Copy') . '</span></a></div>'; |
|
814
|
|
|
} |
|
815
|
|
|
echo "<div class=\"deletelink\"><a class=\"deleteicon\" onclick=\"return delete_fact('" . I18N::translate('Are you sure you want to delete this fact?') . "', '$pid', '$fact_id');\" href=\"#\" title=\"" . I18N::translate('Delete') . "\"><span class=\"link_text\">" . I18N::translate('Delete') . "</span></a></div>"; |
|
816
|
|
|
echo '</div>'; |
|
817
|
|
|
} else { |
|
818
|
|
|
echo GedcomTag::getLabel($factname, $parent); |
|
819
|
|
|
} |
|
820
|
|
|
echo '</td>'; |
|
821
|
|
|
echo '<td class="optionbox ', $styleadd, ' wrap">'; |
|
822
|
|
|
if ($source) { |
|
823
|
|
|
echo '<a href="', $source->getHtmlUrl(), '">', $source->getFullName(), '</a>'; |
|
824
|
|
|
// PUBL |
|
825
|
|
|
$publ = $source->getFirstFact('PUBL'); |
|
826
|
|
|
if ($publ) { |
|
827
|
|
|
echo GedcomTag::getLabelValue('PUBL', $publ->getValue()); |
|
828
|
|
|
} |
|
829
|
|
|
// 2 RESN tags. Note, there can be more than one, such as "privacy" and "locked" |
|
830
|
|
|
if (preg_match_all("/\n2 RESN (.+)/", $factrec, $rmatches)) { |
|
831
|
|
|
foreach ($rmatches[1] as $rmatch) { |
|
832
|
|
|
echo '<br><span class="label">', GedcomTag::getLabel('RESN'), ':</span> <span class="field">'; |
|
833
|
|
|
switch ($rmatch) { |
|
834
|
|
|
case 'none': |
|
835
|
|
|
// Note: "2 RESN none" is not valid gedcom, and the GUI will not let you add it. |
|
836
|
|
|
// However, webtrees privacy rules will interpret it as "show an otherwise private fact to public". |
|
837
|
|
|
echo '<i class="icon-resn-none"></i> ', I18N::translate('Show to visitors'); |
|
838
|
|
|
break; |
|
839
|
|
|
case 'privacy': |
|
840
|
|
|
echo '<i class="icon-resn-privacy"></i> ', I18N::translate('Show to members'); |
|
841
|
|
|
break; |
|
842
|
|
|
case 'confidential': |
|
843
|
|
|
echo '<i class="icon-resn-confidential"></i> ', I18N::translate('Show to managers'); |
|
844
|
|
|
break; |
|
845
|
|
|
case 'locked': |
|
846
|
|
|
echo '<i class="icon-resn-locked"></i> ', I18N::translate('Only managers can edit'); |
|
847
|
|
|
break; |
|
848
|
|
|
default: |
|
849
|
|
|
echo $rmatch; |
|
850
|
|
|
break; |
|
851
|
|
|
} |
|
852
|
|
|
echo '</span>'; |
|
853
|
|
|
} |
|
854
|
|
|
} |
|
855
|
|
|
$cs = preg_match("/$nlevel EVEN (.*)/", $srec, $cmatch); |
|
856
|
|
|
if ($cs > 0) { |
|
857
|
|
|
echo '<br><span class="label">', GedcomTag::getLabel('EVEN'), ' </span><span class="field">', $cmatch[1], '</span>'; |
|
858
|
|
|
$cs = preg_match("/" . ($nlevel + 1) . " ROLE (.*)/", $srec, $cmatch); |
|
859
|
|
|
if ($cs > 0) { |
|
860
|
|
|
echo '<br> <span class="label">', GedcomTag::getLabel('ROLE'), ' </span><span class="field">', $cmatch[1], '</span>'; |
|
861
|
|
|
} |
|
862
|
|
|
} |
|
863
|
|
|
echo self::printSourceStructure(self::getSourceStructure($srec)); |
|
864
|
|
|
echo '<div class="indent">'; |
|
865
|
|
|
self::printMediaLinks($srec, $nlevel); |
|
866
|
|
|
if ($nlevel == 2) { |
|
867
|
|
|
self::printMediaLinks($source->getGedcom(), 1); |
|
868
|
|
|
} |
|
869
|
|
|
echo FunctionsPrint::printFactNotes($srec, $nlevel); |
|
870
|
|
|
if ($nlevel == 2) { |
|
871
|
|
|
echo FunctionsPrint::printFactNotes($source->getGedcom(), 1); |
|
872
|
|
|
} |
|
873
|
|
|
echo '</div>'; |
|
874
|
|
|
} else { |
|
875
|
|
|
echo $sid; |
|
876
|
|
|
} |
|
877
|
|
|
echo '</td></tr>'; |
|
878
|
|
|
} |
|
879
|
|
|
} |
|
880
|
|
|
} |
|
881
|
|
|
|
|
882
|
|
|
/** |
|
883
|
|
|
* Print SOUR structure |
|
884
|
|
|
* This function prints the input array of SOUR sub-records built by the |
|
885
|
|
|
* getSourceStructure() function. |
|
886
|
|
|
* |
|
887
|
|
|
* @param string[] $textSOUR |
|
888
|
|
|
* |
|
889
|
|
|
* @return string |
|
890
|
|
|
*/ |
|
891
|
|
|
public static function printSourceStructure($textSOUR) |
|
892
|
|
|
{ |
|
893
|
|
|
global $WT_TREE; |
|
894
|
|
|
$html = ''; |
|
895
|
|
|
|
|
896
|
|
|
if ($textSOUR['PAGE']) { |
|
897
|
|
|
$html .= GedcomTag::getLabelValue('PAGE', Filter::expandUrls($textSOUR['PAGE'])); |
|
898
|
|
|
} |
|
899
|
|
|
|
|
900
|
|
|
if ($textSOUR['EVEN']) { |
|
901
|
|
|
$html .= GedcomTag::getLabelValue('EVEN', Filter::escapeHtml($textSOUR['EVEN'])); |
|
902
|
|
|
if ($textSOUR['ROLE']) { |
|
903
|
|
|
$html .= GedcomTag::getLabelValue('ROLE', Filter::escapeHtml($textSOUR['ROLE'])); |
|
904
|
|
|
} |
|
905
|
|
|
} |
|
906
|
|
|
|
|
907
|
|
|
if ($textSOUR['DATE'] || count($textSOUR['TEXT'])) { |
|
|
|
|
|
|
908
|
|
|
if ($textSOUR['DATE']) { |
|
909
|
|
|
$date = new Date($textSOUR['DATE']); |
|
910
|
|
|
$html .= GedcomTag::getLabelValue('DATA:DATE', $date->display()); |
|
911
|
|
|
} |
|
912
|
|
|
foreach ($textSOUR['TEXT'] as $text) { |
|
|
|
|
|
|
913
|
|
|
$html .= GedcomTag::getLabelValue('TEXT', Filter::formatText($text, $WT_TREE)); |
|
914
|
|
|
} |
|
915
|
|
|
} |
|
916
|
|
|
|
|
917
|
|
|
if ($textSOUR['QUAY'] != '') { |
|
918
|
|
|
$html .= GedcomTag::getLabelValue('QUAY', GedcomCodeQuay::getValue($textSOUR['QUAY'])); |
|
919
|
|
|
} |
|
920
|
|
|
|
|
921
|
|
|
return '<div class="indent">' . $html . '</div>'; |
|
922
|
|
|
} |
|
923
|
|
|
|
|
924
|
|
|
/** |
|
925
|
|
|
* Extract SOUR structure from the incoming Source sub-record |
|
926
|
|
|
* The output array is defined as follows: |
|
927
|
|
|
* $textSOUR['PAGE'] = Source citation |
|
928
|
|
|
* $textSOUR['EVEN'] = Event type |
|
929
|
|
|
* $textSOUR['ROLE'] = Role in event |
|
930
|
|
|
* $textSOUR['DATA'] = place holder (no text in this sub-record) |
|
931
|
|
|
* $textSOUR['DATE'] = Entry recording date |
|
932
|
|
|
* $textSOUR['TEXT'] = (array) Text from source |
|
933
|
|
|
* $textSOUR['QUAY'] = Certainty assessment |
|
934
|
|
|
* |
|
935
|
|
|
* @param string $srec |
|
936
|
|
|
* |
|
937
|
|
|
* @return string[] |
|
938
|
|
|
*/ |
|
939
|
|
|
public static function getSourceStructure($srec) |
|
940
|
|
|
{ |
|
941
|
|
|
// Set up the output array |
|
942
|
|
|
$textSOUR = array( |
|
943
|
|
|
'PAGE' => '', |
|
944
|
|
|
'EVEN' => '', |
|
945
|
|
|
'ROLE' => '', |
|
946
|
|
|
'DATA' => '', |
|
947
|
|
|
'DATE' => '', |
|
948
|
|
|
'TEXT' => array(), |
|
949
|
|
|
'QUAY' => '', |
|
950
|
|
|
); |
|
951
|
|
|
|
|
952
|
|
|
if ($srec) { |
|
953
|
|
|
$subrecords = explode("\n", $srec); |
|
954
|
|
|
for ($i = 0; $i < count($subrecords); $i++) { |
|
|
|
|
|
|
955
|
|
|
$tag = substr($subrecords[$i], 2, 4); |
|
956
|
|
|
$text = substr($subrecords[$i], 7); |
|
957
|
|
|
$i++; |
|
958
|
|
|
for (; $i < count($subrecords); $i++) { |
|
|
|
|
|
|
959
|
|
|
$nextTag = substr($subrecords[$i], 2, 4); |
|
960
|
|
|
if ($nextTag != 'CONT') { |
|
961
|
|
|
$i--; |
|
962
|
|
|
break; |
|
963
|
|
|
} |
|
964
|
|
|
if ($nextTag == 'CONT') { |
|
965
|
|
|
$text .= "\n"; |
|
966
|
|
|
} |
|
967
|
|
|
$text .= rtrim(substr($subrecords[$i], 7)); |
|
968
|
|
|
} |
|
969
|
|
|
if ($tag == 'TEXT') { |
|
970
|
|
|
$textSOUR[$tag][] = $text; |
|
971
|
|
|
} else { |
|
972
|
|
|
$textSOUR[$tag] = $text; |
|
973
|
|
|
} |
|
974
|
|
|
} |
|
975
|
|
|
} |
|
976
|
|
|
|
|
977
|
|
|
return $textSOUR; |
|
978
|
|
|
} |
|
979
|
|
|
|
|
980
|
|
|
/** |
|
981
|
|
|
* Print a row for the notes tab on the individual page. |
|
982
|
|
|
* |
|
983
|
|
|
* @param Fact $fact |
|
984
|
|
|
* @param int $level |
|
985
|
|
|
*/ |
|
986
|
|
|
public static function printMainNotes(Fact $fact, $level) |
|
987
|
|
|
{ |
|
988
|
|
|
$factrec = $fact->getGedcom(); |
|
989
|
|
|
$fact_id = $fact->getFactId(); |
|
990
|
|
|
$parent = $fact->getParent(); |
|
991
|
|
|
$pid = $parent->getXref(); |
|
992
|
|
|
|
|
993
|
|
|
if ($fact->isPendingAddition()) { |
|
994
|
|
|
$styleadd = ' new'; |
|
995
|
|
|
$can_edit = $level == 1 && $fact->canEdit(); |
|
996
|
|
|
} elseif ($fact->isPendingDeletion()) { |
|
997
|
|
|
$styleadd = ' old'; |
|
998
|
|
|
$can_edit = false; |
|
999
|
|
|
} else { |
|
1000
|
|
|
$styleadd = ''; |
|
1001
|
|
|
$can_edit = $level == 1 && $fact->canEdit(); |
|
1002
|
|
|
} |
|
1003
|
|
|
|
|
1004
|
|
|
$ct = preg_match_all("/$level NOTE (.*)/", $factrec, $match, PREG_SET_ORDER); |
|
1005
|
|
|
for ($j = 0; $j < $ct; $j++) { |
|
1006
|
|
|
// Note object, or inline note? |
|
1007
|
|
|
if (preg_match("/$level NOTE @(.*)@/", $match[$j][0], $nmatch)) { |
|
1008
|
|
|
$note = Note::getInstance($nmatch[1], $fact->getParent()->getTree()); |
|
1009
|
|
|
if ($note && !$note->canShow()) { |
|
1010
|
|
|
continue; |
|
1011
|
|
|
} |
|
1012
|
|
|
} else { |
|
1013
|
|
|
$note = null; |
|
1014
|
|
|
} |
|
1015
|
|
|
|
|
1016
|
|
|
if ($level >= 2) { |
|
1017
|
|
|
echo '<tr class="row_note2"><td class="descriptionbox rela ', $styleadd, ' width20">'; |
|
1018
|
|
|
} else { |
|
1019
|
|
|
echo '<tr><td class="descriptionbox ', $styleadd, ' width20">'; |
|
1020
|
|
|
} |
|
1021
|
|
|
if ($can_edit) { |
|
1022
|
|
|
echo '<a onclick="return edit_record(\'', $pid, '\', \'', $fact_id, '\');" href="#" title="', I18N::translate('Edit'), '">'; |
|
1023
|
|
|
if ($level < 2) { |
|
1024
|
|
|
if ($fact->getParent()->getTree()->getPreference('SHOW_FACT_ICONS')) { |
|
1025
|
|
|
echo '<i class="icon-note"></i> '; |
|
1026
|
|
|
} |
|
1027
|
|
|
if ($note) { |
|
1028
|
|
|
echo GedcomTag::getLabel('SHARED_NOTE'); |
|
1029
|
|
|
} else { |
|
1030
|
|
|
echo GedcomTag::getLabel('NOTE'); |
|
1031
|
|
|
} |
|
1032
|
|
|
echo '</a>'; |
|
1033
|
|
|
echo '<div class="editfacts">'; |
|
1034
|
|
|
echo "<div class=\"editlink\"><a class=\"editicon\" onclick=\"return edit_record('$pid', '$fact_id');\" href=\"#\" title=\"" . I18N::translate('Edit') . "\"><span class=\"link_text\">" . I18N::translate('Edit') . "</span></a></div>"; |
|
1035
|
|
|
echo '<div class="copylink"><a class="copyicon" href="#" onclick="return copy_fact(\'', $pid, '\', \'', $fact_id, '\');" title="' . I18N::translate('Copy') . '"><span class="link_text">' . I18N::translate('Copy') . '</span></a></div>'; |
|
1036
|
|
|
echo "<div class=\"deletelink\"><a class=\"deleteicon\" onclick=\"return delete_fact('" . I18N::translate('Are you sure you want to delete this fact?') . "', '$pid', '$fact_id');\" href=\"#\" title=\"" . I18N::translate('Delete') . "\"><span class=\"link_text\">" . I18N::translate('Delete') . "</span></a></div>"; |
|
1037
|
|
|
if ($note) { |
|
1038
|
|
|
echo '<a class="icon-note" href="', $note->getHtmlUrl(), '" title="' . I18N::translate('View') . '"><span class="link_text">' . I18N::translate('View') . '</span></a>'; |
|
1039
|
|
|
} |
|
1040
|
|
|
echo '</div>'; |
|
1041
|
|
|
} |
|
1042
|
|
|
} else { |
|
1043
|
|
|
if ($level < 2) { |
|
1044
|
|
|
if ($fact->getParent()->getTree()->getPreference('SHOW_FACT_ICONS')) { |
|
1045
|
|
|
echo '<i class="icon-note"></i> '; |
|
1046
|
|
|
} |
|
1047
|
|
|
if ($note) { |
|
1048
|
|
|
echo GedcomTag::getLabel('SHARED_NOTE'); |
|
1049
|
|
|
} else { |
|
1050
|
|
|
echo GedcomTag::getLabel('NOTE'); |
|
1051
|
|
|
} |
|
1052
|
|
|
} |
|
1053
|
|
|
$factlines = explode("\n", $factrec); // 1 BIRT Y\n2 NOTE ... |
|
1054
|
|
|
$factwords = explode(" ", $factlines[0]); // 1 BIRT Y |
|
1055
|
|
|
$factname = $factwords[1]; // BIRT |
|
1056
|
|
|
$parent = GedcomRecord::getInstance($pid, $fact->getParent()->getTree()); |
|
1057
|
|
|
if ($factname == 'EVEN' || $factname == 'FACT') { |
|
1058
|
|
|
// Add ' EVEN' to provide sensible output for an event with an empty TYPE record |
|
1059
|
|
|
$ct = preg_match("/2 TYPE (.*)/", $factrec, $ematch); |
|
1060
|
|
|
if ($ct > 0) { |
|
1061
|
|
|
$factname = trim($ematch[1]); |
|
1062
|
|
|
echo $factname; |
|
1063
|
|
|
} else { |
|
1064
|
|
|
echo GedcomTag::getLabel($factname, $parent); |
|
1065
|
|
|
} |
|
1066
|
|
|
} elseif ($factname != 'NOTE') { |
|
1067
|
|
|
// Note is already printed |
|
1068
|
|
|
echo GedcomTag::getLabel($factname, $parent); |
|
1069
|
|
|
if ($note) { |
|
1070
|
|
|
echo '<div class="editfacts"><a class="icon-note" href="', $note->getHtmlUrl(), '" title="' . I18N::translate('View') . '"><span class="link_text">' . I18N::translate('View') . '</span></a></div>'; |
|
1071
|
|
|
|
|
1072
|
|
|
} |
|
1073
|
|
|
} |
|
1074
|
|
|
} |
|
1075
|
|
|
echo '</td>'; |
|
1076
|
|
|
if ($note) { |
|
1077
|
|
|
// Note objects |
|
1078
|
|
|
if (Module::getModuleByName('GEDFact_assistant')) { |
|
1079
|
|
|
// If Census assistant installed, allow it to format the note |
|
1080
|
|
|
$text = CensusAssistantModule::formatCensusNote($note); |
|
|
|
|
|
|
1081
|
|
|
} else { |
|
1082
|
|
|
$text = Filter::formatText($note->getNote(), $fact->getParent()->getTree()); |
|
|
|
|
|
|
1083
|
|
|
} |
|
1084
|
|
|
} else { |
|
1085
|
|
|
// Inline notes |
|
1086
|
|
|
$nrec = Functions::getSubRecord($level, "$level NOTE", $factrec, $j + 1); |
|
1087
|
|
|
$text = $match[$j][1] . Functions::getCont($level + 1, $nrec); |
|
1088
|
|
|
$text = Filter::formatText($text, $fact->getParent()->getTree()); |
|
1089
|
|
|
} |
|
1090
|
|
|
|
|
1091
|
|
|
echo '<td class="optionbox', $styleadd, ' wrap">'; |
|
1092
|
|
|
echo $text; |
|
1093
|
|
|
|
|
1094
|
|
|
if (!empty($noterec)) { |
|
|
|
|
|
|
1095
|
|
|
echo self::printFactSources($noterec, 1); |
|
1096
|
|
|
} |
|
1097
|
|
|
|
|
1098
|
|
|
// 2 RESN tags. Note, there can be more than one, such as "privacy" and "locked" |
|
1099
|
|
|
if (preg_match_all("/\n2 RESN (.+)/", $factrec, $matches)) { |
|
1100
|
|
|
foreach ($matches[1] as $match) { |
|
1101
|
|
|
echo '<br><span class="label">', GedcomTag::getLabel('RESN'), ':</span> <span class="field">'; |
|
1102
|
|
|
switch ($match) { |
|
1103
|
|
|
case 'none': |
|
1104
|
|
|
// Note: "2 RESN none" is not valid gedcom, and the GUI will not let you add it. |
|
1105
|
|
|
// However, webtrees privacy rules will interpret it as "show an otherwise private fact to public". |
|
1106
|
|
|
echo '<i class="icon-resn-none"></i> ', I18N::translate('Show to visitors'); |
|
1107
|
|
|
break; |
|
1108
|
|
|
case 'privacy': |
|
1109
|
|
|
echo '<i class="icon-resn-privacy"></i> ', I18N::translate('Show to members'); |
|
1110
|
|
|
break; |
|
1111
|
|
|
case 'confidential': |
|
1112
|
|
|
echo '<i class="icon-resn-confidential"></i> ', I18N::translate('Show to managers'); |
|
1113
|
|
|
break; |
|
1114
|
|
|
case 'locked': |
|
1115
|
|
|
echo '<i class="icon-resn-locked"></i> ', I18N::translate('Only managers can edit'); |
|
1116
|
|
|
break; |
|
1117
|
|
|
default: |
|
1118
|
|
|
echo $match; |
|
1119
|
|
|
break; |
|
1120
|
|
|
} |
|
1121
|
|
|
echo '</span>'; |
|
1122
|
|
|
} |
|
1123
|
|
|
} |
|
1124
|
|
|
echo '</td></tr>'; |
|
1125
|
|
|
} |
|
1126
|
|
|
} |
|
1127
|
|
|
|
|
1128
|
|
|
/** |
|
1129
|
|
|
* Print a row for the media tab on the individual page. |
|
1130
|
|
|
* |
|
1131
|
|
|
* @param Fact $fact |
|
1132
|
|
|
* @param int $level |
|
1133
|
|
|
*/ |
|
1134
|
|
|
public static function printMainMedia(Fact $fact, $level) |
|
1135
|
|
|
{ |
|
1136
|
|
|
$factrec = $fact->getGedcom(); |
|
1137
|
|
|
$parent = $fact->getParent(); |
|
1138
|
|
|
|
|
1139
|
|
|
if ($fact->isPendingAddition()) { |
|
1140
|
|
|
$styleadd = 'new'; |
|
1141
|
|
|
$can_edit = $level == 1 && $fact->canEdit(); |
|
1142
|
|
|
} elseif ($fact->isPendingDeletion()) { |
|
1143
|
|
|
$styleadd = 'old'; |
|
1144
|
|
|
$can_edit = false; |
|
1145
|
|
|
} else { |
|
1146
|
|
|
$styleadd = ''; |
|
1147
|
|
|
$can_edit = $level == 1 && $fact->canEdit(); |
|
1148
|
|
|
} |
|
1149
|
|
|
|
|
1150
|
|
|
// -- find source for each fact |
|
1151
|
|
|
preg_match_all('/(?:^|\n)' . $level . ' OBJE @(.*)@/', $factrec, $matches); |
|
1152
|
|
|
foreach ($matches[1] as $xref) { |
|
1153
|
|
|
$media = Media::getInstance($xref, $fact->getParent()->getTree()); |
|
1154
|
|
|
// Allow access to "1 OBJE @non_existent_source@", so it can be corrected/deleted |
|
1155
|
|
|
if (!$media || $media->canShow()) { |
|
1156
|
|
|
if ($level > 1) { |
|
1157
|
|
|
echo '<tr class="row_obje2">'; |
|
1158
|
|
|
} else { |
|
1159
|
|
|
echo '<tr>'; |
|
1160
|
|
|
} |
|
1161
|
|
|
echo '<td class="descriptionbox'; |
|
1162
|
|
|
if ($level > 1) { |
|
1163
|
|
|
echo ' rela'; |
|
1164
|
|
|
} |
|
1165
|
|
|
echo ' ', $styleadd, ' width20">'; |
|
1166
|
|
|
preg_match("/^\d (\w*)/", $factrec, $factname); |
|
1167
|
|
|
$factlines = explode("\n", $factrec); // 1 BIRT Y\n2 SOUR ... |
|
1168
|
|
|
$factwords = explode(" ", $factlines[0]); // 1 BIRT Y |
|
1169
|
|
|
$factname = $factwords[1]; // BIRT |
|
1170
|
|
|
if ($factname == 'EVEN' || $factname == 'FACT') { |
|
1171
|
|
|
// Add ' EVEN' to provide sensible output for an event with an empty TYPE record |
|
1172
|
|
|
$ct = preg_match("/2 TYPE (.*)/", $factrec, $ematch); |
|
1173
|
|
|
if ($ct > 0) { |
|
1174
|
|
|
$factname = $ematch[1]; |
|
1175
|
|
|
echo $factname; |
|
1176
|
|
|
} else { |
|
1177
|
|
|
echo GedcomTag::getLabel($factname, $parent); |
|
1178
|
|
|
} |
|
1179
|
|
|
} elseif ($can_edit) { |
|
1180
|
|
|
echo '<a onclick="window.open(\'addmedia.php?action=editmedia&pid=', $media->getXref(), '\', \'_blank\', edit_window_specs); return false;" href="#" title="', I18N::translate('Edit'), '">'; |
|
1181
|
|
|
echo GedcomTag::getLabel($factname, $parent), '</a>'; |
|
1182
|
|
|
echo '<div class="editfacts">'; |
|
1183
|
|
|
echo '<div class="editlink"><a class="editicon" onclick="window.open(\'addmedia.php?action=editmedia&pid=', $media->getXref(), '\', \'_blank\', edit_window_specs); return false;" href="#" title="', I18N::translate('Edit'), '"><span class="link_text">', I18N::translate('Edit'), '</span></a></div>'; |
|
1184
|
|
|
echo '<div class="copylink"><a class="copyicon" href="#" onclick="jQuery.post(\'action.php\',{action:\'copy-fact\', type:\'\', factgedcom:\'' . rawurlencode($factrec) . '\'},function(){location.reload();})" title="' . I18N::translate('Copy') . '"><span class="link_text">' . I18N::translate('Copy') . '</span></a></div>'; |
|
1185
|
|
|
echo '<div class="deletelink"><a class="deleteicon" onclick="return delete_fact(\'', I18N::translate('Are you sure you want to delete this fact?'), '\', \'', $parent->getXref(), '\', \'', $fact->getFactId(), '\');" href="#" title="', I18N::translate('Delete'), '"><span class="link_text">', I18N::translate('Delete'), '</span></a></div>'; |
|
1186
|
|
|
echo '</div>'; |
|
1187
|
|
|
} else { |
|
1188
|
|
|
echo GedcomTag::getLabel($factname, $parent); |
|
1189
|
|
|
} |
|
1190
|
|
|
echo '</td>'; |
|
1191
|
|
|
echo '<td class="optionbox ', $styleadd, ' wrap">'; |
|
1192
|
|
|
if ($media) { |
|
1193
|
|
|
echo '<span class="field">'; |
|
1194
|
|
|
echo $media->displayImage(); |
|
1195
|
|
|
echo '<a href="' . $media->getHtmlUrl() . '">'; |
|
1196
|
|
|
echo '<em>'; |
|
1197
|
|
|
foreach ($media->getAllNames() as $name) { |
|
1198
|
|
|
if ($name['type'] != 'TITL') { |
|
1199
|
|
|
echo '<br>'; |
|
1200
|
|
|
} |
|
1201
|
|
|
echo $name['full']; |
|
1202
|
|
|
} |
|
1203
|
|
|
echo '</em>'; |
|
1204
|
|
|
echo '</a>'; |
|
1205
|
|
|
echo '</span>'; |
|
1206
|
|
|
|
|
1207
|
|
|
echo GedcomTag::getLabelValue('FORM', $media->mimeType()); |
|
|
|
|
|
|
1208
|
|
|
$imgsize = $media->getImageAttributes('main'); |
|
|
|
|
|
|
1209
|
|
|
if (!empty($imgsize['WxH'])) { |
|
1210
|
|
|
echo GedcomTag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']); |
|
1211
|
|
|
} |
|
1212
|
|
|
if ($media->getFilesizeraw() > 0) { |
|
|
|
|
|
|
1213
|
|
|
echo GedcomTag::getLabelValue('__FILE_SIZE__', $media->getFilesize()); |
|
|
|
|
|
|
1214
|
|
|
} |
|
1215
|
|
|
$mediatype = $media->getMediaType(); |
|
|
|
|
|
|
1216
|
|
|
if ($mediatype) { |
|
1217
|
|
|
echo GedcomTag::getLabelValue('TYPE', GedcomTag::getFileFormTypeValue($mediatype)); |
|
1218
|
|
|
} |
|
1219
|
|
|
|
|
1220
|
|
|
switch ($media->isPrimary()) { |
|
|
|
|
|
|
1221
|
|
|
case 'Y': |
|
1222
|
|
|
echo GedcomTag::getLabelValue('_PRIM', I18N::translate('yes')); |
|
1223
|
|
|
break; |
|
1224
|
|
|
case 'N': |
|
1225
|
|
|
echo GedcomTag::getLabelValue('_PRIM', I18N::translate('no')); |
|
1226
|
|
|
break; |
|
1227
|
|
|
} |
|
1228
|
|
|
echo FunctionsPrint::printFactNotes($media->getGedcom(), 1); |
|
1229
|
|
|
echo self::printFactSources($media->getGedcom(), 1); |
|
1230
|
|
|
} else { |
|
1231
|
|
|
echo $xref; |
|
1232
|
|
|
} |
|
1233
|
|
|
echo '</td></tr>'; |
|
1234
|
|
|
} |
|
1235
|
|
|
} |
|
1236
|
|
|
} |
|
1237
|
|
|
} |
|
1238
|
|
|
|