示例#1
0
文件: NoteRef.php 项目: 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;
 }
示例#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
 /**
  *
  *
  */
 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;
 }
示例#4
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;
 }
示例#5
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;
 }
示例#6
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;
 }
示例#7
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;
 }
示例#8
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;
 }
示例#9
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;
 }
示例#10
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;
 }
示例#11
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;
 }
示例#12
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;
 }