summaryrefslogtreecommitdiff
path: root/library/WT
diff options
context:
space:
mode:
authorfisharebest <fisharebest@gmail.com>2013-07-04 20:11:21 +0000
committerfisharebest <fisharebest@gmail.com>2013-07-04 20:11:21 +0000
commited5d1ddf27deafbacb6c076b169820e70a8ff00c (patch)
tree554ca9c9285c5226418fa156658ea3f3cda519b7 /library/WT
parenta7f67e6898261b991999edbc955e52ac5ee05bc1 (diff)
downloadwebtrees-ed5d1ddf27deafbacb6c076b169820e70a8ff00c.tar.gz
webtrees-ed5d1ddf27deafbacb6c076b169820e70a8ff00c.tar.bz2
webtrees-ed5d1ddf27deafbacb6c076b169820e70a8ff00c.zip
Show missing spouse as an unknown person on charts. Provides more consistent layout and simpler code.
Diffstat (limited to 'library/WT')
-rw-r--r--library/WT/Controller/Descendancy.php18
-rw-r--r--library/WT/Controller/Family.php2
-rw-r--r--library/WT/Controller/Familybook.php28
-rw-r--r--library/WT/Controller/Fanchart.php4
-rw-r--r--library/WT/Controller/GedcomRecord.php4
-rw-r--r--library/WT/Controller/Hourglass.php54
-rw-r--r--library/WT/Controller/Lifespan.php5
-rw-r--r--library/WT/Individual.php47
8 files changed, 57 insertions, 105 deletions
diff --git a/library/WT/Controller/Descendancy.php b/library/WT/Controller/Descendancy.php
index 9ee2c3d733..d40004c0f4 100644
--- a/library/WT/Controller/Descendancy.php
+++ b/library/WT/Controller/Descendancy.php
@@ -196,26 +196,22 @@ class WT_Controller_Descendancy extends WT_Controller_Chart {
if (is_null($family)) return;
if (is_null($person)) return;
- $spouse=$family->getSpouse($person);
- if (!$spouse) {
- // One parent families have no spouse
- $spouse=new WT_Individual('');
- }
-
// print marriage info
echo '<li>';
echo '<img src="', $WT_IMAGES['spacer'], '" height="2" width="', ($Dindent+4), '" alt="">';
echo '<span class="details1" style="white-space:nowrap;">';
echo "<a href=\"#\" onclick=\"expand_layer('".$family->getXref().$personcount."'); return false;\" class=\"top\"><i id=\"".$family->getXref().$personcount."_img\" class=\"icon-minus\" title=\"".WT_I18N::translate('View Family')."\"></i></a>";
- $marriage = $family->getMarriage();
- if ($marriage->canShow()) {
- echo ' <a href="', $family->getHtmlUrl(), '" class="details1">';
- $marriage->print_simple_fact();
- echo '</a>';
+ foreach ($family->getFacts(WT_EVENTS_MARR) as $fact) {
+ if ($fact->canShow()) {
+ echo ' <a href="', $family->getHtmlUrl(), '" class="details1">';
+ $fact->print_simple_fact();
+ echo '</a>';
+ }
}
echo '</span>';
// print spouse
+ $spouse=$family->getSpouse($person);
echo '<ul style="list-style:none; display:block;" id="'.$family->getXref().$personcount.'">';
echo '<li>';
echo '<table border="0" cellpadding="0" cellspacing="0"><tr><td>';
diff --git a/library/WT/Controller/Family.php b/library/WT/Controller/Family.php
index 686627562b..cb9b9181c9 100644
--- a/library/WT/Controller/Family.php
+++ b/library/WT/Controller/Family.php
@@ -68,7 +68,7 @@ class WT_Controller_Family extends WT_Controller_GedcomRecord {
function getTimelineIndis($tags) {
preg_match_all('/\n1 (?:'.implode('|', $tags).') @('.WT_REGEX_XREF.')@/', $this->record->getGedcom(), $matches);
foreach ($matches[1] as &$match) {
- $match='pids[]='.$match;
+ $match='pids%5B%5D='.$match;
}
return implode('&amp;', $matches[1]);
}
diff --git a/library/WT/Controller/Familybook.php b/library/WT/Controller/Familybook.php
index c509a10af4..8d01fcddec 100644
--- a/library/WT/Controller/Familybook.php
+++ b/library/WT/Controller/Familybook.php
@@ -216,22 +216,18 @@ class WT_Controller_Familybook extends WT_Controller_Chart {
if ($count==1 ) {
if ($this->show_spouse) {
foreach ($sfamilies as $family) {
- if (!is_null($family)) {
- $spouse = $family->getSpouse($person);
- if ($spouse!=null) {
- echo '</td></tr><tr><td>';
- //-- shrink the box for the spouses
- $tempw = $bwidth;
- $temph = $bheight;
- $bwidth -= 10;
- $bheight -= 10;
- print_pedigree_person($spouse);
- $bwidth = $tempw;
- $bheight = $temph;
- $numkids += 0.95;
- echo '</td><td></td>';
- }
- }
+ $spouse = $family->getSpouse($person);
+ echo '</td></tr><tr><td>';
+ //-- shrink the box for the spouses
+ $tempw = $bwidth;
+ $temph = $bheight;
+ $bwidth -= 10;
+ $bheight -= 10;
+ print_pedigree_person($spouse);
+ $bwidth = $tempw;
+ $bheight = $temph;
+ $numkids += 0.95;
+ echo '</td><td></td>';
}
}
}
diff --git a/library/WT/Controller/Fanchart.php b/library/WT/Controller/Fanchart.php
index ea6edf7c12..2eccce80f5 100644
--- a/library/WT/Controller/Fanchart.php
+++ b/library/WT/Controller/Fanchart.php
@@ -321,9 +321,7 @@ class WT_Controller_Fanchart extends WT_Controller_Chart {
// spouse(s) and children
foreach ($person->getSpouseFamilies() as $family) {
$spouse=$family->getSpouse($person);
- if ($spouse) {
- $html.= '<br><a href="'.$spouse->getHtmlUrl().'" class="name1">'.$spouse->getFullName().'</a>';
- }
+ $html.= '<br><a href="'.$spouse->getHtmlUrl().'" class="name1">'.$spouse->getFullName().'</a>';
foreach ($family->getChildren() as $child) {
$html.= '<br>&nbsp;&nbsp;<a href="'.$child->getHtmlUrl().'" class="name1">&lt; '.$child->getFullName().'</a>';
}
diff --git a/library/WT/Controller/GedcomRecord.php b/library/WT/Controller/GedcomRecord.php
index 233c7fbaac..205ba4d4d4 100644
--- a/library/WT/Controller/GedcomRecord.php
+++ b/library/WT/Controller/GedcomRecord.php
@@ -29,6 +29,10 @@ class WT_Controller_GedcomRecord extends WT_Controller_Page {
public $record; // individual, source, repository, etc.
public function __construct() {
+ // Non-existant record?
+ if ($this->record->getXref() == WT_GedcomRecord::DUMMY_XREF) {
+ $this->record = null;
+ }
// Automatically fix broken links
if ($this->record && $this->record->canEdit()) {
$broken_links=0;
diff --git a/library/WT/Controller/Hourglass.php b/library/WT/Controller/Hourglass.php
index 01285b296b..d60dcc1e92 100644
--- a/library/WT/Controller/Hourglass.php
+++ b/library/WT/Controller/Hourglass.php
@@ -301,13 +301,8 @@ class WT_Controller_Hourglass extends WT_Controller_Chart {
//-- move the arrow up to line up with the correct box
if ($this->show_spouse) {
foreach ($families as $family) {
- /* @var $family Family */
- if (!is_null($family)) {
- $spouse = $family->getSpouse($person);
- if ($spouse!=null) {
- echo "<br><br><br>";
- }
- }
+ $spouse = $family->getSpouse($person);
+ echo "<br><br><br>";
}
}
echo "</td><td width=\"$bwidth\">";
@@ -321,23 +316,17 @@ class WT_Controller_Hourglass extends WT_Controller_Chart {
//----- Print the spouse
if ($this->show_spouse) {
foreach ($families as $family) {
- /* @var $family Family */
- if (!is_null($family)) {
- $spouse = $family->getSpouse($person);
- if ($spouse!=null) {
- echo "</td></tr><tr><td align=\"$otablealign\">";
- //-- shrink the box for the spouses
- $tempw = $bwidth;
- $temph = $bheight;
- $bwidth -= 10;
- $bheight -= 10;
- print_pedigree_person($spouse);
- $bwidth = $tempw;
- $bheight = $temph;
- $numkids += 0.95;
- echo "</td><td></td>";
- }
- }
+ echo "</td></tr><tr><td align=\"$otablealign\">";
+ //-- shrink the box for the spouses
+ $tempw = $bwidth;
+ $temph = $bheight;
+ $bwidth -= 10;
+ $bheight -= 10;
+ print_pedigree_person($family->getSpouse($person));
+ $bwidth = $tempw;
+ $bheight = $temph;
+ $numkids += 0.95;
+ echo "</td><td></td>";
}
//-- add offset divs to make things line up better
if ($count==$this->dgenerations) echo "<tr><td colspan\"2\"><div style=\"height: ".($bhalfheight/2)."px; width: ".$bwidth."px;\"><br></div>";
@@ -365,16 +354,12 @@ class WT_Controller_Hourglass extends WT_Controller_Chart {
foreach ($famids as $family) {
$spouse = $family->getSpouse($person);
- if ($spouse) {
- $spid = $spouse->getXref();
- echo "<a href=\"hourglass.php?rootid={$spid}&amp;show_spouse={$this->show_spouse}&amp;show_full={$this->show_full}&amp;generations={$this->generations}&amp;box_width={$this->box_width}\" class=\"name1\">";
- echo $spouse->getFullName();
- echo '</a><br>';
-
- }
+ $spid = $spouse->getXref();
+ echo "<a href=\"hourglass.php?rootid={$spid}&amp;show_spouse={$this->show_spouse}&amp;show_full={$this->show_full}&amp;generations={$this->generations}&amp;box_width={$this->box_width}\" class=\"name1\">";
+ echo $spouse->getFullName();
+ echo '</a><br>';
- $children = $family->getChildren();
- foreach ($children as $id=>$child) {
+ foreach ($family->getChildren() as $child) {
$cid = $child->getXref();
echo "&nbsp;&nbsp;<a href=\"hourglass.php?rootid={$cid}&amp;show_spouse={$this->show_spouse}&amp;show_full={$this->show_full}&amp;generations={$this->generations}&amp;box_width={$this->box_width}\" class=\"name1\">";
echo $child->getFullName();
@@ -401,11 +386,10 @@ class WT_Controller_Hourglass extends WT_Controller_Chart {
echo '</a><br>';
}
}
- $children = $family->getChildren();
$num = $family->getNumberOfChildren();
if ($num>2) echo "<span class=\"name1\"><br>".WT_I18N::translate('Siblings')."<br></span>";
if ($num==2) echo "<span class=\"name1\"><br>".WT_I18N::translate('Sibling')."<br></span>";
- foreach ($children as $id=>$child) {
+ foreach ($family->getChildren() as $child) {
$cid = $child->getXref();
if ($cid!=$pid) {
echo "&nbsp;&nbsp;<a href=\"hourglass.php?rootid={$cid}&amp;show_spouse={$this->show_spouse}&amp;show_full={$this->show_full}&amp;generations={$this->generations}&amp;box_width={$this->box_width}\" class=\"name1\">";
diff --git a/library/WT/Controller/Lifespan.php b/library/WT/Controller/Lifespan.php
index e142ad9343..5412b60e95 100644
--- a/library/WT/Controller/Lifespan.php
+++ b/library/WT/Controller/Lifespan.php
@@ -211,10 +211,7 @@ class WT_Controller_Lifespan extends WT_Controller_Page {
$this->pids[]=$person->getXref();
if ($add_family) {
foreach ($person->getSpouseFamilies() as $family) {
- $spouse=$family->getSpouse($person);
- if ($spouse) {
- $this->pids[]=$spouse->getXref();
- }
+ $this->pids[]=$family->getSpouse($person)->getXref();
foreach ($family->getChildren() as $child) {
$this->pids[]=$child->getXref();
}
diff --git a/library/WT/Individual.php b/library/WT/Individual.php
index eefcef6c1c..0f53915a7d 100644
--- a/library/WT/Individual.php
+++ b/library/WT/Individual.php
@@ -208,14 +208,12 @@ class WT_Individual extends WT_GedcomRecord {
}
// Check spouse dates
$spouse=$family->getSpouse($this, WT_PRIV_HIDE);
- if ($spouse) {
- preg_match_all('/\n2 DATE (.+)/', $spouse->gedcom, $date_matches);
- foreach ($date_matches[1] as $date_match) {
- $date=new WT_Date($date_match);
- // Assume max age difference between spouses of 40 years
- if ($date->isOK() && $date->MaxJD() <= WT_SERVER_JD - 365*($MAX_ALIVE_AGE+40)) {
- return true;
- }
+ preg_match_all('/\n2 DATE (.+)/', $spouse->gedcom, $date_matches);
+ foreach ($date_matches[1] as $date_match) {
+ $date=new WT_Date($date_match);
+ // Assume max age difference between spouses of 40 years
+ if ($date->isOK() && $date->MaxJD() <= WT_SERVER_JD - 365*($MAX_ALIVE_AGE+40)) {
+ return true;
}
}
// Check child dates
@@ -907,12 +905,9 @@ class WT_Individual extends WT_GedcomRecord {
$step_families=array();
$families=$this->getSpouseFamilies();
foreach ($families as $family) {
- $spouse=$family->getSpouse($this);
- if ($spouse) {
- foreach ($spouse->getSpouseFamilies() as $step_family) {
- if (!in_array($step_family, $families, true)) {
- $step_families[]=$step_family;
- }
+ foreach ($family->getSpouse($this)->getSpouseFamilies() as $step_family) {
+ if (!in_array($step_family, $families, true)) {
+ $step_families[]=$step_family;
}
}
}
@@ -972,27 +967,9 @@ class WT_Individual extends WT_GedcomRecord {
throw new Exception('Invalid family in WT_Individual::getStepFamilyLabel(' . $family . ')');
}
- /**
- * get the correct label for a family
- * @param Family $family the family to get the label for
- * @return string
- */
- function getSpouseFamilyLabel($family) {
- if (is_null($family)) {
- $spouse=WT_I18N::translate('unknown person');
- } else {
- $husb = $family->getHusband();
- $wife = $family->getWife();
- if ($this->equals($husb) && !is_null($wife)) {
- $spouse = $wife->getFullName();
- } elseif ($this->equals($wife) && !is_null($husb)) {
- $spouse = $husb->getFullName();
- } else {
- $spouse = WT_I18N::translate('unknown person');
- }
- }
- // I18N: %s is the spouse name
- return WT_I18N::translate('Family with %s', $spouse);
+ // TODO - this function doesn't belong in this class
+ function getSpouseFamilyLabel(WT_Family $family) {
+ return /* I18N: %s is the spouse name */ WT_I18N::translate('Family with %s', $family->getSpouse($this)->getFullName());
}
/**