1.
<?php
2.
3.
/*
4.
{{title}}
5.
6.
Export GEDCOM
7.
8.
{{author}}
9.
10.
{{licence}}
11.
12.
{{datetime}}
13.
14.
*/
15.
16.
/*
17.
* http://fauque.fr/gedcom.php
18.
*
19.
*
20.
*
21.
*
22.
* Ajouts tag
23.
* http://www.francegenweb.org/wiki/index.php?title=Contenu_d%27un_fichier_(gedcom)#Enregistrement_d.27un_objet_.27media.27
24.
*
25.
* https://docs.ancestris.org/books/mode-demploi/page/documenter-vos-sources
26.
Étiquette QUAY
27.
0 =source non fiable ou estimation
28.
1 =fiabilité douteuse
29.
2 =source indirecte
30.
3 =preuve indiscutable
31.
*
32.
* La page dans la source - Étiquette PAGE
33.
*
34.
* La retranscription du texte de la source - Étiquettes DATA puis TEXT
35.
Les liens vers les fichiers multimédia - Étiquette OBJE
36.
Le type d'événement cité dans la source (peut être différent de l'événement de l'individu auquel elle est rattachée) - Étiquette EVEN
37.
*
38.
*
39.
* CONC CONT
40.
https://www.tamurajones.net/GEDCOMCONCAndCONT.xhtml
41.
42.
https://chronoplexsoftware.com/gedcomvalidator/help/W462.htm
43.
Long line values which support line breaks should be wrapped using concatenation ('CONC') tags and continuation ('CONT') tags so that the maximum length of the first part of the line value does not exceed the length specified for that field.
44.
In all cases the length of GEDCOM lines must not exceed 255 characters.
45.
46.
47.
Période dates
48.
* https://genopresse.com/blog/2011/03/lentree-des-dates-en-genealogie/
49.
50.
51.
http://www.francegenweb.org/wiki/index.php?title=Grammaire_(gedcom)
52.
53.
*
54.
*/
55.
56.
57.
58.
include_once "dbconnect.php";
59.
60.
61.
class gedcomParser {
62.
63.
public $db;
64.
public $lasterror="";
65.
public $lastInsertId=-1;
66.
public $count = 0;
67.
68.
function __construct( $db ) {
69.
$this->db = $db;
70.
}
71.
72.
function dumpError() {
73.
echo 'ERREUR : '.$this->lasterror;
74.
echo "\n";
75.
}
76.
77.
function selectMeta($code) {
78.
79.
$this->lasterror="";
80.
81.
$sqlSt="
82.
select
83.
a.id as 'a.id',
84.
a.code as 'a.code',
85.
a.name as 'a.name',
86.
a.value as 'a.value',
87.
a.type as 'a.type',
88.
a.description as 'a.description'
89.
90.
91.
from metadata a
92.
93.
where a.code = :code;
94.
";
95.
96.
try {
97.
98.
$stmt = $this->db->prepare($sqlSt);
99.
$stmt->bindParam(':code', $code, PDO::PARAM_STR);
100.
$stmt->execute();
101.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
102.
103.
return $results[0]['a.value'];
104.
105.
} catch (Exception $e) {
106.
$this->lasterror = $e->getMessage().' (code='.$code.')';
107.
return false;
108.
}
109.
}
110.
111.
function selectAllINDI() {
112.
113.
$this->lasterror='';
114.
115.
$sqlSt="
116.
select p.id as 'id',
117.
datecreated,
118.
p.lastname as 'lastname', -- nom de famille
119.
p.firstname as 'givenname', -- Prénom
120.
p.displayname as 'name', -- Un mot ou une combinaison de mots utilisés pour aider à identifier un individu. Pour les femmes mariées, il s'agit du nom de jeune fille. Plus d'une ligne NOM devrait être utilisée pour les gens qui sont connus sous différents noms.
121.
p.firstnameprefix,
122.
p.lastnamesuffix,
123.
p.surname,
124.
p.firstname || ',' || p.lastname as 'name2' ,
125.
p.sex as 'sex'
126.
from person p
127.
order by p.lastname ";
128.
129.
try {
130.
131.
$stmt = $this->db->prepare($sqlSt);
132.
$stmt->execute();
133.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
134.
return $results;
135.
136.
} catch (Exception $e) {
137.
$this->lasterror = $e->getMessage();
138.
$this->count = 0;
139.
return false;
140.
}
141.
}
142.
143.
function selectIndiFAMS( $person_id ) {
144.
145.
$this->lasterror='';
146.
147.
$sqlSt="
148.
select
149.
e.id,
150.
et.code,
151.
e.date_begin as 'date',
152.
e.name,
153.
p1.id as 'wid',
154.
p1.displayname as 'Mere',
155.
p2.id as 'hid',
156.
p2.displayname as 'Pere'
157.
from event e , eventtype et
158.
left outer join person p1 on p1.id = e.person_1_id
159.
left outer join person p2 on p2.id = e.person_2_id
160.
where et.id = e.eventtype_id
161.
and (p1.id = $person_id or p2.id = $person_id)
162.
and e.eventtype_id in (select et.id from Eventtype et where et.code in( 'MARR' , 'UNION'))
163.
";
164.
165.
try {
166.
167.
$stmt = $this->db->prepare($sqlSt);
168.
$stmt->execute();
169.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
170.
return $results[0]['id'];
171.
172.
} catch (Exception $e) {
173.
$this->lasterror = $e->getMessage();
174.
$this->count = 0;
175.
return false;
176.
}
177.
}
178.
179.
function selectIndiParents( $person_id ) {
180.
181.
$this->lasterror='';
182.
183.
$sqlSt="
184.
select
185.
e.person_1_id,
186.
p1.displayname,
187.
y.name as event_type_name,
188.
e.date_begin as event_date,
189.
e.person_2_id,
190.
p2.displayname as Mère,
191.
e.person_3_id,
192.
p3.displayname as Père,
193.
pl.name as place_name
194.
from
195.
event e,
196.
person p1,
197.
eventtype y
198.
left outer join person p2 on e.person_2_id = p2.id
199.
left outer join person p3 on e.person_3_id = p3.id
200.
left outer join place pl on pl.id = e.place_id
201.
where y.id = e.eventtype_id
202.
and e.person_1_id = p1.id
203.
and e.eventtype_id = (select et.id from Eventtype et where et.code in( 'BIRT', 'ADOP' ))
204.
and e.person_1_id = $person_id
205.
order by e.date_begin
206.
207.
";
208.
209.
try {
210.
211.
$stmt = $this->db->prepare($sqlSt);
212.
$stmt->execute();
213.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
214.
return $results;
215.
216.
} catch (Exception $e) {
217.
$this->lasterror = $e->getMessage();
218.
$this->count = 0;
219.
return false;
220.
}
221.
}
222.
223.
function selectIndiEventPlace( $person_id, $event_code ) {
224.
225.
$this->lasterror='';
226.
227.
$sqlSt="
228.
select p.id as 'id', p.city || ',' || ifnull(', ' || p.zipcode,'') || ',' || p.country as 'plac',
229.
p.gpslat, p.gpslon
230.
from event e, place p
231.
where
232.
e.place_id = p.id
233.
and e.person_1_id = $person_id
234.
and e.eventtype_id = ( select et.id from Eventtype et where et.code = '$event_code' )";
235.
236.
try {
237.
238.
$stmt = $this->db->prepare($sqlSt);
239.
$stmt->execute();
240.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
241.
return $results[0];
242.
243.
} catch (Exception $e) {
244.
$this->lasterror = $e->getMessage();
245.
$this->count = 0;
246.
return false;
247.
}
248.
}
249.
250.
function selectIndiEventDate( $person_id ) {
251.
252.
$this->lasterror='';
253.
254.
$sqlSt = "
255.
select e.id as 'id', et.code, e.date_begin as 'date_begin'
256.
from event e , eventtype et
257.
where
258.
e.eventtype_id = et.id
259.
and et.category = 'INDI'
260.
and e.person_1_id = $person_id
261.
";
262.
263.
try {
264.
265.
$stmt = $this->db->prepare($sqlSt);
266.
$stmt->execute();
267.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
268.
//return array ( 'date_begin' => $results[0]['date_begin'], 'hour_begin' => $results[0]['hour_begin']);
269.
return $results;
270.
}
271.
catch (Exception $e) {
272.
$this->lasterror = $e->getMessage();
273.
$this->dumpError();
274.
$this->count = 0;
275.
return false;
276.
}
277.
}
278.
279.
function selectEventDate( $event_id, $event_code ) {
280.
281.
$this->lasterror='';
282.
283.
$sqlSt="
284.
select e.id as 'id', e.date_begin as 'date_begin'
285.
from event e
286.
where
287.
e.id = $event_id
288.
and e.eventtype_id = ( select et.id from Eventtype et where et.code = '$event_code' )
289.
";
290.
291.
try {
292.
293.
$stmt = $this->db->prepare($sqlSt);
294.
$stmt->execute();
295.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
296.
return array ( 'date_begin' => $results[0]['date_begin']);
297.
}
298.
catch (Exception $e) {
299.
$this->lasterror = $e->getMessage();
300.
$this->count = 0;
301.
return false;
302.
}
303.
}
304.
305.
function selectEventPlace( $event_id, $event_code ) {
306.
307.
$this->lasterror='';
308.
309.
$sqlSt="
310.
select p.id as 'id', p.city || ',' || ifnull(', ' || p.zipcode,'') || ',' || p.country as 'plac',
311.
p.gpslat, p.gpslon
312.
from event e, place p
313.
where
314.
e.place_id = p.id
315.
and e.id = $event_id
316.
and e.eventtype_id = ( select et.id from Eventtype et where et.code = '$event_code' )
317.
";
318.
319.
try {
320.
321.
$stmt = $this->db->prepare($sqlSt);
322.
$stmt->execute();
323.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
324.
return $results[0];
325.
326.
} catch (Exception $e) {
327.
$this->lasterror = $e->getMessage();
328.
$this->count = 0;
329.
return false;
330.
}
331.
}
332.
333.
function selectEventSource( $event_id ) {
334.
335.
$this->lasterror='';
336.
337.
$sqlSt="
338.
select
339.
s.id as 'id',
340.
s.quality as 'quality',
341.
s.datecreated as 'date_created',
342.
s.name as 'name',
343.
s.page as 'page',
344.
s.citation as 'citation',
345.
s.description,
346.
s.quality as 'quality',
347.
d.id as 'document_id',
348.
d.name as 'document_name',
349.
e.id as 'envent_id',
350.
e.name as 'event_name'
351.
from event e, event_source es, source s
352.
left outer join document d on d.id = es.document_id
353.
where e.id = es.event_id
354.
and s.id = es.source_id
355.
and e.id = '$event_id'
356.
";
357.
358.
try {
359.
360.
$stmt = $this->db->prepare($sqlSt);
361.
$stmt->execute();
362.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
363.
return $results;
364.
365.
} catch (Exception $e) {
366.
$this->lasterror = $e->getMessage();
367.
$this->dumpError();
368.
$this->count = 0;
369.
return false;
370.
}
371.
}
372.
373.
function selectAllFAM( $event_category ) {
374.
375.
$this->lasterror='';
376.
377.
$sqlSt="
378.
select
379.
e.id,
380.
e.datecreated,
381.
et.code,
382.
e.date_begin as 'date',
383.
e.name,
384.
p1.id as 'wid',
385.
p1.displayname as 'Mere',
386.
p2.id as 'hid',
387.
p2.displayname as 'Pere'
388.
from event e , eventtype et
389.
left outer join person p1 on p1.id = e.person_1_id
390.
left outer join person p2 on p2.id = e.person_2_id
391.
where et.id = e.eventtype_id
392.
and et.category = '$event_category'
393.
";
394.
395.
try {
396.
397.
$stmt = $this->db->prepare($sqlSt);
398.
$stmt->execute();
399.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
400.
return $results;
401.
402.
} catch (Exception $e) {
403.
$this->lasterror = $e->getMessage();
404.
$this->count = 0;
405.
return false;
406.
}
407.
}
408.
409.
function selectAllFAM1( $event_category , $person_id ) {
410.
411.
$this->lasterror='';
412.
413.
$sqlSt="
414.
select
415.
e.id,
416.
e.datecreated,
417.
et.code,
418.
e.date_begin as 'date',
419.
e.name,
420.
p1.id as 'wid',
421.
p1.displayname as 'Mere',
422.
p2.id as 'hid',
423.
p2.displayname as 'Pere'
424.
from event e , eventtype et
425.
left outer join person p1 on p1.id = e.person_1_id
426.
left outer join person p2 on p2.id = e.person_2_id
427.
where et.id = e.eventtype_id
428.
and ( p1.id = $person_id or p2.id = $person_id)
429.
and et.category = '$event_category'
430.
";
431.
432.
try {
433.
434.
$stmt = $this->db->prepare($sqlSt);
435.
$stmt->execute();
436.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
437.
return $results;
438.
439.
} catch (Exception $e) {
440.
$this->lasterror = $e->getMessage();
441.
$this->count = 0;
442.
return false;
443.
}
444.
}
445.
446.
function selectFAMCHILD( $person_id ) {
447.
448.
$this->lasterror='';
449.
450.
$sqlSt="
451.
select
452.
e.person_1_id as 'id',
453.
p1.displayname,
454.
y.name as event_type_name,
455.
e.date_begin as event_date,
456.
e.person_2_id,
457.
p2.displayname as Mère,
458.
e.person_3_id,
459.
p3.displayname as Père,
460.
pl.name as place_name
461.
from
462.
event e,
463.
person p1,
464.
eventtype y
465.
left outer join person p2 on e.person_2_id = p2.id
466.
left outer join person p3 on e.person_3_id = p3.id
467.
left outer join place pl on pl.id = e.place_id
468.
where y.id = e.eventtype_id
469.
and e.person_1_id = p1.id
470.
and e.eventtype_id in (select et.id from Eventtype et where et.code in ('BIRT', 'ADOP') )
471.
and ( e.person_3_id = $person_id or e.person_2_id = $person_id) -- Chercher père ou mère
472.
order by e.date_begin
473.
";
474.
475.
try {
476.
477.
$stmt = $this->db->prepare($sqlSt);
478.
$stmt->execute();
479.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
480.
return $results;
481.
482.
} catch (Exception $e) {
483.
$this->lasterror = $e->getMessage();
484.
$this->count = 0;
485.
return false;
486.
}
487.
}
488.
489.
function selectAllSOURCE() {
490.
491.
$this->lasterror='';
492.
493.
$sqlSt="
494.
select
495.
s.id as 'id', s.datecreated, s.name as 'name',
496.
s.description,
497.
s.quality as 'quality',
498.
d.id as document_id,
499.
d.name as document_name,
500.
p.id as depot_id,
501.
p.name as depot_name
502.
from source s
503.
left outer join event_source es on es.source_id = s.id
504.
left outer join document d on d.id = es.document_id
505.
left outer join depot p on p.id = d.depot_id
506.
";
507.
508.
try {
509.
510.
$stmt = $this->db->prepare($sqlSt);
511.
$stmt->execute();
512.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
513.
return $results;
514.
515.
} catch (Exception $e) {
516.
$this->lasterror = $e->getMessage();
517.
$this->count = 0;
518.
return false;
519.
}
520.
}
521.
522.
function selectAllREPO() {
523.
524.
$this->lasterror='';
525.
526.
$sqlSt="
527.
select d.id as 'id' , d.code, d.name as 'name', d.city, d.adress_1, d.adress_2, d.zip, d.country
528.
from depot d
529.
";
530.
531.
try {
532.
533.
$stmt = $this->db->prepare($sqlSt);
534.
$stmt->execute();
535.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
536.
return $results;
537.
538.
} catch (Exception $e) {
539.
$this->lasterror = $e->getMessage();
540.
$this->count = 0;
541.
return false;
542.
}
543.
}
544.
545.
546.
function selectAllOBJ() {
547.
548.
$this->lasterror='';
549.
550.
$sqlSt="
551.
select
552.
d.id as 'id', d.name as 'name',
553.
d.description as 'description' ,
554.
d.url as 'url',
555.
t.code
556.
from document d, Documenttype t
557.
where d.documenttype_id = t.id
558.
";
559.
560.
try {
561.
562.
$stmt = $this->db->prepare($sqlSt);
563.
$stmt->execute();
564.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
565.
return $results;
566.
567.
} catch (Exception $e) {
568.
$this->lasterror = $e->getMessage();
569.
$this->count = 0;
570.
return false;
571.
}
572.
}
573.
574.
} // end gedcomParser class ---------------------------------------------------
575.
576.
// CONT :
577.
//https://www.tamurajones.net/GEDCOMCONCAndCONT.xhtml
578.
579.
// Sources :
580.
//https://tmg.reigelridge.com/Sources-exporting.htm
581.
//https://wiki.phpgedview.net/en/index.php/Proper_use_of_sources
582.
583.
//http://ged-inline.elasticbeanstalk.com/validate
584.
585.
586.
// Synthèse :
587.
// http://www.tcgr.bufton.org/tcgpgedc.htm
588.
589.
$outLineNumber = 1;
590.
591.
function echoGedcom( $fp, $debugMode, $gedcomLevel, $id, $gedcomTag, $gedcomData ) {
592.
593.
global $outLineNumber;
594.
595.
$gedcomColors = array(
596.
'linenumber' => '#ff33cc',
597.
'level' => '#db4dff',
598.
'id' => '#0020C2',
599.
'tag' => '#C35817',
600.
'data' => '#347C2C'
601.
);
602.
603.
echo '<tr>';
604.
605.
echo '<td>';
606.
echo '<span style="color:'.$gedcomColors['linenumber'].'">';
607.
echo '['.$outLineNumber.']';
608.
$outLineNumber = $outLineNumber + 1;
609.
echo '</span>';
610.
echo '</td>';
611.
612.
echo '<td>';
613.
if ($gedcomLevel !== null) {
614.
echo '<span style="color:'.$gedcomColors['level'].'">';
615.
echo $gedcomLevel;
616.
echo '</span>';
617.
fwrite($fp, $gedcomLevel);
618.
}
619.
echo '</td>';
620.
621.
622.
echo '<td>';
623.
if ($id !== null) {
624.
echo '<span style="color:'.$gedcomColors['id'].'">';
625.
echo $id;
626.
echo '</span>';
627.
fwrite($fp, " ");
628.
fwrite($fp, $id);
629.
}
630.
echo '</td>';
631.
632.
echo '<td>';
633.
for ($i = $gedcomLevel; $i >0; $i=$i-1)
634.
{
635.
echo ' ';
636.
}
637.
638.
if ($gedcomTag !== null) {
639.
echo '<span style="color:'.$gedcomColors['tag'].'">';
640.
echo $gedcomTag;
641.
echo '</span>';
642.
fwrite($fp, " ");
643.
fwrite($fp, $gedcomTag);
644.
}
645.
646.
echo ' ';
647.
648.
if ($gedcomData !== null) {
649.
echo '<span style="color:'.$gedcomColors['data'].'">';
650.
fwrite($fp, " ");
651.
echo '</span>';
652.
echo $gedcomData;
653.
fwrite($fp, $gedcomData);
654.
}
655.
echo '</td>';
656.
657.
fwrite($fp, "\n");
658.
659.
echo '</tr>';
660.
}
661.
662.
// DB : 08/09/1888 16:42
663.
// return : 9 AUG 1642
664.
665.
function formatDate( $indate ) {
666.
$months = array(
667.
'', 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'
668.
);
669.
670.
$indatechunks = explode(" ", $indate);
671.
672.
$datechunks = explode("/", $indatechunks[0]);
673.
674.
return ( $datechunks[0].' '.$months[(int)($datechunks[1])*1].' '.$datechunks[2]);
675.
}
676.
function formatDateTime( $indate ) {
677.
$months = array(
678.
'', 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'
679.
);
680.
681.
$indatechunks = explode(" ", $indate);
682.
683.
$datechunks = explode("/", $indatechunks[0]);
684.
685.
return ( $datechunks[0].' '.$months[(int)($datechunks[1])*1].' '.$datechunks[2].' '.$indatechunks[1]);
686.
}
687.
// TIME HH:MM
688.
function formatHour( $indate ) {
689.
$datechunks = explode(" ", $indate);
690.
if ( $datechunks[1])
691.
return $datechunks[1];
692.
693.
return False;
694.
}
695.
696.
697.
698.
$myGedcom = new gedcomParser( $db );
699.
700.
$debugMode = NULL;
701.
$gedfilename = $myGedcom->selectMeta('GEDCOMFILE') ;
702.
@unlink('tmp/'.$gedfilename);
703.
$fp = fopen('tmp/'.$gedfilename, 'a');
704.
705.
echo '<div style="text-align: center; margin-right:auto; margin-left:auto;width:100%">';
706.
echo '<a href="phputil/gedcomexport_download.php?file=../tmp/'.$gedfilename.'">'.$gedfilename.'</a>';
707.
echo '</div>';
708.
echo '<hr>';
709.
echo '<style> table#gedcomtable tr:nth-child(even) { background-color:#F0FFF0; tr:nth-child(odd) { background-color:#EAF9EA; } </style>';
710.
echo '<div style="margin:auto;width:100%"><tt><table border=0 id="gedcomtable" style="margin-left: auto; margin-right: auto;">';
711.
712.
// -------------------------------------------------
713.
echoGedcom( $fp, $debugMode, 0, null,'HEAD', null );
714.
echoGedcom( $fp, $debugMode, 1, null,'SOUR', $myGedcom->selectMeta('GEDCOMSOUR') );
715.
echoGedcom( $fp, $debugMode, 2, null,'VERS', $myGedcom->selectMeta('GEDCOMSOURVERS') );
716.
echoGedcom( $fp, $debugMode, 2, null,'NAME', $myGedcom->selectMeta('GEDCOMSOURNAME') );
717.
echoGedcom( $fp, $debugMode, 1, null,'DATE', trim($myGedcom->selectMeta('GEDCOMDATE'))==''?strtoupper(date("d M Y")):formatDate($myGedcom->selectMeta('GEDCOMDATE')) );
718.
echoGedcom( $fp, $debugMode, 2, null,'TIME', trim($myGedcom->selectMeta('GEDCOMDATE'))==''?strtoupper(date("H:m")):formatHour($myGedcom->selectMeta('GEDCOMDATE')) );
719.
echoGedcom( $fp, $debugMode, 1, null,'CHAR', 'UTF-8' );
720.
echoGedcom( $fp, $debugMode, 1, null,'FILE', $gedfilename );
721.
echoGedcom( $fp, $debugMode, 1, null,'GEDC', null );
722.
echoGedcom( $fp, $debugMode, 2, null,'FORM', 'LINEAGE-LINKED' );
723.
echoGedcom( $fp, $debugMode, 2, null,'VERS', '5.5.1' );
724.
echoGedcom( $fp, $debugMode, 1, null,'SUBM', '@SUBM@' ); // pt vers Auteur
725.
echoGedcom( $fp, $debugMode, 0, '@SUBM@', 'SUBM', null );
726.
echoGedcom( $fp, $debugMode, 1, null,'NAME', $myGedcom->selectMeta('GEDCOMAUT') );
727.
728.
// --------------------------------------
729.
$indiResults = $myGedcom->selectAllINDI();
730.
if ($indiResults === false) { echo "Erreur : ".$myGedcom->lasterror."<br>"; }
731.
foreach($indiResults as $indikey=>$indival) {
732.
733.
echoGedcom( $fp, $debugMode, 0, '@I'.$indival['id'].'@','INDI', null );
734.
echoGedcom( $fp, $debugMode, 1, null,'NAME', $indival['name'] );
735.
if ($indival['givenname'] ) echoGedcom( $fp, $debugMode, 2, null,'GIVN', $indival['givenname'] ); // Prénom
736.
if ($indival['lastname'] ) echoGedcom( $fp, $debugMode, 2, null,'SURN', $indival['lastname'] ); // Nom de famille
737.
if ($indival['surname'] ) echoGedcom( $fp, $debugMode, 2, null,'NICK', $indival['surname'] ); // surnom
738.
if ($indival['firstnameprefix'] ) echoGedcom( $fp, $debugMode, 2, null,'NPFX', $indival['firstnameprefix'] ); // Docteur, Général, Monseigneur
739.
if ($indival['lastnamesuffix'] ) echoGedcom( $fp, $debugMode, 2, null,'NSFX', $indival['lastnamesuffix'] ); // Jr
740.
741.
echoGedcom( $fp, $debugMode, 1, null,'SEX', $indival['sex'] );
742.
743.
$indiEventResults = $myGedcom->selectIndiEventDate( $indival['id'] );
744.
745.
foreach ( $indiEventResults as $indieventKey => $indiEvent ) {
746.
if ($indiEvent['date_begin']) {
747.
echoGedcom( $fp, $debugMode, 1, null,$indiEvent['code'], null );
748.
echoGedcom( $fp, $debugMode, 2, null,'DATE', formatDate($indiEvent['date_begin']));
749.
$hour_begin = formatHour($indiEvent['date_begin']);
750.
//if ($hour_begin)
751.
// echoGedcom( $fp, $debugMode, 3, null,'TIME', $hour_begin);
752.
}
753.
754.
if (
755.
$indiEvent['code'][0] != '_'
756.
)
757.
{
758.
//echoGedcom( $fp, $debugMode, 1, null, $indiEvent['code'], null );
759.
$eventPlace = $myGedcom->selectIndiEventPlace( $indival['id'], $indiEvent['code']);
760.
if ( $eventPlace )
761.
{
762.
echoGedcom( $fp, $debugMode, 2, null,'PLAC', $eventPlace['plac'] );
763.
if ($eventPlace['gpslat'] and $eventPlace['gpslon']) {
764.
echoGedcom( $fp, $debugMode, 3, null,'MAP', null );
765.
echoGedcom( $fp, $debugMode, 4, null,'LATI', $eventPlace['gpslat'] );
766.
echoGedcom( $fp, $debugMode, 4, null,'LONG', $eventPlace['gpslon'] );
767.
}
768.
}
769.
}
770.
771.
$eventSources = $myGedcom->selectEventSource( $indiEvent['id'] );
772.
if ($eventSources) {
773.
foreach ($eventSources as $eventSourceKey => $eventSourceValue) {
774.
echoGedcom( $fp, $debugMode, 2, null, 'SOUR', '@S'.$eventSourceValue['id'].'@' );
775.
776.
if ($eventSourceValue['description']) {
777.
echoGedcom( $fp, $debugMode, 3, null, 'DATA', null);
778.
echoGedcom( $fp, $debugMode, 4, null, 'TEXT', $eventSourceValue['description'] );
779.
}
780.
if ($eventSourceValue['page'])
781.
echoGedcom( $fp, $debugMode, 3, null, 'PAGE', $eventSourceValue['page'] );
782.
if ($eventSourceValue['datecreated']) {
783.
echoGedcom( $fp, $debugMode, 2, null,'CHAN', null );
784.
echoGedcom( $fp, $debugMode, 3, null,'DATE', formatDate($eventSourceValue['datecreated']) );
785.
if (formatHour($eventSourceValue['datecreated']))
786.
echoGedcom( $fp, $debugMode, 4, null,'TIME', formatHour($eventSourceValue['datecreated']) );
787.
}
788.
echoGedcom( $fp, $debugMode, 3, null, 'QUAY', $eventSourceValue['quality'] );
789.
}
790.
}
791.
}
792.
793.
$indiFams = $myGedcom->selectIndiFAMS( $indival['id'] );
794.
if ($indiFams) echoGedcom( $fp, $debugMode, 1, null, 'FAMS', '@F'.$indiFams.'@' ); // famille de son couple (pointeur vers famille @F3@)
795.
$indiMotherId = $myGedcom->selectIndiParents( $indival['id'] );
796.
$indiMotherId = $indiMotherId[0]['person_2_id'];
797.
$indiFams = $myGedcom->selectIndiFAMS( $indiMotherId);
798.
if ($indiFams) echoGedcom( $fp, $debugMode, 1, null, 'FAMC', '@F'.$indiFams.'@' ); // famille de ses parents (pointeur vers famille @F1@)
799.
800.
if ($indival['datecreated']) {
801.
echoGedcom( $fp, $debugMode, 1, null,'CHAN', null );
802.
echoGedcom( $fp, $debugMode, 2, null,'DATE', formatDate($indival['datecreated']));
803.
}
804.
}
805.
806.
// -------------------------------------
807.
$fam0Results = $myGedcom->selectAllFAM( 'FAM0'); // Mariage, union ...
808.
if ($fam0Results === false) { echo "Erreur : ".$myGedcom->lasterror."<br>"; }
809.
foreach($fam0Results as $famkey=>$famval) {
810.
echoGedcom( $fp, $debugMode, 0, '@F'.$famval['id'].'@', 'FAM', null );
811.
echoGedcom( $fp, $debugMode, 1, null, 'HUSB', '@I'.$famval['hid'].'@' );
812.
echoGedcom( $fp, $debugMode, 1, null, 'WIFE', '@I'.$famval['wid'].'@' );
813.
echoGedcom( $fp, $debugMode, 1, null, $famval['code'], null ); // MARR, UNION ...
814.
815.
$marDateEvent = $myGedcom->selectEventDate( $famval['id'], $famval['code'] );
816.
if ($marDateEvent['date_begin']) {
817.
echoGedcom( $fp, $debugMode, 2, null,'DATE', formatDate($marDateEvent['date_begin'])); // HOUR not allowed
818.
}
819.
820.
$eventPlace = $myGedcom->selectEventPlace( $famval['id'], $famval['code'] );
821.
if ($eventPlace) {
822.
echoGedcom( $fp, $debugMode, 2, null,'PLAC', $eventPlace['plac'] );
823.
if ($eventPlace['gpslat'] and $eventPlace['gpslon']) {
824.
echoGedcom( $fp, $debugMode, 3, null,'MAP', null );
825.
echoGedcom( $fp, $debugMode, 4, null,'LATI', $eventPlace['gpslat'] );
826.
echoGedcom( $fp, $debugMode, 4, null,'LONG', $eventPlace['gpslon'] );
827.
}
828.
}
829.
830.
$famchildResults = $myGedcom->selectFAMCHILD( $famval['wid'] ); // ou $famval['hid']
831.
if ($famchildResults === false) { echo "Erreur : ".$myGedcom->lasterror."<br>"; }
832.
foreach($famchildResults as $famchildkey=>$famchildval) {
833.
echoGedcom( $fp, $debugMode, 1, null, 'CHIL', '@I'.$famchildval['id'].'@' );
834.
}
835.
836.
// Evenements suite au mariage, union : divorce, séparation ...
837.
$fam1Results = $myGedcom->selectAllFAM1( 'FAM1' , $famval['wid'] ); // Mariage, union ...
838.
if ($fam1Results === false) { echo "Erreur : ".$myGedcom->lasterror."<br>"; }
839.
foreach($fam1Results as $fam1key=>$fam1val) {
840.
echoGedcom( $fp, $debugMode, 1, null, $fam1val['code'], null );
841.
$marDateEvent = $myGedcom->selectEventDate( $fam1val['id'], $fam1val['code'] );
842.
if ($marDateEvent['date_begin']) {
843.
echoGedcom( $fp, $debugMode, 2, null,'DATE', formatDate($marDateEvent['date_begin'])); // HOUR not allowed
844.
}
845.
846.
$eventPlace = $myGedcom->selectEventPlace( $fam1val['id'], $fam1val['code'] );
847.
if ($eventPlace) {
848.
echoGedcom( $fp, $debugMode, 2, null,'PLAC', $eventPlace['plac'] );
849.
if ($eventPlace['gpslat'] and $eventPlace['gpslon']) {
850.
echoGedcom( $fp, $debugMode, 3, null,'MAP', null);
851.
echoGedcom( $fp, $debugMode, 4, null,'LATI', $eventPlace['gpslat'] );
852.
echoGedcom( $fp, $debugMode, 4, null,'LONG', $eventPlace['gpslon'] );
853.
}
854.
}
855.
856.
}
857.
858.
if ($famval['datecreated']) {
859.
echoGedcom( $fp, $debugMode, 1, null,'CHAN', null );
860.
echoGedcom( $fp, $debugMode, 2, null,'DATE', formatDate($famval['datecreated']));
861.
}
862.
}
863.
864.
// -------------------------------------------
865.
// --- SOURCES
866.
/*2 SOUR @SOURCE1@
867.
3 PAGE 42
868.
3 DATA
869.
4 DATE 31 DEC 1900
870.
4 TEXT Some death source text.
871.
3 QUAY 3
872.
3 NOTE A death source note.
873.
* */
874.
// -------------------------------------------
875.
$sourceResults = $myGedcom->selectAllSOURCE();
876.
if ($sourceResults === false) { echo "Erreur : ".$myGedcom->lasterror."<br>"; }
877.
foreach($sourceResults as $sourcekey=>$sourceval) {
878.
echoGedcom( $fp, $debugMode, 0, '@S'.$sourceval['id'].'@', 'SOUR', null );
879.
880.
echoGedcom( $fp, $debugMode, 1, null, 'TITL', $sourceval['name'] );
881.
if ($sourceval['description'])
882.
echoGedcom( $fp, $debugMode, 1, null, 'TEXT', $sourceval['description'] );
883.
//if ($sourceval['quality'])
884.
//echoGedcom( $fp, $debugMode, 2, null, 'QUAY', $sourceval['quality'] );
885.
if ($sourceval['datecreated']) {
886.
echoGedcom( $fp, $debugMode, 1, null,'CHAN', null );
887.
echoGedcom( $fp, $debugMode, 2, null,'DATE', formatDate($sourceval['datecreated']) );
888.
if (formatHour($sourceval['datecreated']))
889.
echoGedcom( $fp, $debugMode, 3, null,'TIME', formatHour($sourceval['datecreated']) );
890.
}
891.
892.
/*if ($sourceval['page'])
893.
echoGedcom( $fp, $debugMode, 1, null, 'PAGE', $sourceval['page'] );
894.
// -> level 3(2) DATA
895.
echoGedcom( $fp, $debugMode, 1, null, 'DATA', null );
896.
echoGedcom( $fp, $debugMode, 2, null, 'DATE', formatDate($sourceval['date_created']));
897.
*/
898.
899.
if ($sourceval['depot_id'])
900.
echoGedcom( $fp, $debugMode, 1, null, 'REPO', '@R'.$sourceval['depot_id'].'@' );
901.
902.
}
903.
904.
// -------------------------------------------
905.
// --- MEDIAS / OBJECTS
906.
// -------------------------------------------
907.
$mediaResults = $myGedcom->selectAllOBJ();
908.
if ($mediaResults === false) { echo "Erreur : ".$myGedcom->lasterror."<br>"; }
909.
910.
foreach($mediaResults as $mediakey=>$mediaval) {
911.
echoGedcom( $fp, $debugMode, 0, '@M'.$mediaval['id'].'@', 'OBJE', null );
912.
913.
echoGedcom( $fp, $debugMode, 1, null, 'FILE', basename($mediaval['url'])==''?$mediaval['name']:basename($mediaval['url']) );
914.
915.
echoGedcom( $fp, $debugMode, 2, null, 'TITL', $mediaval['name'] );
916.
917.
echoGedcom( $fp, $debugMode, 2, null, 'FORM', $mediaval['code'] );
918.
919.
if ($mediaval['description'])
920.
echoGedcom( $fp, $debugMode, 1, null,'NOTE', formatDate($mediaval['description']));
921.
}
922.
923.
// -------------------------------------------
924.
// --- DEPOTS
925.
// -------------------------------------------
926.
$repoResults = $myGedcom->selectAllREPO();
927.
if ($repoResults === false) { echo "Erreur : ".$myGedcom->lasterror."<br>"; }
928.
foreach($repoResults as $repokey=>$repoval) {
929.
echoGedcom( $fp, $debugMode, 0, '@R'.$repoval['id'].'@', 'REPO', null );
930.
echoGedcom( $fp, $debugMode, 1, null, 'NAME', $repoval['name'] );
931.
if ($repoval['code']) echoGedcom( $fp, $debugMode, 1, null, 'REFN', $repoval['code'] );
932.
if ($repoval['adress_1']) echoGedcom( $fp, $debugMode, 1, null, 'ADDR', $repoval['adress_1'] );
933.
if ($repoval['adress_2']) echoGedcom( $fp, $debugMode, 2, null, 'ADR1', $repoval['adress_2'] );
934.
if ($repoval['zip']) echoGedcom( $fp, $debugMode, 2, null, 'POST', $repoval['zip'] );
935.
if ($repoval['city']) echoGedcom( $fp, $debugMode, 2, null, 'CITY', $repoval['city'] );
936.
if ($repoval['country']) echoGedcom( $fp, $debugMode, 2, null, 'CTRY', $repoval['country'] );
937.
938.
}
939.
940.
echoGedcom( $fp, $debugMode, 0, null, 'TRLR', null );
941.
942.
fclose($fp);
943.
944.
echo '</table></tt></div>';
945.
?>
946.
947.