summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfisharebest <fisharebest@gmail.com>2010-12-30 15:43:16 +0000
committerfisharebest <fisharebest@gmail.com>2010-12-30 15:43:16 +0000
commitb0ab007ceab1e2277bf7236e65b11698cc760ebf (patch)
tree4b1ba0a672ca925706b9751c84f4c0fb73deccee
parentecbc6db9fae9112dbb21cd9aedbc3b123979526e (diff)
downloadwebtrees-b0ab007ceab1e2277bf7236e65b11698cc760ebf.tar.gz
webtrees-b0ab007ceab1e2277bf7236e65b11698cc760ebf.tar.bz2
webtrees-b0ab007ceab1e2277bf7236e65b11698cc760ebf.zip
Tidy up. Use objects instead of XREFs
-rw-r--r--includes/classes/class_family.php12
-rw-r--r--includes/functions/functions_charts.php9
2 files changed, 10 insertions, 11 deletions
diff --git a/includes/classes/class_family.php b/includes/classes/class_family.php
index fda3c07a52..3750ddb06f 100644
--- a/includes/classes/class_family.php
+++ b/includes/classes/class_family.php
@@ -184,15 +184,15 @@ class Family extends GedcomRecord {
function loadChildren() {
if ($this->children_loaded) return;
$this->childrenIds = array();
- $this->numChildren = preg_match_all('/1\s*CHIL\s*@(.*)@/', $this->gedrec, $smatch, PREG_SET_ORDER);
+ $this->numChildren = preg_match_all('/\n1 CHIL @('.WT_REGEX_XREF.')@/', $this->gedrec, $smatch, PREG_SET_ORDER);
for ($i=0; $i<$this->numChildren; $i++) {
- //-- get the childs ids
- $chil = trim($smatch[$i][1]);
- $this->childrenIds[] = $chil;
+ $this->childrenIds[] = $smatch[$i][1];
}
foreach ($this->childrenIds as $t=>$chil) {
$child=Person::getInstance($chil);
- if (!is_null($child)) $this->children[] = $child;
+ if ($child) {
+ $this->children[] = $child;
+ }
}
$this->children_loaded = true;
}
@@ -205,7 +205,7 @@ class Family extends GedcomRecord {
$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);
+ $nchi3=preg_match_all('/\n1 CHIL @(.*)@/', $this->gedrec, $smatch);
return $this->numChildren=max($nchi1, $nchi2, $nchi3);
}
diff --git a/includes/functions/functions_charts.php b/includes/functions/functions_charts.php
index 7640277ea8..a3be2dbfaf 100644
--- a/includes/functions/functions_charts.php
+++ b/includes/functions/functions_charts.php
@@ -682,7 +682,7 @@ function print_cousins($famid, $personcount="1") {
$ged_id=get_id_from_gedcom($GEDCOM);
$family=Family::getInstance($famid);
- $fchildren=$family->getChildrenIds();
+ $fchildren=$family->getChildren();
$kids = count($fchildren);
$save_show_full = $show_full;
@@ -697,12 +697,12 @@ function print_cousins($famid, $personcount="1") {
if ($kids>1) echo "<td rowspan=\"".$kids."\" valign=\"middle\" align=\"right\"><img width=\"3px\" height=\"". (($bheight+5) * ($kids-1)) ."px\" src=\"".$WT_IMAGES["vline"]."\" alt=\"\" /></td>";
$ctkids = count($fchildren);
$i = 1;
- foreach ($fchildren as $indexval => $fchil) {
+ foreach ($fchildren as $fchil) {
echo "<td><img width=\"10px\" height=\"3px\" style=\"padding-";
if ($TEXT_DIRECTION=="ltr") echo "right";
else echo "left";
echo ": 2px;\" src=\"".$WT_IMAGES["hline"]."\" alt=\"\" /></td><td>";
- print_pedigree_person($fchil, 1 , 0, $personcount);
+ print_pedigree_person($fchil->getXref(), 1 , 0, $personcount);
$personcount++;
echo "</td></tr>";
if ($i < $ctkids) {
@@ -711,8 +711,7 @@ function print_cousins($famid, $personcount="1") {
}
}
echo "</table>";
- }
- else {
+ } else {
$famrec = find_family_record($famid, $ged_id);
$ct = preg_match("/1 NCHI (\w+)/", $famrec, $match);
if ($ct>0) $nchi = $match[1];