Skip to content

Commit

Permalink
bugs fixed
Browse files Browse the repository at this point in the history
issues #57
  • Loading branch information
hartenthaler committed Oct 3, 2021
1 parent a9d4618 commit c9496fa
Show file tree
Hide file tree
Showing 8 changed files with 486 additions and 199 deletions.
70 changes: 18 additions & 52 deletions ExtendedFamily.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
* tbd: offene Punkte
* ------------------
*
* Performance: testen von Variante A und B
* Code: neue Subklasse für die Funktion personExistsInExtendedFamily(), damit die Funktion des ausgegrauten Tabs wieder funktioniert
* Performance: testen von Variante A und B (letztere muss erst noch fertig implementiert werden)
*
* issues/enhancements: see GitHub
* #57 alle Fälle mit gemischtem Geschlecht für Übersetzung vorbereiten, insbesondere bei den Partnern
*
* generelle Familienkennzeichen: statt "Eltern" immer "Ehe/Partnerschaft" verwenden
*
Expand Down Expand Up @@ -57,6 +55,7 @@
* Code: eventuell Verwendung der bestehenden Funktionen "_individuals" zum Aufbau von Familienteilen verwenden statt es jedes Mal vom Probanden aus komplett neu zu gestalten
* Code: Ablaufreihenfolge in function addIndividualToFamily() umbauen wie function addIndividualToFamilyAsPartner()
*
* Test: Übersetzung bei den Partnern testen bei diversen Fällen mit gemischtem Geschlecht
* Test: wie verhält es sich, wenn eine Person als Kind zu zwei Familien gehört (bei P Seudo: C2)
* Test: Stiefcousins (siehe Onkel Walter)
* Test: Schwagerehe (etwa Levirat oder Sororat)
Expand Down Expand Up @@ -146,6 +145,7 @@ class ExtendedFamily
* ->familyPartParameters array of array
* ->sizeThumbnailW int (in pixel)
* ->sizeThumbnailH int (in pixel)
* ->name string // tbd used for Vesta modules
*/
public $config;

Expand Down Expand Up @@ -180,16 +180,6 @@ public function __construct(Individual $proband, object $config)
$this->constructProband($proband);
$this->constructFiltersExtendedFamilyParts();
}

/**
* get object containing configuration parameters
*
* @return object
*/
public function getConfig(): object
{
return $this->config;
}

/**
* construct object containing configuration information based on module parameters
Expand Down Expand Up @@ -259,30 +249,24 @@ private function constructFiltersExtendedFamilyParts()
}

/**
* check if there is at least one person in one of the selected extended family parts (used to decide if tab is grayed out)
* get a name for the relationship between an individual and the proband
*
* @return bool
public function personExistsInExtendedFamily(): bool
* @param Individual $individual
* @param Individual $proband
* @param string $name this should be the name of the ExtendedFamilyTabModule Class
* @return string containing translated relationship name
*/
public static function getRelationshipName(Individual $individual, Individual $proband, string $name): string
{
$obj = (object)[]; // tbd replace $obj by $ef
$extfamObj = (object)[];
$extfamObj->efp = (object)[];
$found = false;
foreach ($this->config->shownFamilyParts as $efp => $element) {
if ($element->enabled) {
$extfamObj->efp->$efp = $this->initializeFamilyPartObject($efp);
$this->callFunction( 'find_' . $efp, $extfamObj->efp->$efp );
$this->filterAndAddCountersToFamilyPartObject( $extfamObj->efp->$efp, 'all' );
if ($extfamObj->efp->$efp->allCount > 0) {
$found = true;
break;
}
}
if (ExtendedFamilyTabModule::VestaModulesAvailable(false)) {
//error_log("Vesta Modules available");
return \Cissee\Webtrees\Module\ExtendedRelationships\ExtendedRelationshipModule::getRelationshipLink(
$name, $individual->tree(), null, $individual->xref(), $proband->xref(), 4);
} else {
//error_log("Vesta Modules not available");
}
// tbd release/unset all objects
return $found;
} */
return '';
}

/**
* list of parts of extended family
Expand Down Expand Up @@ -340,24 +324,6 @@ public static function getFamilyPartParameters(): array
];
}

/**
* get a name for the relationship between an individual and the proband
*
* @param Individual $individual
* @return string
private function getRelationshipName(Individual $individual): string
{
if (ExtendedFamilyTabModule::VestaModulesAvailable(false)) {
error_log("Vesta Modules available");
// return \Cissee\Webtrees\Module\ExtendedRelationships\ExtendedRelationshipModule::getRelationshipLink($this->config->name, $individual->tree(), null, $individual->xref(), $this->proband->indi->xref(), 4);
} else {
error_log("Vesta Modules not available");
}
return '';
}
*/

/**
* get list of options to filter by gender
*
Expand Down
129 changes: 129 additions & 0 deletions ExtendedFamilyPersonExists.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?php
/*
* webtrees - extended family part
*
* Copyright (C) 2021 Hermann Hartenthaler. All rights reserved.
*
* webtrees: online genealogy / web based family history software
* Copyright (C) 2021 webtrees development team.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; If not, see <https://www.gnu.org/licenses/>.
*/

namespace Hartenthaler\Webtrees\Module\ExtendedFamily;

//use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
/*
use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\GedcomCode\GedcomCodePedi;
use Hartenthaler\Webtrees\Module\ExtendedFamily\Grandparents;
use Hartenthaler\Webtrees\Module\ExtendedFamily\Uncles_and_aunts;
use Hartenthaler\Webtrees\Module\ExtendedFamily\Parents;
use Hartenthaler\Webtrees\Module\ExtendedFamily\Siblings;
use Hartenthaler\Webtrees\Module\ExtendedFamily\Cousins;
use Hartenthaler\Webtrees\Module\ExtendedFamily\Nephews_and_nieces;
use Hartenthaler\Webtrees\Module\ExtendedFamily\Children;
use Hartenthaler\Webtrees\Module\ExtendedFamily\Grandchildren;
*/

require_once(__DIR__ . '/src/Factory/ExtendedFamilyPartFactory.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyPart.php');

require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Grandparents.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Uncles_and_aunts.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Uncles_and_aunts_bm.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Parents.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Parents_in_law.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Co_parents_in_law.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Siblings.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Siblings_in_law.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Co_siblings_in_law.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Partners.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Partner_chains.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Cousins.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Nephews_and_nieces.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Children.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Children_in_law.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Grandchildren.php');

/**
* class ExtendedFamilyPersonExists
* to check in efficient way if there exists at least one person in one of the selected extended family parts of the proband
* used in the function to decide if the tab has to be grayed out
*/
class ExtendedFamilyPersonExists extends ExtendedFamily
{
public bool $found;

/**
* constructor for this class
*
* @param Individual $proband the proband for whom the extended family members are searched
* @param object $config configuration parameters for this extended family
*/
public function __construct(Individual $proband, object $config)
{
$this->constructConfig($config);
$this->constructProband($proband);
$this->found = $this->constructCheck();
}

/**
* construct object containing configuration information based on module parameters
*
* @param object $config configuration parameters
*/
private function constructConfig(object $config)
{
$this->config = $config;
}

/**
* construct object containing information related to the proband
*
* @param Individual $proband
*/
private function constructProband(Individual $proband)
{
$this->proband = (object)[];
$this->proband->indi = $proband;
}

/**
* build extended family parts, but stop as soon a person is found in one of the extended family parts
* tbd: start with parents, children, siblings, ... this is maybe a bit more efficient
*
* @return bool
*/
private function constructCheck(): bool
{
$found = false;
foreach ($this->config->shownFamilyParts as $efp => $element) {
if ($element->enabled) {
//$efpObj = ExtendedFamilyPartFactory::create(ucfirst($efp), $this->proband->indi, 'all');
if (ExtendedFamilyPartFactory::create(ucfirst($efp), $this->proband->indi, 'all')->getEfpObject()->allCount > 0) {
$found = true;
break;
}
}
}
return $found; // tbd release/unset all objects
}

public function found(): bool
{
return $this->found;
}
}

0 comments on commit c9496fa

Please sign in to comment.