';
if ($state <= 0) {
// draw children
$html .= $this->drawChildren($person->getSpouseFamilies(), $gen);
} else {
// draw the parent’s lines
$html .= $this->drawVerticalLine($order) . $this->drawHorizontalLine();
}
/* draw the person. Do NOT add person or family id as an id, since a same person could appear more than once in the tree !!! */
// Fixing the width for td to the box initial width when the person is the root person fix a rare bug that happen when a person without child and without known parents is the root person : an unwanted white rectangle appear at the right of the person’s boxes, otherwise.
$html .= '';
$html .= $this->drawPersonName($person);
$fop = []; // $fop is fathers of partners
if (!is_null($partner)) {
$dashed = '';
foreach ($person->getSpouseFamilies() as $family) {
$spouse = $family->getSpouse($person);
if ($spouse) {
if ($spouse === $partner || $this->all_partners === 'true') {
$spouse_parents = $spouse->getPrimaryChildFamily();
if ($spouse_parents && $spouse_parents->getHusband()) {
$fop[] = [$spouse_parents->getHusband(), $spouse_parents];
} elseif ($spouse_parents && $spouse_parents->getWife()) {
$fop[] = [$spouse_parents->getWife(), $spouse_parents];
}
$html .= $this->drawPersonName($spouse, $dashed);
if ($this->all_partners !== 'true') {
break; // we can stop here the foreach loop
}
$dashed = 'dashed';
}
}
}
}
$html .= ' | ';
$primaryChildFamily = $person->getPrimaryChildFamily();
if (!empty($primaryChildFamily)) {
$parent = $primaryChildFamily->getHusband();
if (empty($parent)) {
$parent = $primaryChildFamily->getWife();
}
}
if (!empty($parent) || count($fop) || ($state < 0)) {
$html .= $this->drawHorizontalLine();
}
/* draw the parents */
if ($state >= 0 && (!empty($parent) || count($fop))) {
$unique = (empty($parent) || count($fop) == 0);
$html .= '';
if (!empty($parent)) {
$u = $unique ? 'c' : 't';
$html .= '';
$html .= $this->drawPerson($parent, $gen - 1, 1, $primaryChildFamily, $u);
$html .= ' | ';
}
if (count($fop)) {
$n = 0;
$nb = count($fop);
foreach ($fop as $p) {
$n++;
$u = $unique ? 'c' : ($n == $nb || empty($p[1]) ? 'b' : 'h');
$html .= '' . $this->drawPerson($p[0], $gen - 1, 1, $p[1], $u) . ' | ';
}
}
$html .= ' | ';
}
if ($state < 0) {
$html .= $this->drawVerticalLine($order);
}
$html .= '