From 879a6237b186768356f99caf992f0d25d5ec8612 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sun, 5 Dec 2021 16:38:49 +0100 Subject: Commit --- app/genealogy/tree/mktree.php | 165 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 app/genealogy/tree/mktree.php (limited to 'app/genealogy/tree/mktree.php') diff --git a/app/genealogy/tree/mktree.php b/app/genealogy/tree/mktree.php new file mode 100644 index 0000000..095de92 --- /dev/null +++ b/app/genealogy/tree/mktree.php @@ -0,0 +1,165 @@ + $potential) { + if (isset($potential["family"]) && count($potential["family"]["children"]) > 0 && in_array($id, $potential["family"]["children"]) && $potential["sex"] !== "F") { + $found = true; + $dad = $potential["famname"] . " " . $potential["surname"]; + $dadId = $potid; + } +} + +if (!$found) { + $dad = "???"; +} + +// Mother +$found = false; +foreach ($data as $potid => $potential) { + if (isset($potential["family"]) && count($potential["family"]["children"]) > 0 && in_array($id, $potential["family"]["children"]) && $potential["sex"] === "F") { + $found = true; + $mom = $potential["famname"] . " " . $potential["surname"]; + $momId = $potid; + } +} + +if (!$found) { + $mom = "???"; +} + +// Mother's data +if (isset($momId)) { + // Father + $found = false; + foreach ($data as $potid => $potential) { + if (isset($potential["family"]) && count($potential["family"]["children"]) > 0 && in_array($momId, $potential["family"]["children"]) && $potential["sex"] !== "F") { + $found = true; + $momDad = $potential["famname"] . " " . $potential["surname"]; + $momDadId = $potid; + } + } + + if (!$found) { + $momDad = "???"; + } + + // Mother + $found = false; + foreach ($data as $potid => $potential) { + if (isset($potential["family"]) && count($potential["family"]["children"]) > 0 && in_array($momId, $potential["family"]["children"]) && $potential["sex"] === "F") { + $found = true; + $momMom = $potential["famname"] . " " . $potential["surname"]; + $momMomId = $potid; + } + } + + if (!$found) { + $momMom = "???"; + } +} else { + $momMom = "???"; + $momDad = "???"; +} + +// Father's data +if (isset($dadId)) { + // Father + $found = false; + foreach ($data as $potid => $potential) { + if (isset($potential["family"]) && count($potential["family"]["children"]) > 0 && in_array($dadId, $potential["family"]["children"]) && $potential["sex"] !== "F") { + $found = true; + $dadDad = $potential["famname"] . " " . $potential["surname"]; + $dadDadId = $potid; + } + } + + if (!$found) { + $dadDad = "???"; + } + + // Mother + $found = false; + foreach ($data as $potid => $potential) { + if (isset($potential["family"]) && count($potential["family"]["children"]) > 0 && in_array($dadId, $potential["family"]["children"]) && $potential["sex"] === "F") { + $found = true; + $dadMom = $potential["famname"] . " " . $potential["surname"]; + $dadMomId = $potid; + } + } + + if (!$found) { + $dadMom = "???"; + } +} else { + $dadMom = "???"; + $dadDad = "???"; +} + +?> + + + + + Tree maker 🌳 + + + + +
+ + + + -- cgit