1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* php-gedcom. |
4
|
|
|
* |
5
|
|
|
* php-gedcom is a library for parsing, manipulating, importing and exporting |
6
|
|
|
* GEDCOM 5.5 files in PHP 5.3+. |
7
|
|
|
* |
8
|
|
|
* @author Xiang Ming <[email protected]> |
9
|
|
|
* @copyright Copyright (c) 2010-2013, Xiang Ming |
10
|
|
|
* @license MIT |
11
|
|
|
* |
12
|
|
|
* @link http://github.com/mrkrstphr/php-gedcom |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace PhpGedcom\Writer; |
16
|
|
|
|
17
|
|
|
class Obje |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @param \PhpGedcom\Record\Obje $sour |
21
|
|
|
* @param int $level |
22
|
|
|
* |
23
|
|
|
* @return string |
24
|
|
|
*/ |
25
|
|
|
public static function convert(\PhpGedcom\Record\Obje &$obje) |
26
|
|
|
{ |
27
|
|
|
$level = 0; |
28
|
|
|
$output = ''; |
29
|
|
|
$id = $obje->getId(); |
|
|
|
|
30
|
|
|
if ($id) { |
31
|
|
|
$output .= $level.' '.$id." OBJE\n"; |
|
|
|
|
32
|
|
|
} else { |
33
|
|
|
return $output; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
// level up |
37
|
|
|
$level++; |
38
|
|
|
|
39
|
|
|
// FORM |
40
|
|
|
$form = $obje->getName(); |
|
|
|
|
41
|
|
|
if ($form) { |
42
|
|
|
$output .= $level.' FORM '.$form."\n"; |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
// TITL |
46
|
|
|
$titl = $obje->getTitl(); |
|
|
|
|
47
|
|
|
if ($titl) { |
48
|
|
|
$output .= $level.' TITL '.$titl."\n"; |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
// OBJE |
52
|
|
|
// This is same as FORM |
53
|
|
|
|
54
|
|
|
// RIN |
55
|
|
|
$rin = $obje->getRin(); |
|
|
|
|
56
|
|
|
if ($rin) { |
57
|
|
|
$output .= $level.' RIN '.$rin."\n"; |
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
// REFN |
61
|
|
|
$refn = $obje->getRefn(); |
|
|
|
|
62
|
|
|
if (!empty($refn) && count($refn) > 0) { |
|
|
|
|
63
|
|
|
foreach ($refn as $item) { |
64
|
|
|
if ($item) { |
65
|
|
|
$_convert = \PhpGedcom\Writer\Refn::convert($item, $level); |
66
|
|
|
$output .= $_convert; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
// BLOB |
72
|
|
|
$blob = $obje->getBlob(); |
|
|
|
|
73
|
|
|
if ($blob) { |
74
|
|
|
$output .= $level.' BLOB '.$blob."\n"; |
|
|
|
|
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
// NOTE |
78
|
|
|
$note = $obje->getNote(); |
|
|
|
|
79
|
|
|
if ($note && count($note) > 0) { |
80
|
|
|
foreach ($note as $item) { |
81
|
|
|
if ($item) { |
82
|
|
|
$_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level); |
83
|
|
|
$output .= $_convert; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
// CHAN |
89
|
|
|
$chan = $obje->getChan(); |
|
|
|
|
90
|
|
|
if ($chan) { |
91
|
|
|
$_convert = \PhpGedcom\Writer\Chan::convert($chan, $level); |
|
|
|
|
92
|
|
|
$output .= $_convert; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
// FILE |
96
|
|
|
$file = $obje->getFile(); |
|
|
|
|
97
|
|
|
if ($file) { |
98
|
|
|
$output .= $level.' FILE '.$file."\n"; |
|
|
|
|
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
// |
102
|
|
|
return $output; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|