From 6c0388f9052d53b3420b9ff1f79a1a604d11dac6 Mon Sep 17 00:00:00 2001 From: Ɓukasz Wilenski Date: Tue, 14 Dec 2010 20:16:43 +0000 Subject: number of children can be in NCHI tag, when no recored we should check this tag --- includes/classes/class_family.php | 10 ++++------ modules/family_nav/module.php | 20 ++++++++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/includes/classes/class_family.php b/includes/classes/class_family.php index 3768a7fba9..fda3c07a52 100644 --- a/includes/classes/class_family.php +++ b/includes/classes/class_family.php @@ -203,12 +203,10 @@ class Family extends GedcomRecord { */ function getNumberOfChildren() { - if ($this->numChildren!==false) return $this->numChildren; - - $this->numChildren = get_gedcom_value('NCHI', 1, $this->gedrec); - if ($this->numChildren!='') return $this->numChildren.'.'; - $this->numChildren = preg_match_all('/1\s*CHIL\s*@(.*)@/', $this->gedrec, $smatch); - return $this->numChildren; + $nchi1=(int)get_gedcom_value('NCHI', 1, $this->gedrec); + $nchi2=(int)get_gedcom_value('NCHI', 2, $this->gedrec); + $nchi3=preg_match_all('/1\s*CHIL\s*@(.*)@/', $this->gedrec, $smatch); + return $this->numChildren=max($nchi1, $nchi2, $nchi3); } /** diff --git a/modules/family_nav/module.php b/modules/family_nav/module.php index bcb3590274..f6279a3821 100644 --- a/modules/family_nav/module.php +++ b/modules/family_nav/module.php @@ -739,11 +739,11 @@ function print_pedigree_person_nav($pid, $style=1, $count=0, $personcount="1") { } // Children ------------------------------ @var $child Person - $hasChildren = 'No'; + $hasChildren = false; foreach ($children as $c=>$child) { if ($child) { - if ($hasChildren == 'No') { - $hasChildren = 'Yes'; + if (!$hasChildren) { + $hasChildren = true; $spouselinks .= ""; - } else { - $spouselinks .= "\"".i18n::translate('This ".i18n::translate('This family remained childless')."
"; + } + if (!$hasChildren) { + $numchil = $family->getNumberOfChildren(); + if ($numchil==0) { + $spouselinks .= "\"".i18n::translate('This ".i18n::translate('This family remained childless')."
"; + } else if ($numchil==1) { + $spouselinks .= i18n::translate('1 child'); + } else { + $spouselinks .= $numchil.' '.i18n::translate('children'); + } } } } -- cgit v1.3