|
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 Gedcom\Writer; |
|
16
|
|
|
|
|
17
|
|
|
class Repo |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @param \Gedcom\Record\Repo $sour |
|
21
|
|
|
* @param int $level |
|
22
|
|
|
* |
|
23
|
|
|
* @return string |
|
24
|
|
|
*/ |
|
25
|
|
|
public static function convert(\Gedcom\Record\Repo &$repo) |
|
26
|
|
|
{ |
|
27
|
|
|
$level = 0; |
|
28
|
|
|
$output = ''; |
|
29
|
|
|
$_repo = $repo->getRepo(); |
|
30
|
|
|
if ($_repo) { |
|
31
|
|
|
$output .= $level.' '.$_repo." REPO\n"; |
|
32
|
|
|
} else { |
|
33
|
|
|
return $output; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
// level up |
|
37
|
|
|
$level++; |
|
38
|
|
|
|
|
39
|
|
|
//NAME |
|
40
|
|
|
$name = $repo->getName(); |
|
41
|
|
|
if ($name) { |
|
42
|
|
|
$output .= $level.' NAME '.$name."\n"; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
// ADDR |
|
46
|
|
|
$addr = $repo->getAddr(); |
|
47
|
|
|
if ($addr) { |
|
|
|
|
|
|
48
|
|
|
$_convert = \Gedcom\Writer\Addr::convert($addr, $level); |
|
49
|
|
|
$output .= $_convert; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
// PHON |
|
53
|
|
|
$phon = $repo->getPhon(); |
|
54
|
|
|
if ($phon) { |
|
|
|
|
|
|
55
|
|
|
$_convert = \Gedcom\Writer\Phon::convert($phon, $level); |
|
|
|
|
|
|
56
|
|
|
$output .= $_convert; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
// NOTE array |
|
60
|
|
|
$note = $repo->getNote(); |
|
61
|
|
|
if ($note && count($note) > 0) { |
|
|
|
|
|
|
62
|
|
|
foreach ($note as $item) { |
|
63
|
|
|
if ($item) { |
|
64
|
|
|
$_convert = \Gedcom\Writer\NoteRef::convert($item, $level); |
|
65
|
|
|
$output .= $_convert; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
// REFN |
|
71
|
|
|
$refn = $repo->getRefn(); |
|
72
|
|
|
if (!empty($refn) && count($refn) > 0) { |
|
73
|
|
|
foreach ($refn as $item) { |
|
74
|
|
|
if ($item) { |
|
75
|
|
|
$_convert = \Gedcom\Writer\Refn::convert($item, $level); |
|
76
|
|
|
$output .= $_convert; |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
// CHAN |
|
82
|
|
|
$chan = $repo->getChan(); |
|
83
|
|
|
if ($chan) { |
|
|
|
|
|
|
84
|
|
|
$_convert = \Gedcom\Writer\Chan::convert($chan, $level); |
|
85
|
|
|
$output .= $_convert; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
// RIN |
|
89
|
|
|
$rin = $repo->getRin(); |
|
90
|
|
|
if ($rin) { |
|
91
|
|
|
$output .= $level.' RIN '.$rin."\n"; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
return $output; |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|