Example #1
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 #2
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 #3
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 #4
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 #5
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;
 }
Example #6
0
File: Fam.php Project: hybr/jpm
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $identifier = $parser->normalizeIdentifier($record[1]);
     $depth = (int) $record[0];
     $fam = new \PhpGedcom\Record\Fam();
     $fam->setId($identifier);
     $parser->getGedcom()->addFam($fam);
     $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 'HUSB':
                 $fam->setHusb($parser->normalizeIdentifier($record[2]));
                 break;
             case 'WIFE':
                 $fam->setWife($parser->normalizeIdentifier($record[2]));
                 break;
             case 'CHIL':
                 $fam->addChil($parser->normalizeIdentifier($record[2]));
                 break;
             case 'NCHI':
                 $fam->setNchi(trim($record[2]));
                 break;
             case 'SUBM':
                 $fam->addSubm($parser->normalizeIdentifier($record[2]));
                 break;
             case 'RIN':
                 $fam->setRin(trim($record[2]));
                 break;
             case 'CHAN':
                 $chan = \PhpGedcom\Parser\Chan::parse($parser);
                 $fam->setChan($chan);
                 break;
             case 'SLGS':
                 $slgs = \PhpGedcom\Parser\Fam\Slgs::parse($parser);
                 $fam->addSlgs($slgs);
                 break;
             case 'REFN':
                 $ref = \PhpGedcom\Parser\Refn::parse($parser);
                 $fam->addRefn($ref);
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 $fam->addNote($note);
                 break;
             case 'SOUR':
                 $sour = \PhpGedcom\Parser\SourRef::parse($parser);
                 $fam->addSour($sour);
                 break;
             case 'OBJE':
                 $obje = \PhpGedcom\Parser\ObjeRef::parse($parser);
                 $fam->addObje($obje);
                 break;
             case 'EVEN':
             case 'ANUL':
             case 'CENS':
             case 'DIV':
             case 'DIVF':
             case 'ENGA':
             case 'MARR':
             case 'MARB':
             case 'MARC':
             case 'MARL':
             case 'MARS':
                 $className = ucfirst(strtolower($recordType));
                 $class = '\\PhpGedcom\\Parser\\Fam\\' . $className;
                 $even = $class::parse($parser);
                 $fam->addEven($even);
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $fam;
 }
Example #7
0
File: Sour.php Project: hybr/jpm
 /**
  *
  *
  */
 public static function parse(\PhpGedcom\Parser $parser)
 {
     $record = $parser->getCurrentLineRecord();
     $identifier = $parser->normalizeIdentifier($record[1]);
     $depth = (int) $record[0];
     $sour = new \PhpGedcom\Record\Sour();
     $sour->setId($identifier);
     $parser->getGedcom()->addSour($sour);
     $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 'TITL':
                 $sour->setTitl($parser->parseMultilineRecord());
                 break;
             case 'RIN':
                 $sour->setRin(trim($record[2]));
                 break;
             case 'AUTH':
                 $sour->setAuth($parser->parseMultilineRecord());
                 break;
             case 'TEXT':
                 $sour->setText($parser->parseMultilineRecord());
                 break;
             case 'PUBL':
                 $sour->setPubl($parser->parseMultilineRecord());
                 break;
             case 'ABBR':
                 $sour->setAbbr(trim($record[2]));
                 break;
             case 'REPO':
                 $sour->setRepo(\PhpGedcom\Parser\RepoRef::parse($parser));
                 break;
             case 'NOTE':
                 $note = \PhpGedcom\Parser\NoteRef::parse($parser);
                 $sour->addNote($note);
                 break;
             case 'DATA':
                 $sour->setData(\PhpGedcom\Parser\Sour\Data::parse($parser));
                 break;
             case 'OBJE':
                 $obje = \PhpGedcom\Parser\ObjeRef::parse($parser);
                 $sour->addObje($obje);
                 break;
             case 'REFN':
                 $refn = \PhpGedcom\Parser\Refn::parse($parser);
                 $sour->addRefn($refn);
                 break;
             case 'CHAN':
                 $chan = \PhpGedcom\Parser\Chan::parse($parser);
                 $sour->setChan($chan);
                 break;
             default:
                 $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
         }
         $parser->forward();
     }
     return $sour;
 }
Example #8
0
 /**
  *
  *
  */
 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);
                 if ($note) {
                     $even->addNote($note);
                 }
                 break;
             case 'CHAN':
                 $change = Chan::parse($parser);
                 $even->setChan($change);
                 break;
             default:
                 $self = get_called_class();
                 $method = 'parse' . $recordType;
                 if (method_exists($self, $method)) {
                     $self::$method($parser, $even);
                 } else {
                     $parser->logUnhandledRecord($self . ' @ ' . __LINE__);
                     $parser->skipToNextLevel($currentDepth);
                 }
         }
         $parser->forward();
     }
     return $even;
 }