Example #1
0
File: Char.php Project: hybr/jpm
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $char = new \PhpGedcom\Record\Head\Char();
     $char->setChar(trim($record[2]));
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'VERS':
                 $char->setVers(trim($record[2]));
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $char;
 }
Example #2
0
File: Data.php Project: hybr/jpm
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $data = new \PhpGedcom\Record\Head\Sour\Data();
     $data->setData(trim($record[2]));
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'DATE':
                 $data->setDate(trim($record[2]));
                 break;
             case 'COPR':
                 $data->setCopr(trim($record[2]));
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $data;
 }
Example #3
0
File: Even.php Project: hybr/jpm
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $even = new \PhpGedcom\Record\SourRef\Even();
     $even->setEven(trim($record[2]));
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'ROLE':
                 $even->setRole(trim($record[2]));
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $even;
 }
Example #4
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $identifier = $parser->normalizeIdentifier($record[2]);
     $depth = (int) $record[0];
     $caln = new \PhpGedcom\Record\Caln();
     $caln->setCaln($identifier);
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtolower(trim($record[1]));
         $lineDepth = (int) $record[0];
         if ($lineDepth <= $depth) {
             $parser->back();
             break;
         }
         if ($caln->hasAttribute($recordType)) {
             $caln->{'set' . $recordType}(trim($record[2]));
         } else {
             $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $caln;
 }
Example #5
0
File: Addr.php Project: hybr/jpm
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $line = isset($record[2]) ? trim($record[2]) : '';
     $addr = new \PhpGedcom\Record\Addr();
     $addr->setAddr($line);
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtolower(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         if ($addr->hasAttribute($recordType)) {
             $addr->{'set' . $recordType}(trim($record[2]));
         } else {
             if ($recordType == 'cont') {
                 // FIXME: Can have CONT on multiple attributes
                 $addr->setAddr($addr->getAddr() . "\n");
                 if (isset($record[2])) {
                     $addr->setAddr($addr->getAddr() . trim($record[2]));
                 }
             } else {
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
             }
         }
         $parser->forward();
     }
     return $addr;
 }
Example #6
0
File: Famc.php Project: hybr/jpm
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $famc = $parser->normalizeIdentifier($record[2]);
     $fam = new \PhpGedcom\Record\Indi\Famc();
     $fam->setFamc($famc);
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'PEDI':
                 $fam->setPedi(trim($record[2]));
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 $fam->addNote($note);
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $fam;
 }
Example #7
0
File: RepoRef.php Project: hybr/jpm
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $identifier = $parser->normalizeIdentifier($record[2]);
     $depth = (int) $record[0];
     $repo = new \PhpGedcom\Record\RepoRef();
     $repo->setRepo($identifier);
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $currentDepth = (int) $record[0];
         $recordType = strtoupper(trim($record[1]));
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'CALN':
                 $repo->addCaln(\PhpGedcom\Parser\Caln::parse($parser));
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 $repo->addNote($note);
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $repo;
 }
Example #8
0
File: Corp.php Project: hybr/jpm
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $corp = new \PhpGedcom\Record\Head\Sour\Corp();
     $corp->setCorp(trim($record[2]));
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'ADDR':
                 $corp->setAddr(\PhpGedcom\Parser\Addr::parse($parser));
                 break;
             case 'PHON':
                 $corp->addPhon(trim($record[2]));
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $corp;
 }
Example #9
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $parser->forward();
     $chan = new \PhpGedcom\Record\Chan();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = trim($record[1]);
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'DATE':
                 $chan->setDate(trim($record[2]));
                 break;
             case 'TIME':
                 $chan->setTime(trim($record[2]));
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 if ($note) {
                     $chan->addNote($note);
                 }
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $chan;
 }
Example #10
0
File: NoteRef.php Project: hybr/jpm
 /**
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $note = new \PhpGedcom\Record\NoteRef();
     if (preg_match('/^@(.*)@$/', trim($record[2]))) {
         $note->setIsReference(true);
         $note->setNote($parser->normalizeIdentifier($record[2]));
     } else {
         $before = $parser->getCurrentLine();
         $note->setIsReference(false);
         $note->setNote($parser->parseMultiLineRecord());
     }
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'SOUR':
                 $sour = \PhpGedcom\Parser\SourRef::parse($parser);
                 $note->addSour($sour);
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $note;
 }
Example #11
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     if (count($record) < 3) {
         $parser->logSkippedRecord('Missing family information; ' . get_class(), ' @ ' . __LINE__);
         $parser->skipToNextLevel($depth);
         return null;
     }
     $fams = $parser->normalizeIdentifier($record[2]);
     $fam = new \PhpGedcom\Record\Indi\Fams();
     $fam->setFams($fams);
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 if ($note) {
                     $fam->addNote($note);
                 }
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $fam;
 }
Example #12
0
File: Asso.php Project: hybr/jpm
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $asso = new \PhpGedcom\Record\Indi\Asso();
     $asso->setIndi($parser->normalizeIdentifier($record[2]));
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'RELA':
                 $asso->setRela(trim($record[2]));
                 break;
             case 'SOUR':
                 $sour = \PhpGedcom\Parser\SourRef::parse($parser);
                 $asso->addSour($sour);
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 $asso->addNote($note);
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $asso;
 }
Example #13
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $identifier = $parser->normalizeIdentifier($record[1]);
     $depth = (int) $record[0];
     $subm = new \PhpGedcom\Record\Subm();
     $subm->setSubm($identifier);
     $parser->getGedcom()->addSubm($subm);
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $currentDepth = (int) $record[0];
         $recordType = strtoupper(trim($record[1]));
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'NAME':
                 $subm->setName(isset($record[2]) ? trim($record[2]) : '');
                 break;
             case 'ADDR':
                 $addr = \PhpGedcom\Parser\Addr::parse($parser);
                 $subm->setAddr($addr);
                 break;
             case 'PHON':
                 $phone = \PhpGedcom\Parser\Phon::parse($parser);
                 $subm->addPhon($phone);
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 if ($note) {
                     $subm->addNote($note);
                 }
                 break;
             case 'OBJE':
                 $obje = \PhpGedcom\Parser\ObjeRef::parse($parser);
                 $subm->addObje($obje);
                 break;
             case 'CHAN':
                 $chan = \PhpGedcom\Parser\Chan::parse($parser);
                 $subm->setChan($chan);
                 break;
             case 'RIN':
                 $subm->setRin(isset($record[2]) ? trim($record[2]) : '');
                 break;
             case 'RFN':
                 $subm->setRfn(isset($record[2]) ? trim($record[2]) : '');
                 break;
             case 'LANG':
                 $subm->addLang(isset($record[2]) ? trim($record[2]) : '');
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $subm;
 }
Example #14
0
File: Subn.php Project: hybr/jpm
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $identifier = $parser->normalizeIdentifier($record[1]);
     $depth = (int) $record[0];
     $subn = new \PhpGedcom\Record\Subn();
     $subn->setId($identifier);
     $parser->getGedcom()->setSubn($subn);
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $currentDepth = (int) $record[0];
         $recordType = strtoupper(trim($record[1]));
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'SUBM':
                 $subn->setSubm($parser->normalizeIdentifier($record[2]));
                 break;
             case 'FAMF':
                 $subn->setFamf(trim($record[2]));
                 break;
             case 'TEMP':
                 $subn->setTemp(trim($record[2]));
                 break;
             case 'ANCE':
                 $subn->setAnce(trim($record[2]));
                 break;
             case 'DESC':
                 $subn->setDesc(trim($record[2]));
                 break;
             case 'ORDI':
                 $subn->setOrdi(trim($record[2]));
                 break;
             case 'RIN':
                 $subn->setRin(trim($record[2]));
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $subn;
 }
Example #15
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord(4);
     $identifier = $parser->normalizeIdentifier($record[1]);
     $depth = (int) $record[0];
     $note = new \PhpGedcom\Record\Note();
     $note->setId($identifier);
     if (isset($record[3])) {
         $note->setNote($record[3]);
     }
     $parser->getGedcom()->addNote($note);
     if (isset($record[3])) {
         $note->note = $record[3];
     }
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $currentDepth = (int) $record[0];
         $recordType = strtoupper(trim($record[1]));
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'RIN':
                 $note->setRin(trim($record[2]));
                 break;
             case 'CONT':
                 $note->setNote($note->getNote() . "\n");
                 if (isset($record[2])) {
                     $note->setNote($note->getNote() . $record[2]);
                 }
                 break;
             case 'CONC':
                 if (isset($record[2])) {
                     $note->setNote($note->getNote() . $record[2]);
                 }
                 break;
             case 'REFN':
                 $refn = \PhpGedcom\Parser\Refn::parse($parser);
                 $note->addRefn($refn);
                 break;
             case 'CHAN':
                 $chan = \PhpGedcom\Parser\Chan::parse($parser);
                 $note->setChan($chan);
                 break;
             case 'SOUR':
                 $sour = \PhpGedcom\Parser\SourRef::parse($parser);
                 $note->addSour($sour);
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $note;
 }
Example #16
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $sour = new \PhpGedcom\Record\SourRef();
     $sour->setSour($record[2]);
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'CONT':
                 $sour->setSour($sour->getSour() . "\n");
                 if (isset($record[2])) {
                     $sour->setSour($sour->getSour() . $record[2]);
                 }
                 break;
             case 'CONC':
                 if (isset($record[2])) {
                     $sour->setSour($sour->getSour() . $record[2]);
                 }
                 break;
             case 'TEXT':
                 $sour->setText($parser->parseMultiLineRecord());
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 if ($note) {
                     $sour->addNote($note);
                 }
                 break;
             case 'DATA':
                 $sour->setData(\PhpGedcom\Parser\Sour\Data::parse($parser));
                 break;
             case 'QUAY':
                 $sour->setQuay(trim($record[2]));
                 break;
             case 'PAGE':
                 $sour->setPage(trim($record[2]));
                 break;
             case 'EVEN':
                 $even = \PhpGedcom\Parser\SourRef\Even::parse($parser);
                 $sour->setEven($even);
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $sour;
 }
Example #17
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $identifier = $parser->normalizeIdentifier($record[1]);
     $depth = (int) $record[0];
     $obje = new \PhpGedcom\Record\Obje();
     $obje->setId($identifier);
     $parser->getGedcom()->addObje($obje);
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $currentDepth = (int) $record[0];
         $recordType = strtoupper(trim($record[1]));
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'FORM':
                 $obje->setForm(trim($record[2]));
                 break;
             case 'TITL':
                 $obje->setTitl(trim($record[2]));
                 break;
             case 'OBJE':
                 $obje->setForm($parser->normalizeIdentifier($record[2]));
                 break;
             case 'RIN':
                 $obje->setRin(trim($record[2]));
                 break;
             case 'REFN':
                 $refn = \PhpGedcom\Parser\Refn::parse($parser);
                 $obje->addRefn($refn);
                 break;
             case 'BLOB':
                 $obje->setBlob($parser->parseMultiLineRecord());
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 if ($note) {
                     $obje->addNote($note);
                 }
                 break;
             case 'CHAN':
                 $chan = \PhpGedcom\Parser\Chan::parse($parser);
                 $obje->setChan($chan);
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $obje;
 }
Example #18
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $name = new \PhpGedcom\Record\Indi\Name();
     $name->setName(trim($record[2]));
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'NPFX':
                 $name->setNpfx(trim($record[2]));
                 break;
             case 'GIVN':
                 $name->setGivn(trim($record[2]));
                 break;
             case 'NICK':
                 $name->setNick(trim($record[2]));
                 break;
             case 'SPFX':
                 $name->setSpfx(trim($record[2]));
                 break;
             case 'SURN':
                 $name->setSurn(trim($record[2]));
                 break;
             case 'NSFX':
                 $name->setNsfx(trim($record[2]));
                 break;
             case 'SOUR':
                 $sour = \PhpGedcom\Parser\SourRef::parse($parser);
                 $name->addSour($sour);
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 if ($note) {
                     $name->addNote($note);
                 }
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $name;
 }
Example #19
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $className = '\\PhpGedcom\\Record\\Indi\\' . ucfirst(strtolower(trim($record[1])));
     $lds = new $className();
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'STAT':
                 $lds->setStat(trim($record[2]));
                 break;
             case 'DATE':
                 $lds->setDate(trim($record[2]));
                 break;
             case 'PLAC':
                 $lds->setPlac(trim($record[2]));
                 break;
             case 'TEMP':
                 $lds->setTemp(trim($record[2]));
                 break;
             case 'SOUR':
                 $sour = \PhpGedcom\Parser\SourRef::parse($parser);
                 $lds->addSour($sour);
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 if ($note) {
                     $lds->addNote($note);
                 }
                 break;
             default:
                 $self = get_called_class();
                 $method = 'parse' . $recordType;
                 if (method_exists($self, $method)) {
                     $self::$method($parser, $lds);
                 } else {
                     $parser->logUnhandledRecord($self . ' @ ' . __LINE__);
                 }
         }
         $parser->forward();
     }
     return $lds;
 }
Example #20
0
File: Repo.php Project: hybr/jpm
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $identifier = $parser->normalizeIdentifier($record[1]);
     $depth = (int) $record[0];
     $repo = new \PhpGedcom\Record\Repo();
     $repo->setId($identifier);
     $parser->getGedcom()->addRepo($repo);
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $currentDepth = (int) $record[0];
         $recordType = strtoupper(trim($record[1]));
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'NAME':
                 $repo->setName(trim($record[2]));
                 break;
             case 'ADDR':
                 $addr = \PhpGedcom\Parser\Addr::parse($parser);
                 $repo->setAddr($addr);
                 break;
             case 'PHON':
                 $phon = \PhpGedcom\Parser\Phon::parse($parser);
                 $repo->addPhon($phon);
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 $repo->addNote($note);
                 break;
             case 'REFN':
                 $refn = \PhpGedcom\Parser\Refn::parse($parser);
                 $repo->addRefn($refn);
                 break;
             case 'CHAN':
                 $chan = \PhpGedcom\Parser\Chan::parse($parser);
                 $repo->setChan($chan);
                 break;
             case 'RIN':
                 $repo->setRin(trim($record[2]));
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $repo;
 }
Example #21
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $slgs = new \PhpGedcom\Record\Fam\Slgs();
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'STAT':
                 $slgs->setStat(trim($record[2]));
                 break;
             case 'DATE':
                 $slgs->setDate(trim($record[2]));
                 break;
             case 'PLAC':
                 $slgs->setPlac(trim($record[2]));
                 break;
             case 'TEMP':
                 $slgs->setTemp(trim($record[2]));
                 break;
             case 'SOUR':
                 $sour = \PhpGedcom\Parser\SourRef::parse($parser);
                 $slgs->addSour($sour);
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 if ($note) {
                     $slgs->addNote($note);
                 }
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $slgs;
 }
Example #22
0
 /**
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $obje = new \PhpGedcom\Record\ObjeRef();
     if (isset($record[2])) {
         $obje->setIsReference(true);
         $obje->setObje($parser->normalizeIdentifier($record[2]));
     } else {
         $obje->setIsReference(false);
     }
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'TITL':
                 $obje->setTitl(trim($record[2]));
                 break;
             case 'FILE':
                 $obje->setFile(trim($record[2]));
                 break;
             case 'FORM':
                 $obje->setForm(trim($record[2]));
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 if ($note) {
                     $obje->addNote($note);
                 }
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $obje;
 }
Example #23
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $data = new \PhpGedcom\Record\Sour\Data();
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'EVEN':
                 $data->addEven(\PhpGedcom\Parser\Sour\Data\Even::parse($parser));
                 break;
             case 'DATE':
                 $data->setDate(trim($record[2]));
                 break;
             case 'AGNC':
                 $data->setAgnc(trim($record[2]));
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 if ($note) {
                     $data->addNote($note);
                 }
                 break;
             case 'TEXT':
                 $data->setText($parser->parseMultiLineRecord());
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $data;
 }
Example #24
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $plac = new \PhpGedcom\Record\Indi\Even\Plac();
     if (isset($record[2])) {
         $plac->setPlac(trim($record[2]));
     }
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'FORM':
                 $plac->setForm(trim($record[2]));
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 if ($note) {
                     $plac->addNote($note);
                 }
                 break;
             case 'SOUR':
                 $sour = \PhpGedcom\Parser\SourRef::parse($parser);
                 $plac->addSour($sour);
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $plac;
 }
Example #25
0
File: Sour.php Project: hybr/jpm
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $source = new \PhpGedcom\Record\Head\Sour();
     $source->setSour(trim($record[2]));
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'VERS':
                 $source->setVers(trim($record[2]));
                 break;
             case 'NAME':
                 $source->setName(trim($record[2]));
                 break;
             case 'CORP':
                 $corp = \PhpGedcom\Parser\Head\Sour\Corp::parse($parser);
                 $source->setCorp($corp);
                 break;
             case 'DATA':
                 $data = \PhpGedcom\Parser\Head\Sour\Data::parse($parser);
                 $source->setData($data);
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $source;
 }
Example #26
0
File: Even.php Project: hybr/jpm
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $even = null;
     if (strtoupper(trim($record[1])) != 'EVEN') {
         $className = '\\PhpGedcom\\Record\\Indi\\' . ucfirst(strtolower(trim($record[1])));
         $even = new $className();
     } else {
         $even = new \PhpGedcom\Record\Indi\Even();
     }
     if (isset($record[1]) && strtoupper(trim($record[1])) != 'EVEN') {
         $even->setType(trim($record[1]));
     }
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'TYPE':
                 $even->setType(trim($record[2]));
                 break;
             case 'DATE':
                 $even->setDate(trim($record[2]));
                 break;
             case 'PLAC':
                 $plac = \PhpGedcom\Parser\Indi\Even\Plac::parse($parser);
                 $even->setPlac($plac);
                 break;
             case 'ADDR':
                 $even->setAddr(\PhpGedcom\Parser\Addr::parse($parser));
                 break;
             case 'PHON':
                 $phone = \PhpGedcom\Parser\Phone::parse($parser);
                 $even->addPhone($phone);
                 break;
             case 'CAUS':
                 $even->setCaus(trim($record[2]));
                 break;
             case 'AGE':
                 $even->setAge(trim($record[2]));
                 break;
             case 'AGNC':
                 $even->setAgnc(trim($record[2]));
                 break;
             case 'SOUR':
                 $sour = \PhpGedcom\Parser\SourRef::parse($parser);
                 $even->addSour($sour);
                 break;
             case 'OBJE':
                 $obje = \PhpGedcom\Parser\ObjeRef::parse($parser);
                 $even->addObje($obje);
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 $even->addNote($note);
                 break;
             default:
                 $self = get_called_class();
                 $method = 'parse' . $recordType;
                 if (method_exists($self, $method)) {
                     $self::$method($parser, $even);
                 } else {
                     $parser->logUnhandledRecord($self . ' @ ' . __LINE__);
                 }
         }
         $parser->forward();
     }
     return $even;
 }
Example #27
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $className = '\\PhpGedcom\\Record\\Indi\\' . ucfirst(strtolower(trim($record[1])));
     $attr = new $className();
     $attr->setType(trim($record[1]));
     if (isset($record[2])) {
         $attr->setAttr(trim($record[2]));
     }
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'TYPE':
                 $attr->setType(trim($record[2]));
                 break;
             case 'DATE':
                 $attr->setDate(trim($record[2]));
                 break;
             case 'PLAC':
                 $plac = \PhpGedcom\Parser\Indi\Even\Plac::parse($parser);
                 $attr->setPlac($plac);
                 break;
             case 'ADDR':
                 $attr->setAddr(\PhpGedcom\Parser\Addr::parse($parser));
                 break;
             case 'PHON':
                 $phone = \PhpGedcom\Parser\Phon::parse($parser);
                 $attr->addPhon($phone);
                 break;
             case 'CAUS':
                 $attr->setCaus(trim($record[2]));
                 break;
             case 'AGE':
                 $attr->setAge(trim($record[2]));
                 break;
             case 'AGNC':
                 $attr->setAgnc(trim($record[2]));
                 break;
             case 'SOUR':
                 $sour = \PhpGedcom\Parser\SourRef::parse($parser);
                 $attr->addSour($sour);
                 break;
             case 'OBJE':
                 $obje = \PhpGedcom\Parser\ObjeRef::parse($parser);
                 $attr->addObje($obje);
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 if ($note) {
                     $attr->addNote($note);
                 }
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $attr;
 }
Example #28
0
File: Head.php Project: hybr/jpm
 /**
  *
  * @param \PhpGedcom\Parser $parser
  * @return \PhpGedcom\Record\Head
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $identifier = $parser->normalizeIdentifier($record[1]);
     $depth = (int) $record[0];
     $head = new \PhpGedcom\Record\Head();
     $parser->getGedcom()->setHead($head);
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $currentDepth = (int) $record[0];
         $recordType = strtoupper(trim($record[1]));
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'SOUR':
                 $sour = \PhpGedcom\Parser\Head\Sour::parse($parser);
                 $head->setSour($sour);
                 break;
             case 'DEST':
                 $head->setDest(trim($record[2]));
                 break;
             case 'SUBM':
                 $head->setSubm($parser->normalizeIdentifier($record[2]));
                 break;
             case 'SUBN':
                 $head->setSubn($parser->normalizeIdentifier($record[2]));
                 break;
             case 'DEST':
                 $head->setDest(trim($record[2]));
                 break;
             case 'FILE':
                 $head->setFile(trim($record[2]));
                 break;
             case 'COPR':
                 $head->setCopr(trim($record[2]));
                 break;
             case 'LANG':
                 $head->setLang(trim($record[2]));
                 break;
             case 'DATE':
                 $date = \PhpGedcom\Parser\Head\Date::parse($parser);
                 $head->setDate($date);
                 break;
             case 'GEDC':
                 $gedc = \PhpGedcom\Parser\Head\Gedc::parse($parser);
                 $head->setGedc($gedc);
                 break;
             case 'CHAR':
                 $char = \PhpGedcom\Parser\Head\Char::parse($parser);
                 $head->setChar($char);
                 break;
             case 'PLAC':
                 $plac = \PhpGedcom\Parser\Head\Plac::parse($parser);
                 $head->setPlac($plac);
                 break;
             case 'NOTE':
                 $head->setNote($parser->parseMultiLineRecord());
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $head;
 }
Example #29
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $depth = (int) $record[0];
     $even = new \PhpGedcom\Record\Fam\Even();
     if (isset($record[1]) && strtoupper(trim($record[1])) != 'EVEN') {
         $even->setType(trim($record[1]));
     }
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'TYPE':
                 $even->setType(trim($record[2]));
                 break;
             case 'DATE':
                 $even->setDate(trim($record[2]));
                 break;
             case 'PLAC':
                 $plac = \PhpGedcom\Parser\Indi\Even\Plac::parse($parser);
                 $even->setPlac($plac);
                 break;
             case 'ADDR':
                 $addr = \PhpGedcom\Parser\Addr::parse($parser);
                 $even->setAddr($addr);
                 break;
             case 'PHON':
                 $phone = \PhpGedcom\Parser\Phon::parse($parser);
                 $even->addPhone($phone);
                 break;
             case 'CAUS':
                 $even->setCaus(trim($record[2]));
                 break;
             case 'AGE':
                 $even->setAge(trim($record[2]));
                 break;
             case 'AGNC':
                 $even->setAgnc(trim($record[2]));
                 break;
             case 'HUSB':
                 $husb = \PhpGedcom\Parser\Fam\Even\Husb::parse($parser);
                 $even->setHusb($husb);
                 break;
             case 'WIFE':
                 $wife = \PhpGedcom\Parser\Fam\Even\Wife::parse($parser);
                 $even->setWife($wife);
                 break;
             case 'SOUR':
                 $sour = \PhpGedcom\Parser\SourRef::parse($parser);
                 $even->addSour($sour);
                 break;
             case 'OBJE':
                 $obje = \PhpGedcom\Parser\ObjeRef::parse($parser);
                 $even->addObje($obje);
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 if ($note) {
                     $even->addNote($note);
                 }
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $even;
 }
Example #30
0
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $identifier = $parser->normalizeIdentifier($record[1]);
     $depth = (int) $record[0];
     $indi = new \PhpGedcom\Record\Indi();
     $indi->setId($identifier);
     $parser->getGedcom()->addIndi($indi);
     $parser->forward();
     while (!$parser->eof()) {
         $record = $parser->getCurrentLineRecord();
         $recordType = strtoupper(trim($record[1]));
         $currentDepth = (int) $record[0];
         if ($currentDepth <= $depth) {
             $parser->back();
             break;
         }
         switch ($recordType) {
             case 'NAME':
                 $name = \PhpGedcom\Parser\Indi\Name::parse($parser);
                 $indi->addName($name);
                 break;
             case 'ALIA':
                 $indi->addAlia($parser->normalizeIdentifier($record[2]));
                 break;
             case 'SEX':
                 $indi->setSex(trim($record[2]));
                 break;
             case 'RIN':
                 $indi->setRin(trim($record[2]));
                 break;
             case 'RESN':
                 $indi->setResn(trim($record[2]));
                 break;
             case 'RFN':
                 $indi->setRfn(trim($record[2]));
                 break;
             case 'AFN':
                 $indi->setAfn(trim($record[2]));
                 break;
             case 'CHAN':
                 $chan = \PhpGedcom\Parser\Chan::parse($parser);
                 $indi->setChan($chan);
                 break;
             case 'FAMS':
                 $fams = \PhpGedcom\Parser\Indi\Fams::parse($parser);
                 if ($fams) {
                     $indi->addFams($fams);
                 }
                 break;
             case 'FAMC':
                 $famc = \PhpGedcom\Parser\Indi\Famc::parse($parser);
                 if ($famc) {
                     $indi->addFamc($famc);
                 }
                 break;
             case 'ASSO':
                 $asso = \PhpGedcom\Parser\Indi\Asso::parse($parser);
                 $indi->addAsso($asso);
                 break;
             case 'ANCI':
                 $indi->addAnci($parser->normalizeIdentifier($record[2]));
                 break;
             case 'DESI':
                 $indi->addDesi($parser->normalizeIdentifier($record[2]));
                 break;
             case 'SUBM':
                 $indi->addSubm($parser->normalizeIdentifier($record[2]));
                 break;
             case 'REFN':
                 $ref = \PhpGedcom\Parser\Refn::parse($parser);
                 $indi->addRefn($ref);
                 break;
             case 'BAPL':
             case 'CONL':
             case 'ENDL':
             case 'SLGC':
                 $className = ucfirst(strtolower($recordType));
                 $class = '\\PhpGedcom\\Parser\\Indi\\' . $className;
                 $lds = $class::parse($parser);
                 $indi->{'set' . $recordType}($lds);
                 break;
             case 'OBJE':
                 $obje = \PhpGedcom\Parser\ObjeRef::parse($parser);
                 $indi->addObje($obje);
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 if ($note) {
                     $indi->addNote($note);
                 }
                 break;
             case 'SOUR':
                 $sour = \PhpGedcom\Parser\SourRef::parse($parser);
                 $indi->addSour($sour);
                 break;
             case 'ADOP':
             case 'BIRT':
             case 'BAPM':
             case 'BARM':
             case 'BASM':
             case 'BLES':
             case 'BURI':
             case 'CENS':
             case 'CHR':
             case 'CHRA':
             case 'CONF':
             case 'CREM':
             case 'DEAT':
             case 'EMIG':
             case 'FCOM':
             case 'GRAD':
             case 'IMMI':
             case 'NATU':
             case 'ORDN':
             case 'RETI':
             case 'PROB':
             case 'WILL':
             case 'EVEN':
                 $className = ucfirst(strtolower($recordType));
                 $class = '\\PhpGedcom\\Parser\\Indi\\' . $className;
                 $event = $class::parse($parser);
                 $indi->addEven($event);
                 break;
             case 'CAST':
             case 'DSCR':
             case 'EDUC':
             case 'IDNO':
             case 'NATI':
             case 'NCHI':
             case 'NMR':
             case 'OCCU':
             case 'PROP':
             case 'RELI':
             case 'RESI':
             case 'SSN':
             case 'TITL':
                 $className = ucfirst(strtolower($recordType));
                 $class = '\\PhpGedcom\\Parser\\Indi\\' . $className;
                 $att = $class::parse($parser);
                 $indi->addAttr($att);
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $indi;
 }