summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--edit_interface.php12
-rw-r--r--includes/functions/functions_charts.php4
-rw-r--r--includes/functions/functions_export.php8
-rw-r--r--includes/functions/functions_print.php12
-rw-r--r--includes/functions/functions_print_facts.php4
-rw-r--r--includes/functions/functions_print_lists.php2
-rw-r--r--library/WT/Family.php2
-rw-r--r--library/WT/GedcomRecord.php26
-rw-r--r--library/WT/Media.php2
-rw-r--r--library/WT/Report/Base.php6
-rw-r--r--library/WT/Stats.php8
-rw-r--r--modules_v3/sitemap/module.php2
12 files changed, 53 insertions, 35 deletions
diff --git a/edit_interface.php b/edit_interface.php
index 03b7cacc24..7d32a18885 100644
--- a/edit_interface.php
+++ b/edit_interface.php
@@ -2154,14 +2154,14 @@ function print_indi_form($nextaction, WT_Individual $person=null, WT_Family $fam
$family = WT_Family::getInstance($famid);
if ($family) {
$father = $family->getHusband();
- if ($father->getFactByType('NAME')) {
- $father_name = $father->getFactByType('NAME')->getValue();
+ if ($father->getFirstFact('NAME')) {
+ $father_name = $father->getFirstFact('NAME')->getValue();
} else {
$father_name='';
}
$mother = $family->getWife();
- if ($mother->getFactByType('NAME')) {
- $mother_name = $mother->getFactByType('NAME')->getValue();
+ if ($mother->getFirstFact('NAME')) {
+ $mother_name = $mother->getFirstFact('NAME')->getValue();
} else {
$mother_name = '';
}
@@ -2170,8 +2170,8 @@ function print_indi_form($nextaction, WT_Individual $person=null, WT_Family $fam
$father_name = '';
}
// We'll need the spouse/child's name to set the spouse/parent's surname
- if ($person && $person->getFactByType('NAME')) {
- $indi_name = $person->getFactByType('NAME')->getValue();
+ if ($person && $person->getFirstFact('NAME')) {
+ $indi_name = $person->getFirstFact('NAME')->getValue();
} else {
$indi_name = '';
}
diff --git a/includes/functions/functions_charts.php b/includes/functions/functions_charts.php
index 2c2cde4a89..9e8b3216b6 100644
--- a/includes/functions/functions_charts.php
+++ b/includes/functions/functions_charts.php
@@ -329,8 +329,8 @@ function print_family_children(WT_Family $family, $childid = "", $sosa = 0, $lab
echo "<td class=\"details1\" valign=\"middle\" align=\"center\">";
$spouse = $famids[$f]->getSpouse($child);
- $marr = $famids[$f]->getFactbyType('MARR');
- $div = $famids[$f]->getFactByType('DIV');
+ $marr = $famids[$f]->getFirstFact('MARR');
+ $div = $famids[$f]->getFirstFact('DIV');
if ($marr && $marr->canShow()) {
// marriage date
echo $marr->getDate()->minDate()->Format('%Y');
diff --git a/includes/functions/functions_export.php b/includes/functions/functions_export.php
index 979bc8a0e8..41715ea111 100644
--- a/includes/functions/functions_export.php
+++ b/includes/functions/functions_export.php
@@ -107,16 +107,16 @@ function gedcom_header($gedfile) {
// Preserve some values from the original header
$record = WT_GedcomRecord::getInstance('HEAD');
- if ($fact = $record->getFactByType('PLAC')) {
+ if ($fact = $record->getFirstFact('PLAC')) {
$PLAC = $fact->getAttribute('FORM');
}
- if ($fact = $record->getFactByType('LANG')) {
+ if ($fact = $record->getFirstFact('LANG')) {
$LANG = $fact->getValue();
}
- if ($fact = $record->getFactByType('SUBN')) {
+ if ($fact = $record->getFirstFact('SUBN')) {
$SUBN = $fact->getValue();
}
- if ($fact = $record->getFactByType('COPR')) {
+ if ($fact = $record->getFirstFact('COPR')) {
$COPR = $fact->getValue();
}
// Link to actual SUBM/SUBN records, if they exist
diff --git a/includes/functions/functions_print.php b/includes/functions/functions_print.php
index 9dcd2b7005..1c91a86395 100644
--- a/includes/functions/functions_print.php
+++ b/includes/functions/functions_print.php
@@ -186,7 +186,7 @@ function print_pedigree_person($person, $style=1, $count=0, $personcount="1") {
if ($show_full) {
foreach (explode('|', WT_EVENTS_BIRT) as $birttag) {
if (!in_array($birttag, $opt_tags)) {
- $event = $person->getFactByType($birttag);
+ $event = $person->getFirstFact($birttag);
if ($event && ($event->getDate()->isOK() || $event->getPlace())) {
$BirthDeath .= $event->print_simple_fact(true);
break;
@@ -197,7 +197,7 @@ function print_pedigree_person($person, $style=1, $count=0, $personcount="1") {
// Show optional events (before death)
foreach ($opt_tags as $key=>$tag) {
if (!preg_match('/^('.WT_EVENTS_DEAT.')$/', $tag)) {
- $event = $person->getFactByType($tag);
+ $event = $person->getFirstFact($tag);
if (!is_null($event)) {
$BirthDeath .= $event->print_simple_fact(true);
unset ($opt_tags[$key]);
@@ -207,7 +207,7 @@ function print_pedigree_person($person, $style=1, $count=0, $personcount="1") {
// Show DEAT or equivalent event
if ($show_full) {
foreach (explode('|', WT_EVENTS_DEAT) as $deattag) {
- $event = $person->getFactByType($deattag);
+ $event = $person->getFirstFact($deattag);
if (!is_null($event) && ($event->getDate()->isOK() || $event->getPlace() || $event->getValue()=='Y')) {
$BirthDeath .= $event->print_simple_fact(true);
if (in_array($deattag, $opt_tags)) {
@@ -219,7 +219,7 @@ function print_pedigree_person($person, $style=1, $count=0, $personcount="1") {
}
// Show remaining optional events (after death)
foreach ($opt_tags as $tag) {
- $event = $person->getFactByType($tag);
+ $event = $person->getFirstFact($tag);
if ($event) {
$BirthDeath .= $event->print_simple_fact(true);
}
@@ -228,7 +228,7 @@ function print_pedigree_person($person, $style=1, $count=0, $personcount="1") {
$opt_tags=preg_split('/\W/', $CHART_BOX_TAGS, 0, PREG_SPLIT_NO_EMPTY);
foreach (explode('|', WT_EVENTS_BIRT) as $birttag) {
if (!in_array($birttag, $opt_tags)) {
- $event = $person->getFactByType($birttag);
+ $event = $person->getFirstFact($birttag);
if ($event && ($event->getDate()->isOK() || $event->getPlace())) {
$tmp=new WT_Place($event->getPlace(), WT_GED_ID);
$birthplace .= $tmp->getShortName();
@@ -793,7 +793,7 @@ function format_fact_date(WT_Fact $event, WT_GedcomRecord $record, $anchor=false
// Can't use getDeathDate(), as this also gives BURI/CREM events, which
// wouldn't give the correct "days after death" result for people with
// no DEAT.
- $death_event=$record->getFactByType('DEAT');
+ $death_event=$record->getFirstFact('DEAT');
if ($death_event) {
$death_date=$death_event->getDate();
} else {
diff --git a/includes/functions/functions_print_facts.php b/includes/functions/functions_print_facts.php
index 2eea2f810f..f6087251fa 100644
--- a/includes/functions/functions_print_facts.php
+++ b/includes/functions/functions_print_facts.php
@@ -517,7 +517,7 @@ function print_fact_sources($factrec, $level, $return=false) {
}
$data .= ' class="source_citations">';
// PUBL
- $publ = $source->getFactByType('PUBL');
+ $publ = $source->getFirstFact('PUBL');
if ($publ) {
$data .= WT_Gedcom_Tag::getLabelValue('PUBL', $publ->getValue());
}
@@ -688,7 +688,7 @@ function print_main_sources(WT_Fact $fact, $level) {
if ($source) {
echo '<a href="', $source->getHtmlUrl(), '">', $source->getFullName(), '</a>';
// PUBL
- $publ = $source->getFactByType('PUBL');
+ $publ = $source->getFirstFact('PUBL');
if ($publ) {
echo WT_Gedcom_Tag::getLabelValue('PUBL', $publ->getValue());
}
diff --git a/includes/functions/functions_print_lists.php b/includes/functions/functions_print_lists.php
index c6f4f4712e..4eefc98627 100644
--- a/includes/functions/functions_print_lists.php
+++ b/includes/functions/functions_print_lists.php
@@ -958,7 +958,7 @@ function format_sour_table($datalist) {
// Sortable name
$html .= '<td>'. strip_tags($source->getFullName()). '</td>';
//-- Author
- $auth = $source->getFactByType('AUTH');
+ $auth = $source->getFirstFact('AUTH');
if ($auth) {
$author = $auth->getValue();
} else {
diff --git a/library/WT/Family.php b/library/WT/Family.php
index b793dc1614..5e43c83fe1 100644
--- a/library/WT/Family.php
+++ b/library/WT/Family.php
@@ -175,7 +175,7 @@ class WT_Family extends WT_GedcomRecord {
* @return WT_Fact
*/
function getMarriage() {
- return $this->getFactByType('MARR');
+ return $this->getFirstFact('MARR');
}
// Return whether or not this family ended in a divorce or was never married.
diff --git a/library/WT/GedcomRecord.php b/library/WT/GedcomRecord.php
index 721d3fa4e2..e7419b3dfb 100644
--- a/library/WT/GedcomRecord.php
+++ b/library/WT/GedcomRecord.php
@@ -676,7 +676,7 @@ class WT_GedcomRecord {
}
// Get the first WT_Fact for the given fact type
- public function getFactByType($tag) {
+ public function getFirstFact($tag) {
foreach ($this->getFacts() as $fact) {
if ($fact->getTag() == $tag && $fact->canShow()) {
return $fact;
@@ -705,7 +705,7 @@ class WT_GedcomRecord {
// (for display) or as a unix timestamp (for sorting)
//////////////////////////////////////////////////////////////////////////////
public function LastChangeTimestamp($sorting=false) {
- $chan = $this->getFactByType('CHAN');
+ $chan = $this->getFirstFact('CHAN');
if ($chan) {
// The record does have a CHAN event
@@ -736,7 +736,7 @@ class WT_GedcomRecord {
// Get the last-change user for this record
//////////////////////////////////////////////////////////////////////////////
public function LastChangeUser() {
- $chan = $this->getFactByType('CHAN');
+ $chan = $this->getFirstFact('CHAN');
if (is_null($chan)) {
return '&nbsp;';
@@ -783,7 +783,7 @@ class WT_GedcomRecord {
}
$new_gedcom = '0 @' . $this->getXref() . '@ ' . static::RECORD_TYPE;
- $old_chan = $this->getFactByType('CHAN');
+ $old_chan = $this->getFirstFact('CHAN');
// Replacing (or deleting) an existing fact
foreach ($this->getFacts() as $fact) {
if ($fact->getFactId() == $fact_id) {
@@ -933,4 +933,22 @@ class WT_GedcomRecord {
AddToLog('Delete: ' . static::RECORD_TYPE . ' ' . $this->xref, 'edit');
}
+
+ // Remove all links from this record to $xref
+ public function removeLinks($xref) {
+ $value = '@' . $xref . '@';
+
+ foreach ($this->getFacts() as $fact) {
+ if ($fact->getValue() == $value) {
+ $this->deleteFact($fact->factId());
+ } elseif (preg_match('/\n(\d) ' . WT_REGEX_TAG . ' ' . $value . '/', $fact->getGedcom(), $matches, PREG_SET_ORDER)) {
+ $gedcom = $fact->getGedcom();
+ foreach ($matches as $match) {
+ $next_levels = '[' . $match[1]+1 . '-9]';
+ $gedcom = preg_replace('/' . $match[1] . '(\n' . $next_levels .'.*)*/', '', $gedcom);
+ }
+ $this->updateFact($fact->factId(), $gedcom);
+ }
+ }
+ }
}
diff --git a/library/WT/Media.php b/library/WT/Media.php
index ba4d5ec017..feb8580c1f 100644
--- a/library/WT/Media.php
+++ b/library/WT/Media.php
@@ -83,7 +83,7 @@ class WT_Media extends WT_GedcomRecord {
// Get the first note attached to this media object
public function getNote() {
- $note = $this->getFactByType('NOTE');
+ $note = $this->getFirstFact('NOTE');
if ($note) {
$text = $note->getValue();
if (preg_match('/@' . WT_REGEX_XREF . '@/', $text)) {
diff --git a/library/WT/Report/Base.php b/library/WT/Report/Base.php
index 23ce35043b..a18570743c 100644
--- a/library/WT/Report/Base.php
+++ b/library/WT/Report/Base.php
@@ -2676,7 +2676,7 @@ function AgeAtDeathSHandler() {
// Can't use getDeathDate(), as this also gives BURI/CREM events, which
// wouldn't give the correct "days after death" result for people with
// no DEAT.
- $death_event=$person->getFactByType('DEAT');
+ $death_event=$person->getFirstFact('DEAT');
if ($death_event) {
$death_date=$death_event->getDate();
} else {
@@ -3243,8 +3243,8 @@ function ListSHandler($attrs) {
break;
case "CHAN":
uasort($list, function($x, $y) {
- $f1 = $x->getFactByType('CHAN');
- $f2 = $y->getFactByType('CHAN');
+ $f1 = $x->getFirstFact('CHAN');
+ $f2 = $y->getFirstFact('CHAN');
if ($f1 && $f2) {
$d1 = $f1->getDate();
$d2 = $f2->getDate();
diff --git a/library/WT/Stats.php b/library/WT/Stats.php
index 046c7b9b10..1dfc193742 100644
--- a/library/WT/Stats.php
+++ b/library/WT/Stats.php
@@ -176,7 +176,7 @@ class WT_Stats {
$source = '';
$head = WT_GedcomRecord::getInstance('HEAD');
- $sour = $head->getFactByType('SOUR');
+ $sour = $head->getFirstFact('SOUR');
if ($sour) {
$source = $sour->getValue();
$title = $sour->getAttribute('NAME');
@@ -209,7 +209,7 @@ class WT_Stats {
global $DATE_FORMAT;
$head = WT_GedcomRecord::getInstance('HEAD');
- $fact = $head->getFactByType('DATE');
+ $fact = $head->getFirstFact('DATE');
if ($fact) {
$date=new WT_Date($fact->getValue());
return $date->Display(false, $DATE_FORMAT); // Override $PUBLIC_DATE_FORMAT
@@ -833,7 +833,7 @@ class WT_Stats {
$result="<a href=\"".$record->getHtmlUrl()."\">".$record->getFullName()."</a>";
break;
case 'place':
- $fact=WT_GedcomRecord::getInstance($row['d_gid'])->getFactByType($row['d_fact']);
+ $fact=WT_GedcomRecord::getInstance($row['d_gid'])->getFirstFact($row['d_fact']);
if ($fact) {
$result=format_fact_place($fact, true, true, true);
} else {
@@ -1773,7 +1773,7 @@ class WT_Stats {
$result="<a href=\"".$record->getHtmlUrl()."\">".$record->getFullName()."</a>";
break;
case 'place':
- $fact=$record->getFactByType($row['fact']);
+ $fact=$record->getFirstFact($row['fact']);
if ($fact) {
$result=format_fact_place($fact, true, true, true);
} else {
diff --git a/modules_v3/sitemap/module.php b/modules_v3/sitemap/module.php
index 967b3f7626..d79aedf353 100644
--- a/modules_v3/sitemap/module.php
+++ b/modules_v3/sitemap/module.php
@@ -190,7 +190,7 @@ class sitemap_WT_Module extends WT_Module implements WT_Module_Config {
if ($record->canShowName()) {
$data.='<url>';
$data.='<loc>'.WT_SERVER_NAME.WT_SCRIPT_PATH.$record->getHtmlUrl().'</loc>';
- $chan=$record->getFactByType('CHAN');
+ $chan=$record->getFirstFact('CHAN');
if ($chan) {
$date=$chan->getDate();
if ($date->isOK()) {