1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace FamilyTree365\LaravelGedcom\Utils\Exporter; |
4
|
|
|
|
5
|
|
|
use FamilyTree365\LaravelGedcom\Models\Source; |
6
|
|
|
|
7
|
|
|
class Sour |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Gedcom\Record\Subn $subn |
11
|
|
|
* String $group |
12
|
|
|
* Integer $group_id. |
13
|
|
|
*/ |
14
|
|
|
public static function read($conn, $sour, $obje_ids = []) |
15
|
|
|
{ |
16
|
|
|
if ($sour == null || is_array($sour)) { |
17
|
|
|
return 0; |
18
|
|
|
} |
19
|
|
|
$auth = $sour->getAuth(); // string |
20
|
|
|
$titl = $sour->getTitl(); // string |
21
|
|
|
$abbr = $sour->getAbbr(); // string |
22
|
|
|
$publ = $sour->getPubl(); // string |
23
|
|
|
$rin = $sour->getRin(); // string |
24
|
|
|
$text = $sour->getText(); // string |
25
|
|
|
|
26
|
|
|
$record = Source::on($conn)->updateOrCreate( |
27
|
|
|
compact('titl', 'rin', 'auth', 'text', 'publ', 'abbr'), |
28
|
|
|
compact('titl', 'rin', 'auth', 'text', 'publ', 'abbr') |
29
|
|
|
); |
30
|
|
|
|
31
|
|
|
$_group = 'sour'; |
32
|
|
|
$_gid = $record->id; |
33
|
|
|
|
34
|
|
|
$chan = $sour->getChan(); // Record/Chan |
35
|
|
|
if ($chan !== null) { |
36
|
|
|
\FamilyTree365\LaravelGedcom\Utils\Importer\Chan::read($conn, $chan, $_group, $_gid = 0); |
37
|
|
|
} |
38
|
|
|
$repo = $sour->getRepo(); // Repo |
39
|
|
|
if ($repo !== null) { |
40
|
|
|
\FamilyTree365\LaravelGedcom\Utils\Importer\Sour\Repo::read($conn, $repo, $_group, $_gid = 0); |
41
|
|
|
} |
42
|
|
|
$data = $sour->getData(); // object |
43
|
|
|
if ($data !== null) { |
44
|
|
|
\FamilyTree365\LaravelGedcom\Utils\Importer\Sour\Data::read($conn, $data, $_group, $_gid = 0); |
45
|
|
|
} |
46
|
|
|
$refn = $sour->getRefn(); // array |
47
|
|
|
if ($refn && count($refn) > 0) { |
48
|
|
|
foreach ($refn as $item) { |
49
|
|
|
if ($item) { |
50
|
|
|
\FamilyTree365\LaravelGedcom\Utils\Importer\Refn::read($conn, $item, $_group, $_gid = 0); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$note = $sour->getNote(); // array |
56
|
|
|
if ($note != null && count($note) > 0) { |
57
|
|
|
foreach ($note as $item) { |
58
|
|
|
\FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $item, $_group, $_gid); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$obje = $sour->getObje(); // array |
63
|
|
|
if ($obje && count($obje) > 0) { |
64
|
|
|
foreach ($obje as $item) { |
65
|
|
|
if ($item) { |
66
|
|
|
\FamilyTree365\LaravelGedcom\Utils\Importer\ObjeRef::read($conn, $item, $_group, $_gid, $obje_ids); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
$sour = $sour->getSour(); // string id |
|
|
|
|
72
|
|
|
|
73
|
|
|
return $_gid; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|