From 2dd2675dbaea2526af502d7d57b36a9705ad6cad Mon Sep 17 00:00:00 2001 From: thanh-dev0306 <87410617+thanh-dev0306@users.noreply.github.com> Date: Wed, 15 Dec 2021 21:21:09 +0700 Subject: [PATCH] working in exporte --- src/Commands/GedcomExporter.php | 92 +++++++ src/Facades/GedcomExpFacade.php | 13 + src/Utils/exporter/Addr.php | 45 +++ src/Utils/exporter/Caln.php | 32 +++ src/Utils/exporter/Chan.php | 37 +++ src/Utils/exporter/Date.php | 27 ++ src/Utils/exporter/Fam/Even.php | 162 +++++++++++ src/Utils/exporter/Fam/Slgs.php | 72 +++++ src/Utils/exporter/Indi/Alia.php | 25 ++ src/Utils/exporter/Indi/Anci.php | 30 ++ src/Utils/exporter/Indi/Asso.php | 47 ++++ src/Utils/exporter/Indi/Desi.php | 24 ++ src/Utils/exporter/Indi/Even.php | 376 ++++++++++++++++++++++++++ src/Utils/exporter/Indi/Even/Plac.php | 22 ++ src/Utils/exporter/Indi/Lds.php | 72 +++++ src/Utils/exporter/Indi/Name.php | 87 ++++++ src/Utils/exporter/Indi/Name/Fone.php | 53 ++++ src/Utils/exporter/Indi/Name/Romn.php | 50 ++++ src/Utils/exporter/Indi/Subm.php | 31 +++ src/Utils/exporter/Note.php | 59 ++++ src/Utils/exporter/NoteRef.php | 34 +++ src/Utils/exporter/Obje.php | 72 +++++ src/Utils/exporter/ObjeRef.php | 48 ++++ src/Utils/exporter/ObjeRef/File.php | 28 ++ src/Utils/exporter/Phon.php | 28 ++ src/Utils/exporter/Refn.php | 23 ++ src/Utils/exporter/Repo.php | 80 ++++++ src/Utils/exporter/RepoRef.php | 49 ++++ src/Utils/exporter/Sour.php | 75 +++++ src/Utils/exporter/Sour/Data.php | 44 +++ src/Utils/exporter/Sour/Data/Even.php | 24 ++ src/Utils/exporter/Sour/Repo.php | 52 ++++ src/Utils/exporter/SourRef.php | 73 +++++ src/Utils/exporter/SourRef/Even.php | 24 ++ src/Utils/exporter/Subm.php | 92 +++++++ src/Utils/exporter/Subn.php | 47 ++++ 36 files changed, 2149 insertions(+) create mode 100644 src/Commands/GedcomExporter.php create mode 100644 src/Facades/GedcomExpFacade.php create mode 100644 src/Utils/exporter/Addr.php create mode 100644 src/Utils/exporter/Caln.php create mode 100644 src/Utils/exporter/Chan.php create mode 100644 src/Utils/exporter/Date.php create mode 100644 src/Utils/exporter/Fam/Even.php create mode 100644 src/Utils/exporter/Fam/Slgs.php create mode 100644 src/Utils/exporter/Indi/Alia.php create mode 100644 src/Utils/exporter/Indi/Anci.php create mode 100644 src/Utils/exporter/Indi/Asso.php create mode 100644 src/Utils/exporter/Indi/Desi.php create mode 100644 src/Utils/exporter/Indi/Even.php create mode 100644 src/Utils/exporter/Indi/Even/Plac.php create mode 100644 src/Utils/exporter/Indi/Lds.php create mode 100644 src/Utils/exporter/Indi/Name.php create mode 100644 src/Utils/exporter/Indi/Name/Fone.php create mode 100644 src/Utils/exporter/Indi/Name/Romn.php create mode 100644 src/Utils/exporter/Indi/Subm.php create mode 100644 src/Utils/exporter/Note.php create mode 100644 src/Utils/exporter/NoteRef.php create mode 100644 src/Utils/exporter/Obje.php create mode 100644 src/Utils/exporter/ObjeRef.php create mode 100644 src/Utils/exporter/ObjeRef/File.php create mode 100644 src/Utils/exporter/Phon.php create mode 100644 src/Utils/exporter/Refn.php create mode 100644 src/Utils/exporter/Repo.php create mode 100644 src/Utils/exporter/RepoRef.php create mode 100644 src/Utils/exporter/Sour.php create mode 100644 src/Utils/exporter/Sour/Data.php create mode 100644 src/Utils/exporter/Sour/Data/Even.php create mode 100644 src/Utils/exporter/Sour/Repo.php create mode 100644 src/Utils/exporter/SourRef.php create mode 100644 src/Utils/exporter/SourRef/Even.php create mode 100644 src/Utils/exporter/Subm.php create mode 100644 src/Utils/exporter/Subn.php diff --git a/src/Commands/GedcomExporter.php b/src/Commands/GedcomExporter.php new file mode 100644 index 0000000..5d33acb --- /dev/null +++ b/src/Commands/GedcomExporter.php @@ -0,0 +1,92 @@ +argument('filename').".GED"; + + $file_path = $dir . '/' . $filename; + + if (!file_exists($dir)) { + Storage::makeDirectory($dir); + } + + $query = DB::table('subms'); + $query->join('addrs', 'addrs.id', '=', 'subms.addr_id'); + $query->select([ + 'subms.name', + 'addrs.adr1', + 'addrs.adr2', + 'addrs.city', + 'addrs.stae', + 'addrs.post', + 'addrs.ctry', + 'subms.phon', + ])->get(); + + $people = Person::all(); + $submissions = $query->get(); + + $data =array ( + 'submissions' => $submissions, + 'people' => $people, + ); + + $source = View::make('stubs.ged', $data)->render(); + + $ged_doc = "HEAD \nGEDC \nVERS 5.5.5 \nFORM LINEAGE-LINKED \nVERS 5.5.5 \nCHAR UTF-8 \nSOUR GS \nVERS 5.5.5 \nCORP gedcom.org\n"; + + $handle = fopen($filename, 'w'); + + fputs($handle, $ged_doc.$source); + + fclose($handle); + + $headers = array( + 'Content-Type' => 'text/ged', + ); + + } +} diff --git a/src/Facades/GedcomExpFacade.php b/src/Facades/GedcomExpFacade.php new file mode 100644 index 0000000..820e232 --- /dev/null +++ b/src/Facades/GedcomExpFacade.php @@ -0,0 +1,13 @@ +getAdr1(); + $adr2 = $addr->getAdr2(); + $city = $addr->getCity(); + $stae = $addr->getStae(); + $post = $addr->getPost(); + $ctry = $addr->getCtry(); + + $addr = MAddr::on($conn)->where([ + ['adr1', '=', $adr1], + ['adr2', '=', $adr2], + ['city', '=', $city], + + ['stae', '=', $stae], + ['post', '=', $post], + ['ctry', '=', $ctry], + ])->first(); + if ($addr !== null) { + $id = $addr->id; + } else { + $addr = MAddr::on($conn)->create(compact('adr1', 'adr2', 'city', 'stae', 'post', 'ctry')); + $id = $addr->id; + } + + return $id; + } +} diff --git a/src/Utils/exporter/Caln.php b/src/Utils/exporter/Caln.php new file mode 100644 index 0000000..a11845c --- /dev/null +++ b/src/Utils/exporter/Caln.php @@ -0,0 +1,32 @@ +getMedi(); + + $key = [ + 'group'=> $group, + 'gid' => $gid, + 'medi' => $medi, + ]; + $data = [ + 'group'=> $group, + 'gid' => $gid, + 'medi' => $medi, + ]; + $_caln = MCaln::on($conn)->updateOrCreate($key, $data); + } +} diff --git a/src/Utils/exporter/Chan.php b/src/Utils/exporter/Chan.php new file mode 100644 index 0000000..dc36af0 --- /dev/null +++ b/src/Utils/exporter/Chan.php @@ -0,0 +1,37 @@ +getDate(); + $time = $chan->getTime(); + + // store chan + $key = ['group'=>$group, 'gid'=>$group_id, 'date'=>$date, 'time'=>$time]; + $data = ['group'=>$group, 'gid'=>$group_id, 'date'=>$date, 'time'=>$time]; + $record = MChan::on($conn)->updateOrCreate($key, $data); + + // store Sources of Note + $_group = 'chan'; + $_gid = $record->id; + // SourRef array + $note = $chan->getNote(); + if ($note && count($note) > 0) { + foreach ($note as $item) { + if ($item) { + NoteRef::read($conn, $item, $_group, $_gid); + } + } + } + } +} diff --git a/src/Utils/exporter/Date.php b/src/Utils/exporter/Date.php new file mode 100644 index 0000000..3ad8f4b --- /dev/null +++ b/src/Utils/exporter/Date.php @@ -0,0 +1,27 @@ +getDate(); + } + } else { + // $input_date = Carbon::parse($input_date)->timestamp; + return "$input_date"; + } + } +} diff --git a/src/Utils/exporter/Fam/Even.php b/src/Utils/exporter/Fam/Even.php new file mode 100644 index 0000000..84773bc --- /dev/null +++ b/src/Utils/exporter/Fam/Even.php @@ -0,0 +1,162 @@ +getType(); + $_date = $even->getDate(); + $date = \FamilyTree365\LaravelGedcom\Utils\Importer\Date::read($conn, $_date); + if (strpos($date, 'BEF') !== false) { + $newdate = trim(str_replace('BEF', '', $date)); + $date_cnvert = strtotime($newdate); + } elseif (strpos($date, 'AFT') !== false) { + $newdate = trim(str_replace('AFT', '', $date)); + $date_cnvert = strtotime($newdate); + } else { + $date_cnvert = strtotime($date); + } + $_plac = $even->getPlac(); + $plac = \FamilyTree365\LaravelGedcom\Utils\Importer\Indi\Even\Plac::read($conn, $_plac); + $_phon = $even->getPhon(); + $phon = \FamilyTree365\LaravelGedcom\Utils\Importer\Phon::read($conn, $_phon); + $_addr = $even->getAddr(); + $addr_id = \FamilyTree365\LaravelGedcom\Utils\Importer\Addr::read($conn, $_addr); + $caus = $even->getCaus(); + $age = $even->getAge(); + $agnc = $even->getAgnc(); + $fam_id = $fam->id; + $husb_id = $fam->husband_id; + $wife_id = $fam->wife_id; + // update husb age + $_husb = $even->getHusb(); + if ($_husb) { + $husb = Person::on($conn)->find($husb_id); + if ($husb) { + $husb->age = $_husb->getAge(); + $husb->save(); + } + } + + // update wife age + $_wife = $even->getWife(); + if ($_wife) { + $wife = Person::on($conn)->find($wife_id); + if ($wife) { + $wife->age = $_wife->getAge(); + $wife->save(); + } + } + + switch ($class_name) { + case 'Even': + break; + case 'Anul': + break; + case 'Cens': + break; + case 'Div': + break; + case 'Divf': + break; + case 'Enga': + break; + case 'Marr': + break; + case 'Marb': + break; + case 'Marc': + break; + case 'Marl': + break; + case 'Mars': + break; + default: + } + $adop = ''; + $adop_famc = ''; + $birt_famc = ''; + // store Fam/Even + $key = [ + 'family_id' => $fam_id, + 'title' => $class_name, + 'type' => $type, + 'date' => $date, + 'converted_date' => $date_cnvert, + 'plac' => $plac, + 'phon' => $phon, + 'caus' => $caus, + 'age' => $age, + 'agnc' => $agnc, + 'husb' => $husb_id, + 'wife' => $wife_id, + ]; + $data = [ + 'family_id' => $fam_id, + 'title' => $class_name, + 'type' => $type, // + 'date' => $date, + 'converted_date' => $date_cnvert, + 'plac' => $plac, // + 'addr_id' => $addr_id, // + 'phon' => $phon, // + 'caus' => $caus, // + 'age' => $age, // + 'agnc' => $agnc, // + 'husb' => $husb_id, // + 'wife' => $wife_id, // + ]; + + $record = FamilyEvent::on($conn)->updateOrCreate($key, $data); + + $_group = 'fam_even'; + $_gid = $record->id; + + // array + $sour = $even->getSour(); + if ($sour && count($sour) > 0) { + foreach ($sour as $item) { + if ($item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\SourRef::read($conn, $item, $_group, $_gid); + } + } + } + $obje = $even->getObje(); + if ($obje && count($obje) > 0) { + foreach ($obje as $item) { + if ($item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\ObjeRef::read($conn, $item, $_group, $_gid, $obje_ids); + } + } + } + $notes = $even->getNote(); + if ($notes && count($notes) > 0) { + foreach ($notes as $item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $item, $_group, $_gid); + } + } + } + catch(Throwable $e) + { + report($e); + } + } +} diff --git a/src/Utils/exporter/Fam/Slgs.php b/src/Utils/exporter/Fam/Slgs.php new file mode 100644 index 0000000..16bc2d1 --- /dev/null +++ b/src/Utils/exporter/Fam/Slgs.php @@ -0,0 +1,72 @@ +getStat(); + $date = $slgs->getDate(); + $plac = $slgs->getPlac(); + $temp = $slgs->getTemp(); + + $key = [ + 'family_id'=> $fam->id, + 'stat' => $stat, + 'date' => $date, + 'plac' => $plac, + 'temp' => $temp, + ]; + $data = [ + 'family_id'=> $fam->id, + 'stat' => $stat, + 'date' => $date, + 'plac' => $plac, + 'temp' => $temp, + ]; + + $record = FamilySlgs::on($conn)->updateOrCreate($key, $data); + + $_group = 'fam_slgs'; + $_gid = $record->id; + + // array + $sour = $slgs->getSour(); + if ($sour && count($sour) > 0) { + foreach ($sour as $item) { + if ($item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\SourRef::read($conn, $item, $_group, $_gid); + } + } + } + + $note = $slgs->getNote(); + if ($note && count($note) > 0) { + foreach ($note as $item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $item, $_group, $_gid); + } + } + } + catch(Throwable $e) + { + report($e); + } + } +} diff --git a/src/Utils/exporter/Indi/Alia.php b/src/Utils/exporter/Indi/Alia.php new file mode 100644 index 0000000..2bdf5c1 --- /dev/null +++ b/src/Utils/exporter/Indi/Alia.php @@ -0,0 +1,25 @@ +$group, 'gid'=>$group_id, 'alia'=>$alia]; + $aliaData[] = $data; + } + } + PersonAlia::on($conn)->insert($aliaData); + } +} diff --git a/src/Utils/exporter/Indi/Anci.php b/src/Utils/exporter/Indi/Anci.php new file mode 100644 index 0000000..c287e20 --- /dev/null +++ b/src/Utils/exporter/Indi/Anci.php @@ -0,0 +1,30 @@ +$group, 'gid'=>$group_id, 'anci'=>$subm_id]; + $data = ['group'=>$group, 'gid'=>$group_id, 'anci'=>$subm_id]; + $record[] = $data; + } + } + } + PersonAnci::insert($record); + } +} diff --git a/src/Utils/exporter/Indi/Asso.php b/src/Utils/exporter/Indi/Asso.php new file mode 100644 index 0000000..0cbb872 --- /dev/null +++ b/src/Utils/exporter/Indi/Asso.php @@ -0,0 +1,47 @@ +getIndi(); + $rela = $asso->getRela(); + + // store asso + $key = ['group'=>$group, 'gid'=>$group_id, 'rela'=>$rela, 'indi' => $_indi]; + $data = ['group'=>$group, 'gid'=>$group_id, 'rela'=>$rela, 'indi' => $_indi]; + $record = PersonAsso::on($conn)->updateOrCreate($key, $data); + + $_group = 'indi_asso'; + $_gid = $record->id; + // store Note + $note = $asso->getNote(); + if ($note && count($note) > 0) { + foreach ($note as $item) { + if ($item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $item, $_group, $_gid); + } + } + } + + // store sourref + $sour = $asso->getSour(); + if ($sour && count($sour) > 0) { + foreach ($sour as $item) { + if ($item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\SourRef::read($conn, $item, $_group, $_gid); + } + } + } + } +} diff --git a/src/Utils/exporter/Indi/Desi.php b/src/Utils/exporter/Indi/Desi.php new file mode 100644 index 0000000..71167af --- /dev/null +++ b/src/Utils/exporter/Indi/Desi.php @@ -0,0 +1,24 @@ +$group, 'gid'=>$group_id, 'desi'=>$desi]; + $data = ['group'=>$group, 'gid'=>$group_id, 'desi'=>$desi]; + $record = PersonDesi::on($conn)->updateOrCreate($key, $data); + } + } +} diff --git a/src/Utils/exporter/Indi/Even.php b/src/Utils/exporter/Indi/Even.php new file mode 100644 index 0000000..3e0ab97 --- /dev/null +++ b/src/Utils/exporter/Indi/Even.php @@ -0,0 +1,376 @@ + 0) { + $even = $event[0]; + $class_name = get_class($even); + $person_id = $person->id; + $type = $even->getType(); + $attr = $even->getAttr(); + $_date = $even->getDate(); + $date = \FamilyTree365\LaravelGedcom\Utils\Importer\Date::read($conn, $_date); + if (strpos($date, 'BEF') !== false) { + $newdate = trim(str_replace('BEF', '', $date)); + $date_cnvert = strtotime($newdate); + } elseif (strpos($date, 'AFT') !== false) { + $newdate = trim(str_replace('AFT', '', $date)); + $date_cnvert = strtotime($newdate); + } else { + $date_cnvert = strtotime($date); + } + $_plac = $even->getPlac(); + $plac = \FamilyTree365\LaravelGedcom\Utils\Importer\Indi\Even\Plac::read($conn, $_plac); + $_phon = $even->getPhon(); + $phon = \FamilyTree365\LaravelGedcom\Utils\Importer\Phon::read($conn, $_phon); + $_addr = $even->getAddr(); + //$addr_id = \FamilyTree365\LaravelGedcom\Utils\Importer\Addr::read($conn, $_addr); + if (!empty($_addr)) { + $addr_id = \FamilyTree365\LaravelGedcom\Utils\Importer\Addr::read($conn, $_addr); + } else { + $addr_id = null; + } + + $caus = $even->getCaus(); + $age = $even->getAge(); + $agnc = $even->getAgnc(); + $adop = ''; + $adop_famc = ''; + $birt_famc = ''; + switch ($class_name) { + case 'Adop': + $adop = $even->getAdop(); + $adop_famc = $even->getFamc(); + break; + case 'Birt': + $birt_famc = $even->getFamc(); + break; + case 'Bapm': + break; + case 'Barm': + break; + case 'Basm': + break; + case 'Bles': + break; + case 'Buri': + break; + case 'Cast': + break; + case 'Cens': + break; + case 'Chr': + $chr_famc = $even->getFamc(); + break; + case 'Chra': + break; + case 'Conf': + break; + case 'Crem': + break; + case 'Dscr': + break; + case 'Deat': + break; + case 'Educ': + break; + case 'Emig': + break; + case 'Fcom': + break; + case 'Grad': + break; + case 'Idno': + break; + case 'Immi': + break; + case 'Nati': + break; + case 'Nchi': + break; + case 'Natu': + break; + case 'Nmr': + break; + case 'Occu': + break; + case 'Ordn': + break; + case 'Reti': + break; + case 'Prob': + break; + case 'Prop': + break; + case 'Reli': + break; + case 'Resi': + break; + case 'Ssn': + break; + case 'Titl': + break; + case 'Will': + break; + case 'Even': + break; + default: + } + $adop = ''; + $adop_famc = ''; + $birt_famc = ''; + // store Even + $key = [ + ['person_id', $person_id], + ['title', $class_name], + ['type', $type], + ['attr', $attr], + ['date', $date], + ['plac', $plac], + ['phon', $phon], + ['caus', $caus], + ['age', $age], + ['agnc', $agnc], + ['adop', $adop], + ['adop_famc', $adop_famc], + ['birt_famc', $birt_famc], + ]; + $check = PersonEvent::on($conn)->where($key)->first(); + if (empty($check)) { + $data = [ + 'person_id' => $person_id, + 'title' => $class_name, + 'type' => $type, // + 'attr' => $attr, // + 'date' => $date, + 'converted_date' => $date_cnvert, + 'plac' => $plac, // + 'addr_id' => $addr_id, // + 'phon' => $phon, // + 'caus' => $caus, // + 'age' => $age, // + 'agnc' => $agnc, // + 'adop' => $adop, // + 'adop_famc' => $adop_famc, // + 'birt_famc' => $birt_famc, // + ]; + + $eventData[] = $data; + } + } + } + PersonEvent::on($conn)->insert($eventData); + $new = new Even(); + $new->otherField($conn, $events, $person); + } + + public static function otherField($conn, $events, $person) + { + try + { + foreach ($events as $event) { + + if ($event && count($event) > 0) { + $even = $event[0]; + $class_name = get_class($even); + $person_id = $person->id; + $type = $even->getType(); + $attr = $even->getAttr(); + $_date = $even->getDate(); + $date = \FamilyTree365\LaravelGedcom\Utils\Importer\Date::read($conn, $_date); + $_plac = $even->getPlac(); + $plac = \FamilyTree365\LaravelGedcom\Utils\Importer\Indi\Even\Plac::read($conn, $_plac); + $_phon = $even->getPhon(); + $phon = \FamilyTree365\LaravelGedcom\Utils\Importer\Phon::read($conn, $_phon); + $_addr = $even->getAddr(); + //$addr_id = \FamilyTree365\LaravelGedcom\Utils\Importer\Addr::read($conn, $_addr); + if (!empty($_addr)) { + $addr_id = \FamilyTree365\LaravelGedcom\Utils\Importer\Addr::read($conn, $_addr); + } else { + $addr_id = null; + } + + $caus = $even->getCaus(); + $age = $even->getAge(); + $agnc = $even->getAgnc(); + $adop = ''; + $adop_famc = ''; + $birt_famc = ''; + switch ($class_name) { + case 'Adop': + $adop = $even->getAdop(); + $adop_famc = $even->getFamc(); + break; + case 'Birt': + $birt_famc = $even->getFamc(); + break; + case 'Bapm': + break; + case 'Barm': + break; + case 'Basm': + break; + case 'Bles': + break; + case 'Buri': + break; + case 'Cast': + break; + case 'Cens': + break; + case 'Chr': + $chr_famc = $even->getFamc(); + break; + case 'Chra': + break; + case 'Conf': + break; + case 'Crem': + break; + case 'Dscr': + break; + case 'Deat': + break; + case 'Educ': + break; + case 'Emig': + break; + case 'Fcom': + break; + case 'Grad': + break; + case 'Idno': + break; + case 'Immi': + break; + case 'Nati': + break; + case 'Nchi': + break; + case 'Natu': + break; + case 'Nmr': + break; + case 'Occu': + break; + case 'Ordn': + break; + case 'Reti': + break; + case 'Prob': + break; + case 'Prop': + break; + case 'Reli': + break; + case 'Resi': + break; + case 'Ssn': + break; + case 'Titl': + break; + case 'Will': + break; + case 'Even': + break; + default: + } + $adop = ''; + $adop_famc = ''; + $birt_famc = ''; + // store Even + $key = [ + ['person_id', $person_id], + ['title', $class_name], + ['type', $type], + ['attr', $attr], + ['date', $date], + ['plac', $plac], + ['phon', $phon], + ['caus', $caus], + ['age', $age], + ['agnc', $agnc], + ['adop', $adop], + ['adop_famc', $adop_famc], + ['birt_famc', $birt_famc], + ]; + + // update person's record + if ($class_name == 'BIRT' && !empty($date)) { + $person->birthday = date('Y-m-d', strtotime($date)); + } + // add deathyear to person table ( for form builder ) + if ($class_name == 'DEAT' && !empty($date)) { + $person->deathday = date('Y-m-d', strtotime($date)); + } + $person->save(); + + $sour = $even->getSour(); + $notes = $even->getNote(); + $obje = $even->getObje(); + $_chan = $even->getChan() ?? null; + if ((!empty($sour) && count($sour) > 0) || (!empty($obje) && count($obje) > 0) || (!empty($notes) && count($notes) > 0) || !empty($_chan)) { + $record = PersonEvent::on($conn)->where($key)->first(); + $_group = 'indi_even'; + $_gid = $record->id; + } + + // array + //$sour = $even->getSour(); + if ($sour && count($sour) > 0) { + foreach ($sour as $item) { + if ($item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\SourRef::read($conn, $item, $_group, $_gid); + } + } + } + //$obje = $even->getObje(); + if ($obje && count($obje) > 0) { + foreach ($obje as $item) { + if ($item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\ObjeRef::read($conn, $item, $_group, $_gid, $obje); + } + } + } + //$notes = $even->getNote(); + if ($notes && count($notes) > 0) { + foreach ($notes as $item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $item, $_group, $_gid); + } + } + // object + //$_chan = $even->getChan() ?? null; + if ($_chan !== null) { + \FamilyTree365\LaravelGedcom\Utils\Importer\Chan::read($conn, $_chan, $_group, $_gid); + } + + // $_type = $even->getType(); + // $person->addEvent($_type, $date, $plac); + } + } + } + catch(Throwable $e) + { + report($e); + } + } +} diff --git a/src/Utils/exporter/Indi/Even/Plac.php b/src/Utils/exporter/Indi/Even/Plac.php new file mode 100644 index 0000000..1e7db10 --- /dev/null +++ b/src/Utils/exporter/Indi/Even/Plac.php @@ -0,0 +1,22 @@ +getPlac(); + } + + return $place; + } +} diff --git a/src/Utils/exporter/Indi/Lds.php b/src/Utils/exporter/Indi/Lds.php new file mode 100644 index 0000000..953bbab --- /dev/null +++ b/src/Utils/exporter/Indi/Lds.php @@ -0,0 +1,72 @@ +getStat(); + $date = $lds->getDate(); + $plac = $lds->getPlac(); + $temp = $lds->getTemp(); + + $slgc_famc = ''; + if ($type == 'SLGC') { + $slgc_famc = $lds->getFamc(); + } + // store refn + $key = [ + 'group' => $group, + 'gid' => $group_id, + 'type' => $type, + 'stat' => $stat, + 'date' => $date, + 'plac' => $plac, + 'temp' => $temp, + 'slgc_famc' => $slgc_famc, + ]; + $data = [ + 'group' => $group, + 'gid' => $group_id, + 'type' => $type, + 'stat' => $stat, + 'date' => $date, + 'plac' => $plac, + 'temp' => $temp, + 'slgc_famc' => $slgc_famc, + ]; + $record = PersonLds::on($conn)->updateOrCreate($key, $data); + + $_group = 'indi_lds'; + $_gid = $record->id; + // add sour + $sour = $lds->getSour(); + if ($sour && count($sour) > 0) { + foreach ($sour as $item) { + if ($item) { + SourRef::read($conn, $item, $_group, $_gid, $sour_ids, $obje_ids); + } + } + } + + // add note + $note = $lds->getNote(); + if ($note && count($note) > 0) { + foreach ($note as $item) { + if ($item) { + NoteRef::read($conn, $item, $_group, $_gid); + } + } + } + } +} diff --git a/src/Utils/exporter/Indi/Name.php b/src/Utils/exporter/Indi/Name.php new file mode 100644 index 0000000..5455165 --- /dev/null +++ b/src/Utils/exporter/Indi/Name.php @@ -0,0 +1,87 @@ +getName(); + $type = $item->getType(); + $npfx = $item->getNpfx(); + $givn = $item->getGivn(); + $nick = $item->getNick(); + $spfx = $item->getSpfx(); + $surn = $item->getSurn(); + $nsfx = $item->getNsfx(); + + // store asso + $key = [ + 'group'=> $group, + 'gid' => $group_id, + 'type' => $type, + 'name' => $name, + 'npfx' => $npfx, + 'givn' => $givn, + 'nick' => $nick, + 'spfx' => $spfx, + 'surn' => $surn, + 'nsfx' => $nsfx, + ]; + $data = [ + 'group'=> $group, + 'gid' => $group_id, + 'type' => $type, + 'name' => $name, + 'npfx' => $npfx, + 'givn' => $givn, + 'nick' => $nick, + 'spfx' => $spfx, + 'surn' => $surn, + 'nsfx' => $nsfx, + ]; + + $record = PersonName::on($conn)->updateOrCreate($key, $data); + + $_group = 'indi_name'; + $_gid = $record->id; + // store Note + $note = $item->getNote(); + if ($note && count($note) > 0) { + foreach ($note as $_item) { + if ($_item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $_item, $_group, $_gid); + } + } + } + + // store sourref + $sour = $item->getSour(); + if ($sour && count($sour) > 0) { + foreach ($sour as $_item) { + if ($_item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\SourRef::read($conn, $_item, $_group, $_gid); + } + } + } + + // store fone + $fone = $item->getFone(); + if ($fone != null) { + \FamilyTree365\LaravelGedcom\Utils\Importer\Indi\Name\Fone::read($conn, $fone, $_group, $_gid); + } + + // store romn + $romn = $item->getRomn(); + if ($romn != null) { + \FamilyTree365\LaravelGedcom\Utils\Importer\Indi\Name\Romn::read($conn, $romn, $_group, $_gid); + } + } +} diff --git a/src/Utils/exporter/Indi/Name/Fone.php b/src/Utils/exporter/Indi/Name/Fone.php new file mode 100644 index 0000000..d8149e5 --- /dev/null +++ b/src/Utils/exporter/Indi/Name/Fone.php @@ -0,0 +1,53 @@ +getType(); + $name = $item->getName(); + $npfx = $item->getNpfx(); + $givn = $item->getGivn(); + $nick = $item->getNick(); + $spfx = $item->getSpfx(); + $surn = $item->getSurn(); + $nsfx = $item->getNsfx(); + + // store asso + $key = [ + 'group'=> $group, + 'gid' => $group_id, + 'type' => $type, + 'name' => $name, + 'npfx' => $npfx, + 'givn' => $givn, + 'nick' => $nick, + 'spfx' => $spfx, + 'surn' => $surn, + 'nsfx' => $nsfx, + ]; + $data = [ + 'group'=> $group, + 'gid' => $group_id, + 'type' => $type, + 'name' => $name, + 'npfx' => $npfx, + 'givn' => $givn, + 'nick' => $nick, + 'spfx' => $spfx, + 'surn' => $surn, + 'nsfx' => $nsfx, + ]; + + $record = PersonNameFone::on($conn)->updateOrCreate($key, $data); + } +} diff --git a/src/Utils/exporter/Indi/Name/Romn.php b/src/Utils/exporter/Indi/Name/Romn.php new file mode 100644 index 0000000..efaafd5 --- /dev/null +++ b/src/Utils/exporter/Indi/Name/Romn.php @@ -0,0 +1,50 @@ +getType(); + $npfx = $item->getNpfx(); + $givn = $item->getGivn(); + $nick = $item->getNick(); + $spfx = $item->getSpfx(); + $surn = $item->getSurn(); + $nsfx = $item->getNsfx(); + + // store asso + $key = [ + 'group'=> $group, + 'gid' => $group_id, + 'type' => $type, + 'npfx' => $npfx, + 'givn' => $givn, + 'nick' => $nick, + 'spfx' => $spfx, + 'surn' => $surn, + 'nsfx' => $nsfx, + ]; + $data = [ + 'group'=> $group, + 'gid' => $group_id, + 'type' => $type, + 'npfx' => $npfx, + 'givn' => $givn, + 'nick' => $nick, + 'spfx' => $spfx, + 'surn' => $surn, + 'nsfx' => $nsfx, + ]; + + $record = PersonNameRomn::on($conn)->updateOrCreate($key, $data); + } +} diff --git a/src/Utils/exporter/Indi/Subm.php b/src/Utils/exporter/Indi/Subm.php new file mode 100644 index 0000000..e153c77 --- /dev/null +++ b/src/Utils/exporter/Indi/Subm.php @@ -0,0 +1,31 @@ +$group, 'gid'=>$group_id, 'subm'=>$subm_id]; + $data = ['group'=>$group, 'gid'=>$group_id, 'subm'=>$subm_id]; + $record[] = $data; + } + } + } + + PersonSubm::on($conn)->insert($record); + } +} diff --git a/src/Utils/exporter/Note.php b/src/Utils/exporter/Note.php new file mode 100644 index 0000000..667b236 --- /dev/null +++ b/src/Utils/exporter/Note.php @@ -0,0 +1,59 @@ +getNote(); + $rin = $note->getRin(); + + // store note + $key = ['group'=>$group, 'gid'=>$group_id, 'note'=> utf8_encode($_note) ]; + $data = ['group'=>$group, 'gid'=>$group_id, 'note'=> utf8_encode($_note), 'rin'=>$rin]; + $record = MNote::on($conn)->updateOrCreate($key, $data); + + // store Sources of Note + $_group = 'note'; + $_gid = $record->id; + // SourRef array + $sour = $note->getSour(); + if ($sour && count($sour) > 0) { + foreach ($sour as $item) { + SourRef::read($conn, $item, $_group, $_gid); + } + } + // Refn array + $refn = $note->getRefn(); + if ($refn && count($refn) > 0) { + foreach ($refn as $item) { + Refn::read($conn, $item, $_group, $_gid); + } + } + + // Chan + $chan = $note->getChan(); + if ($chan !== null) { + Chan::read($conn, $chan, $_group, $_gid); + } + + return $_gid; + } + catch(Throwable $e) + { + report($e); + } + + } +} diff --git a/src/Utils/exporter/NoteRef.php b/src/Utils/exporter/NoteRef.php new file mode 100644 index 0000000..03aa3b8 --- /dev/null +++ b/src/Utils/exporter/NoteRef.php @@ -0,0 +1,34 @@ +getNote(); + + // store note + $key = ['group'=>$group, 'gid'=>$group_id, 'note'=>$note]; + $data = ['group'=>$group, 'gid'=>$group_id, 'note'=>$note]; + $record = Note::on($conn)->updateOrCreate($key, $data); + + // store Sources of Note + $_group = 'note'; + $_gid = $record->id; + // SourRef array + $sour = $noteref->getSour(); + if ($sour && count($sour) > 0) { + foreach ($sour as $item) { + SourRef::read($conn, $item, $_group, $_gid); + } + } + } +} diff --git a/src/Utils/exporter/Obje.php b/src/Utils/exporter/Obje.php new file mode 100644 index 0000000..9d0c07a --- /dev/null +++ b/src/Utils/exporter/Obje.php @@ -0,0 +1,72 @@ +getId(); + $rin = $obje->getRin(); // string + + // store Object + $key = [ + 'group' => $group, + 'gid' => $group_id, + 'rin' => $rin, + 'obje_id' => $id, + ]; + $data = [ + 'group' => $group, + 'gid' => $group_id, + 'rin' => $rin, + 'obje_id' => $id, + ]; + + $record = MediaObject::on($conn)->updateOrCreate($key, $data); + + $_group = 'obje'; + $_gid = $record->id; + + $refn = $obje->getRefn(); // Record/Refn array + if ($refn && count($refn) > 0) { + foreach ($refn as $item) { + Refn::read($conn, $item, $_group, $_gid); + } + } + + // store Note + $note = $obje->getNote(); // Record/NoteRef array + if ($note && count($note) > 0) { + foreach ($note as $item) { + NoteRef::read($conn, $item, $_group, $_gid); + } + } + + // store Note + $files = $obje->getFile(); // Record/NoteRef array + if (($files && count((is_countable($files) ? $files : [])))) { + foreach ($files as $item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\ObjeRef\File::read($conn, $item, $_group, $_gid); + } + } + + $chan = $obje->getChan(); // Recore/Chan + if ($chan !== null) { + \FamilyTree365\LaravelGedcom\Utils\Importer\Chan::read($conn, $chan, $_group, $_gid); + } + + return $_gid; + } +} diff --git a/src/Utils/exporter/ObjeRef.php b/src/Utils/exporter/ObjeRef.php new file mode 100644 index 0000000..16b8974 --- /dev/null +++ b/src/Utils/exporter/ObjeRef.php @@ -0,0 +1,48 @@ +getObje(); + if (isset($obje_ids[$obje_id])) { + $obje_id = $obje_ids[$obje_id]; + } + $titl = $objeref->getTitl(); + $file = $objeref->getFile(); + + // store MediaObject + $key = ['group'=>$group, 'gid'=>$group_id, 'titl'=>$titl]; + $data = [ + 'group' => $group, + 'gid' => $group_id, + 'obje_id'=> $obje_id, + 'titl' => $titl, + ]; + $record = MediaObject::on($conn)->updateOrCreate($key, $data); + + $_group = 'objeref'; + $_gid = $record->id; + // store Note + + $files = $objeref->getFile(); + if ($files && count((is_countable($files) ? $files : []))) { + foreach ($files as $item) { + File::read($conn, $item, $_group, $_gid); + } + } + } +} diff --git a/src/Utils/exporter/ObjeRef/File.php b/src/Utils/exporter/ObjeRef/File.php new file mode 100644 index 0000000..9d56000 --- /dev/null +++ b/src/Utils/exporter/ObjeRef/File.php @@ -0,0 +1,28 @@ +getForm(); + $medi = null; + $type = null; + if ($form) { + $medi = $form->getMedi(); + } + + // store File + $key = ['group'=>$group, 'gid'=>$group_id, 'form'=>$form, 'medi'=>$medi, 'type'=> $type]; + $data = ['group'=>$group, 'gid'=>$group_id, 'form'=>$form, 'medi'=>$medi, 'type'=>$type]; + $record = MediaObjeectFile::on($conn)->updateOrCreate($key, $data); + } +} diff --git a/src/Utils/exporter/Phon.php b/src/Utils/exporter/Phon.php new file mode 100644 index 0000000..c1e52c5 --- /dev/null +++ b/src/Utils/exporter/Phon.php @@ -0,0 +1,28 @@ +getPhon(); + } + } else { + if (is_array($phon)) { + return json_encode($phon); + } else { + return "$phon"; + } + } + } +} diff --git a/src/Utils/exporter/Refn.php b/src/Utils/exporter/Refn.php new file mode 100644 index 0000000..5c262e6 --- /dev/null +++ b/src/Utils/exporter/Refn.php @@ -0,0 +1,23 @@ +getRefn(); + $type = $refn->getType(); + // store refn + $key = ['group'=>$group, 'gid'=>$group_id, 'refn'=>$_refn, 'type'=>$type]; + $data = ['group'=>$group, 'gid'=>$group_id, 'refn'=>$_refn, 'type'=>$type]; + $record = MRefn::on($conn)->updateOrCreate($key, $data); + } +} diff --git a/src/Utils/exporter/Repo.php b/src/Utils/exporter/Repo.php new file mode 100644 index 0000000..398e80c --- /dev/null +++ b/src/Utils/exporter/Repo.php @@ -0,0 +1,80 @@ +getName(); // string + $rin = $repo->getRin(); // string + $addr = $repo->getAddr(); // Record/Addr + $addr_id = \FamilyTree365\LaravelGedcom\Utils\Importer\Addr::read($conn, $addr); + $_phon = $repo->getPhon(); // Record/Phon array + $phon = implode(',', $_phon); + $_email = $repo->getEmail(); + $email = implode(',', $_email); + $_fax = $repo->getFax(); + $fax = implode(',', $_fax); + $_www = $repo->getWww(); + $www = implode(',', $_www); + // store Source + $key = [ + 'group' => $group, + 'gid' => $group_id, + 'name' => $name, + 'rin' => $rin, + 'addr_id' => $addr_id, + 'phon' => $phon, + 'email' => $email, + 'fax' => $fax, + 'www' => $www, + ]; + $data = [ + 'group' => $group, + 'gid' => $group_id, + 'name' => $name, + 'rin' => $rin, + 'addr_id' => $addr_id, + 'phon' => $phon, + 'email' => $email, + 'fax' => $fax, + 'www' => $www, + ]; + + $record = Repository::on($conn)->updateOrCreate($key, $data); + + $_group = 'repo'; + $_gid = $record->id; + // store Note + $note = $repo->getNote(); // Record/NoteRef array + if ($note && count($note) > 0) { + foreach ($note as $item) { + NoteRef::read($conn, $item, $_group, $_gid); + } + } + $refn = $repo->getRefn(); // Record/Refn array + if ($refn && count($refn) > 0) { + foreach ($refn as $item) { + Refn::read($conn, $item, $_group, $_gid); + } + } + + $chan = $repo->getChan(); // Recore/Chan + if ($chan !== null) { + \FamilyTree365\LaravelGedcom\Utils\Importer\Chan::read($conn, $chan, $_group, $_gid); + } + + return $_gid; + } +} diff --git a/src/Utils/exporter/RepoRef.php b/src/Utils/exporter/RepoRef.php new file mode 100644 index 0000000..3a2b1f0 --- /dev/null +++ b/src/Utils/exporter/RepoRef.php @@ -0,0 +1,49 @@ +getRepo(); + // store Source + $key = ['group'=>$group, 'gid'=>$group_id, 'repo' => $repo]; + $data = [ + 'group'=> $group, + 'gid' => $group_id, + 'repo' => $repo, + ]; + $record = Repository::on($conn)->updateOrCreate($key, $data); + + $_group = 'reporef'; + $_gid = $record->id; + // store Note + $notes = $reporef->getNote(); + if ($notes && count($notes) > 0) { + foreach ($notes as $item) { + NoteRef::read($conn, $item, $_group, $_gid); + } + } + + // store Caln + $caln = $reporef->getCaln(); + if ($caln && count($caln) > 0) { + foreach ($caln as $item) { + if ($item) { + Caln::read($conn, $item, $_group, $_gid); + } + } + } + } +} diff --git a/src/Utils/exporter/Sour.php b/src/Utils/exporter/Sour.php new file mode 100644 index 0000000..2c12252 --- /dev/null +++ b/src/Utils/exporter/Sour.php @@ -0,0 +1,75 @@ +getAuth(); // string + $titl = $sour->getTitl(); // string + $abbr = $sour->getAbbr(); // string + $publ = $sour->getPubl(); // string + $rin = $sour->getRin(); // string + $text = $sour->getText(); // string + + $record = Source::on($conn)->updateOrCreate( + compact('titl', 'rin', 'auth', 'text', 'publ', 'abbr'), + compact('titl', 'rin', 'auth', 'text', 'publ', 'abbr') + ); + + $_group = 'sour'; + $_gid = $record->id; + + $chan = $sour->getChan(); // Record/Chan + if ($chan !== null) { + \FamilyTree365\LaravelGedcom\Utils\Importer\Chan::read($conn, $chan, $_group, $_gid = 0); + } + $repo = $sour->getRepo(); // Repo + if ($repo !== null) { + \FamilyTree365\LaravelGedcom\Utils\Importer\Sour\Repo::read($conn, $repo, $_group, $_gid = 0); + } + $data = $sour->getData(); // object + if ($data !== null) { + \FamilyTree365\LaravelGedcom\Utils\Importer\Sour\Data::read($conn, $data, $_group, $_gid = 0); + } + $refn = $sour->getRefn(); // array + if ($refn && count($refn) > 0) { + foreach ($refn as $item) { + if ($item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\Refn::read($conn, $item, $_group, $_gid = 0); + } + } + } + + $note = $sour->getNote(); // array + if ($note != null && count($note) > 0) { + foreach ($note as $item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $item, $_group, $_gid); + } + } + + $obje = $sour->getObje(); // array + if ($obje && count($obje) > 0) { + foreach ($obje as $item) { + if ($item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\ObjeRef::read($conn, $item, $_group, $_gid, $obje_ids); + } + } + } + + $sour = $sour->getSour(); // string id + + return $_gid; + } +} diff --git a/src/Utils/exporter/Sour/Data.php b/src/Utils/exporter/Sour/Data.php new file mode 100644 index 0000000..072ac9f --- /dev/null +++ b/src/Utils/exporter/Sour/Data.php @@ -0,0 +1,44 @@ +getDate(); + $agnc = $data->getAgnc(); + $text = $data->getText(); + + // store Data of sources + $key = ['group'=>$group, 'gid'=>$group_id, 'date'=>$date, 'text'=>$text, 'agnc'=>$agnc]; + $_data = ['group'=>$group, 'gid'=>$group_id, 'date'=>$date, 'text'=>$text, 'agnc'=>$agnc]; + $record = SourceData::on($conn)->updateOrCreate($key, $_data); + + $_group = 'sourcedata'; + $_gid = $record->id; + // \Gedcom\Record\Sour\Data\Even array + $even = $data->getEven(); + if ($even && count($even) > 0) { + foreach ($even as $item) { + Even::read($conn, $item, $_group, $_gid); + } + } + // \Gedcom\Record\NoteRef array + $note = $data->getNote(); + if ($note && count($note) > 0) { + foreach ($note as $item) { + NoteRef::read($conn, $item, $_group, $_gid); + } + } + } +} diff --git a/src/Utils/exporter/Sour/Data/Even.php b/src/Utils/exporter/Sour/Data/Even.php new file mode 100644 index 0000000..2eaa9d6 --- /dev/null +++ b/src/Utils/exporter/Sour/Data/Even.php @@ -0,0 +1,24 @@ +getDate(); + $plac = $even->getPlac(); + + // store Even of source/data + $key = ['group'=>$group, 'gid'=>$group_id, 'date'=>$date, 'plac'=>$plac]; + $data = ['group'=>$group, 'gid'=>$group_id, 'date'=>$date, 'plac'=>$plac]; + $record = SourceDataEven::on($conn)->updateOrCreate($key, $data); + } +} diff --git a/src/Utils/exporter/Sour/Repo.php b/src/Utils/exporter/Sour/Repo.php new file mode 100644 index 0000000..e5f51d0 --- /dev/null +++ b/src/Utils/exporter/Sour/Repo.php @@ -0,0 +1,52 @@ +getRepo(); + if (empty($repo_id)) { + $repo_id = rand(1, 10000); + } + $_caln = $data->getCaln(); + $caln = ''; + if ($_caln != null && count($_caln) > 0) { + $temp = []; + foreach ($_caln as $item) { + $__caln = $item->getCaln(); + $__medi = $item->getMedi(); + $temp_item = $__caln.':'.$__medi; + $temp[] = $temp_item; + } + $caln = implode(',', $temp); + unset($temp); + // example + // +1 1123 123123:avi,+1 123 123 123:mpg + } + // store Data of sources + $key = ['group'=>$group, 'gid'=>$group_id, 'repo_id'=>$repo_id]; + $_data = ['group'=>$group, 'gid'=>$group_id, 'repo_id'=>$repo_id, 'caln'=>$caln]; + $record = SourceRepo::on($conn)->updateOrCreate($key, $_data); + + $_group = 'sourcerepo'; + $_gid = $record->id; + + // \Gedcom\Record\NoteRef array + $note = $data->getNote(); + if ($note && count($note) > 0) { + foreach ($note as $item) { + NoteRef::read($conn, $item, $_group, $_gid); + } + } + } +} diff --git a/src/Utils/exporter/SourRef.php b/src/Utils/exporter/SourRef.php new file mode 100644 index 0000000..b5075c3 --- /dev/null +++ b/src/Utils/exporter/SourRef.php @@ -0,0 +1,73 @@ +getSour(); + if (!isset($sour_ids[$sour])) { + return; + } + $sour_id = $sour_ids[$sour]; + $text = $sourref->getText(); + $quay = $sourref->getQuay(); + $page = $sourref->getPage(); + + // store Source + $key = ['group'=>$group, 'gid'=>$group_id, 'sour_id'=>$sour_id]; + $data = [ + 'group' => $group, + 'gid' => $group_id, + 'sour_id'=> $sour_id, + 'text' => $text, + 'quay' => $quay, + 'page' => $page, + ]; + $record = SourceRef::on($conn)->updateOrCreate($key, $data); + + $_group = 'sourref'; + $_gid = $record->id; + // store MediaObje + $objes = $sourref->getObje(); + if ($objes && count($objes) > 0) { + foreach ($objes as $item) { + ObjeRef::read($conn, $item, $_group, $_gid, $obje_ids); + } + } + + // store Note + $notes = $sourref->getNote(); + if ($notes && count($notes) > 0) { + foreach ($notes as $item) { + NoteRef::read($conn, $item, $_group, $_gid); + } + } + + // store Data + $data = $sourref->getData(); + if ($data) { + Data::read($conn, $data, $_group, $_gid); + } + + // store \Gedcom\Record\SourRef\Even + $even = $sourref->getEven(); + if ($even) { + Even::read($conn, $even, $_group, $_gid); + } + } +} diff --git a/src/Utils/exporter/SourRef/Even.php b/src/Utils/exporter/SourRef/Even.php new file mode 100644 index 0000000..c58cc17 --- /dev/null +++ b/src/Utils/exporter/SourRef/Even.php @@ -0,0 +1,24 @@ +getEven(); + $role = $even->getRole(); + + // store Even of source/data + $key = ['group'=>$group, 'gid'=>$group_id, 'even'=>$_even, 'role'=>$role]; + $data = ['group'=>$group, 'gid'=>$group_id, 'even'=>$_even, 'role'=>$role]; + $record = SourceRefEven::on($conn)->updateOrCreate($key, $data); + } +} diff --git a/src/Utils/exporter/Subm.php b/src/Utils/exporter/Subm.php new file mode 100644 index 0000000..49cca47 --- /dev/null +++ b/src/Utils/exporter/Subm.php @@ -0,0 +1,92 @@ +getName() ?? null; // string + if (!is_object($subm)) { + $name = $subm; + } + $addr = $subm->getAddr() ?? null; + $addr_id = \FamilyTree365\LaravelGedcom\Utils\Importer\Addr::read($conn, $addr); + $_phon = $subm->getPhon() ?? []; // array + $phon = implode(',', $_phon); + $_email = $subm->getEmail() ?? []; + $email = implode(',', $_email); + $_fax = $subm->getFax() ?? []; + $fax = implode(',', $_fax); + $_www = $subm->getWww() ?? []; + $www = implode(',', $_www); + + $rin = $subm->getRin() ?? null; // string + $rfn = $subm->getRfn() ?? null; // string + + $_lang = $subm->getLang(); // string array + $lang = implode(',', $_lang); + $key = [ + 'group' => $group, + 'gid' => $gid, + 'name' => $name, + 'addr_id' => $addr_id, + 'lang' => $lang, + 'phon' => $phon, + 'email' => $email, + 'fax' => $fax, + 'www' => $www, + 'rin' => $rin, + 'rfn' => $rfn, + ]; + $data = [ + 'group' => $group, + 'gid' => $gid, + 'name' => $name, + 'addr_id' => $addr_id, + 'lang' => $lang, + 'phon' => $phon, + 'email' => $email, + 'fax' => $fax, + 'www' => $www, + 'rin' => $rin, + 'rfn' => $rfn, + ]; + $record = MSubm::on($conn)->updateOrCreate($key, $data); + $_group = 'subm'; + $_gid = $record->id; + + $note = $subm->getNote(); // array --- + + if ($note != null && count($note) > 0) { + foreach ($note as $item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $item, $_group, $_gid); + } + } + $obje = $subm->getObje() ?? null; // array --- + if ($obje && count($obje) > 0) { + foreach ($obje as $item) { + if ($item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\ObjeRef::read($conn, $item, $_group, $_gid, $obje_ids); + } + } + } + $chan = $subm->getChan() ?? null; // Record\Chan--- + if ($chan !== null) { + \FamilyTree365\LaravelGedcom\Utils\Importer\Chan::read($conn, $chan, $_group, $_gid); + } + + return $_gid; + } +} diff --git a/src/Utils/exporter/Subn.php b/src/Utils/exporter/Subn.php new file mode 100644 index 0000000..cdd0ab6 --- /dev/null +++ b/src/Utils/exporter/Subn.php @@ -0,0 +1,47 @@ +getSubm(); + $subm = null; + if (isset($subm_ids[$subm])) { + $subm = $subm_ids[$_subm]; + } + $famf = $subn->getFamf(); + $temp = $subn->getTemp(); + $ance = $subn->getAnce(); + $desc = $subn->getDesc(); + $ordi = $subn->getOrdi(); + $rin = $subn->getRin(); + $record = MSubn::on($conn)->updateOrCreate(compact('subm', 'famf', 'temp', 'ance', 'desc', 'ordi', 'rin'), compact('subm', 'famf', 'temp', 'ance', 'desc', 'ordi', 'rin')); + + $_group = 'subn'; + $_gid = $record->id; + + $note = $subn->getNote(); // array --- + + if ($note != null && count($note) > 0) { + foreach ($note as $item) { + \FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $item, $_group, $_gid); + } + } + $chan = $subn->getChan() ?? null; // Record\Chan--- + if ($chan !== null) { + \FamilyTree365\LaravelGedcom\Utils\Importer\Chan::read($conn, $chan, $_group, $_gid); + } + } +}