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
|
|
|
* @package php-gedcom |
11
|
|
|
* @license MIT |
12
|
|
|
* @link http://github.com/mrkrstphr/php-gedcom |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace PhpGedcom\Writer; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* |
19
|
|
|
*/ |
20
|
|
|
class Subm |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @param \PhpGedcom\Record\Subm $note |
24
|
|
|
* @param int $level |
25
|
|
|
* @return string |
26
|
|
|
*/ |
27
|
|
|
public static function convert(\PhpGedcom\Record\Subm &$subm) |
28
|
|
|
{ |
29
|
|
|
$level = 0; |
30
|
|
|
$output = ""; |
31
|
|
|
$_subm = $subm->getSubn(); |
|
|
|
|
32
|
|
|
if(empty($_subm)){ |
33
|
|
|
return $output; |
34
|
|
|
}else{ |
35
|
|
|
$output.=$level." ".$_subm." SUBM "."\n"; |
|
|
|
|
36
|
|
|
} |
37
|
|
|
// level up |
38
|
|
|
$level++; |
39
|
|
|
|
40
|
|
|
// NAME |
41
|
|
|
$name = $subm->getName(); |
42
|
|
|
if(!empty($name)){ |
43
|
|
|
$output.=$level." NAME ".$name."\n"; |
44
|
|
|
} |
45
|
|
|
// $chan |
46
|
|
|
$chan = $subm->getChan(); |
47
|
|
|
if($chan){ |
|
|
|
|
48
|
|
|
$_convert = \PhpGedcom\Writer\Chan::convert($chan, $level); |
49
|
|
|
$output.=$_convert; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
// $addr |
53
|
|
|
$addr = $subm->getAddr(); |
54
|
|
|
if($addr){ |
|
|
|
|
55
|
|
|
$_convert = \PhpGedcom\Writer\Addr::convert($addr, $level); |
56
|
|
|
$output.=$_convert; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
// $rin |
60
|
|
|
$rin = $subm->getRin(); |
61
|
|
|
if(!empty($rin)){ |
62
|
|
|
$output.=$level." RIN ".$rin."\n"; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
// $rfn |
66
|
|
|
$rfn = $subm->getRfn(); |
67
|
|
|
if(!empty($rfn)){ |
68
|
|
|
$output.=$level." RFN ".$rfn."\n"; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
// $lang = array() |
72
|
|
|
$langs = $subm->getLang(); |
73
|
|
|
if(!empty($langs) && count($langs) > 0){ |
74
|
|
|
foreach($langs as $item){ |
75
|
|
|
if($item){ |
76
|
|
|
$_convert = $level." LANG ".$item."\n"; |
77
|
|
|
$output.=$_convert; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
// $phon = array() |
83
|
|
|
$phon = $subm->getLang(); |
84
|
|
|
if(!empty($phon) && count($phon) > 0){ |
85
|
|
|
foreach($phon as $item){ |
86
|
|
|
if($item){ |
87
|
|
|
$_convert = \PhpGedcom\Writer\Phon::convert($item, $level); |
88
|
|
|
$output.= $_convert; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
// $obje = array() |
94
|
|
|
$obje = $subm->getObje(); |
95
|
|
|
if(!empty($obje) && count($obje) > 0){ |
96
|
|
|
foreach($obje as $item){ |
97
|
|
|
$_convert = \PhpGedcom\Writer\ObjeRef::convert($item, $level); |
98
|
|
|
$output.=$_convert; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
// note |
103
|
|
|
$note = $subm->getNote(); |
104
|
|
|
if(!empty($note) && count($note) > 0){ |
105
|
|
|
foreach($note as $item){ |
106
|
|
|
$_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level); |
107
|
|
|
$output.=$_convert; |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
return $output; |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|