From 3743ab9094f0f98d4cf3c62bf58af0253a577ac4 Mon Sep 17 00:00:00 2001 From: divinity666 <65871511+divinity666@users.noreply.github.com> Date: Sun, 24 May 2020 23:17:12 +0200 Subject: [PATCH 1/3] Add kekule number support --- app/Report/ReportParserGenerate.php | 39 +++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/app/Report/ReportParserGenerate.php b/app/Report/ReportParserGenerate.php index b6a5211b0b5..7a5596c8bb2 100644 --- a/app/Report/ReportParserGenerate.php +++ b/app/Report/ReportParserGenerate.php @@ -159,6 +159,9 @@ class ReportParserGenerate extends ReportParserBase /** @var int The current generational level */ private $generation = 1; + + /** @var int The current kekule order number */ + private $kekule_number = 1; /** @var array Source data for processing lists */ private $list = []; @@ -1471,6 +1474,8 @@ protected function setVarStartHandler(array $attrs): void $value = $this->desc; } elseif ($value === '@generation') { $value = (string) $this->generation; + } elseif ($value === '@kekule_number') { + $value = (string) $this->kekule_number; } elseif (preg_match("/@(\w+)/", $value, $match)) { $gmatch = []; if (preg_match("/\d $match[1] (.+)/", $this->gedrec, $gmatch)) { @@ -1553,6 +1558,8 @@ protected function ifStartHandler(array $attrs): void $value = '"' . addslashes($this->desc) . '"'; } elseif ($id === 'generation') { $value = '"' . $this->generation . '"'; + } elseif ($id === 'kekule_number') { + $value = '"' . $this->kekule_number .'"'; } else { $level = (int) explode(' ', trim($this->gedrec))[0]; if ($level === 0) { @@ -2546,6 +2553,9 @@ protected function relativesEndHandler(): void if (isset($value->generation)) { $this->generation = $value->generation; } + if (isset($value->kekule_number)) { + $this->kekule_number = $value->kekule_number; + } $tmp = Factory::gedcomRecord()->make((string) $xref, $this->tree); $this->gedrec = $tmp->privatizeGedcom(Auth::accessLevel($this->tree)); @@ -2594,6 +2604,17 @@ protected function generationStartHandler(): void $this->current_element->addText((string) $this->generation); } + /** + * Handle + * Prints the kekule order number + * + * @return void + */ + protected function kekuleNumberStartHandler(): void + { + $this->current_element->addText((string) $this->kekule_number); + } + /** * Handle * Has to be placed in an element (header, body or footer) @@ -2704,9 +2725,12 @@ private function addDescendancy(&$list, $pid, $parents = false, $generations = - private function addAncestors(array &$list, string $pid, bool $children = false, int $generations = -1): void { $genlist = [$pid]; + $kekulelist = [1]; $list[$pid]->generation = 1; + $list[$pid]->kekule_number = 1; while (count($genlist) > 0) { $id = array_shift($genlist); + $kekule_number = array_shift($kekulelist); if (strpos($id, 'empty') === 0) { continue; // id can be something like “empty7” } @@ -2715,19 +2739,24 @@ private function addAncestors(array &$list, string $pid, bool $children = false, $husband = $family->husband(); $wife = $family->wife(); if ($husband) { - $list[$husband->xref()] = $husband; - $list[$husband->xref()]->generation = $list[$id]->generation + 1; + $list[$husband->xref()] = $husband; + $list[$husband->xref()]->generation = $list[$id]->generation + 1; + $list[$husband->xref()]->kekule_number = $kekule_number; } + $list[$husband->xref()]->generation = $list[$id]->generation + 1; if ($wife) { - $list[$wife->xref()] = $wife; - $list[$wife->xref()]->generation = $list[$id]->generation + 1; + $list[$wife->xref()] = $wife; + $list[$wife->xref()]->generation = $list[$id]->generation + 1; + $list[$wife->xref()]->kekule_number = $kekule_number + 1; } if ($generations == -1 || $list[$id]->generation + 1 < $generations) { if ($husband) { - $genlist[] = $husband->xref(); + $genlist[] = $husband->xref(); + $kekulelist[] = $kekule_number * 2; } if ($wife) { $genlist[] = $wife->xref(); + $kekulelist[] = ($kekule_number + 1) * 2; } } if ($children) { From 5f4ed7247eba61a4e429719068f749d413c63fe4 Mon Sep 17 00:00:00 2001 From: divinity666 <65871511+divinity666@users.noreply.github.com> Date: Mon, 25 May 2020 00:34:41 +0200 Subject: [PATCH 2/3] Fix kekule support after final test --- app/Report/ReportParserGenerate.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/Report/ReportParserGenerate.php b/app/Report/ReportParserGenerate.php index 7a5596c8bb2..1b868c51ae7 100644 --- a/app/Report/ReportParserGenerate.php +++ b/app/Report/ReportParserGenerate.php @@ -2605,7 +2605,7 @@ protected function generationStartHandler(): void } /** - * Handle + * Handle * Prints the kekule order number * * @return void @@ -2730,7 +2730,7 @@ private function addAncestors(array &$list, string $pid, bool $children = false, $list[$pid]->kekule_number = 1; while (count($genlist) > 0) { $id = array_shift($genlist); - $kekule_number = array_shift($kekulelist); + $kekule_number = array_shift($kekulelist) + 1; if (strpos($id, 'empty') === 0) { continue; // id can be something like “empty7” } @@ -2743,7 +2743,6 @@ private function addAncestors(array &$list, string $pid, bool $children = false, $list[$husband->xref()]->generation = $list[$id]->generation + 1; $list[$husband->xref()]->kekule_number = $kekule_number; } - $list[$husband->xref()]->generation = $list[$id]->generation + 1; if ($wife) { $list[$wife->xref()] = $wife; $list[$wife->xref()]->generation = $list[$id]->generation + 1; @@ -2752,11 +2751,11 @@ private function addAncestors(array &$list, string $pid, bool $children = false, if ($generations == -1 || $list[$id]->generation + 1 < $generations) { if ($husband) { $genlist[] = $husband->xref(); - $kekulelist[] = $kekule_number * 2; + $kekulelist[] = ($kekule_number) * 2 - 1; } if ($wife) { $genlist[] = $wife->xref(); - $kekulelist[] = ($kekule_number + 1) * 2; + $kekulelist[] = ($kekule_number + 1) * 2 - 1; } } if ($children) { From fed3f739b1f966395ff805fd5486d49187045d9f Mon Sep 17 00:00:00 2001 From: divinity666 <65871511+divinity666@users.noreply.github.com> Date: Mon, 25 May 2020 00:35:22 +0200 Subject: [PATCH 3/3] Modify report to use kekule support --- resources/xml/reports/ahnentafel_report.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/xml/reports/ahnentafel_report.xml b/resources/xml/reports/ahnentafel_report.xml index 2447a46647b..512883f9bb6 100644 --- a/resources/xml/reports/ahnentafel_report.xml +++ b/resources/xml/reports/ahnentafel_report.xml @@ -100,8 +100,8 @@ - - . + + .