summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/classes/class_family.php10
-rw-r--r--modules/family_nav/module.php20
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 .= "<ul class=\"clist ".$TEXT_DIRECTION."\">";
}
$persons="Yes";
@@ -754,10 +754,18 @@ function print_pedigree_person_nav($pid, $style=1, $count=0, $personcount="1") {
$spouselinks .= "</a>";
}
}
- if ($hasChildren == 'Yes') {
+ if ($hasChildren) {
$spouselinks .= "</ul>";
- } else {
- $spouselinks .= "<img src=\"images/small/childless.gif\" alt=\"".i18n::translate('This family remained childless')."\" height=\"15\" align=\"middle\"/> ".i18n::translate('This family remained childless')."<br />";
+ }
+ if (!$hasChildren) {
+ $numchil = $family->getNumberOfChildren();
+ if ($numchil==0) {
+ $spouselinks .= "<img src=\"images/small/childless.gif\" alt=\"".i18n::translate('This family remained childless')."\" height=\"15\" align=\"middle\"/> ".i18n::translate('This family remained childless')."<br />";
+ } else if ($numchil==1) {
+ $spouselinks .= i18n::translate('1 child');
+ } else {
+ $spouselinks .= $numchil.'&nbsp;'.i18n::translate('children');
+ }
}
}
}