summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Family.php28
-rw-r--r--app/Functions/FunctionsCharts.php24
-rw-r--r--app/Functions/FunctionsEdit.php2
-rw-r--r--app/Functions/FunctionsExport.php4
-rw-r--r--app/Functions/FunctionsPrint.php2
-rw-r--r--app/Functions/FunctionsPrintFacts.php4
-rw-r--r--app/GedcomRecord.php22
-rw-r--r--app/Http/Controllers/Admin/FixLevel0MediaController.php6
-rw-r--r--app/Http/Controllers/BranchesController.php2
-rw-r--r--app/Http/Controllers/EditFamilyController.php5
-rw-r--r--app/Individual.php16
-rw-r--r--app/Media.php3
-rw-r--r--app/Module/BatchUpdate/BatchUpdateMissingDeathPlugin.php2
-rw-r--r--app/Module/DescendancyChartModule.php6
-rw-r--r--app/Module/DescendancyModule.php3
-rw-r--r--app/Module/HourglassChartModule.php8
-rw-r--r--app/Module/InteractiveTree/TreeView.php2
-rw-r--r--app/Module/ModuleThemeTrait.php16
-rw-r--r--app/Module/PedigreeMapModule.php2
-rw-r--r--app/Module/PlacesModule.php2
-rw-r--r--app/Report/ReportParserGenerate.php42
-rw-r--r--app/Statistics/Repository/EventRepository.php5
-rw-r--r--app/Statistics/Repository/FamilyDatesRepository.php5
-rw-r--r--app/Statistics/Repository/GedcomRepository.php13
-rw-r--r--resources/views/admin/fix-level-0-media-action.phtml29
-rw-r--r--resources/views/chart-box.phtml11
-rw-r--r--resources/views/edit/new-individual.phtml352
-rw-r--r--resources/views/lists/sources-table.phtml2
-rw-r--r--resources/views/modules/relatives/family.phtml2
-rw-r--r--resources/views/modules/sitemap/sitemap-file.xml.phtml4
30 files changed, 314 insertions, 310 deletions
diff --git a/app/Family.php b/app/Family.php
index f80e43f3ad..dfb11d5a84 100644
--- a/app/Family.php
+++ b/app/Family.php
@@ -19,6 +19,7 @@ namespace Fisharebest\Webtrees;
use Closure;
use Illuminate\Database\Capsule\Manager as DB;
+use Illuminate\Support\Collection;
use stdClass;
/**
@@ -243,14 +244,16 @@ class Family extends GedcomRecord
*
* @param int|null $access_level
*
- * @return Individual[]
+ * @return Collection|Individual[]
*/
- public function spouses($access_level = null): array
+ public function spouses($access_level = null): Collection
{
- return array_filter([
+ $spouses = new Collection([
$this->husband($access_level),
$this->wife($access_level),
]);
+
+ return $spouses->filter();
}
/**
@@ -258,9 +261,9 @@ class Family extends GedcomRecord
*
* @param int|null $access_level
*
- * @return Individual[]
+ * @return Collection|Individual[]
*/
- public function children($access_level = null): array
+ public function children($access_level = null): Collection
{
if ($access_level === null) {
$access_level = Auth::accessLevel($this->tree);
@@ -268,11 +271,13 @@ class Family extends GedcomRecord
$SHOW_PRIVATE_RELATIONSHIPS = (bool) $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS');
- $children = [];
+ $children = new Collection();
+
foreach ($this->facts(['CHIL'], false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) {
$child = $fact->target();
+
if ($child instanceof Individual && ($SHOW_PRIVATE_RELATIONSHIPS || $child->canShowName($access_level))) {
- $children[] = $child;
+ $children->push($child);
}
}
@@ -286,7 +291,8 @@ class Family extends GedcomRecord
*/
public function numberOfChildren(): int
{
- $nchi = count($this->children());
+ $nchi = $this->children()->count();
+
foreach ($this->facts(['NCHI']) as $fact) {
$nchi = max($nchi, (int) $fact->value());
}
@@ -299,9 +305,9 @@ class Family extends GedcomRecord
*
* @return Fact|null
*/
- public function getMarriage()
+ public function getMarriage(): ?Fact
{
- return $this->firstFact('MARR');
+ return $this->facts(['MARR'])->first();
}
/**
@@ -309,7 +315,7 @@ class Family extends GedcomRecord
*
* @return Date
*/
- public function getMarriageDate()
+ public function getMarriageDate(): Date
{
$marriage = $this->getMarriage();
if ($marriage) {
diff --git a/app/Functions/FunctionsCharts.php b/app/Functions/FunctionsCharts.php
index cf969a65da..c5a6ba8521 100644
--- a/app/Functions/FunctionsCharts.php
+++ b/app/Functions/FunctionsCharts.php
@@ -309,12 +309,10 @@ class FunctionsCharts
string $label = '',
bool $show_cousins = false
) {
- $bheight = app()->make(ModuleThemeInterface::class)->parameter('chart-box-y');
-
+ $bheight = app()->make(ModuleThemeInterface::class)->parameter('chart-box-y');
$pbheight = $bheight + 14;
-
$children = $family->children();
- $numchil = count($children);
+ $numchil = $children->count();
echo '<table border="0" cellpadding="0" cellspacing="0"><tr>';
if ($sosa > 0) {
@@ -354,7 +352,8 @@ class FunctionsCharts
echo '</tr>';
$nchi = 1;
- if ($children) {
+
+ if ($children->isNotEmpty()) {
foreach ($children as $child) {
echo '<tr>';
if ($sosa != 0) {
@@ -385,8 +384,7 @@ class FunctionsCharts
echo '</tr><tr><td></td>';
echo '<td style="text-align:end; vertical-align: top;">';
//find out how many cousins there are to establish vertical line on second families
- $fchildren = $famids[$f]->children();
- $kids = count($fchildren);
+ $kids = $famids[$f]->children()->count();
if ($show_cousins) {
if ($kids > 0) {
@@ -407,8 +405,8 @@ class FunctionsCharts
echo '<td class="details1" style="text-align:center;">';
$spouse = $famids[$f]->spouse($child);
- $marr = $famids[$f]->firstFact('MARR');
- $div = $famids[$f]->firstFact('DIV');
+ $marr = $famids[$f]->facts(['MARR'])->first();
+ $div = $famids[$f]->facts(['DIV'])->first();
if ($marr) {
// marriage date
echo $marr->date()->minimumDate()->format('%Y');
@@ -510,15 +508,15 @@ class FunctionsCharts
{
$bheight = app()->make(ModuleThemeInterface::class)->parameter('chart-box-y');
$fchildren = $family->children();
- $kids = count($fchildren);
+ $kids = $fchildren->count();
echo '<td>';
- if ($kids) {
+ if ($fchildren->isNotEmpty()) {
echo '<table cellspacing="0" cellpadding="0" border="0" ><tr>';
- if ($kids > 1) {
+ if ($fchildren->count() > 1) {
echo '<td rowspan="', $kids, '"><img width="3px" height="', (($bheight) * ($kids - 1)), 'px" src="', e(asset('css/images/vline.png')), '"></td>';
}
- $ctkids = count($fchildren);
+ $ctkids = $fchildren->count();
$i = 1;
foreach ($fchildren as $fchil) {
if ($i == 1) {
diff --git a/app/Functions/FunctionsEdit.php b/app/Functions/FunctionsEdit.php
index d5132fed6f..a06ba2efbd 100644
--- a/app/Functions/FunctionsEdit.php
+++ b/app/Functions/FunctionsEdit.php
@@ -564,7 +564,7 @@ class FunctionsEdit
if ($fact === 'HUSB' || $fact === 'WIFE') {
$family = Family::getInstance($xref, $tree);
if ($family) {
- $spouse_link = $family->firstFact($fact);
+ $spouse_link = $family->facts([$fact])->first();
if ($spouse_link) {
$spouse = $spouse_link->target();
if ($spouse instanceof Individual) {
diff --git a/app/Functions/FunctionsExport.php b/app/Functions/FunctionsExport.php
index f16a85ca1c..c49ba96742 100644
--- a/app/Functions/FunctionsExport.php
+++ b/app/Functions/FunctionsExport.php
@@ -101,11 +101,11 @@ class FunctionsExport
// Preserve some values from the original header
$record = GedcomRecord::getInstance('HEAD', $tree);
- $fact = $record->firstFact('COPR');
+ $fact = $record->facts(['COPR'])->first();
if ($fact instanceof Fact) {
$COPR = "\n1 COPR " .$fact->value();
}
- $fact = $record->firstFact('LANG');
+ $fact = $record->facts(['LANG'])->first();
if ($fact instanceof Fact) {
$LANG = "\n1 LANG " .$fact->value();
}
diff --git a/app/Functions/FunctionsPrint.php b/app/Functions/FunctionsPrint.php
index 5ff06a1e13..ecf14bf930 100644
--- a/app/Functions/FunctionsPrint.php
+++ b/app/Functions/FunctionsPrint.php
@@ -274,7 +274,7 @@ class FunctionsPrint
// 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->firstFact('DEAT');
+ $death_event = $record->facts(['DEAT'])->first();
if ($death_event) {
$death_date = $death_event->date();
} else {
diff --git a/app/Functions/FunctionsPrintFacts.php b/app/Functions/FunctionsPrintFacts.php
index 540f522618..2d7ce2e7f1 100644
--- a/app/Functions/FunctionsPrintFacts.php
+++ b/app/Functions/FunctionsPrintFacts.php
@@ -606,7 +606,7 @@ class FunctionsPrintFacts
}
$data .= ' class="source_citations">';
// PUBL
- $publ = $source->firstFact('PUBL');
+ $publ = $source->facts(['PUBL'])->first();
if ($publ) {
$data .= GedcomTag::getLabelValue('PUBL', $publ->value());
}
@@ -790,7 +790,7 @@ class FunctionsPrintFacts
if ($source) {
echo '<a href="', e($source->url()), '">', $source->fullName(), '</a>';
// PUBL
- $publ = $source->firstFact('PUBL');
+ $publ = $source->facts(['PUBL'])->first();
if ($publ) {
echo GedcomTag::getLabelValue('PUBL', $publ->value());
}
diff --git a/app/GedcomRecord.php b/app/GedcomRecord.php
index ffae9af09f..3eabde397e 100644
--- a/app/GedcomRecord.php
+++ b/app/GedcomRecord.php
@@ -1066,24 +1066,6 @@ class GedcomRecord
}
/**
- * Get the first (i.e. prefered) Fact for the given fact type
- *
- * @param string $tag
- *
- * @return Fact|null
- */
- public function firstFact(string $tag)
- {
- foreach ($this->facts() as $fact) {
- if ($fact->getTag() === $tag) {
- return $fact;
- }
- }
-
- return null;
- }
-
- /**
* The facts and events for this record.
*
* @param string[] $filter
@@ -1125,7 +1107,7 @@ class GedcomRecord
*/
public function lastChangeTimestamp(bool $sorting = false)
{
- $chan = $this->firstFact('CHAN');
+ $chan = $this->facts(['CHAN'])->first();
if ($chan) {
// The record does have a CHAN event
@@ -1159,7 +1141,7 @@ class GedcomRecord
*/
public function lastChangeUser()
{
- $chan = $this->firstFact('CHAN');
+ $chan = $this->facts(['CHAN'])->first();
if ($chan === null) {
return I18N::translate('Unknown');
diff --git a/app/Http/Controllers/Admin/FixLevel0MediaController.php b/app/Http/Controllers/Admin/FixLevel0MediaController.php
index 220a870b54..af5a342607 100644
--- a/app/Http/Controllers/Admin/FixLevel0MediaController.php
+++ b/app/Http/Controllers/Admin/FixLevel0MediaController.php
@@ -151,20 +151,20 @@ class FixLevel0MediaController extends AbstractAdminController
$facts = [];
}
- $facts = array_map(function (Fact $fact) use ($individual, $media): string {
+ $facts = $facts->map(function (Fact $fact) use ($individual, $media): string {
return view('admin/fix-level-0-media-action', [
'fact' => $fact,
'individual' => $individual,
'media' => $media,
]);
- }, $facts);
+ });
return [
$tree->name(),
$media->displayImage(100, 100, 'fit', ['class' => 'img-thumbnail']),
'<a href="' . e($media->url()) . '">' . $media->fullName() . '</a>',
'<a href="' . e($individual->url()) . '">' . $individual->fullName() . '</a>',
- implode(' ', $facts),
+ $facts->implode(' '),
];
});
}
diff --git a/app/Http/Controllers/BranchesController.php b/app/Http/Controllers/BranchesController.php
index dbde24195d..e539a12c13 100644
--- a/app/Http/Controllers/BranchesController.php
+++ b/app/Http/Controllers/BranchesController.php
@@ -324,7 +324,7 @@ class BranchesController extends AbstractBaseController
$marriage_year = $family->getMarriageYear();
if ($marriage_year) {
$fam_html .= ' <a href="' . e($family->url()) . '" title="' . strip_tags($family->getMarriageDate()->display()) . '"><i class="icon-rings"></i>' . $marriage_year . '</a>';
- } elseif ($family->firstFact('MARR')) {
+ } elseif ($family->facts(['MARR'])->first()) {
$fam_html .= ' <a href="' . e($family->url()) . '" title="' . I18N::translate('Marriage') . '"><i class="icon-rings"></i></a>';
} else {
$fam_html .= ' <a href="' . e($family->url()) . '" title="' . I18N::translate('Not married') . '"><i class="icon-rings"></i></a>';
diff --git a/app/Http/Controllers/EditFamilyController.php b/app/Http/Controllers/EditFamilyController.php
index 964840d465..1f430f39ee 100644
--- a/app/Http/Controllers/EditFamilyController.php
+++ b/app/Http/Controllers/EditFamilyController.php
@@ -19,6 +19,7 @@ namespace Fisharebest\Webtrees\Http\Controllers;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Date;
+use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\GedcomCode\GedcomCodePedi;
use Fisharebest\Webtrees\I18N;
@@ -263,7 +264,7 @@ class EditFamilyController extends AbstractEditController
$spouse = $tree->createIndividual($gedrec);
// Update the existing family - add marriage, etc
- if ($family->firstFact('HUSB')) {
+ if ($family->facts(['HUSB'])->first() instanceof Fact) {
$family->createFact('1 WIFE @' . $spouse->xref() . '@', true);
} else {
$family->createFact('1 HUSB @' . $spouse->xref() . '@', true);
@@ -405,7 +406,7 @@ class EditFamilyController extends AbstractEditController
}
foreach ($new_children as $new_child) {
- if ($new_child && !in_array($new_child, $old_children)) {
+ if ($new_child && !$old_children->contains($new_child)) {
// Add new FAMC link
$new_child->createFact('1 FAMC @' . $family->xref() . '@', true);
// Add new CHIL link
diff --git a/app/Individual.php b/app/Individual.php
index 277e47812f..d6ec8ab3bf 100644
--- a/app/Individual.php
+++ b/app/Individual.php
@@ -961,9 +961,9 @@ class Individual extends GedcomRecord
/**
* Get a list of step-parent families.
*
- * @return Family[]
+ * @return Collection|Family[]
*/
- public function childStepFamilies(): array
+ public function childStepFamilies(): Collection
{
$step_families = [];
$families = $this->childFamilies();
@@ -986,20 +986,22 @@ class Individual extends GedcomRecord
}
}
- return $step_families;
+ return new Collection($step_families);
}
/**
* Get a list of step-parent families.
*
- * @return Family[]
+ * @return Collection|Family[]
*/
- public function spouseStepFamilies(): array
+ public function spouseStepFamilies(): Collection
{
$step_families = [];
$families = $this->spouseFamilies();
+
foreach ($families as $family) {
$spouse = $family->spouse($this);
+
if ($spouse) {
foreach ($family->spouse($this)->spouseFamilies() as $step_family) {
if (!$families->containsStrict($step_family)) {
@@ -1009,7 +1011,7 @@ class Individual extends GedcomRecord
}
}
- return $step_families;
+ return new Collection($step_families);
}
/**
@@ -1019,7 +1021,7 @@ class Individual extends GedcomRecord
*
* @return string
*/
- public function getChildFamilyLabel(Family $family)
+ public function getChildFamilyLabel(Family $family): string
{
if (preg_match('/\n1 FAMC @' . $family->xref() . '@(?:\n[2-9].*)*\n2 PEDI (.+)/', $this->gedcom(), $match)) {
// A specified pedigree
diff --git a/app/Media.php b/app/Media.php
index 8c7b5e9e56..b4b901d05a 100644
--- a/app/Media.php
+++ b/app/Media.php
@@ -146,7 +146,8 @@ class Media extends GedcomRecord
*/
public function getNote()
{
- $fact = $this->firstFact('NOTE');
+ $fact = $this->facts(['NOTE'])->first();
+
if ($fact instanceof Fact) {
// Link to note object
$note = $fact->target();
diff --git a/app/Module/BatchUpdate/BatchUpdateMissingDeathPlugin.php b/app/Module/BatchUpdate/BatchUpdateMissingDeathPlugin.php
index 671d3b29bb..0dc7d2e45b 100644
--- a/app/Module/BatchUpdate/BatchUpdateMissingDeathPlugin.php
+++ b/app/Module/BatchUpdate/BatchUpdateMissingDeathPlugin.php
@@ -55,7 +55,7 @@ class BatchUpdateMissingDeathPlugin extends BatchUpdateBasePlugin
*/
public function doesRecordNeedUpdate(GedcomRecord $record): bool
{
- return $record instanceof Individual && $record->firstFact('DEAT') === null && $record->isDead();
+ return $record instanceof Individual && $record->facts(['DEAT'])->isEmpty() && $record->isDead();
}
/**
diff --git a/app/Module/DescendancyChartModule.php b/app/Module/DescendancyChartModule.php
index 29c5192db6..75c43bea4c 100644
--- a/app/Module/DescendancyChartModule.php
+++ b/app/Module/DescendancyChartModule.php
@@ -350,13 +350,13 @@ class DescendancyChartModule extends AbstractModule implements ModuleChartInterf
// children
$children = $family->children();
echo '<tr><td colspan="3" class="details1" >&nbsp;&nbsp;';
- if (!empty($children)) {
- echo GedcomTag::getLabel('NCHI') . ': ' . count($children);
+ if ($children->isNotEmpty()) {
+ echo GedcomTag::getLabel('NCHI') . ': ' . $children->count();
} else {
// Distinguish between no children (NCHI 0) and no recorded
// children (no CHIL records)
if (strpos($family->gedcom(), '\n1 NCHI 0') !== false) {
- echo GedcomTag::getLabel('NCHI') . ': ' . count($children);
+ echo GedcomTag::getLabel('NCHI') . ': ' . $children->count();
} else {
echo I18N::translate('No children');
}
diff --git a/app/Module/DescendancyModule.php b/app/Module/DescendancyModule.php
index fe73dc1d24..c11f6f8859 100644
--- a/app/Module/DescendancyModule.php
+++ b/app/Module/DescendancyModule.php
@@ -237,7 +237,8 @@ class DescendancyModule extends AbstractModule implements ModuleSidebarInterface
$out = '';
if ($family->canShow()) {
$children = $family->children();
- if ($children) {
+
+ if ($children->isNotEmpty()) {
foreach ($children as $child) {
$out .= $this->getPersonLi($child, $generations - 1);
}
diff --git a/app/Module/HourglassChartModule.php b/app/Module/HourglassChartModule.php
index 5a34a1ce97..7ab237c9eb 100644
--- a/app/Module/HourglassChartModule.php
+++ b/app/Module/HourglassChartModule.php
@@ -372,13 +372,13 @@ class HourglassChartModule extends AbstractModule implements ModuleChartInterfac
}
// filter out root person from children array so only siblings remain
- $siblings = array_filter($family->children(), function (Individual $x) use ($individual): bool {
+ $siblings = $family->children()->filter(function (Individual $x) use ($individual): bool {
return $x !== $individual;
});
- $count_siblings = count($siblings);
- if ($count_siblings > 0) {
+
+ if ($siblings->count() > 0) {
echo '<span class="name1">';
- echo $count_siblings > 1 ? I18N::translate('Siblings') : I18N::translate('Sibling');
+ echo $siblings->count() > 1 ? I18N::translate('Siblings') : I18N::translate('Sibling');
echo '</span>';
foreach ($siblings as $child) {
echo '<a href="' . e(route('hourglass', [
diff --git a/app/Module/InteractiveTree/TreeView.php b/app/Module/InteractiveTree/TreeView.php
index 04804c58a2..6411504846 100644
--- a/app/Module/InteractiveTree/TreeView.php
+++ b/app/Module/InteractiveTree/TreeView.php
@@ -186,7 +186,7 @@ class TreeView
foreach ($familyList as $f) {
$children = $f->children();
- if ($children) {
+ if ($children->isNotEmpty()) {
$f2load[] = $f->xref();
foreach ($children as $child) {
// Eliminate duplicates - e.g. when adopted by a step-parent
diff --git a/app/Module/ModuleThemeTrait.php b/app/Module/ModuleThemeTrait.php
index fb20594a51..3e7a9c4ee8 100644
--- a/app/Module/ModuleThemeTrait.php
+++ b/app/Module/ModuleThemeTrait.php
@@ -172,8 +172,8 @@ trait ModuleThemeTrait
// Show BIRT or equivalent event
foreach (Gedcom::BIRTH_EVENTS as $birttag) {
if (!in_array($birttag, $opt_tags)) {
- $event = $individual->firstFact($birttag);
- if ($event) {
+ $event = $individual->facts([$birttag])->first();
+ if ($event instanceof Fact) {
$html .= $event->summary();
break;
}
@@ -182,8 +182,8 @@ trait ModuleThemeTrait
// Show optional events (before death)
foreach ($opt_tags as $key => $tag) {
if (!in_array($tag, Gedcom::DEATH_EVENTS)) {
- $event = $individual->firstFact($tag);
- if ($event !== null) {
+ $event = $individual->facts([$tag])->first();
+ if ($event instanceof Fact) {
$html .= $event->summary();
unset($opt_tags[$key]);
}
@@ -191,8 +191,8 @@ trait ModuleThemeTrait
}
// Show DEAT or equivalent event
foreach (Gedcom::DEATH_EVENTS as $deattag) {
- $event = $individual->firstFact($deattag);
- if ($event) {
+ $event = $individual->facts([$deattag])->first();
+ if ($event instanceof Fact) {
$html .= $event->summary();
if (in_array($deattag, $opt_tags)) {
unset($opt_tags[array_search($deattag, $opt_tags)]);
@@ -202,8 +202,8 @@ trait ModuleThemeTrait
}
// Show remaining optional events (after death)
foreach ($opt_tags as $tag) {
- $event = $individual->firstFact($tag);
- if ($event) {
+ $event = $individual->facts([$tag])->first();
+ if ($event instanceof Fact) {
$html .= $event->summary();
}
}
diff --git a/app/Module/PedigreeMapModule.php b/app/Module/PedigreeMapModule.php
index e4516aea59..91de38d673 100644
--- a/app/Module/PedigreeMapModule.php
+++ b/app/Module/PedigreeMapModule.php
@@ -286,7 +286,7 @@ class PedigreeMapModule extends AbstractModule implements ModuleChartInterface
$facts = [];
foreach ($ancestors as $sosa => $person) {
if ($person->canShow()) {
- $birth = $person->firstFact('BIRT');
+ $birth = $person->facts(['BIRT'])->first();
if ($birth instanceof Fact && $birth->place()->gedcomName() !== '') {
$facts[$sosa] = $birth;
}
diff --git a/app/Module/PlacesModule.php b/app/Module/PlacesModule.php
index 63b1010eab..232eb38828 100644
--- a/app/Module/PlacesModule.php
+++ b/app/Module/PlacesModule.php
@@ -216,7 +216,7 @@ class PlacesModule extends AbstractModule implements ModuleTabInterface
$facts = $facts->merge($family->facts());
// Add birth of children from this family to the facts array
foreach ($family->children() as $child) {
- $childsBirth = $child->firstFact('BIRT');
+ $childsBirth = $child->facts(['BIRT'])->first();
if ($childsBirth && $childsBirth->place()->gedcomName() !== '') {
$facts->push($childsBirth);
}
diff --git a/app/Report/ReportParserGenerate.php b/app/Report/ReportParserGenerate.php
index 51a00a49ee..3c07d9d864 100644
--- a/app/Report/ReportParserGenerate.php
+++ b/app/Report/ReportParserGenerate.php
@@ -1296,8 +1296,7 @@ class ReportParserGenerate extends ReportParserBase
$record = GedcomRecord::getInstance($id, $this->tree);
if (empty($attrs['diff']) && !empty($id)) {
- throw new \Exception('eek');
- Functions::sortFacts($facts);
+ $facts = $record->facts([], true);
$this->repeats = [];
$nonfacts = explode(',', $tag);
foreach ($facts as $fact) {
@@ -2405,37 +2404,23 @@ class ReportParserGenerate extends ReportParserBase
switch ($group) {
case 'child-family':
foreach ($person->childFamilies() as $family) {
- $husband = $family->husband();
- $wife = $family->wife();
- if (!empty($husband)) {
- $this->list[$husband->xref()] = $husband;
+ foreach ($family->spouses() as $spouse) {
+ $this->list[$spouse->xref()] = $spouse;
}
- if (!empty($wife)) {
- $this->list[$wife->xref()] = $wife;
- }
- $children = $family->children();
- foreach ($children as $child) {
- if (!empty($child)) {
- $this->list[$child->xref()] = $child;
- }
+
+ foreach ($family->children() as $child) {
+ $this->list[$child->xref()] = $child;
}
}
break;
case 'spouse-family':
foreach ($person->spouseFamilies() as $family) {
- $husband = $family->husband();
- $wife = $family->wife();
- if (!empty($husband)) {
- $this->list[$husband->xref()] = $husband;
+ foreach ($family->spouses() as $spouse) {
+ $this->list[$spouse->xref()] = $spouse;
}
- if (!empty($wife)) {
- $this->list[$wife->xref()] = $wife;
- }
- $children = $family->children();
- foreach ($children as $child) {
- if (!empty($child)) {
- $this->list[$child->xref()] = $child;
- }
+
+ foreach ($family->children() as $child) {
+ $this->list[$child->xref()] = $child;
}
}
break;
@@ -2749,10 +2734,13 @@ class ReportParserGenerate extends ReportParserBase
}
}
}
+
$children = $family->children();
+
foreach ($children as $child) {
if ($child) {
$list[$child->xref()] = $child;
+
if (isset($list[$pid]->generation)) {
$list[$child->xref()]->generation = $list[$pid]->generation + 1;
} else {
@@ -2778,7 +2766,7 @@ class ReportParserGenerate extends ReportParserBase
*
* @return void
*/
- private function addAncestors(&$list, $pid, $children = false, $generations = -1)
+ private function addAncestors(array &$list, string $pid, bool $children = false, int $generations = -1)
{
$genlist = [$pid];
$list[$pid]->generation = 1;
diff --git a/app/Statistics/Repository/EventRepository.php b/app/Statistics/Repository/EventRepository.php
index fca9856992..6a79b56797 100644
--- a/app/Statistics/Repository/EventRepository.php
+++ b/app/Statistics/Repository/EventRepository.php
@@ -18,6 +18,7 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Statistics\Repository;
use Fisharebest\Webtrees\Date;
+use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Functions\FunctionsPrint;
use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomRecord;
@@ -401,10 +402,10 @@ class EventRepository implements EventRepositoryInterface
$fact = null;
if ($record) {
- $fact = $record->firstFact($row->fact);
+ $fact = $record->facts([$row->fact])->first();
}
- if ($fact) {
+ if ($fact instanceof Fact) {
return FunctionsPrint::formatFactPlace($fact, true, true, true);
}
}
diff --git a/app/Statistics/Repository/FamilyDatesRepository.php b/app/Statistics/Repository/FamilyDatesRepository.php
index 7beac8f5ef..e1cfd1b084 100644
--- a/app/Statistics/Repository/FamilyDatesRepository.php
+++ b/app/Statistics/Repository/FamilyDatesRepository.php
@@ -18,6 +18,7 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Statistics\Repository;
use Fisharebest\Webtrees\Date;
+use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Functions\FunctionsPrint;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\I18N;
@@ -367,10 +368,10 @@ class FamilyDatesRepository implements FamilyDatesRepositoryInterface
$fact = null;
if ($record) {
- $fact = $record->firstFact($row->fact);
+ $fact = $record->facts([$row->fact])->first();
}
- if ($fact) {
+ if ($fact instanceof Fact) {
return FunctionsPrint::formatFactPlace($fact, true, true, true);
}
}
diff --git a/app/Statistics/Repository/GedcomRepository.php b/app/Statistics/Repository/GedcomRepository.php
index 869bd27f2b..eb9047c939 100644
--- a/app/Statistics/Repository/GedcomRepository.php
+++ b/app/Statistics/Repository/GedcomRepository.php
@@ -18,6 +18,7 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Statistics\Repository;
use Fisharebest\Webtrees\Date;
+use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\Statistics\Repository\Interfaces\GedcomRepositoryInterface;
use Fisharebest\Webtrees\Tree;
@@ -57,10 +58,10 @@ class GedcomRepository implements GedcomRepositoryInterface
$head = GedcomRecord::getInstance('HEAD', $this->tree);
- if ($head !== null) {
- $sour = $head->firstFact('SOUR');
+ if ($head instanceof GedcomRecord) {
+ $sour = $head->facts(['SOUR'])->first();
- if ($sour !== null) {
+ if ($sour instanceof Fact) {
$source = $sour->value();
$title = $sour->attribute('NAME');
$version = $sour->attribute('VERS');
@@ -139,10 +140,10 @@ class GedcomRepository implements GedcomRepositoryInterface
{
$head = GedcomRecord::getInstance('HEAD', $this->tree);
- if ($head !== null) {
- $fact = $head->firstFact('DATE');
+ if ($head instanceof GedcomRecord) {
+ $fact = $head->facts(['DATE'])->first();
- if ($fact) {
+ if ($fact instanceof Fact) {
return (new Date($fact->value()))->display();
}
}
diff --git a/resources/views/admin/fix-level-0-media-action.phtml b/resources/views/admin/fix-level-0-media-action.phtml
index 262b1e4c3d..8c42292b21 100644
--- a/resources/views/admin/fix-level-0-media-action.phtml
+++ b/resources/views/admin/fix-level-0-media-action.phtml
@@ -1,14 +1,27 @@
-<?php use Fisharebest\Webtrees\I18N; ?>
+<?php
+
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\I18N;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Media;
+
+/**
+ * @var Fact $fact
+ * @var Individual $individual
+ * @var Media $media
+ */
+?>
<button
- class="btn btn-primary btn-small mb-1 wt-fix-button"
- data-confirm="<?= I18N::translate('Move the media object?') ?>"
- data-fact-id="<?= e($fact->id()) ?>"
- data-tree-id="<?= e($tree->id()) ?>"
- data-individual-xref="<?= e($individual->xref()) ?>"
- data-media-xref="<?= e($media->xref()) ?>"
- type="button"
+class="btn btn-primary btn-small mb-1 wt-fix-button"
+data-confirm="<?= I18N::translate('Move the media object?') ?>"
+data-fact-id="<?= e($fact->id()) ?>"
+data-tree-id="<?= e($tree->id()) ?>"
+data-individual-xref="<?= e($individual->xref()) ?>"
+data-media-xref="<?= e($media->xref()) ?>"
+type="button"
>
<?= $fact->label() ?>
+ <?= $fact->value() ?>
<?= $fact->date()->display(false, '%Y', false) ?>
</button>
diff --git a/resources/views/chart-box.phtml b/resources/views/chart-box.phtml
index 6f9fca96ba..d6cd95f54e 100644
--- a/resources/views/chart-box.phtml
+++ b/resources/views/chart-box.phtml
@@ -83,12 +83,11 @@ foreach ($individual->spouseFamilies() as $family) {
$all_facts->push($fact);
}
}
-Functions::sortFacts($all_facts);
-
$all_facts = $all_facts->filter(function (Fact $fact) use ($exclude): bool {
return !in_array($fact->getTag(), $exclude);
});
+Functions::sortFacts($all_facts);
$id = Uuid::uuid4()->toString();
@@ -152,7 +151,7 @@ $id = Uuid::uuid4()->toString();
foreach (Gedcom::BIRTH_EVENTS as $birttag) {
if (!in_array($birttag, $opt_tags)) {
- $event = $individual->firstFact($birttag);
+ $event = $individual->facts([$birttag])->first();
if ($event instanceof Fact) {
echo $event->summary();
break;
@@ -162,7 +161,7 @@ $id = Uuid::uuid4()->toString();
// Show optional events (before death)
foreach ($opt_tags as $key => $tag) {
if (!in_array($tag, Gedcom::DEATH_EVENTS)) {
- $event = $individual->firstFact($tag);
+ $event = $individual->facts([$tag])->first();
if ($event instanceof Fact) {
echo $event->summary();
unset($opt_tags[$key]);
@@ -171,7 +170,7 @@ $id = Uuid::uuid4()->toString();
}
// Show DEAT or equivalent event
foreach (Gedcom::DEATH_EVENTS as $deattag) {
- $event = $individual->firstFact($deattag);
+ $event = $individual->facts([$deattag])->first();
if ($event instanceof Fact) {
echo $event->summary();
if (in_array($deattag, $opt_tags)) {
@@ -182,7 +181,7 @@ $id = Uuid::uuid4()->toString();
}
// Show remaining optional events (after death)
foreach ($opt_tags as $tag) {
- $event = $individual->firstFact($tag);
+ $event = $individual->facts([$tag])->first();
if ($event instanceof Fact) {
echo $event->summary();
}
diff --git a/resources/views/edit/new-individual.phtml b/resources/views/edit/new-individual.phtml
index f43ee4ccd2..b2ab80a58c 100644
--- a/resources/views/edit/new-individual.phtml
+++ b/resources/views/edit/new-individual.phtml
@@ -1,15 +1,25 @@
-<?php use Fisharebest\Webtrees\Auth; ?>
-<?php use Fisharebest\Webtrees\Config; ?>
-<?php use Fisharebest\Webtrees\Fact; ?>
-<?php use Fisharebest\Webtrees\Functions\FunctionsEdit; ?>
-<?php use Fisharebest\Webtrees\Gedcom; ?>
-<?php use Fisharebest\Webtrees\GedcomTag; ?>
-<?php use Fisharebest\Webtrees\I18N; ?>
-<?php use Fisharebest\Webtrees\SurnameTradition; ?>
-<?php use Fisharebest\Webtrees\View; ?>
+<?php
+
+use Fisharebest\Webtrees\Auth;
+use Fisharebest\Webtrees\Config;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Functions\FunctionsEdit;
+use Fisharebest\Webtrees\Gedcom;
+use Fisharebest\Webtrees\GedcomTag;
+use Fisharebest\Webtrees\I18N;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\SurnameTradition;
+use Fisharebest\Webtrees\View;
+
+/**
+ * @var Individual|null $individual
+ * @var Fact|null $name_fact
+ */
+
+?>
<?php
-if ($individual !== null) {
+if ($individual instanceof Individual) {
$xref = $individual->xref();
$cancel_url = $individual->url();
} elseif ($family !== null) {
@@ -23,7 +33,7 @@ if ($individual !== null) {
// Different cultures do surnames differently
$surname_tradition = SurnameTradition::create($tree->getPreference('SURNAME_TRADITION'));
-if ($name_fact !== null) {
+if ($name_fact instanceof Fact) {
// Editing an existing name
$name_fact_id = $name_fact->id();
$namerec = $name_fact->gedcom();
@@ -66,14 +76,14 @@ if ($name_fact !== null) {
// Inherit surname from parents, spouse or child
if ($family) {
$father = $family->husband();
- if ($father && $father->firstFact('NAME')) {
- $father_name = $father->firstFact('NAME')->value();
+ if ($father instanceof Individual && $father->facts(['NAME'])->isNotEmpty()) {
+ $father_name = $father->facts(['NAME'])->first()->value();
} else {
$father_name = '';
}
$mother = $family->wife();
- if ($mother && $mother->firstFact('NAME')) {
- $mother_name = $mother->firstFact('NAME')->value();
+ if ($mother instanceof Individual && $mother->facts(['NAME'])->isNotEmpty()) {
+ $mother_name = $mother->facts(['NAME'])->first()->value();
} else {
$mother_name = '';
}
@@ -83,8 +93,8 @@ if ($name_fact !== null) {
$father_name = '';
$mother_name = '';
}
- if ($individual && $individual->firstFact('NAME')) {
- $indi_name = $individual->firstFact('NAME')->value();
+ if ($individual && $individual->facts(['NAME'])->isNotEmpty()) {
+ $indi_name = $individual->facts(['NAME'])->first()->value();
} else {
$indi_name = '';
}
@@ -277,15 +287,15 @@ $bdm = ''; // used to copy '1 SOUR' to '2 SOUR' for BIRT DEAT MARR
]);
echo view('cards/add-note', [
'level' => 2,
- 'tree' => $tree,
+ 'tree' => $tree,
]);
echo view('cards/add-shared-note', [
'level' => 2,
- 'tree' => $tree,
+ 'tree' => $tree,
]);
echo view('cards/add-restriction', [
'level' => 2,
- 'tree' => $tree,
+ 'tree' => $tree,
]);
} else {
echo view('cards/add-source-citation', [
@@ -299,15 +309,15 @@ $bdm = ''; // used to copy '1 SOUR' to '2 SOUR' for BIRT DEAT MARR
]);
echo view('cards/add-note', [
'level' => 1,
- 'tree' => $tree,
+ 'tree' => $tree,
]);
echo view('cards/add-shared-note', [
'level' => 1,
- 'tree' => $tree,
+ 'tree' => $tree,
]);
echo view('cards/add-restriction', [
'level' => 1,
- 'tree' => $tree,
+ 'tree' => $tree,
]);
}
@@ -347,177 +357,177 @@ $bdm = ''; // used to copy '1 SOUR' to '2 SOUR' for BIRT DEAT MARR
<?php View::push('javascript') ?>
<script>
- var SURNAME_TRADITION = <?= json_encode($tree->getPreference('SURNAME_TRADITION')) ?>;
- var gender = <?= json_encode($gender) ?>;
- var famtag = <?= json_encode($famtag) ?>;
+ var SURNAME_TRADITION = <?= json_encode($tree->getPreference('SURNAME_TRADITION')) ?>;
+ var gender = <?= json_encode($gender) ?>;
+ var famtag = <?= json_encode($famtag) ?>;
- var NAME = $("[name=NAME]");
+ var NAME = $("[name=NAME]");
- function trim(str) {
- str = str.replace(/\s\s+/g, " ");
- return str.replace(/(^\s+)|(\s+$)/g, "");
- }
+ function trim(str) {
+ str = str.replace(/\s\s+/g, " ");
+ return str.replace(/(^\s+)|(\s+$)/g, "");
+ }
- function lang_class(str) {
- if (str.match(/[\u0370-\u03FF]/)) return "greek";
- if (str.match(/[\u0400-\u04FF]/)) return "cyrillic";
- if (str.match(/[\u0590-\u05FF]/)) return "hebrew";
- if (str.match(/[\u0600-\u06FF]/)) return "arabic";
- return "latin"; // No matched text implies latin :-)
- }
+ function lang_class(str) {
+ if (str.match(/[\u0370-\u03FF]/)) return "greek";
+ if (str.match(/[\u0400-\u04FF]/)) return "cyrillic";
+ if (str.match(/[\u0590-\u05FF]/)) return "hebrew";
+ if (str.match(/[\u0600-\u06FF]/)) return "arabic";
+ return "latin"; // No matched text implies latin :-)
+ }
- // Generate a full name from the name components
- function generate_name() {
- var npfx = $("[name=NPFX]").val();
- var givn = $("[name=GIVN]").val();
- var spfx = $("[name=SPFX]").val();
- var surn = $("[name=SURN]").val();
- var nsfx = $("[name=NSFX]").val();
+ // Generate a full name from the name components
+ function generate_name() {
+ var npfx = $("[name=NPFX]").val();
+ var givn = $("[name=GIVN]").val();
+ var spfx = $("[name=SPFX]").val();
+ var surn = $("[name=SURN]").val();
+ var nsfx = $("[name=NSFX]").val();
- if (SURNAME_TRADITION === "polish" && (gender === "F" || famtag === "WIFE")) {
- surn = surn.replace(/ski$/, "ska");
- surn = surn.replace(/cki$/, "cka");
- surn = surn.replace(/dzki$/, "dzka");
- surn = surn.replace(/żki$/, "żka");
- }
+ if (SURNAME_TRADITION === "polish" && (gender === "F" || famtag === "WIFE")) {
+ surn = surn.replace(/ski$/, "ska");
+ surn = surn.replace(/cki$/, "cka");
+ surn = surn.replace(/dzki$/, "dzka");
+ surn = surn.replace(/żki$/, "żka");
+ }
- // Commas are used in the GIVN and SURN field to separate lists of surnames.
- // For example, to differentiate the two Spanish surnames from an English
- // double-barred name.
- // Commas *may* be used in other fields, and will form part of the NAME.
- var locale = document.documentElement.lang;
- if (locale === "vi" || locale === "hu") {
- // Default format: /SURN/ GIVN
- return trim(npfx + " /" + trim(spfx + " " + surn).replace(/ *, */g, " ") + "/ " + givn.replace(/ *, */g, " ") + " " + nsfx);
- } else if (locale === "zh-Hans" || locale === "zh-Hant") {
- // Default format: /SURN/GIVN
- return npfx + "/" + spfx + surn + "/" + givn + nsfx;
- } else {
- // Default format: GIVN /SURN/
- return trim(npfx + " " + givn.replace(/ *, */g, " ") + " /" + trim(spfx + " " + surn).replace(/ *, */g, " ") + "/ " + nsfx);
+ // Commas are used in the GIVN and SURN field to separate lists of surnames.
+ // For example, to differentiate the two Spanish surnames from an English
+ // double-barred name.
+ // Commas *may* be used in other fields, and will form part of the NAME.
+ var locale = document.documentElement.lang;
+ if (locale === "vi" || locale === "hu") {
+ // Default format: /SURN/ GIVN
+ return trim(npfx + " /" + trim(spfx + " " + surn).replace(/ *, */g, " ") + "/ " + givn.replace(/ *, */g, " ") + " " + nsfx);
+ } else if (locale === "zh-Hans" || locale === "zh-Hant") {
+ // Default format: /SURN/GIVN
+ return npfx + "/" + spfx + surn + "/" + givn + nsfx;
+ } else {
+ // Default format: GIVN /SURN/
+ return trim(npfx + " " + givn.replace(/ *, */g, " ") + " /" + trim(spfx + " " + surn).replace(/ *, */g, " ") + "/ " + nsfx);
+ }
}
- }
- // Update the NAME and _MARNM fields from the name components
- // and also display the value in read-only "gedcom" format.
- function updatewholename() {
- // Don’t update the name if the user manually changed it
- if (manualChange) {
- return;
- }
+ // Update the NAME and _MARNM fields from the name components
+ // and also display the value in read-only "gedcom" format.
+ function updatewholename() {
+ // Don’t update the name if the user manually changed it
+ if (manualChange) {
+ return;
+ }
- var npfx = $("[name=NPFX]").val();
- var givn = $("[name=GIVN]").val();
- var spfx = $("[name=SPFX]").val();
- var surn = $("[name=SURN]").val();
- var nsfx = $("[name=NSFX]").val();
- var name = generate_name();
+ var npfx = $("[name=NPFX]").val();
+ var givn = $("[name=GIVN]").val();
+ var spfx = $("[name=SPFX]").val();
+ var surn = $("[name=SURN]").val();
+ var nsfx = $("[name=NSFX]").val();
+ var name = generate_name();
- var display_id = NAME.attr('id') + "_display";
+ var display_id = NAME.attr("id") + "_display";
- NAME.val(name);
- $("#" + display_id).text(name);
- // Married names inherit some NSFX values, but not these
- nsfx = nsfx.replace(/^(I|II|III|IV|V|VI|Junior|Jr\.?|Senior|Sr\.?)$/i, "");
- // Update _MARNM field from _MARNM_SURN field and display it
- // Be careful of mixing latin/hebrew/etc. character sets.
- var ip = document.getElementsByTagName("input");
- var marnm_id = "";
- var romn = "";
- var heb = "";
- for (var i = 0; i < ip.length; i++) {
- var val = trim(ip[i].value);
- if (ip[i].id.indexOf("_HEB") === 0)
- heb = val;
- if (ip[i].id.indexOf("ROMN") === 0)
- romn = val;
- if (ip[i].id.indexOf("_MARNM") === 0) {
- if (ip[i].id.indexOf("_MARNM_SURN") === 0) {
- var msurn = "";
- if (val !== "") {
- var lc = lang_class(document.getElementById(ip[i].id).value);
- if (lang_class(name) === lc)
- msurn = trim(npfx + " " + givn + " /" + val + "/ " + nsfx);
- else if (lc === "hebrew")
- msurn = heb.replace(/\/.*\//, "/" + val + "/");
- else if (lang_class(romn) === lc)
- msurn = romn.replace(/\/.*\//, "/" + val + "/");
- }
- document.getElementById(marnm_id).value = msurn;
- document.getElementById(marnm_id + "_display").innerHTML = msurn;
- } else {
- marnm_id = ip[i].id;
+ NAME.val(name);
+ $("#" + display_id).text(name);
+ // Married names inherit some NSFX values, but not these
+ nsfx = nsfx.replace(/^(I|II|III|IV|V|VI|Junior|Jr\.?|Senior|Sr\.?)$/i, "");
+ // Update _MARNM field from _MARNM_SURN field and display it
+ // Be careful of mixing latin/hebrew/etc. character sets.
+ var ip = document.getElementsByTagName("input");
+ var marnm_id = "";
+ var romn = "";
+ var heb = "";
+ for (var i = 0; i < ip.length; i++) {
+ var val = trim(ip[i].value);
+ if (ip[i].id.indexOf("_HEB") === 0)
+ heb = val;
+ if (ip[i].id.indexOf("ROMN") === 0)
+ romn = val;
+ if (ip[i].id.indexOf("_MARNM") === 0) {
+ if (ip[i].id.indexOf("_MARNM_SURN") === 0) {
+ var msurn = "";
+ if (val !== "") {
+ var lc = lang_class(document.getElementById(ip[i].id).value);
+ if (lang_class(name) === lc)
+ msurn = trim(npfx + " " + givn + " /" + val + "/ " + nsfx);
+ else if (lc === "hebrew")
+ msurn = heb.replace(/\/.*\//, "/" + val + "/");
+ else if (lang_class(romn) === lc)
+ msurn = romn.replace(/\/.*\//, "/" + val + "/");
+ }
+ document.getElementById(marnm_id).value = msurn;
+ document.getElementById(marnm_id + "_display").innerHTML = msurn;
+ } else {
+ marnm_id = ip[i].id;
+ }
+ }
}
- }
}
- }
- // Toggle the name editor fields between
- // <input type="hidden"> <span style="display:inline">
- // <input type="text"> <span style="display:none">
+ // Toggle the name editor fields between
+ // <input type="hidden"> <span style="display:inline">
+ // <input type="text"> <span style="display:none">
- var oldName = "";
+ var oldName = "";
- // Calls to generate_name() trigger an update - hence need to
- // set the manual change to true first. We are probably
- // listening to the wrong events on the input fields...
- var manualChange = generate_name() !== NAME.val();
+ // Calls to generate_name() trigger an update - hence need to
+ // set the manual change to true first. We are probably
+ // listening to the wrong events on the input fields...
+ var manualChange = generate_name() !== NAME.val();
- function convertHidden(eid) {
- var input1 = $("#" + eid);
- var input2 = $("#" + eid + "_display");
- // Note that IE does not allow us to change the type of an input, so we must create a new one.
- if (input1.attr("type") === "hidden") {
- input1.replaceWith(input1.clone().attr("type", "text"));
- input2.hide();
- } else {
- input1.replaceWith(input1.clone().attr("type", "hidden"));
- input2.show();
+ function convertHidden(eid) {
+ var input1 = $("#" + eid);
+ var input2 = $("#" + eid + "_display");
+ // Note that IE does not allow us to change the type of an input, so we must create a new one.
+ if (input1.attr("type") === "hidden") {
+ input1.replaceWith(input1.clone().attr("type", "text"));
+ input2.hide();
+ } else {
+ input1.replaceWith(input1.clone().attr("type", "hidden"));
+ input2.show();
+ }
}
- }
- /**
- * if the user manually changed the NAME field, then update the textual
- * HTML representation of it
- * If the value changed set manualChange to true so that changing
- * the other fields doesn’t change the NAME line
- */
- function updateTextName(eid) {
- var element = document.getElementById(eid);
- if (element) {
- if (element.value !== oldName) {
- manualChange = true;
- }
- var delement = document.getElementById(eid + "_display");
- if (delement) {
- delement.innerHTML = element.value;
- }
+ /**
+ * if the user manually changed the NAME field, then update the textual
+ * HTML representation of it
+ * If the value changed set manualChange to true so that changing
+ * the other fields doesn’t change the NAME line
+ */
+ function updateTextName(eid) {
+ var element = document.getElementById(eid);
+ if (element) {
+ if (element.value !== oldName) {
+ manualChange = true;
+ }
+ var delement = document.getElementById(eid + "_display");
+ if (delement) {
+ delement.innerHTML = element.value;
+ }
+ }
}
- }
- function checkform() {
- var ip = document.getElementsByTagName("input");
- for (var i = 0; i < ip.length; i++) {
- // ADD slashes to _HEB and _AKA names
- if (ip[i].id.indexOf("_AKA") === 0 || ip[i].id.indexOf("_HEB") === 0 || ip[i].id.indexOf("ROMN") === 0)
- if (ip[i].value.indexOf("/") < 0 && ip[i].value !== "")
- ip[i].value = ip[i].value.replace(/([^\s]+)\s*$/, "/$1/");
- // Blank out temporary _MARNM_SURN
- if (ip[i].id.indexOf("_MARNM_SURN") === 0)
- ip[i].value = "";
- // Convert "xxx yyy" and "xxx y yyy" surnames to "xxx,yyy"
- if ((SURNAME_TRADITION === "spanish" || "SURNAME_TRADITION" === "portuguese") && ip[i].id.indexOf("SURN") === 0) {
- ip[i].value = document.forms[0].SURN.value.replace(/^\s*([^\s,]{2,})\s+([iIyY] +)?([^\s,]{2,})\s*$/, "$1,$3");
- }
+ function checkform() {
+ var ip = document.getElementsByTagName("input");
+ for (var i = 0; i < ip.length; i++) {
+ // ADD slashes to _HEB and _AKA names
+ if (ip[i].id.indexOf("_AKA") === 0 || ip[i].id.indexOf("_HEB") === 0 || ip[i].id.indexOf("ROMN") === 0)
+ if (ip[i].value.indexOf("/") < 0 && ip[i].value !== "")
+ ip[i].value = ip[i].value.replace(/([^\s]+)\s*$/, "/$1/");
+ // Blank out temporary _MARNM_SURN
+ if (ip[i].id.indexOf("_MARNM_SURN") === 0)
+ ip[i].value = "";
+ // Convert "xxx yyy" and "xxx y yyy" surnames to "xxx,yyy"
+ if ((SURNAME_TRADITION === "spanish" || "SURNAME_TRADITION" === "portuguese") && ip[i].id.indexOf("SURN") === 0) {
+ ip[i].value = document.forms[0].SURN.value.replace(/^\s*([^\s,]{2,})\s+([iIyY] +)?([^\s,]{2,})\s*$/, "$1,$3");
+ }
+ }
+ return true;
}
- return true;
- }
- // If the name isn’t initially formed from the components in a standard way,
- // then don’t automatically update it.
- if (NAME.val() !== generate_name() && NAME.val() !== "//") {
- convertHidden(NAME.attr("id"));
- }
+ // If the name isn’t initially formed from the components in a standard way,
+ // then don’t automatically update it.
+ if (NAME.val() !== generate_name() && NAME.val() !== "//") {
+ convertHidden(NAME.attr("id"));
+ }
</script>
<?php View::endpush() ?>
diff --git a/resources/views/lists/sources-table.phtml b/resources/views/lists/sources-table.phtml
index 9563c24468..b414189b8e 100644
--- a/resources/views/lists/sources-table.phtml
+++ b/resources/views/lists/sources-table.phtml
@@ -97,7 +97,7 @@ $count_notes = DB::table('other')
<!-- Author -->
<td>
- <?= e($source->firstFact('AUTH') ? $source->firstFact('AUTH')->value() : '') ?>
+ <?= e($source->facts(['AUTH'])->isNotEmpty() ? $source->facts(['AUTH'])->first()->value() : '') ?>
</td>
<!-- Count of linked individuals -->
diff --git a/resources/views/modules/relatives/family.phtml b/resources/views/modules/relatives/family.phtml
index 6821633379..5a47c868ed 100644
--- a/resources/views/modules/relatives/family.phtml
+++ b/resources/views/modules/relatives/family.phtml
@@ -190,7 +190,7 @@
<?php if ($family->canEdit()) : ?>
<tr>
<th scope="row">
- <?php if (count($family->children()) > 1) : ?>
+ <?php if ($family->children()->count() > 1) : ?>
<a href="<?= e(route('reorder-children', ['ged' => $family->tree()->name(), 'xref' => $family->xref()])) ?>">
<?= view('icons/reorder') ?>
<?= I18N::translate('Re-order children') ?>
diff --git a/resources/views/modules/sitemap/sitemap-file.xml.phtml b/resources/views/modules/sitemap/sitemap-file.xml.phtml
index 68720591bd..8babf51967 100644
--- a/resources/views/modules/sitemap/sitemap-file.xml.phtml
+++ b/resources/views/modules/sitemap/sitemap-file.xml.phtml
@@ -3,8 +3,8 @@
<?php foreach ($records as $record) : ?>
<url>
<loc><?= e($record->url()) ?></loc>
- <?php if ($record->firstFact('CHAN') !== null) : ?>
- <lastmod><?= $record->firstFact('CHAN')->date()->minimumDate()->Format('%Y-%m-%d') ?></lastmod>
+ <?php if ($record->facts(['CHAN'])->isNotEmpty()) : ?>
+ <lastmod><?= $record->facts(['CHAN'])->first()->date()->minimumDate()->Format('%Y-%m-%d') ?></lastmod>
<?php endif ?>
</url>
<?php endforeach ?>