|
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 SourRef |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @param \PhpGedcom\Record\SourRef $sour |
|
21
|
|
|
* @param int $level |
|
22
|
|
|
* |
|
23
|
|
|
* @return string |
|
24
|
|
|
*/ |
|
25
|
|
|
public static function convert(\PhpGedcom\Record\SourRef &$sour, $level) |
|
26
|
|
|
{ |
|
27
|
|
|
$output = ''; |
|
28
|
|
|
$_sour = $sour->getSour(); |
|
|
|
|
|
|
29
|
|
|
if (!empty($_sour)) { |
|
30
|
|
|
$output .= $level.' SOUR '.$_sour."\n"; |
|
|
|
|
|
|
31
|
|
|
} |
|
32
|
|
|
$level++; |
|
33
|
|
|
// protected $_text = null; |
|
34
|
|
|
$_text = $sour->getText(); |
|
|
|
|
|
|
35
|
|
|
if (!empty($_text)) { |
|
36
|
|
|
$output .= $level.' TEXT '.$_text."\n"; |
|
|
|
|
|
|
37
|
|
|
} |
|
38
|
|
|
// protected $_note = array(); |
|
39
|
|
|
$note = $sour->getNote(); |
|
|
|
|
|
|
40
|
|
|
if ($note && count($note) > 0) { |
|
|
|
|
|
|
41
|
|
|
foreach ($note as $item) { |
|
42
|
|
|
$_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level); |
|
43
|
|
|
$output .= $_convert; |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
// protected $_data = null; |
|
47
|
|
|
$_data = $sour->getData(); |
|
|
|
|
|
|
48
|
|
|
if ($_data) { |
|
49
|
|
|
$_convert = \PhpGedcom\Writer\Sour\Data::convert($_data, $level); |
|
|
|
|
|
|
50
|
|
|
$output .= $_convert; |
|
51
|
|
|
} |
|
52
|
|
|
// protected $_page setPage |
|
53
|
|
|
$_page = $sour->getPage(); |
|
|
|
|
|
|
54
|
|
|
if (!empty($_page)) { |
|
55
|
|
|
$output .= $level.' PAGE '.$_page."\n"; |
|
|
|
|
|
|
56
|
|
|
} |
|
57
|
|
|
// protected $_even = null; |
|
58
|
|
|
$_even = $sour->getData(); |
|
59
|
|
|
if ($_even) { |
|
60
|
|
|
$_convert = \PhpGedcom\Writer\SourRef\Even::convert($_even, $level); |
|
|
|
|
|
|
61
|
|
|
$output .= $_convert; |
|
62
|
|
|
} |
|
63
|
|
|
// protected $_quay |
|
64
|
|
|
$_quay = $sour->getQuay(); |
|
|
|
|
|
|
65
|
|
|
if (!empty($_quay)) { |
|
66
|
|
|
$output .= $level.' QUAY '.$_quay."\n"; |
|
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
// protected $_obje = array(); |
|
69
|
|
|
// This is not defined in parser. |
|
70
|
|
|
return $output; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|