Skip to content

Commit

Permalink
Working on GEDCOM tags/elements
Browse files Browse the repository at this point in the history
  • Loading branch information
fisharebest committed Jun 6, 2020
1 parent 79de923 commit 7fe676e
Show file tree
Hide file tree
Showing 34 changed files with 79 additions and 79 deletions.
14 changes: 7 additions & 7 deletions app/Fact.php
Expand Up @@ -355,7 +355,7 @@ public function canEdit(): bool
}

// Members cannot edit RESN, CHAN and locked records
return Auth::isEditor($this->record->tree()) && strpos($this->gedcom, "\n2 RESN locked") === false && $this->tag() !== 'RESN' && $this->tag() !== 'CHAN';
return Auth::isEditor($this->record->tree()) && strpos($this->gedcom, "\n2 RESN locked") === false && $this->tag !== 'RESN' && $this->tag !== 'CHAN';
}

/**
Expand Down Expand Up @@ -415,7 +415,7 @@ public function id(): string
*/
public function tag(): string
{
return $this->tag;
return $this->record::RECORD_TYPE . ':' . $this->tag;
}

/**
Expand All @@ -427,7 +427,7 @@ public function tag(): string
*/
public function getTag(): string
{
return $this->tag();
return $this->tag;
}

/**
Expand Down Expand Up @@ -606,7 +606,7 @@ public function summary(): string
// Fact date
$date = $this->date();
if ($date->isOK()) {
if ($this->record() instanceof Individual && in_array($this->tag(), Gedcom::BIRTH_EVENTS, true) && $this->record()->tree()->getPreference('SHOW_PARENTS_AGE')) {
if ($this->record() instanceof Individual && in_array($this->tag, Gedcom::BIRTH_EVENTS, true) && $this->record()->tree()->getPreference('SHOW_PARENTS_AGE')) {
$attributes[] = $date->display() . FunctionsPrint::formatParentsAges($this->record(), $date);
} else {
$attributes[] = $date->display();
Expand All @@ -618,7 +618,7 @@ public function summary(): string
}
}

$class = 'fact_' . $this->tag();
$class = 'fact_' . $this->tag;
if ($this->isPendingAddition()) {
$class .= ' wt-new';
} elseif ($this->isPendingDeletion()) {
Expand Down Expand Up @@ -683,8 +683,8 @@ public static function typeComparator(): Closure
return $a->sortOrder - $b->sortOrder;
}

$atag = $a->tag();
$btag = $b->tag();
$atag = $a->tag;
$btag = $b->tag;

// Events not in the above list get mapped onto one that is.
if (!array_key_exists($atag, $factsort)) {
Expand Down
6 changes: 3 additions & 3 deletions app/Functions/Functions.php
Expand Up @@ -630,7 +630,7 @@ public static function getRelationshipNameFromPath($path, Individual $person1 =
$event = $family->facts(['ANUL', 'DIV', 'ENGA', 'MARR'], true, Auth::PRIV_HIDE, true)->last();

if ($event instanceof Fact) {
switch ($event->tag()) {
switch ($event->getTag()) {
case 'ANUL':
case 'DIV':
return I18N::translate('ex-husband');
Expand All @@ -654,7 +654,7 @@ public static function getRelationshipNameFromPath($path, Individual $person1 =
$event = $family->facts(['ANUL', 'DIV', 'ENGA', 'MARR'], true, Auth::PRIV_HIDE, true)->last();

if ($event instanceof Fact) {
switch ($event->tag()) {
switch ($event->getTag()) {
case 'ANUL':
case 'DIV':
return I18N::translate('ex-wife');
Expand All @@ -677,7 +677,7 @@ public static function getRelationshipNameFromPath($path, Individual $person1 =
$event = $family->facts(['ANUL', 'DIV', 'ENGA', 'MARR'], true, Auth::PRIV_HIDE, true)->last();

if ($event instanceof Fact) {
switch ($event->tag()) {
switch ($event->getTag()) {
case 'ANUL':
case 'DIV':
return I18N::translate('ex-spouse');
Expand Down
4 changes: 2 additions & 2 deletions app/Functions/FunctionsEdit.php
Expand Up @@ -2,7 +2,7 @@

/**
* webtrees: online genealogy
* Copyright (C) 2017 webtrees development team
* Copyright (C) 2020 webtrees development team
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
Expand Down Expand Up @@ -733,7 +733,7 @@ public static function createEditForm(Fact $fact): void
self::$tags = [];

$level0type = $record::RECORD_TYPE;
$level1type = $fact->tag();
$level1type = $fact->getTag();

// List of tags we would expect at the next level
// NB insertMissingSubtags() already takes care of the simple cases
Expand Down
4 changes: 2 additions & 2 deletions app/Functions/FunctionsPrint.php
Expand Up @@ -296,7 +296,7 @@ public static function formatFactDate(Fact $event, GedcomRecord $record, $anchor
}

// Calculated age
$fact = $event->tag();
$fact = $event->getTag();
if (preg_match('/\n2 DATE (.+)/', $factrec, $match)) {
$date = new Date($match[1]);
$html .= ' ' . $date->display($anchor);
Expand Down Expand Up @@ -461,7 +461,7 @@ public static function formatFactPlace(Fact $event, $anchor = false, $sub_record
public static function checkFactUnique(array $uniquefacts, Collection $recfacts): array
{
foreach ($recfacts as $factarray) {
$fact = $factarray->tag();
$fact = $factarray->getTag();

$key = array_search($fact, $uniquefacts, true);
if ($key !== false) {
Expand Down
2 changes: 1 addition & 1 deletion app/Functions/FunctionsPrintFacts.php
Expand Up @@ -76,7 +76,7 @@ public static function printFact(Fact $fact, GedcomRecord $record): void
{
$parent = $fact->record();
$tree = $parent->tree();
$tag = $fact->tag();
$tag = $fact->getTag();
$label = $fact->label();
$value = $fact->value();
$type = $fact->attribute('TYPE');
Expand Down
4 changes: 2 additions & 2 deletions app/GedcomRecord.php
Expand Up @@ -824,7 +824,7 @@ public function facts(
$facts = new Collection();
if ($this->canShow($access_level)) {
foreach ($this->facts as $fact) {
if (($filter === [] || in_array($fact->tag(), $filter, true)) && $fact->canShow($access_level)) {
if (($filter === [] || in_array($fact->getTag(), $filter, true)) && $fact->canShow($access_level)) {
$facts->push($fact);
}
}
Expand Down Expand Up @@ -961,7 +961,7 @@ public function updateFact(string $fact_id, string $gedcom, bool $update_chan):
$new_gedcom .= "\n" . $gedcom;
}
$fact_id = 'NOT A VALID FACT ID'; // Only replace/delete one copy of a duplicate fact
} elseif ($fact->tag() !== 'CHAN' || !$update_chan) {
} elseif ($fact->getTag() !== 'CHAN' || !$update_chan) {
$new_gedcom .= "\n" . $fact->gedcom();
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Admin/FixLevel0MediaController.php
Expand Up @@ -170,7 +170,7 @@ public function fixLevel0MediaData(ServerRequestInterface $request): ResponseInt
return
!$fact->isPendingDeletion() &&
!preg_match('/^@' . Gedcom::REGEX_XREF . '@$/', $fact->value()) &&
!in_array($fact->tag(), $ignore_facts, true);
!in_array($fact->getTag(), $ignore_facts, true);
});

// The link to the media object may have been deleted in a pending change.
Expand Down
2 changes: 1 addition & 1 deletion app/Http/RequestHandlers/EditFact.php
Expand Up @@ -68,7 +68,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface

$can_edit_raw = Auth::isAdmin() || $tree->getPreference('SHOW_GEDCOM_RECORD');

$title = $record->fullName() . ' - ' . GedcomTag::getLabel($fact->tag());
$title = $record->fullName() . ' - ' . GedcomTag::getLabel($fact->getTag());

return $this->viewResponse('edit/edit-fact', [
'can_edit_raw' => $can_edit_raw,
Expand Down
2 changes: 1 addition & 1 deletion app/Http/RequestHandlers/FamilyPage.php
Expand Up @@ -85,7 +85,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface

$facts = $family->facts([], true)
->filter(static function (Fact $fact): bool {
return !in_array($fact->tag(), ['HUSB', 'WIFE', 'CHIL'], true);
return !in_array($fact->getTag(), ['HUSB', 'WIFE', 'CHIL'], true);
});

return $this->viewResponse('family-page', [
Expand Down
4 changes: 2 additions & 2 deletions app/Http/RequestHandlers/HeaderPage.php
Expand Up @@ -106,8 +106,8 @@ private function facts(Header $record): Collection
{
return $record->facts()
->sort(static function (Fact $x, Fact $y): int {
$sort_x = array_search($x->tag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_y = array_search($y->tag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_x = array_search($x->getTag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_y = array_search($y->getTag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;

return $sort_x <=> $sort_y;
});
Expand Down
2 changes: 1 addition & 1 deletion app/Http/RequestHandlers/MediaPage.php
Expand Up @@ -106,7 +106,7 @@ private function facts(Media $record): Collection
{
return $record->facts()
->filter(static function (Fact $fact): bool {
return $fact->tag() !== 'FILE';
return $fact->getTag() !== 'FILE';
});
}
}
4 changes: 2 additions & 2 deletions app/Http/RequestHandlers/MergeFactsPage.php
Expand Up @@ -82,13 +82,13 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$facts2 = [];

foreach ($record1->facts() as $fact) {
if (!$fact->isPendingDeletion() && $fact->tag() !== 'CHAN') {
if (!$fact->isPendingDeletion() && $fact->getTag() !== 'CHAN') {
$facts1[$fact->id()] = $fact;
}
}

foreach ($record2->facts() as $fact) {
if (!$fact->isPendingDeletion() && $fact->tag() !== 'CHAN') {
if (!$fact->isPendingDeletion() && $fact->getTag() !== 'CHAN') {
$facts2[$fact->id()] = $fact;
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/RequestHandlers/NotePage.php
Expand Up @@ -104,7 +104,7 @@ private function facts(Note $record): Collection
{
return $record->facts()
->filter(static function (Fact $fact): bool {
return $fact->tag() !== 'CONT';
return $fact->getTag() !== 'CONT';
});
}
}
2 changes: 1 addition & 1 deletion app/Http/RequestHandlers/ReorderChildrenAction.php
Expand Up @@ -66,7 +66,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface

// Split facts into FAMS and other
foreach ($family->facts() as $fact) {
if ($fact->tag() === 'CHIL') {
if ($fact->getTag() === 'CHIL') {
$sort_facts[$fact->id()] = $fact->gedcom();
} else {
$keep_facts[] = $fact->gedcom();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/RequestHandlers/ReorderFamiliesAction.php
Expand Up @@ -67,7 +67,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface

// Split facts into FAMS and other
foreach ($individual->facts() as $fact) {
$tag = $fact->tag();
$tag = $fact->getTag();

if ($tag === 'FAMC' || $tag === 'FAMS') {
$sort_facts[$fact->id()] = $fact->gedcom();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/RequestHandlers/ReorderMediaAction.php
Expand Up @@ -67,7 +67,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface

// Split facts into OBJE and other
foreach ($individual->facts() as $fact) {
if ($fact->tag() === 'OBJE') {
if ($fact->getTag() === 'OBJE') {
$sort_facts[$fact->id()] = $fact->gedcom();
} else {
$keep_facts[] = $fact->gedcom();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/RequestHandlers/ReorderNamesAction.php
Expand Up @@ -66,7 +66,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface

// Split facts into NAME and other
foreach ($individual->facts() as $fact) {
if ($fact->tag() === 'NAME') {
if ($fact->getTag() === 'NAME') {
$sort_facts[$fact->id()] = $fact->gedcom();
} else {
$keep_facts[] = $fact->gedcom();
Expand Down
4 changes: 2 additions & 2 deletions app/Http/RequestHandlers/RepositoryPage.php
Expand Up @@ -114,8 +114,8 @@ private function facts(Repository $record): Collection
{
return $record->facts()
->sort(static function (Fact $x, Fact $y): int {
$sort_x = array_search($x->tag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_y = array_search($y->tag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_x = array_search($x->getTag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_y = array_search($y->getTag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;

return $sort_x <=> $sort_y;
});
Expand Down
4 changes: 2 additions & 2 deletions app/Http/RequestHandlers/SourcePage.php
Expand Up @@ -122,8 +122,8 @@ private function facts(Source $record): Collection
{
return $record->facts()
->sort(static function (Fact $x, Fact $y): int {
$sort_x = array_search($x->tag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_y = array_search($y->tag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_x = array_search($x->getTag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_y = array_search($y->getTag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;

return $sort_x <=> $sort_y;
});
Expand Down
4 changes: 2 additions & 2 deletions app/Http/RequestHandlers/SubmissionPage.php
Expand Up @@ -104,8 +104,8 @@ private function facts(Submission $record): Collection
{
return $record->facts()
->sort(static function (Fact $x, Fact $y): int {
$sort_x = array_search($x->tag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_y = array_search($y->tag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_x = array_search($x->getTag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_y = array_search($y->getTag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;

return $sort_x <=> $sort_y;
});
Expand Down
4 changes: 2 additions & 2 deletions app/Http/RequestHandlers/SubmitterPage.php
Expand Up @@ -102,8 +102,8 @@ private function facts(Submitter $record): Collection
{
return $record->facts()
->sort(static function (Fact $x, Fact $y): int {
$sort_x = array_search($x->tag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_y = array_search($y->tag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_x = array_search($x->getTag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;
$sort_y = array_search($y->getTag(), self::FACT_ORDER, true) ?: PHP_INT_MAX;

return $sort_x <=> $sort_y;
});
Expand Down
4 changes: 2 additions & 2 deletions app/Module/FixPrimaryTag.php
Expand Up @@ -2,7 +2,7 @@

/**
* webtrees: online genealogy
* Copyright (C) 2019 webtrees development team
* Copyright (C) 2020 webtrees development team
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
Expand Down Expand Up @@ -155,7 +155,7 @@ private function updateMediaLinks(Individual $individual, string $xref, bool $pr
$facts4 = new Collection();

foreach ($facts as $fact) {
if ($fact->tag() !== 'OBJE') {
if ($fact->getTag() !== 'OBJE') {
$facts1->push($fact);
} elseif ($fact->value() !== '@' . $xref . '@') {
$facts3->push($fact);
Expand Down

0 comments on commit 7fe676e

Please sign in to comment.