Exemple #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;
 }
Exemple #2
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;
 }
Exemple #3
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;
 }
Exemple #4
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;
 }
Exemple #5
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);
                 $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;
 }
Exemple #6
0
Fichier : Fam.php Projet : 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;
 }
Exemple #7
0
 /**
  *
  *
  */
 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;
 }