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\Indi; |
16
|
|
|
|
17
|
|
|
class Name |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @param \Gedcom\Record\Indi\Name $attr |
21
|
|
|
* @param int $level |
22
|
|
|
* |
23
|
|
|
* @return string |
24
|
|
|
*/ |
25
|
|
|
public static function convert(\Gedcom\Record\Indi\Name &$name, $level = 0) |
26
|
|
|
{ |
27
|
|
|
$output = ''; |
28
|
|
|
// NAME |
29
|
|
|
$_name = $name->getName(); |
30
|
|
|
if (empty($_name)) { |
31
|
|
|
return $output; |
32
|
|
|
} |
33
|
|
|
$output .= $level.' NAME '.$_name."\n"; |
34
|
|
|
// level up |
35
|
|
|
$level++; |
36
|
|
|
|
37
|
|
|
// NPFX |
38
|
|
|
$npfx = $name->getNpfx(); |
39
|
|
|
if (!empty($npfx)) { |
40
|
|
|
$output .= $level.' NPFX '.$npfx."\n"; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
// GIVN |
44
|
|
|
$givn = $name->getGivn(); |
45
|
|
|
if (!empty($givn)) { |
46
|
|
|
$output .= $level.' GIVN '.$givn."\n"; |
47
|
|
|
} |
48
|
|
|
// NICK |
49
|
|
|
$nick = $name->getNick(); |
50
|
|
|
if (!empty($nick)) { |
51
|
|
|
$output .= $level.' NICK '.$nick."\n"; |
52
|
|
|
} |
53
|
|
|
// SPFX |
54
|
|
|
$spfx = $name->getSpfx(); |
55
|
|
|
if (!empty($spfx)) { |
56
|
|
|
$output .= $level.' SPFX '.$spfx."\n"; |
57
|
|
|
} |
58
|
|
|
// SURN |
59
|
|
|
$surn = $name->getSurn(); |
60
|
|
|
if (!empty($surn)) { |
61
|
|
|
$output .= $level.' SURN '.$surn."\n"; |
62
|
|
|
} |
63
|
|
|
// NSFX |
64
|
|
|
$nsfx = $name->getNsfx(); |
65
|
|
|
if (!empty($nsfx)) { |
66
|
|
|
$output .= $level.' NSFX '.$nsfx."\n"; |
67
|
|
|
} |
68
|
|
|
// SOUR |
69
|
|
|
$sour = $name->getSour(); |
|
|
|
|
70
|
|
|
if (!empty($sour) && count($sour) > 0) { |
|
|
|
|
71
|
|
|
foreach ($sour as $item) { |
72
|
|
|
$_convert = \Gedcom\Writer\SourRef::convert($item, $level); |
73
|
|
|
$output .= $_convert; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
// note |
77
|
|
|
$note = $name->getSour(); |
78
|
|
|
if (!empty($note) && count($note) > 0) { |
79
|
|
|
foreach ($note as $item) { |
80
|
|
|
$_convert = \Gedcom\Writer\NoteRef::convert($item, $level); |
81
|
|
|
$output .= $_convert; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
return $output; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|