From 0dc1bc1b4fdf72de6d44adec58ef9d4797bff82b Mon Sep 17 00:00:00 2001 From: Neriderc <89974636+Neriderc@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:45:52 +1300 Subject: [PATCH 1/2] Add option to bypass using alt events Added option "Use similar events if information not available". This is enabled by default and is the current state - webtrees currently uses dates and places of christening/baptism for a date of birth if the DOB is not known. And a date and place of cremation/burial for deaths if not known. This new option allows for this to be disabled, and only a birth or death event is used. --- app/FormSubmission.php | 1 + app/Person.php | 48 ++++++++++++++++--- config.php | 1 + .../MainPage/Appearance/TileContents.phtml | 17 ++++--- 4 files changed, 54 insertions(+), 13 deletions(-) diff --git a/app/FormSubmission.php b/app/FormSubmission.php index ca049e2..3ccd54b 100644 --- a/app/FormSubmission.php +++ b/app/FormSubmission.php @@ -143,6 +143,7 @@ public function load($vars, $module): array } $settings['show_marriage_place'] = isset($vars['show_marriage_place']); + $settings['use_alt_events'] = isset($vars['use_alt_events']); $settings['show_indi_sex'] = isset($vars['show_indi_sex']); $settings['show_xref_individuals'] = isset($vars['show_xref_individuals']); $settings['show_xref_families'] = isset($vars['show_xref_families']); diff --git a/app/Person.php b/app/Person.php index 661b3ee..233f992 100644 --- a/app/Person.php +++ b/app/Person.php @@ -102,6 +102,7 @@ function printPersonLabel(string $pid, SharedNoteList $sharednotes, bool $relate $out = ''; $border_colour = $this->dot->settings["border_col"]; // Border colour of the INDI's box $death_place = ""; + $birthplace = ""; $i = $this->dot->getUpdatedPerson($pid); // Get the personal data if ($this->dot->settings["diagram_type"] == "combined" && (substr($pid, 0, 3) == "I_H" || substr($pid, 0, 3) == "I_W") || substr($pid, 0, 3) == "I_N") { @@ -134,27 +135,60 @@ function printPersonLabel(string $pid, SharedNoteList $sharednotes, bool $relate // --- Birth date --- if ($this->dot->settings["show_birthdate"]) { - $birthdate = Dot::formatDate($i->getBirthDate(), $this->dot->settings["birthdate_year_only"], $this->dot->settings["use_abbr_month"]); - } else { + if ($this->dot->settings["use_alt_events"]) { + $date = $i->getBirthDate(); + } else { + $dates = $i->getAllEventDates(['BIRT']); + if ($dates !== []) { + $date = $dates[0]; + } else { + $date = new Date(''); + } + } + $birthdate = Dot::formatDate($date, $this->dot->settings["birthdate_year_only"], $this->dot->settings["use_abbr_month"]); + + } else { $birthdate = ""; } if ($this->dot->settings["show_birthplace"]) { // Show birthplace - $birthplace = Dot::getAbbreviatedPlace($i->getBirthPlace()->gedcomName(), $this->dot->settings); - } else { - $birthplace = ""; + if ($this->dot->settings["use_alt_events"]) { + $birthplace = Dot::getAbbreviatedPlace($i->getBirthPlace()->gedcomName(), $this->dot->settings); + } else { + $places = $i->getAllEventPlaces(['BIRT']); + if ($places !== []) { + $birthplace = $places[0]->gedcomName(); + } + } } // --- Death date --- if ($this->dot->settings["show_death_date"]) { - $death_date = Dot::formatDate($i->getDeathDate(), $this->dot->settings["death_date_year_only"], $this->dot->settings["use_abbr_month"]); + if ($this->dot->settings["use_alt_events"]) { + $date = $i->getDeathDate(); + } else { + $dates = $i->getAllEventDates(['DEAT']); + if ($dates !== []) { + $date = $dates[0]; + } else { + $date = new Date(''); + } + } + $death_date = Dot::formatDate($date, $this->dot->settings["death_date_year_only"], $this->dot->settings["use_abbr_month"]); } else { $death_date = ""; } if ($this->dot->settings["show_death_place"]) { // Show death place - $death_place = Dot::getAbbreviatedPlace($i->getDeathPlace()->gedcomName(), $this->dot->settings); + if ($this->dot->settings["use_alt_events"]) { + $death_place = Dot::getAbbreviatedPlace($i->getDeathPlace()->gedcomName(), $this->dot->settings); + } else { + $places = $i->getAllEventPlaces(['DEAT']); + if ($places !== []) { + $death_place = $places[0]->gedcomName(); + } + } } // --- Name --- $names = $i->getAllNames(); diff --git a/config.php b/config.php index 9ff0247..fd77ce6 100644 --- a/config.php +++ b/config.php @@ -29,6 +29,7 @@ 'show_death_date' => true, // Whether to show death date for individuals 'death_date_year_only' => false, // Whether to show just the year or the full GEDCOM date pf death 'show_death_place' => true, // Whether to show death date for individuals + 'use_alt_events' => true, // Whether to use similar events if the birth or death place is not available (e.g. Christening or Burial) 'show_marriage_date' => true, // Whether to show marriage date on the family record 'marr_date_year_only' => false, // Whether to show just the year or the full GEDCOM date of marriage 'show_marriage_place' => true, // Whether to show the place of marriage on the family record diff --git a/resources/views/MainPage/Appearance/TileContents.phtml b/resources/views/MainPage/Appearance/TileContents.phtml index e8b994a..138af2c 100644 --- a/resources/views/MainPage/Appearance/TileContents.phtml +++ b/resources/views/MainPage/Appearance/TileContents.phtml @@ -61,11 +61,11 @@ use Fisharebest\Webtrees\I18N; } ?> > - +