示例#1
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;
 }
示例#2
0
文件: Asso.php 项目: 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;
 }
示例#3
0
文件: Famc.php 项目: 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;
 }
示例#4
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;
 }
示例#5
0
文件: RepoRef.php 项目: 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;
 }
示例#6
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;
 }
示例#7
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;
 }
示例#8
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;
 }
示例#9
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;
 }
示例#10
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;
 }
示例#11
0
文件: Repo.php 项目: 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;
 }
示例#12
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;
 }
示例#13
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;
 }
示例#14
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;
 }
示例#15
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;
 }
示例#16
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;
 }
示例#17
0
文件: Even.php 项目: 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;
 }
示例#18
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;
 }
示例#19
0
文件: Sour.php 项目: 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;
 }
示例#20
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;
 }
示例#21
0
文件: Fam.php 项目: 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;
 }