From 3d61243a4fdc86b69bf167d00ad585d3e25bcbc9 Mon Sep 17 00:00:00 2001 From: Greg Roach Date: Fri, 8 Mar 2019 09:27:31 +0000 Subject: Simplify logic --- app/Functions/FunctionsCharts.php | 56 ++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/app/Functions/FunctionsCharts.php b/app/Functions/FunctionsCharts.php index 3fe6988f5e..273bd4b010 100644 --- a/app/Functions/FunctionsCharts.php +++ b/app/Functions/FunctionsCharts.php @@ -80,7 +80,7 @@ class FunctionsCharts echo (string) $sosa; if ($sosa !== 1 && $pid !== '' && $icon !== '') { echo '
'; - echo '' . e($pid); + echo ''; echo view($icon); echo ''; } @@ -146,12 +146,11 @@ class FunctionsCharts echo ''; // husband’s parents $hfam = $husb->primaryChildFamily(); - if ($hfam) { - // remove the|| test for $sosa + if ($hfam instanceof Family) { echo ''; echo ''; // husband’s father - if ($hfam && $hfam->husband()) { + if ($hfam->husband() instanceof Individual) { echo ''; if ($sosa > 0) { self::printSosaNumber($sosa * 4, $hfam->husband()->xref(), 'icons/arrow-down'); @@ -162,24 +161,23 @@ class FunctionsCharts echo '
'; echo FunctionsPrint::printPedigreePerson($hfam->husband()); echo '
'; - } elseif ($hfam && !$hfam->husband()) { + } else { // Empty box for grandfather echo ''; echo '
'; - echo FunctionsPrint::printPedigreePerson($hfam->husband()); + echo FunctionsPrint::printPedigreePerson(null); echo '
'; } echo ''; - } - if ($hfam && ($sosa !== -1)) { - echo ''; - echo '' . view('icons/arrow-right') . ''; - echo ''; - } - if ($hfam) { + if ($sosa !== -1) { + echo ''; + echo '' . view('icons/arrow-right') . ''; + echo ''; + } + // husband’s mother echo ''; - if ($hfam && $hfam->wife()) { + if ($hfam->wife() instanceof Individual) { echo ''; if ($sosa > 0) { self::printSosaNumber($sosa * 4 + 1, $hfam->wife()->xref(), 'icons/arrow-down'); @@ -190,11 +188,11 @@ class FunctionsCharts echo '
'; echo FunctionsPrint::printPedigreePerson($hfam->wife()); echo '
'; - } elseif ($hfam && !$hfam->wife()) { + } else { // Empty box for grandmother echo ''; echo '
'; - echo FunctionsPrint::printPedigreePerson($hfam->wife()); + echo FunctionsPrint::printPedigreePerson(null); echo '
'; } echo ''; @@ -234,11 +232,11 @@ class FunctionsCharts echo ''; // wife’s parents $wfam = $wife->primaryChildFamily(); - if ($wfam) { + if ($wfam instanceof Family) { echo ''; echo ''; // wife’s father - if ($wfam && $wfam->husband()) { + if ($wfam->husband() instanceof Individual) { echo ''; if ($sosa > 0) { self::printSosaNumber($sosa * 4 + 2, $wfam->husband()->xref(), 'icons/arrow-down'); @@ -249,24 +247,22 @@ class FunctionsCharts echo '
'; echo FunctionsPrint::printPedigreePerson($wfam->husband()); echo '
'; - } elseif ($wfam && !$wfam->husband()) { + } else { // Empty box for grandfather echo ''; echo '
'; - echo FunctionsPrint::printPedigreePerson($wfam->husband()); + echo FunctionsPrint::printPedigreePerson(null); echo '
'; } echo ''; - } - if ($wfam && ($sosa !== -1)) { - echo ''; - echo '' . view('icons/arrow-right') . ''; - echo ''; - } - if ($wfam) { + if ($sosa !== -1) { + echo ''; + echo '' . view('icons/arrow-right') . ''; + echo ''; + } // wife’s mother echo ''; - if ($wfam && $wfam->wife()) { + if ($wfam->wife() instanceof Individual) { echo ''; if ($sosa > 0) { self::printSosaNumber($sosa * 4 + 3, $wfam->wife()->xref(), 'icons/arrow-down'); @@ -277,11 +273,11 @@ class FunctionsCharts echo '
'; echo FunctionsPrint::printPedigreePerson($wfam->wife()); echo '
'; - } elseif ($wfam && !$wfam->wife()) { + } else { // Empty box for grandmother echo ''; echo '
'; - echo FunctionsPrint::printPedigreePerson($wfam->wife()); + echo FunctionsPrint::printPedigreePerson(null); echo '
'; } echo ''; -- cgit v1.3