Skip to content

Commit

Permalink
CHECK AGAIN WRITER & FIX SMALL ISSUES
Browse files Browse the repository at this point in the history
  • Loading branch information
jyyblue committed Jun 18, 2020
1 parent c1e846b commit 15eb72f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion library/PhpGedcom/Parser/Head/Gedc.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function parse(\PhpGedcom\Parser $parser)

switch ($recordType) {
case 'VERS':
$gedc->setVers(trim($record[2]));
$gedc->setVersion(trim($record[2]));
break;
case 'FORM':
$gedc->setForm(trim($record[2]));
Expand Down
12 changes: 9 additions & 3 deletions library/PhpGedcom/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,17 @@ public static function convert(Gedcom $gedcom, $format = self::GEDCOM55)
$repos = $gedcom->getRepo(); // array()
$objes = $gedcom->getObje(); // array()

// head
$output = Head::convert($head, $format);
$output = $level." FORMAT ".$format."\n";

// head
if($head){
$output = Head::convert($head, $format);
}

// subn
$output .= Subn::convert($subn);
if($subn){
$output .= Subn::convert($subn);
}

// subms
if(!empty($subms) && count($subms) > 0){
Expand Down
4 changes: 1 addition & 3 deletions library/PhpGedcom/Writer/Head.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ public static function convert(\PhpGedcom\Record\Head &$head, $format = self::GE
// level up
$level++;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//SOUR
$sour = $head->getSour();
if($sour){
$_convert = \PhpGedcom\Writer\Head\Sour::convert($sour, $level);
$output.=$_convert;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// DEST
$dest = $head->getDest();
Expand Down Expand Up @@ -91,7 +89,7 @@ public static function convert(\PhpGedcom\Record\Head &$head, $format = self::GE
$output.=$_convert;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// CHAR
$char = $head->getChar();
if($char){
Expand Down
4 changes: 2 additions & 2 deletions library/PhpGedcom/Writer/Indi.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function convert(\PhpGedcom\Record\Indi &$indi, $format = self::GE
// $attr
// PhpGedcom/Record/Attr extend PhpGedcom/Record/Even and there is no change.
// So used convert Even
$attr = $indi->getAttr();
$attr = $indi->getAllAttr();
if(!empty($attr) && count($attr) > 0){
foreach($attr as $item){
$_convert = \PhpGedcom\Writer\Indi\Even::convert($item, $level);
Expand All @@ -59,7 +59,7 @@ public static function convert(\PhpGedcom\Record\Indi &$indi, $format = self::GE
}

// $even
$even = $indi->getEven();
$even = $indi->getAllEven();
if(!empty($even) && count($even) > 0){
foreach($even as $item){
$_convert = \PhpGedcom\Writer\Indi\Even::convert($item, $level);
Expand Down

0 comments on commit 15eb72f

Please sign in to comment.