genealogiawebsite /
php-gedcom
| 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 Subm |
||||
| 18 | { |
||||
| 19 | /** |
||||
| 20 | * @param \PhpGedcom\Record\Subm $note |
||||
| 21 | * @param int $level |
||||
| 22 | * |
||||
| 23 | * @return string |
||||
| 24 | */ |
||||
| 25 | public static function convert(\PhpGedcom\Record\Subm &$subm) |
||||
| 26 | { |
||||
| 27 | $level = 0; |
||||
| 28 | $output = ''; |
||||
| 29 | $_subm = $subm->getSubn(); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 30 | if (empty($_subm)) { |
||||
| 31 | return $output; |
||||
| 32 | } else { |
||||
| 33 | $output .= $level.' '.$_subm.' SUBM '."\n"; |
||||
|
0 ignored issues
–
show
Are you sure
$_subm of type PhpGedcom\Record\Subm|mixed can be used in concatenation?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 34 | } |
||||
| 35 | // level up |
||||
| 36 | $level++; |
||||
| 37 | |||||
| 38 | // NAME |
||||
| 39 | $name = $subm->getName(); |
||||
| 40 | if (!empty($name)) { |
||||
| 41 | $output .= $level.' NAME '.$name."\n"; |
||||
| 42 | } |
||||
| 43 | // $chan |
||||
| 44 | $chan = $subm->getChan(); |
||||
| 45 | if ($chan) { |
||||
|
0 ignored issues
–
show
|
|||||
| 46 | $_convert = \PhpGedcom\Writer\Chan::convert($chan, $level); |
||||
| 47 | $output .= $_convert; |
||||
| 48 | } |
||||
| 49 | |||||
| 50 | // $addr |
||||
| 51 | $addr = $subm->getAddr(); |
||||
| 52 | if ($addr) { |
||||
|
0 ignored issues
–
show
|
|||||
| 53 | $_convert = \PhpGedcom\Writer\Addr::convert($addr, $level); |
||||
| 54 | $output .= $_convert; |
||||
| 55 | } |
||||
| 56 | |||||
| 57 | // $rin |
||||
| 58 | $rin = $subm->getRin(); |
||||
| 59 | if (!empty($rin)) { |
||||
| 60 | $output .= $level.' RIN '.$rin."\n"; |
||||
| 61 | } |
||||
| 62 | |||||
| 63 | // $rfn |
||||
| 64 | $rfn = $subm->getRfn(); |
||||
| 65 | if (!empty($rfn)) { |
||||
| 66 | $output .= $level.' RFN '.$rfn."\n"; |
||||
| 67 | } |
||||
| 68 | |||||
| 69 | // $lang = array() |
||||
| 70 | $langs = $subm->getLang(); |
||||
| 71 | if (!empty($langs) && count($langs) > 0) { |
||||
| 72 | foreach ($langs as $item) { |
||||
| 73 | if ($item) { |
||||
| 74 | $_convert = $level.' LANG '.$item."\n"; |
||||
| 75 | $output .= $_convert; |
||||
| 76 | } |
||||
| 77 | } |
||||
| 78 | } |
||||
| 79 | |||||
| 80 | // $phon = array() |
||||
| 81 | $phon = $subm->getLang(); |
||||
| 82 | if (!empty($phon) && count($phon) > 0) { |
||||
| 83 | foreach ($phon as $item) { |
||||
| 84 | if ($item) { |
||||
| 85 | $_convert = \PhpGedcom\Writer\Phon::convert($item, $level); |
||||
| 86 | $output .= $_convert; |
||||
| 87 | } |
||||
| 88 | } |
||||
| 89 | } |
||||
| 90 | |||||
| 91 | // $obje = array() |
||||
| 92 | $obje = $subm->getObje(); |
||||
| 93 | if (!empty($obje) && count($obje) > 0) { |
||||
| 94 | foreach ($obje as $item) { |
||||
| 95 | $_convert = \PhpGedcom\Writer\ObjeRef::convert($item, $level); |
||||
| 96 | $output .= $_convert; |
||||
| 97 | } |
||||
| 98 | } |
||||
| 99 | |||||
| 100 | // note |
||||
| 101 | $note = $subm->getNote(); |
||||
| 102 | if (!empty($note) && count($note) > 0) { |
||||
| 103 | foreach ($note as $item) { |
||||
| 104 | $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level); |
||||
| 105 | $output .= $_convert; |
||||
| 106 | } |
||||
| 107 | } |
||||
| 108 | |||||
| 109 | return $output; |
||||
| 110 | } |
||||
| 111 | } |
||||
| 112 |