summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2018-11-17 15:22:08 +0000
committerGreg Roach <fisharebest@webtrees.net>2018-11-18 18:18:42 +0000
commit8d0ebef0d075981bd943e8256e2c81a3b1e92b4b (patch)
tree6ce584137d2125125417a6c749d5d5e9a11611f1 /app
parentada1c84947c5c97bcc08a94582e9443f18df3d13 (diff)
downloadwebtrees-8d0ebef0d075981bd943e8256e2c81a3b1e92b4b.tar.gz
webtrees-8d0ebef0d075981bd943e8256e2c81a3b1e92b4b.tar.bz2
webtrees-8d0ebef0d075981bd943e8256e2c81a3b1e92b4b.zip
Prefer class-constants to global-constants
Diffstat (limited to 'app')
-rw-r--r--app/Census/AbstractCensusColumnCondition.php4
-rw-r--r--app/Census/CensusColumnAgeMarried.php2
-rw-r--r--app/Census/CensusColumnFullName.php2
-rw-r--r--app/Census/CensusColumnMarriedWithinYear.php2
-rw-r--r--app/Census/CensusColumnMonthIfMarriedWithinYear.php2
-rw-r--r--app/Census/CensusColumnNationality.php2
-rw-r--r--app/Census/CensusColumnOccupation.php2
-rw-r--r--app/Census/CensusColumnYearsMarried.php2
-rw-r--r--app/CommonMark/XrefParser.php3
-rw-r--r--app/Fact.php10
-rw-r--r--app/FactLocation.php16
-rw-r--r--app/Family.php18
-rw-r--r--app/Functions/Functions.php19
-rw-r--r--app/Functions/FunctionsCharts.php3
-rw-r--r--app/Functions/FunctionsEdit.php11
-rw-r--r--app/Functions/FunctionsExport.php3
-rw-r--r--app/Functions/FunctionsImport.php13
-rw-r--r--app/Functions/FunctionsPrint.php13
-rw-r--r--app/Functions/FunctionsPrintFacts.php11
-rw-r--r--app/Gedcom.php22
-rw-r--r--app/GedcomRecord.php34
-rw-r--r--app/Http/Controllers/AbstractEditController.php5
-rw-r--r--app/Http/Controllers/AdminController.php9
-rw-r--r--app/Http/Controllers/AdminTreesController.php7
-rw-r--r--app/Http/Controllers/AdminUpgradeController.php6
-rw-r--r--app/Http/Controllers/AncestorsChartController.php3
-rw-r--r--app/Http/Controllers/BranchesController.php2
-rw-r--r--app/Http/Controllers/DescendantsChartController.php3
-rw-r--r--app/Http/Controllers/EditFamilyController.php14
-rw-r--r--app/Http/Controllers/EditGedcomRecordController.php15
-rw-r--r--app/Http/Controllers/EditIndividualController.php4
-rw-r--r--app/Http/Controllers/FamilyController.php2
-rw-r--r--app/Http/Controllers/GedcomFileController.php3
-rw-r--r--app/Http/Controllers/IndividualController.php16
-rw-r--r--app/Http/Controllers/PendingChangesController.php3
-rw-r--r--app/Http/Controllers/PlaceHierarchyController.php3
-rw-r--r--app/Http/Controllers/ReportEngineController.php5
-rw-r--r--app/Http/Controllers/SearchController.php21
-rw-r--r--app/Http/Controllers/SetupController.php7
-rw-r--r--app/I18N.php8
-rw-r--r--app/Individual.php44
-rw-r--r--app/Media.php2
-rw-r--r--app/Module.php4
-rw-r--r--app/Module/AlbumModule.php5
-rw-r--r--app/Module/BatchUpdate/BatchUpdateMissingDeathPlugin.php4
-rw-r--r--app/Module/ChartsBlockModule.php3
-rw-r--r--app/Module/ClippingsCartModule.php8
-rw-r--r--app/Module/IndividualFactsTabModule.php15
-rw-r--r--app/Module/InteractiveTree/TreeView.php7
-rw-r--r--app/Module/InteractiveTreeModule.php8
-rw-r--r--app/Module/MediaTabModule.php3
-rw-r--r--app/Module/OnThisDayModule.php4
-rw-r--r--app/Module/PedigreeMapModule.php3
-rw-r--r--app/Module/PlacesModule.php3
-rw-r--r--app/Module/ResearchTaskModule.php2
-rw-r--r--app/Module/UpcomingAnniversariesModule.php4
-rw-r--r--app/Note.php2
-rw-r--r--app/Report/AbstractReport.php8
-rw-r--r--app/Report/ReportHtml.php3
-rw-r--r--app/Report/ReportParserGenerate.php6
-rw-r--r--app/Report/ReportPdf.php11
-rw-r--r--app/Repository.php2
-rw-r--r--app/Schema/Migration30.php3
-rw-r--r--app/Select2.php4
-rw-r--r--app/Services/UpgradeService.php5
-rw-r--r--app/Source.php2
-rw-r--r--app/Stats.php52
-rw-r--r--app/Theme/AbstractTheme.php18
-rw-r--r--app/View.php4
-rw-r--r--app/Webtrees.php90
70 files changed, 398 insertions, 261 deletions
diff --git a/app/Census/AbstractCensusColumnCondition.php b/app/Census/AbstractCensusColumnCondition.php
index a15569bd0f..44ec1366f3 100644
--- a/app/Census/AbstractCensusColumnCondition.php
+++ b/app/Census/AbstractCensusColumnCondition.php
@@ -71,7 +71,7 @@ abstract class AbstractCensusColumnCondition extends AbstractCensusColumn implem
$family = $this->spouseFamily($individual);
$sex = $individual->getSex();
- if ($family === null || count($family->facts('MARR')) === 0) {
+ if ($family === null || count($family->facts(['MARR'])) === 0) {
if ($this->isChild($individual)) {
return $this->conditionChild($sex);
}
@@ -79,7 +79,7 @@ abstract class AbstractCensusColumnCondition extends AbstractCensusColumn implem
return $this->conditionSingle($sex);
}
- if (count($family->facts('DIV')) > 0) {
+ if (count($family->facts(['DIV'])) > 0) {
return $this->conditionDivorced($sex);
}
diff --git a/app/Census/CensusColumnAgeMarried.php b/app/Census/CensusColumnAgeMarried.php
index 8185c345de..93406d8b01 100644
--- a/app/Census/CensusColumnAgeMarried.php
+++ b/app/Census/CensusColumnAgeMarried.php
@@ -37,7 +37,7 @@ class CensusColumnAgeMarried extends AbstractCensusColumn implements CensusColum
{
if ($individual->getBirthDate()->isOK()) {
foreach ($individual->getSpouseFamilies() as $family) {
- foreach ($family->facts('MARR', true) as $fact) {
+ foreach ($family->facts(['MARR'], true) as $fact) {
if ($fact->date()->isOK()) {
return (string) Date::getAgeYears($individual->getBirthDate(), $fact->date());
}
diff --git a/app/Census/CensusColumnFullName.php b/app/Census/CensusColumnFullName.php
index 85044997d3..1772adefe1 100644
--- a/app/Census/CensusColumnFullName.php
+++ b/app/Census/CensusColumnFullName.php
@@ -55,7 +55,7 @@ class CensusColumnFullName extends AbstractCensusColumn implements CensusColumnI
$name = $names[0];
foreach ($individual->getSpouseFamilies() as $family) {
- foreach ($family->facts('MARR') as $marriage) {
+ foreach ($family->facts(['MARR']) as $marriage) {
if ($marriage->date()->isOK() && Date::compare($marriage->date(), $census_date) < 0) {
$spouse = $family->getSpouse($individual);
foreach ($names as $individual_name) {
diff --git a/app/Census/CensusColumnMarriedWithinYear.php b/app/Census/CensusColumnMarriedWithinYear.php
index d19f4efa81..fcbb450431 100644
--- a/app/Census/CensusColumnMarriedWithinYear.php
+++ b/app/Census/CensusColumnMarriedWithinYear.php
@@ -35,7 +35,7 @@ class CensusColumnMarriedWithinYear extends AbstractCensusColumn implements Cens
public function generate(Individual $individual, Individual $head): string
{
foreach ($individual->getSpouseFamilies() as $family) {
- foreach ($family->facts('MARR') as $fact) {
+ foreach ($family->facts(['MARR']) as $fact) {
$marriage_jd = $fact->date()->julianDay();
$census_jd = $this->date()->julianDay();
if ($marriage_jd <= $census_jd && $marriage_jd >= $census_jd - 365) {
diff --git a/app/Census/CensusColumnMonthIfMarriedWithinYear.php b/app/Census/CensusColumnMonthIfMarriedWithinYear.php
index a972017e51..55d0e81760 100644
--- a/app/Census/CensusColumnMonthIfMarriedWithinYear.php
+++ b/app/Census/CensusColumnMonthIfMarriedWithinYear.php
@@ -35,7 +35,7 @@ class CensusColumnMonthIfMarriedWithinYear extends AbstractCensusColumn implemen
public function generate(Individual $individual, Individual $head): string
{
foreach ($individual->getSpouseFamilies() as $family) {
- foreach ($family->facts('MARR') as $fact) {
+ foreach ($family->facts(['MARR']) as $fact) {
$marriage_jd = $fact->date()->julianDay();
$census_jd = $this->date()->julianDay();
if ($marriage_jd <= $census_jd && $marriage_jd >= $census_jd - 365) {
diff --git a/app/Census/CensusColumnNationality.php b/app/Census/CensusColumnNationality.php
index eaf3272b67..bb80028618 100644
--- a/app/Census/CensusColumnNationality.php
+++ b/app/Census/CensusColumnNationality.php
@@ -52,7 +52,7 @@ class CensusColumnNationality extends AbstractCensusColumn implements CensusColu
}
// Did we emigrate or naturalise?
- foreach ($individual->facts('IMMI|EMIG|NATU', true) as $fact) {
+ foreach ($individual->facts(['IMMI' ,'EMIG', 'NATU'], true) as $fact) {
if (Date::compare($fact->date(), $this->date()) <= 0) {
$place = $fact->place()->getGedcomName();
}
diff --git a/app/Census/CensusColumnOccupation.php b/app/Census/CensusColumnOccupation.php
index ad84e4ade4..8e0727f35e 100644
--- a/app/Census/CensusColumnOccupation.php
+++ b/app/Census/CensusColumnOccupation.php
@@ -34,7 +34,7 @@ class CensusColumnOccupation extends AbstractCensusColumn implements CensusColum
*/
public function generate(Individual $individual, Individual $head): string
{
- foreach ($individual->facts('OCCU') as $fact) {
+ foreach ($individual->facts(['OCCU']) as $fact) {
return $fact->value();
}
diff --git a/app/Census/CensusColumnYearsMarried.php b/app/Census/CensusColumnYearsMarried.php
index 1b7eb60097..cb8108fa6a 100644
--- a/app/Census/CensusColumnYearsMarried.php
+++ b/app/Census/CensusColumnYearsMarried.php
@@ -38,7 +38,7 @@ class CensusColumnYearsMarried extends AbstractCensusColumn implements CensusCol
$marriage_date = null;
foreach ($individual->getSpouseFamilies() as $family) {
- foreach ($family->facts('MARR', true) as $fact) {
+ foreach ($family->facts(['MARR'], true) as $fact) {
if ($fact->date()->isOK() && Date::compare($fact->date(), $this->date()) <= 0) {
$marriage_date = $fact->date();
}
diff --git a/app/CommonMark/XrefParser.php b/app/CommonMark/XrefParser.php
index 2b4b1ff842..f9d5869c45 100644
--- a/app/CommonMark/XrefParser.php
+++ b/app/CommonMark/XrefParser.php
@@ -17,6 +17,7 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\CommonMark;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\Tree;
use League\CommonMark\Inline\Element\Link;
@@ -64,7 +65,7 @@ class XrefParser extends AbstractInlineParser
// If this isn't the start of an XREF, we'll need to rewind.
$previous_state = $cursor->saveState();
- $handle = $cursor->match('/@' . WT_REGEX_XREF . '@/');
+ $handle = $cursor->match('/@' . Gedcom::REGEX_XREF . '@/');
if (empty($handle)) {
// Not an XREF?
$cursor->restoreState($previous_state);
diff --git a/app/Fact.php b/app/Fact.php
index 2db871719d..104625e07f 100644
--- a/app/Fact.php
+++ b/app/Fact.php
@@ -171,7 +171,7 @@ class Fact
*/
public function __construct($gedcom, GedcomRecord $parent, $id)
{
- if (preg_match('/^1 (' . WT_REGEX_TAG . ')/', $gedcom, $match)) {
+ if (preg_match('/^1 (' . Gedcom::REGEX_TAG . ')/', $gedcom, $match)) {
$this->gedcom = $gedcom;
$this->record = $parent;
$this->id = $id;
@@ -442,7 +442,7 @@ class Fact
*/
public function getCitations(): array
{
- preg_match_all('/\n(2 SOUR @(' . WT_REGEX_XREF . ')@(?:\n[3-9] .*)*)/', $this->gedcom(), $matches, PREG_SET_ORDER);
+ preg_match_all('/\n(2 SOUR @(' . Gedcom::REGEX_XREF . ')@(?:\n[3-9] .*)*)/', $this->gedcom(), $matches, PREG_SET_ORDER);
$citations = [];
foreach ($matches as $match) {
$source = Source::getInstance($match[2], $this->record()->tree());
@@ -465,7 +465,7 @@ class Fact
preg_match_all('/\n2 NOTE ?(.*(?:\n3.*)*)/', $this->gedcom(), $matches);
foreach ($matches[1] as $match) {
$note = preg_replace("/\n3 CONT ?/", "\n", $match);
- if (preg_match('/@(' . WT_REGEX_XREF . ')@/', $note, $nmatch)) {
+ if (preg_match('/@(' . Gedcom::REGEX_XREF . ')@/', $note, $nmatch)) {
$note = Note::getInstance($nmatch[1], $this->record()->tree());
if ($note && $note->canShow()) {
// A note object
@@ -488,7 +488,7 @@ class Fact
public function getMedia(): array
{
$media = [];
- preg_match_all('/\n2 OBJE @(' . WT_REGEX_XREF . ')@/', $this->gedcom(), $matches);
+ preg_match_all('/\n2 OBJE @(' . Gedcom::REGEX_XREF . ')@/', $this->gedcom(), $matches);
foreach ($matches[1] as $match) {
$obje = Media::getInstance($match, $this->record()->tree());
if ($obje && $obje->canShow()) {
@@ -519,7 +519,7 @@ class Fact
// Fact date
$date = $this->date();
if ($date->isOK()) {
- if (in_array($this->getTag(), explode('|', WT_EVENTS_BIRT)) && $this->record() instanceof Individual && $this->record()->tree()->getPreference('SHOW_PARENTS_AGE')) {
+ if (in_array($this->getTag(), Gedcom::BIRTH_EVENTS) && $this->record() instanceof Individual && $this->record()->tree()->getPreference('SHOW_PARENTS_AGE')) {
$attributes[] = $date->display() . FunctionsPrint::formatParentsAges($this->record(), $date);
} else {
$attributes[] = $date->display();
diff --git a/app/FactLocation.php b/app/FactLocation.php
index 218b45ce49..39d9575c7a 100644
--- a/app/FactLocation.php
+++ b/app/FactLocation.php
@@ -103,42 +103,42 @@ class FactLocation extends Location
public function getIconDetails(): array
{
$tag = $this->fact->getTag();
- if (false !== stripos(WT_EVENTS_BIRT, $tag)) {
+ if (in_array($tag, Gedcom::BIRTH_EVENTS)) {
$icon = [
'color' => 'Crimson',
'name' => 'birthday-cake',
];
- } elseif (false !== stripos(WT_EVENTS_MARR, $tag)) {
+ } elseif (in_array($tag, Gedcom::MARRIAGE_EVENTS)) {
$icon = [
'color' => 'Green',
'name' => 'venus-mars',
];
- } elseif (false !== stripos(WT_EVENTS_DEAT, $tag)) {
+ } elseif (in_array($tag, Gedcom::DEATH_EVENTS)) {
$icon = [
'color' => 'Black',
'name' => 'plus',
];
- } elseif (false !== stripos('CENS', $tag)) {
+ } elseif ($tag === 'CENS') {
$icon = [
'color' => 'MediumBlue',
'name' => 'users',
];
- } elseif (false !== stripos('RESI', $tag)) {
+ } elseif ($tag === 'RESI') {
$icon = [
'color' => 'MediumBlue',
'name' => 'home',
];
- } elseif (false !== stripos('OCCU', $tag)) {
+ } elseif ($tag === 'OCCU') {
$icon = [
'color' => 'MediumBlue',
'name' => 'briefcase',
];
- } elseif (false !== stripos('GRAD', $tag)) {
+ } elseif ($tag === 'GRAD') {
$icon = [
'color' => 'MediumBlue',
'name' => 'graduation-cap',
];
- } elseif (false !== stripos('EDUC', $tag)) {
+ } elseif ($tag === 'EDUC') {
$icon = [
'color' => 'MediumBlue',
'name' => 'university',
diff --git a/app/Family.php b/app/Family.php
index 62fe2347f4..b40084246f 100644
--- a/app/Family.php
+++ b/app/Family.php
@@ -94,7 +94,7 @@ class Family extends GedcomRecord
$rec = '0 @' . $this->xref . '@ FAM';
// Just show the 1 CHIL/HUSB/WIFE tag, not any subtags, which may contain private data
- preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . WT_REGEX_XREF . ')@/', $this->gedcom, $matches, PREG_SET_ORDER);
+ preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . Gedcom::REGEX_XREF . ')@/', $this->gedcom, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$rela = Individual::getInstance($match[1], $this->tree);
if ($rela && ($SHOW_PRIVATE_RELATIONSHIPS || $rela->canShow($access_level))) {
@@ -169,7 +169,7 @@ class Family extends GedcomRecord
protected function canShowByType(int $access_level): bool
{
// Hide a family if any member is private
- preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . WT_REGEX_XREF . ')@/', $this->gedcom, $matches);
+ preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . Gedcom::REGEX_XREF . ')@/', $this->gedcom, $matches);
foreach ($matches[1] as $match) {
$person = Individual::getInstance($match, $this->tree);
if ($person && !$person->canShow($access_level)) {
@@ -242,7 +242,7 @@ class Family extends GedcomRecord
$SHOW_PRIVATE_RELATIONSHIPS = (bool) $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS');
$children = [];
- foreach ($this->facts('CHIL', false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) {
+ 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;
@@ -273,7 +273,7 @@ class Family extends GedcomRecord
public function getNumberOfChildren(): int
{
$nchi = count($this->getChildren());
- foreach ($this->facts('NCHI') as $fact) {
+ foreach ($this->facts(['NCHI']) as $fact) {
$nchi = max($nchi, (int) $fact->value());
}
@@ -334,8 +334,8 @@ class Family extends GedcomRecord
*/
public function getAllMarriageDates(): array
{
- foreach (explode('|', WT_EVENTS_MARR) as $event) {
- if ($array = $this->getAllEventDates($event)) {
+ foreach (Gedcom::MARRIAGE_EVENTS as $event) {
+ if ($array = $this->getAllEventDates([$event])) {
return $array;
}
}
@@ -350,7 +350,7 @@ class Family extends GedcomRecord
*/
public function getAllMarriagePlaces(): array
{
- foreach (explode('|', WT_EVENTS_MARR) as $event) {
+ foreach (Gedcom::MARRIAGE_EVENTS as $event) {
$places = $this->getAllEventPlaces($event);
if (!empty($places)) {
return $places;
@@ -446,7 +446,7 @@ class Family extends GedcomRecord
public function formatListDetails(): string
{
return
- $this->formatFirstMajorFact(WT_EVENTS_MARR, 1) .
- $this->formatFirstMajorFact(WT_EVENTS_DIV, 1);
+ $this->formatFirstMajorFact(Gedcom::MARRIAGE_EVENTS, 1) .
+ $this->formatFirstMajorFact(Gedcom::DIVORCE_EVENTS, 1);
}
}
diff --git a/app/Functions/Functions.php b/app/Functions/Functions.php
index 493a8a7661..a4b45afea4 100644
--- a/app/Functions/Functions.php
+++ b/app/Functions/Functions.php
@@ -20,6 +20,7 @@ namespace Fisharebest\Webtrees\Functions;
use Exception;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
@@ -677,15 +678,15 @@ class Functions
if ($person1 && $person2) {
foreach ($person1->getSpouseFamilies() as $family) {
if ($person2 === $family->getSpouse($person1)) {
- if ($family->facts('MARR')) {
- if ($family->facts(WT_EVENTS_DIV)) {
+ if ($family->facts(['MARR'])) {
+ if ($family->facts(Gedcom::DIVORCE_EVENTS)) {
return I18N::translate('ex-husband');
}
return I18N::translate('husband');
}
- if ($family->facts(WT_EVENTS_DIV)) {
+ if ($family->facts(Gedcom::DIVORCE_EVENTS)) {
return I18N::translateContext('MALE', 'ex-partner');
}
}
@@ -697,15 +698,15 @@ class Functions
if ($person1 && $person2) {
foreach ($person1->getSpouseFamilies() as $family) {
if ($person2 === $family->getSpouse($person1)) {
- if ($family->facts('MARR')) {
- if ($family->facts(WT_EVENTS_DIV)) {
+ if ($family->facts(['MARR'])) {
+ if ($family->facts(Gedcom::DIVORCE_EVENTS)) {
return I18N::translate('ex-wife');
}
return I18N::translate('wife');
}
- if ($family->facts(WT_EVENTS_DIV)) {
+ if ($family->facts(Gedcom::DIVORCE_EVENTS)) {
return I18N::translateContext('FEMALE', 'ex-partner');
}
}
@@ -717,15 +718,15 @@ class Functions
if ($person1 && $person2) {
foreach ($person1->getSpouseFamilies() as $family) {
if ($person2 === $family->getSpouse($person1)) {
- if ($family->facts('MARR')) {
- if ($family->facts(WT_EVENTS_DIV)) {
+ if ($family->facts(['MARR'])) {
+ if ($family->facts(Gedcom::DIVORCE_EVENTS)) {
return I18N::translate('ex-spouse');
}
return I18N::translate('spouse');
}
- if ($family->facts(WT_EVENTS_DIV)) {
+ if ($family->facts(Gedcom::DIVORCE_EVENTS)) {
return I18N::translate('ex-partner');
}
}
diff --git a/app/Functions/FunctionsCharts.php b/app/Functions/FunctionsCharts.php
index 9b9829e8b1..0afea645d7 100644
--- a/app/Functions/FunctionsCharts.php
+++ b/app/Functions/FunctionsCharts.php
@@ -20,6 +20,7 @@ namespace Fisharebest\Webtrees\Functions;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\FontAwesome;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Theme;
@@ -198,7 +199,7 @@ class FunctionsCharts
echo '</tr></table>';
echo '<br>';
if ($sosa && $family->canShow()) {
- foreach ($family->facts(WT_EVENTS_MARR) as $fact) {
+ foreach ($family->facts(Gedcom::MARRIAGE_EVENTS) as $fact) {
echo '<a href="', e($family->url()), '" class="details1">';
echo $fact->summary();
echo '</a>';
diff --git a/app/Functions/FunctionsEdit.php b/app/Functions/FunctionsEdit.php
index 64bfa4e663..8ac25e8350 100644
--- a/app/Functions/FunctionsEdit.php
+++ b/app/Functions/FunctionsEdit.php
@@ -24,6 +24,7 @@ use Fisharebest\Webtrees\Config;
use Fisharebest\Webtrees\Date;
use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Family;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomCode\GedcomCodeAdop;
use Fisharebest\Webtrees\GedcomCode\GedcomCodeName;
use Fisharebest\Webtrees\GedcomCode\GedcomCodePedi;
@@ -506,7 +507,7 @@ class FunctionsEdit
'PLAC' => '',
];
- preg_match('/^(?:(\d+) (' . WT_REGEX_TAG . ') ?(.*))/', $tag, $match);
+ preg_match('/^(?:(\d+) (' . Gedcom::REGEX_TAG . ') ?(.*))/', $tag, $match);
list(, $level, $fact, $value) = $match;
if ($level === '0') {
@@ -901,7 +902,7 @@ class FunctionsEdit
if (!in_array($fact, Config::nonPlaceFacts())) {
echo self::addSimpleTag($tree, '0 PLAC', $fact, GedcomTag::getLabel($fact . ':PLAC'));
- if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $tree->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
+ if (preg_match_all('/(' . Gedcom::REGEX_TAG . ')/', $tree->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
foreach ($match[1] as $tag) {
echo self::addSimpleTag($tree, '0 ' . $tag, $fact, GedcomTag::getLabel($fact . ':PLAC:' . $tag));
}
@@ -1007,7 +1008,7 @@ class FunctionsEdit
$expected_subtags['DATE'] = ['TIME'];
}
- if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $record->tree()->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
+ if (preg_match_all('/(' . Gedcom::REGEX_TAG . ')/', $record->tree()->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
$expected_subtags['PLAC'] = array_merge($match[1], $expected_subtags['PLAC']);
}
@@ -1129,7 +1130,7 @@ class FunctionsEdit
// Add level 3/4 tags as appropriate
switch ($key) {
case 'PLAC':
- if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $tree->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
+ if (preg_match_all('/(' . Gedcom::REGEX_TAG . ')/', $tree->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
foreach ($match[1] as $tag) {
echo self::addSimpleTag($tree, '3 ' . $tag, '', GedcomTag::getLabel($level1tag . ':PLAC:' . $tag));
}
@@ -1173,7 +1174,7 @@ class FunctionsEdit
if (!in_array($tag, self::$tags)) {
echo self::addSimpleTag($tree, '2 ' . $tag);
if ($tag === 'PLAC') {
- if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $tree->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
+ if (preg_match_all('/(' . Gedcom::REGEX_TAG . ')/', $tree->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
foreach ($match[1] as $ptag) {
echo self::addSimpleTag($tree, '3 ' . $ptag, '', GedcomTag::getLabel($level1tag . ':PLAC:' . $ptag));
}
diff --git a/app/Functions/FunctionsExport.php b/app/Functions/FunctionsExport.php
index 2237f139da..ca4a5b63f1 100644
--- a/app/Functions/FunctionsExport.php
+++ b/app/Functions/FunctionsExport.php
@@ -29,6 +29,7 @@ use Fisharebest\Webtrees\Note;
use Fisharebest\Webtrees\Repository;
use Fisharebest\Webtrees\Source;
use Fisharebest\Webtrees\Tree;
+use Fisharebest\Webtrees\Webtrees;
/**
* Class FunctionsExport - common functions
@@ -87,7 +88,7 @@ class FunctionsExport
{
// Default values for a new header
$HEAD = '0 HEAD';
- $SOUR = "\n1 SOUR " . WT_WEBTREES . "\n2 NAME " . WT_WEBTREES . "\n2 VERS " . WT_VERSION;
+ $SOUR = "\n1 SOUR " . Webtrees::NAME . "\n2 NAME " . Webtrees::NAME . "\n2 VERS " . Webtrees::VERSION;
$DEST = "\n1 DEST DISKETTE";
$DATE = "\n1 DATE " . strtoupper(date('d M Y')) . "\n2 TIME " . date('H:i:s');
$GEDC = "\n1 GEDC\n2 VERS 5.5.1\n2 FORM Lineage-Linked";
diff --git a/app/Functions/FunctionsImport.php b/app/Functions/FunctionsImport.php
index a61cd53f13..a374616e87 100644
--- a/app/Functions/FunctionsImport.php
+++ b/app/Functions/FunctionsImport.php
@@ -20,6 +20,7 @@ namespace Fisharebest\Webtrees\Functions;
use Fisharebest\Webtrees\Database;
use Fisharebest\Webtrees\Date;
use Fisharebest\Webtrees\DebugBar;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\GedcomTag;
use Fisharebest\Webtrees\I18N;
@@ -613,7 +614,7 @@ class FunctionsImport
$gedrec = self::reformatRecord($gedrec, $tree);
// import different types of records
- if (preg_match('/^0 @(' . WT_REGEX_XREF . ')@ (' . WT_REGEX_TAG . ')/', $gedrec, $match)) {
+ if (preg_match('/^0 @(' . Gedcom::REGEX_XREF . ')@ (' . Gedcom::REGEX_TAG . ')/', $gedrec, $match)) {
list(, $xref, $type) = $match;
// check for a _UID, if the record doesn't have one, add one
if ($tree->getPreference('GENERATE_UIDS') && !strpos($gedrec, "\n1 _UID ")) {
@@ -674,17 +675,17 @@ class FunctionsImport
// Convert inline media into media objects
$gedrec = self::convertInlineMedia($tree, $gedrec);
- if (preg_match('/\n1 HUSB @(' . WT_REGEX_XREF . ')@/', $gedrec, $match)) {
+ if (preg_match('/\n1 HUSB @(' . Gedcom::REGEX_XREF . ')@/', $gedrec, $match)) {
$husb = $match[1];
} else {
$husb = '';
}
- if (preg_match('/\n1 WIFE @(' . WT_REGEX_XREF . ')@/', $gedrec, $match)) {
+ if (preg_match('/\n1 WIFE @(' . Gedcom::REGEX_XREF . ')@/', $gedrec, $match)) {
$wife = $match[1];
} else {
$wife = '';
}
- $nchi = preg_match_all('/\n1 CHIL @(' . WT_REGEX_XREF . ')@/', $gedrec, $match);
+ $nchi = preg_match_all('/\n1 CHIL @(' . Gedcom::REGEX_XREF . ')@/', $gedrec, $match);
if (preg_match('/\n1 NCHI (\d+)/', $gedrec, $match)) {
$nchi = max($nchi, $match[1]);
}
@@ -958,7 +959,7 @@ class FunctionsImport
*/
public static function updateLinks($xref, $ged_id, $gedrec)
{
- if (preg_match_all('/^\d+ (' . WT_REGEX_TAG . ') @(' . WT_REGEX_XREF . ')@/m', $gedrec, $matches, PREG_SET_ORDER)) {
+ if (preg_match_all('/^\d+ (' . Gedcom::REGEX_TAG . ') @(' . Gedcom::REGEX_XREF . ')@/m', $gedrec, $matches, PREG_SET_ORDER)) {
$data = [];
foreach ($matches as $match) {
// Include each link once only.
@@ -1207,7 +1208,7 @@ class FunctionsImport
*/
public static function updateRecord($gedrec, Tree $tree, bool $delete)
{
- if (preg_match('/^0 @(' . WT_REGEX_XREF . ')@ (' . WT_REGEX_TAG . ')/', $gedrec, $match)) {
+ if (preg_match('/^0 @(' . Gedcom::REGEX_XREF . ')@ (' . Gedcom::REGEX_TAG . ')/', $gedrec, $match)) {
list(, $gid, $type) = $match;
} elseif (preg_match('/^0 (HEAD)(?:\n|$)/', $gedrec, $match)) {
// The HEAD record has no XREF. Any others?
diff --git a/app/Functions/FunctionsPrint.php b/app/Functions/FunctionsPrint.php
index 2f1e10dbd5..de6d0d0592 100644
--- a/app/Functions/FunctionsPrint.php
+++ b/app/Functions/FunctionsPrint.php
@@ -23,6 +23,7 @@ use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\Filter;
use Fisharebest\Webtrees\FontAwesome;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomCode\GedcomCodeStat;
use Fisharebest\Webtrees\GedcomCode\GedcomCodeTemp;
use Fisharebest\Webtrees\GedcomRecord;
@@ -74,7 +75,7 @@ class FunctionsPrint
$text .= Functions::getCont($nlevel, $nrec);
// Check if shared note (we have already checked that it exists)
- if (preg_match('/^0 @(' . WT_REGEX_XREF . ')@ NOTE/', $nrec, $match)) {
+ if (preg_match('/^0 @(' . Gedcom::REGEX_XREF . ')@ NOTE/', $nrec, $match)) {
$note = Note::getInstance($match[1], $tree);
$label = 'SHARED_NOTE';
$html = Filter::formatText($note->getNote(), $tree);
@@ -137,7 +138,7 @@ class FunctionsPrint
if (!isset($match[$j][1])) {
$match[$j][1] = '';
}
- if (!preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $match[$j][1], $nmatch)) {
+ if (!preg_match('/^@(' . Gedcom::REGEX_XREF . ')@$/', $match[$j][1], $nmatch)) {
$data .= self::printNoteRecord($tree, $match[$j][1], $nlevel, $nrec);
} else {
$note = Note::getInstance($nmatch[1], $tree);
@@ -600,13 +601,13 @@ class FunctionsPrint
*/
public static function getLdsSummary(Individual $individual): string
{
- $BAPL = $individual->facts('BAPL') ? 'B' : '_';
- $ENDL = $individual->facts('ENDL') ? 'E' : '_';
- $SLGC = $individual->facts('SLGC') ? 'C' : '_';
+ $BAPL = $individual->facts(['BAPL']) ? 'B' : '_';
+ $ENDL = $individual->facts(['ENDL']) ? 'E' : '_';
+ $SLGC = $individual->facts(['SLGC']) ? 'C' : '_';
$SLGS = '_';
foreach ($individual->getSpouseFamilies() as $family) {
- if ($family->facts('SLGS')) {
+ if ($family->facts(['SLGS'])) {
$SLGS = '';
}
}
diff --git a/app/Functions/FunctionsPrintFacts.php b/app/Functions/FunctionsPrintFacts.php
index d526db0122..bed18ddd12 100644
--- a/app/Functions/FunctionsPrintFacts.php
+++ b/app/Functions/FunctionsPrintFacts.php
@@ -23,6 +23,7 @@ use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\Filter;
use Fisharebest\Webtrees\FontAwesome;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomCode\GedcomCodeAdop;
use Fisharebest\Webtrees\GedcomCode\GedcomCodeQuay;
use Fisharebest\Webtrees\GedcomCode\GedcomCodeRela;
@@ -311,7 +312,7 @@ class FunctionsPrintFacts
// Do not display "Yes".
break;
default:
- if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $fact->value(), $match)) {
+ if (preg_match('/^@(' . Gedcom::REGEX_XREF . ')@$/', $fact->value(), $match)) {
$target = GedcomRecord::getInstance($match[1], $tree);
if ($target) {
echo '<div><a href="', e($target->url()), '">', $target->getFullName(), '</a></div>';
@@ -359,7 +360,7 @@ class FunctionsPrintFacts
}
// Print any other "2 XXXX" attributes, in the order in which they appear.
- preg_match_all('/\n2 (' . WT_REGEX_TAG . ') (.+)/', $fact->gedcom(), $matches, PREG_SET_ORDER);
+ preg_match_all('/\n2 (' . Gedcom::REGEX_TAG . ') (.+)/', $fact->gedcom(), $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
switch ($match[1]) {
case 'DATE':
@@ -464,7 +465,7 @@ class FunctionsPrintFacts
break;
default:
if ($tree->getPreference('HIDE_GEDCOM_ERRORS') === '1' || GedcomTag::isTag($match[1])) {
- if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $match[2], $xmatch)) {
+ if (preg_match('/^@(' . Gedcom::REGEX_XREF . ')@$/', $match[2], $xmatch)) {
// Links
$linked_record = GedcomRecord::getInstance($xmatch[1], $tree);
if ($linked_record) {
@@ -509,8 +510,8 @@ class FunctionsPrintFacts
return '';
}
- preg_match_all('/^1 ASSO @(' . WT_REGEX_XREF . ')@((\n[2-9].*)*)/', $event->gedcom(), $amatches1, PREG_SET_ORDER);
- preg_match_all('/\n2 _?ASSO @(' . WT_REGEX_XREF . ')@((\n[3-9].*)*)/', $event->gedcom(), $amatches2, PREG_SET_ORDER);
+ preg_match_all('/^1 ASSO @(' . Gedcom::REGEX_XREF . ')@((\n[2-9].*)*)/', $event->gedcom(), $amatches1, PREG_SET_ORDER);
+ preg_match_all('/\n2 _?ASSO @(' . Gedcom::REGEX_XREF . ')@((\n[3-9].*)*)/', $event->gedcom(), $amatches2, PREG_SET_ORDER);
$html = '';
// For each ASSO record
diff --git a/app/Gedcom.php b/app/Gedcom.php
index 42227e64ff..48a9c7f12d 100644
--- a/app/Gedcom.php
+++ b/app/Gedcom.php
@@ -27,4 +27,26 @@ class Gedcom
// 255 less the EOL character.
const LINE_LENGTH = 253;
+
+ // Gedcom tags which indicate the start of life.
+ const BIRTH_EVENTS = ['BIRT', 'CHR', 'BAPM', 'ADOP'];
+
+ // Gedcom tags which indicate the end of life.
+ const DEATH_EVENTS = ['DEAT', 'BURI', 'CREM'];
+
+ // Gedcom tags which indicate the start of a relationship.
+ const MARRIAGE_EVENTS = ['MARR', '_NMR'];
+
+ // Gedcom tags which indicate the end of a relationship.
+ const DIVORCE_EVENTS = ['DIV', 'ANUL', '_SEPR'];
+
+ // Regular expression to match a GEDCOM tag.
+ const REGEX_TAG = '[_A-Z][_A-Z0-9]*';
+
+ // Regular expression to match a GEDCOM XREF.
+ const REGEX_XREF = '[A-Za-z0-9:_-]+';
+
+ // UTF-8 encoded files may begin with an optional byte-order-mark (U+FEFF).
+ const UTF8_BOM = "\xEF\xBB\xBF";
+
}
diff --git a/app/GedcomRecord.php b/app/GedcomRecord.php
index d692050493..aaa827a38d 100644
--- a/app/GedcomRecord.php
+++ b/app/GedcomRecord.php
@@ -189,7 +189,7 @@ class GedcomRecord
}
// Create the object
- if (preg_match('/^0 @(' . WT_REGEX_XREF . ')@ (' . WT_REGEX_TAG . ')/', $gedcom . $pending, $match)) {
+ if (preg_match('/^0 @(' . Gedcom::REGEX_XREF . ')@ (' . Gedcom::REGEX_TAG . ')/', $gedcom . $pending, $match)) {
$xref = $match[1]; // Collation - we may have requested I123 and found i123
$type = $match[2];
} elseif (preg_match('/^0 (HEAD|TRLR)/', $gedcom . $pending, $match)) {
@@ -499,7 +499,7 @@ class GedcomRecord
list($gedrec) = explode("\n", $this->gedcom, 2);
// Check each of the facts for access
- foreach ($this->facts('', false, $access_level) as $fact) {
+ foreach ($this->facts([], false, $access_level) as $fact) {
$gedrec .= "\n" . $fact->gedcom();
}
@@ -806,12 +806,12 @@ class GedcomRecord
/**
* Extract/format the first fact from a list of facts.
*
- * @param string $facts
- * @param int $style
+ * @param string[] $facts
+ * @param int $style
*
* @return string
*/
- public function formatFirstMajorFact(string $facts, int $style): string
+ public function formatFirstMajorFact(array $facts, int $style): string
{
foreach ($this->facts($facts, true) as $event) {
// Only display if it has a date or place (or both)
@@ -1038,14 +1038,14 @@ class GedcomRecord
* calendars, place-names in both latin and hebrew character sets, etc.
* It also allows us to combine dates/places from different events in the summaries.
*
- * @param string $event_type
+ * @param string[] $events
*
* @return Date[]
*/
- public function getAllEventDates(string $event_type): array
+ public function getAllEventDates(array $events): array
{
$dates = [];
- foreach ($this->facts($event_type) as $event) {
+ foreach ($this->facts($events) as $event) {
if ($event->date()->isOK()) {
$dates[] = $event->date();
}
@@ -1057,14 +1057,14 @@ class GedcomRecord
/**
* Get all the places for a particular type of event
*
- * @param string $event_type
+ * @param string[] $events
*
* @return Place[]
*/
- public function getAllEventPlaces(string $event_type): array
+ public function getAllEventPlaces(array $events): array
{
$places = [];
- foreach ($this->facts($event_type) as $event) {
+ foreach ($this->facts($events) as $event) {
if (preg_match_all('/\n(?:2 PLAC|3 (?:ROMN|FONE|_HEB)) +(.+)/', $event->gedcom(), $ged_places)) {
foreach ($ged_places[1] as $ged_place) {
$places[] = new Place($ged_place, $this->tree);
@@ -1096,14 +1096,14 @@ class GedcomRecord
/**
* The facts and events for this record.
*
- * @param string $filter
+ * @param string[] $filter
* @param bool $sort
* @param int|null $access_level
* @param bool $override Include private records, to allow us to implement $SHOW_PRIVATE_RELATIONSHIPS and $SHOW_LIVING_NAMES.
*
* @return Fact[]
*/
- public function facts(string $filter = '', bool $sort = false, int $access_level = null, bool $override = false): array
+ public function facts(array $filter = [], bool $sort = false, int $access_level = null, bool $override = false): array
{
if ($access_level === null) {
$access_level = Auth::accessLevel($this->tree);
@@ -1112,7 +1112,7 @@ class GedcomRecord
$facts = [];
if ($this->canShow($access_level) || $override) {
foreach ($this->facts as $fact) {
- if (($filter === '' || preg_match('/^' . $filter . '$/', $fact->getTag())) && $fact->canShow($access_level)) {
+ if (($filter === [] || in_array($fact->getTag(), $filter)) && $fact->canShow($access_level)) {
$facts[] = $fact;
}
}
@@ -1228,7 +1228,7 @@ class GedcomRecord
if ($this->pending === '') {
throw new Exception('Cannot edit a deleted record');
}
- if ($gedcom !== '' && !preg_match('/^1 ' . WT_REGEX_TAG . '/', $gedcom)) {
+ if ($gedcom !== '' && !preg_match('/^1 ' . Gedcom::REGEX_TAG . '/', $gedcom)) {
throw new Exception('Invalid GEDCOM data passed to GedcomRecord::updateFact(' . $gedcom . ')');
}
@@ -1242,7 +1242,7 @@ class GedcomRecord
list($new_gedcom) = explode("\n", $old_gedcom, 2);
// Replacing (or deleting) an existing fact
- foreach ($this->facts('', false, Auth::PRIV_HIDE) as $fact) {
+ foreach ($this->facts([], false, Auth::PRIV_HIDE) as $fact) {
if (!$fact->isPendingDeletion()) {
if ($fact->id() === $fact_id) {
if ($gedcom !== '') {
@@ -1378,7 +1378,7 @@ class GedcomRecord
foreach ($this->facts() as $fact) {
if ($fact->value() === $value) {
$this->deleteFact($fact->id(), $update_chan);
- } elseif (preg_match_all('/\n(\d) ' . WT_REGEX_TAG . ' ' . $value . '/', $fact->gedcom(), $matches, PREG_SET_ORDER)) {
+ } elseif (preg_match_all('/\n(\d) ' . Gedcom::REGEX_TAG . ' ' . $value . '/', $fact->gedcom(), $matches, PREG_SET_ORDER)) {
$gedcom = $fact->gedcom();
foreach ($matches as $match) {
$next_level = $match[1] + 1;
diff --git a/app/Http/Controllers/AbstractEditController.php b/app/Http/Controllers/AbstractEditController.php
index dd60c5b7a3..8d46f5d39a 100644
--- a/app/Http/Controllers/AbstractEditController.php
+++ b/app/Http/Controllers/AbstractEditController.php
@@ -17,6 +17,7 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Http\Controllers;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\Tree;
use Symfony\Component\HttpFoundation\Request;
@@ -285,7 +286,7 @@ abstract class AbstractEditController extends AbstractBaseController
if ($PLAC) {
$gedrec .= "\n2 PLAC " . $PLAC;
- if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $tree->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
+ if (preg_match_all('/(' . Gedcom::REGEX_TAG . ')/', $tree->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
foreach ($match[1] as $tag) {
$TAG = $request->get($fact . '_' . $tag, '');
if ($TAG !== '') {
@@ -394,7 +395,7 @@ abstract class AbstractEditController extends AbstractBaseController
'NSFX',
];
- if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $tree->getPreference('ADVANCED_NAME_FACTS'), $match)) {
+ if (preg_match_all('/(' . Gedcom::REGEX_TAG . ')/', $tree->getPreference('ADVANCED_NAME_FACTS'), $match)) {
$tags = array_merge($tags, $match[1]);
}
diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php
index d13e61d5c9..c3aa303114 100644
--- a/app/Http/Controllers/AdminController.php
+++ b/app/Http/Controllers/AdminController.php
@@ -26,6 +26,7 @@ use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\FlashMessages;
use Fisharebest\Webtrees\Functions\FunctionsDb;
use Fisharebest\Webtrees\Functions\FunctionsImport;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\GedcomTag;
use Fisharebest\Webtrees\I18N;
@@ -274,7 +275,7 @@ class AdminController extends AbstractBaseController
$record ? '<a href="' . e($record->url()) . '">' . $record->xref() . '</a>' : $row->xref,
'<div class="gedcom-data" dir="ltr">' .
preg_replace_callback(
- '/@(' . WT_REGEX_XREF . ')@/',
+ '/@(' . Gedcom::REGEX_XREF . ')@/',
function (array $match) use ($tree) : string {
$record = GedcomRecord::getInstance($match[1], $tree);
@@ -412,7 +413,7 @@ class AdminController extends AbstractBaseController
foreach ($individual->facts() as $fact1) {
if ($fact1->id() === $fact_id) {
$individual->updateFact($fact_id, $fact1->gedcom() . "\n2 OBJE @" . $obje_xref . '@', false);
- foreach ($individual->facts('OBJE') as $fact2) {
+ foreach ($individual->facts(['OBJE']) as $fact2) {
if ($fact2->target() === $media) {
$individual->deleteFact($fact2->id(), false);
}
@@ -496,14 +497,14 @@ class AdminController extends AbstractBaseController
$media = Media::getInstance($datum->m_id, $tree, $datum->m_gedcom);
$individual = Individual::getInstance($datum->i_id, $tree, $datum->i_gedcom);
- $facts = $individual->facts('', true);
+ $facts = $individual->facts([], true);
$facts = array_filter($facts, function (Fact $fact) use ($ignore_facts): bool {
return !$fact->isPendingDeletion() && !in_array($fact->getTag(), $ignore_facts);
});
// The link to the media object may have been deleted in a pending change.
$deleted = true;
- foreach ($individual->facts('OBJE') as $fact) {
+ foreach ($individual->facts(['OBJE']) as $fact) {
if ($fact->target() === $media && !$fact->isPendingDeletion()) {
$deleted = false;
}
diff --git a/app/Http/Controllers/AdminTreesController.php b/app/Http/Controllers/AdminTreesController.php
index 3df65a2470..e7ca8dc9a2 100644
--- a/app/Http/Controllers/AdminTreesController.php
+++ b/app/Http/Controllers/AdminTreesController.php
@@ -27,6 +27,7 @@ use Fisharebest\Webtrees\File;
use Fisharebest\Webtrees\FlashMessages;
use Fisharebest\Webtrees\Functions\Functions;
use Fisharebest\Webtrees\Functions\FunctionsExport;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomTag;
use Fisharebest\Webtrees\Html;
use Fisharebest\Webtrees\I18N;
@@ -201,7 +202,7 @@ class AdminTreesController extends AbstractBaseController
foreach ($records as $record) {
$all_links[$record->xref] = [];
$upper_links[strtoupper($record->xref)] = $record->xref;
- preg_match_all('/\n\d (' . WT_REGEX_TAG . ') @([^#@\n][^\n@]*)@/', $record->gedrec, $matches, PREG_SET_ORDER);
+ preg_match_all('/\n\d (' . Gedcom::REGEX_TAG . ') @([^#@\n][^\n@]*)@/', $record->gedrec, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$all_links[$record->xref][$match[2]] = $match[1];
}
@@ -1046,7 +1047,7 @@ class AdminTreesController extends AbstractBaseController
$tree->setPreference('META_TITLE', $request->get('META_TITLE'));
$tree->setPreference('NO_UPDATE_CHAN', (string) (bool) $request->get('NO_UPDATE_CHAN'));
$tree->setPreference('PEDIGREE_LAYOUT', (string) (bool) $request->get('PEDIGREE_LAYOUT'));
- $tree->setPreference('PEDIGREE_ROOT_ID', $request->get('PEDIGREE_ROOT_ID', WT_REGEX_XREF));
+ $tree->setPreference('PEDIGREE_ROOT_ID', $request->get('PEDIGREE_ROOT_ID'));
$tree->setPreference('PEDIGREE_SHOW_GENDER', (string) (bool) $request->get('PEDIGREE_SHOW_GENDER'));
$tree->setPreference('PREFER_LEVEL2_SOURCES', $request->get('PREFER_LEVEL2_SOURCES'));
$tree->setPreference('QUICK_REQUIRED_FACTS', implode(',', $request->get('QUICK_REQUIRED_FACTS', [])));
@@ -1995,7 +1996,7 @@ class AdminTreesController extends AbstractBaseController
$fp = fopen(WT_DATA_DIR . $f, 'rb');
$header = fread($fp, 64);
fclose($fp);
- if (preg_match('/^(' . WT_UTF8_BOM . ')?0 *HEAD/', $header)) {
+ if (preg_match('/^(' . Gedcom::UTF8_BOM . ')?0 *HEAD/', $header)) {
$files[] = $f;
}
}
diff --git a/app/Http/Controllers/AdminUpgradeController.php b/app/Http/Controllers/AdminUpgradeController.php
index 010c8ac4d6..e9df2f85b0 100644
--- a/app/Http/Controllers/AdminUpgradeController.php
+++ b/app/Http/Controllers/AdminUpgradeController.php
@@ -19,11 +19,11 @@ namespace Fisharebest\Webtrees\Http\Controllers;
use Exception;
use Fisharebest\Webtrees\Database;
-use Fisharebest\Webtrees\DebugBar;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Services\TimeoutService;
use Fisharebest\Webtrees\Services\UpgradeService;
use Fisharebest\Webtrees\Tree;
+use Fisharebest\Webtrees\Webtrees;
use GuzzleHttp\Client;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
@@ -92,7 +92,7 @@ class AdminUpgradeController extends AbstractBaseController
}
return $this->viewResponse('admin/upgrade/wizard', [
- 'current_version' => WT_VERSION,
+ 'current_version' => Webtrees::VERSION,
'latest_version' => $this->upgrade_service->latestVersion(),
'title' => $title,
]);
@@ -171,7 +171,7 @@ class AdminUpgradeController extends AbstractBaseController
return $this->failure(I18N::translate('No upgrade information is available.'));
}
- if (version_compare(WT_VERSION, $latest_version) >= 0) {
+ if (version_compare(Webtrees::VERSION, $latest_version) >= 0) {
return $this->failure(I18N::translate('This is the latest version of webtrees. No upgrade is available.'));
}
diff --git a/app/Http/Controllers/AncestorsChartController.php b/app/Http/Controllers/AncestorsChartController.php
index 4b66c8b08d..acf30c7349 100644
--- a/app/Http/Controllers/AncestorsChartController.php
+++ b/app/Http/Controllers/AncestorsChartController.php
@@ -20,6 +20,7 @@ namespace Fisharebest\Webtrees\Http\Controllers;
use Fisharebest\Webtrees\FontAwesome;
use Fisharebest\Webtrees\Functions\FunctionsCharts;
use Fisharebest\Webtrees\Functions\FunctionsPrint;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Theme;
@@ -198,7 +199,7 @@ class AncestorsChartController extends AbstractChartController
echo ' <span class="person_box">', I18N::number($sosa * 2), '</span> ', I18N::translate('and');
echo ' <span class="person_boxF">', I18N::number($sosa * 2 + 1), '</span>';
if ($family->canShow()) {
- foreach ($family->facts(WT_EVENTS_MARR) as $fact) {
+ foreach ($family->facts(Gedcom::MARRIAGE_EVENTS) as $fact) {
echo ' <a href="', e($family->url()), '" class="details1">', $fact->summary(), '</a>';
}
}
diff --git a/app/Http/Controllers/BranchesController.php b/app/Http/Controllers/BranchesController.php
index 74041dbcdd..5ecbd2509e 100644
--- a/app/Http/Controllers/BranchesController.php
+++ b/app/Http/Controllers/BranchesController.php
@@ -274,7 +274,7 @@ class BranchesController extends AbstractBaseController
// If this is not a birth pedigree (e.g. an adoption), highlight it
if ($parents) {
$pedi = '';
- foreach ($individual->facts('FAMC') as $fact) {
+ foreach ($individual->facts(['FAMC']) as $fact) {
if ($fact->target() === $parents) {
$pedi = $fact->attribute('PEDI');
break;
diff --git a/app/Http/Controllers/DescendantsChartController.php b/app/Http/Controllers/DescendantsChartController.php
index 677de9dfe8..1e9acad82c 100644
--- a/app/Http/Controllers/DescendantsChartController.php
+++ b/app/Http/Controllers/DescendantsChartController.php
@@ -21,6 +21,7 @@ use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\FontAwesome;
use Fisharebest\Webtrees\Functions\FunctionsCharts;
use Fisharebest\Webtrees\Functions\FunctionsPrint;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomTag;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
@@ -251,7 +252,7 @@ class DescendantsChartController extends AbstractChartController
echo '<span class="details1">';
echo '<a href="#" onclick="expand_layer(\'' . $uid . '\'); return false;" class="top"><i id="' . $uid . '_img" class="icon-minus" title="' . I18N::translate('View this family') . '"></i></a>';
if ($family->canShow()) {
- foreach ($family->facts(WT_EVENTS_MARR) as $fact) {
+ foreach ($family->facts(Gedcom::MARRIAGE_EVENTS) as $fact) {
echo ' <a href="', e($family->url()), '" class="details1">', $fact->summary(), '</a>';
}
}
diff --git a/app/Http/Controllers/EditFamilyController.php b/app/Http/Controllers/EditFamilyController.php
index 9b24c06096..b1ea242d5e 100644
--- a/app/Http/Controllers/EditFamilyController.php
+++ b/app/Http/Controllers/EditFamilyController.php
@@ -166,7 +166,7 @@ class EditFamilyController extends AbstractEditController
// Insert new child at the right place
$done = false;
- foreach ($family->facts('CHIL') as $fact) {
+ foreach ($family->facts(['CHIL']) as $fact) {
$old_child = $fact->target();
if ($old_child instanceof Individual && Date::compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate()) < 0) {
// Insert before this child
@@ -343,13 +343,13 @@ class EditFamilyController extends AbstractEditController
if ($old_father !== $new_father) {
if ($old_father) {
// Remove old FAMS link
- foreach ($old_father->facts('FAMS') as $fact) {
+ foreach ($old_father->facts(['FAMS']) as $fact) {
if ($fact->target() === $family) {
$old_father->deleteFact($fact->id(), true);
}
}
// Remove old HUSB link
- foreach ($family->facts('HUSB|WIFE') as $fact) {
+ foreach ($family->facts(['HUSB', 'WIFE']) as $fact) {
if ($fact->target() === $old_father) {
$family->deleteFact($fact->id(), true);
}
@@ -366,13 +366,13 @@ class EditFamilyController extends AbstractEditController
if ($old_mother !== $new_mother) {
if ($old_mother) {
// Remove old FAMS link
- foreach ($old_mother->facts('FAMS') as $fact) {
+ foreach ($old_mother->facts(['FAMS']) as $fact) {
if ($fact->target() === $family) {
$old_mother->deleteFact($fact->id(), true);
}
}
// Remove old WIFE link
- foreach ($family->facts('HUSB|WIFE') as $fact) {
+ foreach ($family->facts(['HUSB', 'WIFE']) as $fact) {
if ($fact->target() === $old_mother) {
$family->deleteFact($fact->id(), true);
}
@@ -389,13 +389,13 @@ class EditFamilyController extends AbstractEditController
foreach ($old_children as $old_child) {
if ($old_child && !in_array($old_child, $new_children)) {
// Remove old FAMC link
- foreach ($old_child->facts('FAMC') as $fact) {
+ foreach ($old_child->facts(['FAMC']) as $fact) {
if ($fact->target() === $family) {
$old_child->deleteFact($fact->id(), true);
}
}
// Remove old CHIL link
- foreach ($family->facts('CHIL') as $fact) {
+ foreach ($family->facts(['CHIL']) as $fact) {
if ($fact->target() === $old_child) {
$family->deleteFact($fact->id(), true);
}
diff --git a/app/Http/Controllers/EditGedcomRecordController.php b/app/Http/Controllers/EditGedcomRecordController.php
index f69d5632c0..17593c9d3c 100644
--- a/app/Http/Controllers/EditGedcomRecordController.php
+++ b/app/Http/Controllers/EditGedcomRecordController.php
@@ -20,6 +20,7 @@ namespace Fisharebest\Webtrees\Http\Controllers;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\FlashMessages;
use Fisharebest\Webtrees\Functions\FunctionsDb;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\GedcomTag;
use Fisharebest\Webtrees\I18N;
@@ -144,7 +145,7 @@ class EditGedcomRecordController extends AbstractEditController
// record itself) may have already been deleted.
if ($old_gedcom !== $new_gedcom) {
// If we have removed a link from a family to an individual, and it has only one member
- if (preg_match('/^0 @' . WT_REGEX_XREF . '@ FAM/', $new_gedcom) && preg_match_all('/\n1 (HUSB|WIFE|CHIL) @(' . WT_REGEX_XREF . ')@/', $new_gedcom, $match) == 1) {
+ if (preg_match('/^0 @' . Gedcom::REGEX_XREF . '@ FAM/', $new_gedcom) && preg_match_all('/\n1 (HUSB|WIFE|CHIL) @(' . Gedcom::REGEX_XREF . ')@/', $new_gedcom, $match) == 1) {
// Delete the family
$family = GedcomRecord::getInstance($xref, $tree);
/* I18N: %s is the name of a family group, e.g. “Husband name + Wife name” */
@@ -299,7 +300,7 @@ class EditGedcomRecordController extends AbstractEditController
$gedcom = '0 @' . $record->xref() . '@ ' . $record::RECORD_TYPE;
// Retain any private facts
- foreach ($record->facts('', false, Auth::PRIV_HIDE) as $fact) {
+ foreach ($record->facts([], false, Auth::PRIV_HIDE) as $fact) {
if (!in_array($fact->id(), $fact_ids) && !$fact->isPendingDeletion()) {
$gedcom .= "\n" . $fact->gedcom();
}
@@ -502,11 +503,11 @@ class EditGedcomRecordController extends AbstractEditController
*/
private function removeLinks($gedrec, $xref): string
{
- $gedrec = preg_replace('/\n1 ' . WT_REGEX_TAG . ' @' . $xref . '@(\n[2-9].*)*/', '', $gedrec);
- $gedrec = preg_replace('/\n2 ' . WT_REGEX_TAG . ' @' . $xref . '@(\n[3-9].*)*/', '', $gedrec);
- $gedrec = preg_replace('/\n3 ' . WT_REGEX_TAG . ' @' . $xref . '@(\n[4-9].*)*/', '', $gedrec);
- $gedrec = preg_replace('/\n4 ' . WT_REGEX_TAG . ' @' . $xref . '@(\n[5-9].*)*/', '', $gedrec);
- $gedrec = preg_replace('/\n5 ' . WT_REGEX_TAG . ' @' . $xref . '@(\n[6-9].*)*/', '', $gedrec);
+ $gedrec = preg_replace('/\n1 ' . Gedcom::REGEX_TAG . ' @' . $xref . '@(\n[2-9].*)*/', '', $gedrec);
+ $gedrec = preg_replace('/\n2 ' . Gedcom::REGEX_TAG . ' @' . $xref . '@(\n[3-9].*)*/', '', $gedrec);
+ $gedrec = preg_replace('/\n3 ' . Gedcom::REGEX_TAG . ' @' . $xref . '@(\n[4-9].*)*/', '', $gedrec);
+ $gedrec = preg_replace('/\n4 ' . Gedcom::REGEX_TAG . ' @' . $xref . '@(\n[5-9].*)*/', '', $gedrec);
+ $gedrec = preg_replace('/\n5 ' . Gedcom::REGEX_TAG . ' @' . $xref . '@(\n[6-9].*)*/', '', $gedrec);
return $gedrec;
}
diff --git a/app/Http/Controllers/EditIndividualController.php b/app/Http/Controllers/EditIndividualController.php
index 9cabe04ace..15d36fa8c3 100644
--- a/app/Http/Controllers/EditIndividualController.php
+++ b/app/Http/Controllers/EditIndividualController.php
@@ -713,7 +713,7 @@ class EditIndividualController extends AbstractEditController
// Replace any existing child->family link (we may be changing the PEDI);
$fact_id = '';
- foreach ($individual->facts('FAMC') as $fact) {
+ foreach ($individual->facts(['FAMC']) as $fact) {
if ($family === $fact->target()) {
$fact_id = $fact->id();
break;
@@ -725,7 +725,7 @@ class EditIndividualController extends AbstractEditController
// Only set the family->child link if it does not already exist
$chil_link_exists = false;
- foreach ($family->facts('CHIL') as $fact) {
+ foreach ($family->facts(['CHIL']) as $fact) {
if ($individual === $fact->target()) {
$chil_link_exists = true;
break;
diff --git a/app/Http/Controllers/FamilyController.php b/app/Http/Controllers/FamilyController.php
index 942449f0dd..96291ab518 100644
--- a/app/Http/Controllers/FamilyController.php
+++ b/app/Http/Controllers/FamilyController.php
@@ -44,7 +44,7 @@ class FamilyController extends AbstractBaseController
$this->checkFamilyAccess($family, false);
return $this->viewResponse('family-page', [
- 'facts' => $family->facts('', true),
+ 'facts' => $family->facts([], true),
'meta_robots' => 'index,follow',
'record' => $family,
'significant' => $this->significant($family),
diff --git a/app/Http/Controllers/GedcomFileController.php b/app/Http/Controllers/GedcomFileController.php
index 4443588521..bcc4045159 100644
--- a/app/Http/Controllers/GedcomFileController.php
+++ b/app/Http/Controllers/GedcomFileController.php
@@ -20,6 +20,7 @@ namespace Fisharebest\Webtrees\Http\Controllers;
use Fisharebest\Webtrees\Database;
use Fisharebest\Webtrees\DebugBar;
use Fisharebest\Webtrees\Functions\FunctionsImport;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Services\TimeoutService;
use Fisharebest\Webtrees\Tree;
@@ -95,7 +96,7 @@ class GedcomFileController extends AbstractBaseController
" SET chunk_data=TRIM(LEADING :bom FROM chunk_data)" .
" WHERE gedcom_chunk_id = :chunk_id"
)->execute([
- 'bom' => WT_UTF8_BOM,
+ 'bom' => Gedcom::UTF8_BOM,
'chunk_id' => $data->gedcom_chunk_id,
]);
// Re-fetch the data, now that we have removed the BOM
diff --git a/app/Http/Controllers/IndividualController.php b/app/Http/Controllers/IndividualController.php
index 8251fe3118..77a0c5fa49 100644
--- a/app/Http/Controllers/IndividualController.php
+++ b/app/Http/Controllers/IndividualController.php
@@ -114,12 +114,12 @@ class IndividualController extends AbstractBaseController
$individual_media = array_filter($individual_media);
$name_records = [];
- foreach ($individual->facts('NAME') as $n => $name_fact) {
+ foreach ($individual->facts(['NAME']) as $n => $name_fact) {
$name_records[] = $this->formatNameRecord($tree, $n, $name_fact);
}
$sex_records = [];
- foreach ($individual->facts('SEX') as $n => $sex_fact) {
+ foreach ($individual->facts(['SEX']) as $n => $sex_fact) {
$sex_records[] = $this->formatSexRecord($sex_fact);
}
@@ -134,9 +134,9 @@ class IndividualController extends AbstractBaseController
return $this->viewResponse('individual-page', [
'age' => $age,
- 'count_media' => $this->countFacts($individual, 'OBJE'),
- 'count_names' => $this->countFacts($individual, 'NAME'),
- 'count_sex' => $this->countFacts($individual, 'SEX'),
+ 'count_media' => $this->countFacts($individual, ['OBJE']),
+ 'count_names' => $this->countFacts($individual, ['NAME']),
+ 'count_sex' => $this->countFacts($individual, ['SEX']),
'individual' => $individual,
'individual_media' => $individual_media,
'meta_robots' => 'index,follow',
@@ -218,15 +218,15 @@ class IndividualController extends AbstractBaseController
* Count the (non-pending-delete) name records for an individual.
*
* @param Individual $individual
- * @param string $fact_name
+ * @param string[] $tags
*
* @return int
*/
- private function countFacts(Individual $individual, $fact_name): int
+ private function countFacts(Individual $individual, array $tags): int
{
$count = 0;
- foreach ($individual->facts($fact_name) as $fact) {
+ foreach ($individual->facts($tags) as $fact) {
if (!$fact->isPendingDeletion()) {
$count++;
}
diff --git a/app/Http/Controllers/PendingChangesController.php b/app/Http/Controllers/PendingChangesController.php
index effa3cbf75..deb7e11b1c 100644
--- a/app/Http/Controllers/PendingChangesController.php
+++ b/app/Http/Controllers/PendingChangesController.php
@@ -22,6 +22,7 @@ use Fisharebest\Webtrees\Database;
use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\FlashMessages;
use Fisharebest\Webtrees\Functions\FunctionsImport;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
@@ -278,7 +279,7 @@ class PendingChangesController extends AbstractBaseController
foreach ($rows as $row) {
$change_tree = Tree::findById($row->gedcom_id);
- preg_match('/^0 (?:@' . WT_REGEX_XREF . '@ )?(' . WT_REGEX_TAG . ')/', $row->old_gedcom . $row->new_gedcom, $match);
+ preg_match('/^0 (?:@' . Gedcom::REGEX_XREF . '@ )?(' . Gedcom::REGEX_TAG . ')/', $row->old_gedcom . $row->new_gedcom, $match);
switch ($match[1]) {
case 'INDI':
diff --git a/app/Http/Controllers/PlaceHierarchyController.php b/app/Http/Controllers/PlaceHierarchyController.php
index 7c8b4c8fcc..40d1fbcb57 100644
--- a/app/Http/Controllers/PlaceHierarchyController.php
+++ b/app/Http/Controllers/PlaceHierarchyController.php
@@ -27,6 +27,7 @@ use Fisharebest\Webtrees\Place;
use Fisharebest\Webtrees\Site;
use Fisharebest\Webtrees\Stats;
use Fisharebest\Webtrees\Tree;
+use Fisharebest\Webtrees\Webtrees;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -231,7 +232,7 @@ class PlaceHierarchyController extends AbstractBaseController
$placeObj = new Place($reference, $tree);
$places = $placeObj->getChildPlaces();
$features = [];
- $flag_path = WT_MODULES_DIR . 'openstreetmap/';
+ $flag_path = Webtrees::MODULES_PATH . 'openstreetmap/';
$stats = new Stats($tree);
$showlink = true;
if (empty($places)) {
diff --git a/app/Http/Controllers/ReportEngineController.php b/app/Http/Controllers/ReportEngineController.php
index c461abd9a1..891d93edb0 100644
--- a/app/Http/Controllers/ReportEngineController.php
+++ b/app/Http/Controllers/ReportEngineController.php
@@ -32,6 +32,7 @@ use Fisharebest\Webtrees\Report\ReportParserSetup;
use Fisharebest\Webtrees\Report\ReportPdf;
use Fisharebest\Webtrees\Source;
use Fisharebest\Webtrees\Tree;
+use Fisharebest\Webtrees\Webtrees;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
@@ -77,7 +78,7 @@ class ReportEngineController extends AbstractBaseController
return $this->reportList($tree);
}
- $report_xml = WT_ROOT . WT_MODULES_DIR . $report . '/report.xml';
+ $report_xml = WT_ROOT . Webtrees::MODULES_PATH . $report . '/report.xml';
$report_array = (new ReportParserSetup($report_xml))->reportProperties();
$description = $report_array['description'];
@@ -240,7 +241,7 @@ class ReportEngineController extends AbstractBaseController
}
}
- $report_xml = WT_ROOT . WT_MODULES_DIR . $report . '/report.xml';
+ $report_xml = WT_ROOT . Webtrees::MODULES_PATH . $report . '/report.xml';
switch ($output) {
diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php
index 13aeb48f8f..362b2af8f4 100644
--- a/app/Http/Controllers/SearchController.php
+++ b/app/Http/Controllers/SearchController.php
@@ -21,6 +21,7 @@ use Fisharebest\Webtrees\Database;
use Fisharebest\Webtrees\Date;
use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\FlashMessages;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\GedcomTag;
use Fisharebest\Webtrees\I18N;
@@ -661,9 +662,9 @@ class SearchController extends AbstractBaseController
// Ignore non-genealogy data
$gedrec = preg_replace('/\n\d (_UID|_WT_USER|FILE|FORM|TYPE|CHAN|RESN) .*/', '', $record->gedcom());
// Ignore links and tags
- $gedrec = preg_replace('/\n\d ' . WT_REGEX_TAG . '( @' . WT_REGEX_XREF . '@)?/', '', $gedrec);
+ $gedrec = preg_replace('/\n\d ' . Gedcom::REGEX_TAG . '( @' . Gedcom::REGEX_XREF . '@)?/', '', $gedrec);
// Ignore tags
- $gedrec = preg_replace('/\n\d ' . WT_REGEX_TAG . ' ?/', '', $gedrec);
+ $gedrec = preg_replace('/\n\d ' . Gedcom::REGEX_TAG . ' ?/', '', $gedrec);
// Re-apply the filtering
$gedrec = I18N::strtoupper($gedrec);
foreach ($queryregex as $regex) {
@@ -770,7 +771,7 @@ class SearchController extends AbstractBaseController
// Ignore non-genealogy data
$gedrec = preg_replace('/\n\d (_UID|_WT_USER|FILE|FORM|TYPE|CHAN|RESN) .*/', '', $record->gedcom());
// Ignore links and tags
- $gedrec = preg_replace('/\n\d ' . WT_REGEX_TAG . '( @' . WT_REGEX_XREF . '@)?/', '', $gedrec);
+ $gedrec = preg_replace('/\n\d ' . Gedcom::REGEX_TAG . '( @' . Gedcom::REGEX_XREF . '@)?/', '', $gedrec);
// Re-apply the filtering
$gedrec = I18N::strtoupper($gedrec);
foreach ($queryregex as $regex) {
@@ -1162,7 +1163,7 @@ class SearchController extends AbstractBaseController
$person = Individual::getInstance($row->xref, $tree, $row->gedcom);
// Check for XXXX:PLAC fields, which were only partially matched by SQL
foreach ($fields as $field_name => $field_value) {
- if (preg_match('/^(' . WT_REGEX_TAG . '):PLAC$/', $field_name, $match)) {
+ if (preg_match('/^(' . Gedcom::REGEX_TAG . '):PLAC$/', $field_name, $match)) {
if (!preg_match('/\n1 ' . $match[1] . '(\n[2-9].*)*\n2 PLAC .*' . preg_quote($field_value, '/') . '/i', $person->gedcom())) {
continue 2;
}
@@ -1331,9 +1332,9 @@ class SearchController extends AbstractBaseController
// Ignore non-genealogy data
$gedrec = preg_replace('/\n\d (_UID|_WT_USER|FILE|FORM|TYPE|CHAN|RESN) .*/', '', $record->gedcom());
// Ignore links and tags
- $gedrec = preg_replace('/\n\d ' . WT_REGEX_TAG . '( @' . WT_REGEX_XREF . '@)?/', '', $gedrec);
+ $gedrec = preg_replace('/\n\d ' . Gedcom::REGEX_TAG . '( @' . Gedcom::REGEX_XREF . '@)?/', '', $gedrec);
// Ignore tags
- $gedrec = preg_replace('/\n\d ' . WT_REGEX_TAG . ' ?/', '', $gedrec);
+ $gedrec = preg_replace('/\n\d ' . Gedcom::REGEX_TAG . ' ?/', '', $gedrec);
// Re-apply the filtering
$gedrec = I18N::strtoupper($gedrec);
foreach ($queryregex as $regex) {
@@ -1387,9 +1388,9 @@ class SearchController extends AbstractBaseController
// Ignore non-genealogy data
$gedrec = preg_replace('/\n\d (_UID|_WT_USER|FILE|FORM|TYPE|CHAN|RESN) .*/', '', $record->gedcom());
// Ignore links and tags
- $gedrec = preg_replace('/\n\d ' . WT_REGEX_TAG . '( @' . WT_REGEX_XREF . '@)?/', '', $gedrec);
+ $gedrec = preg_replace('/\n\d ' . Gedcom::REGEX_TAG . '( @' . Gedcom::REGEX_XREF . '@)?/', '', $gedrec);
// Ignore tags
- $gedrec = preg_replace('/\n\d ' . WT_REGEX_TAG . ' ?/', '', $gedrec);
+ $gedrec = preg_replace('/\n\d ' . Gedcom::REGEX_TAG . ' ?/', '', $gedrec);
// Re-apply the filtering
$gedrec = I18N::strtoupper($gedrec);
foreach ($queryregex as $regex) {
@@ -1443,9 +1444,9 @@ class SearchController extends AbstractBaseController
// Ignore non-genealogy data
$gedrec = preg_replace('/\n\d (_UID|_WT_USER|FILE|FORM|TYPE|CHAN|RESN) .*/', '', $record->gedcom());
// Ignore links and tags
- $gedrec = preg_replace('/\n\d ' . WT_REGEX_TAG . '( @' . WT_REGEX_XREF . '@)?/', '', $gedrec);
+ $gedrec = preg_replace('/\n\d ' . Gedcom::REGEX_TAG . '( @' . Gedcom::REGEX_XREF . '@)?/', '', $gedrec);
// Ignore tags
- $gedrec = preg_replace('/\n\d ' . WT_REGEX_TAG . ' ?/', '', $gedrec);
+ $gedrec = preg_replace('/\n\d ' . Gedcom::REGEX_TAG . ' ?/', '', $gedrec);
// Re-apply the filtering
$gedrec = I18N::strtoupper($gedrec);
foreach ($queryregex as $regex) {
diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php
index 4fba92f3cb..3b3a716366 100644
--- a/app/Http/Controllers/SetupController.php
+++ b/app/Http/Controllers/SetupController.php
@@ -24,6 +24,7 @@ use Fisharebest\Webtrees\Database;
use Fisharebest\Webtrees\DebugBar;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\User;
+use Fisharebest\Webtrees\Webtrees;
use PDOException;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
@@ -34,8 +35,6 @@ use Symfony\Component\HttpFoundation\Response;
*/
class SetupController extends AbstractBaseController
{
- const WT_CONFIG_FILE = 'config.ini.php';
-
/**
* Installation wizard - check user input and proceed to the next step.
*
@@ -292,7 +291,7 @@ class SetupController extends AbstractBaseController
'dbpass' => $dbpass,
'tblpfx' => $tblpfx,
]);
- Database::updateSchema('\Fisharebest\Webtrees\Schema', 'WT_SCHEMA_VERSION', 30);
+ Database::updateSchema('\Fisharebest\Webtrees\Schema', 'WT_SCHEMA_VERSION', Webtrees::SCHEMA_VERSION);
// If we are re-installing, then this user may already exist.
$admin = User::findByIdentifier($wtemail);
@@ -323,7 +322,7 @@ class SetupController extends AbstractBaseController
'dbname="' . addcslashes($dbname, '"') . '"' . PHP_EOL .
'tblpfx="' . addcslashes($tblpfx, '"') . '"' . PHP_EOL;
- file_put_contents(WT_DATA_DIR . 'config.ini.php', $config_ini_php);
+ file_put_contents(Webtrees::CONFIG_FILE, $config_ini_php);
// Done - start using webtrees!
return '';
diff --git a/app/I18N.php b/app/I18N.php
index e17ca91f6a..9714815d6c 100644
--- a/app/I18N.php
+++ b/app/I18N.php
@@ -415,16 +415,16 @@ class I18N
if (defined('GLOB_BRACE')) {
$translation_files = array_merge(
[WT_ROOT . 'language/' . self::$locale->languageTag() . '.mo'],
- glob(WT_MODULES_DIR . '*/language/' . self::$locale->languageTag() . '.{csv,php,mo}', GLOB_BRACE) ?: [],
+ glob(Webtrees::MODULES_PATH . '*/language/' . self::$locale->languageTag() . '.{csv,php,mo}', GLOB_BRACE) ?: [],
glob(WT_DATA_DIR . 'language/' . self::$locale->languageTag() . '.{csv,php,mo}', GLOB_BRACE) ?: []
);
} else {
// Some servers do not have GLOB_BRACE - see http://php.net/manual/en/function.glob.php
$translation_files = array_merge(
[WT_ROOT . 'language/' . self::$locale->languageTag() . '.mo'],
- glob(WT_MODULES_DIR . '*/language/' . self::$locale->languageTag() . '.csv') ?: [],
- glob(WT_MODULES_DIR . '*/language/' . self::$locale->languageTag() . '.php') ?: [],
- glob(WT_MODULES_DIR . '*/language/' . self::$locale->languageTag() . '.mo') ?: [],
+ glob(Webtrees::MODULES_PATH . '*/language/' . self::$locale->languageTag() . '.csv') ?: [],
+ glob(Webtrees::MODULES_PATH . '*/language/' . self::$locale->languageTag() . '.php') ?: [],
+ glob(Webtrees::MODULES_PATH . '*/language/' . self::$locale->languageTag() . '.mo') ?: [],
glob(WT_DATA_DIR . 'language/' . self::$locale->languageTag() . '.csv') ?: [],
glob(WT_DATA_DIR . 'language/' . self::$locale->languageTag() . '.php') ?: [],
glob(WT_DATA_DIR . 'language/' . self::$locale->languageTag() . '.mo') ?: []
diff --git a/app/Individual.php b/app/Individual.php
index cafb0279bc..03239c3931 100644
--- a/app/Individual.php
+++ b/app/Individual.php
@@ -129,7 +129,7 @@ class Individual extends GedcomRecord
$keep_alive = false;
$KEEP_ALIVE_YEARS_BIRTH = (int) $this->tree->getPreference('KEEP_ALIVE_YEARS_BIRTH');
if ($KEEP_ALIVE_YEARS_BIRTH) {
- preg_match_all('/\n1 (?:' . WT_EVENTS_BIRT . ').*(?:\n[2-9].*)*(?:\n2 DATE (.+))/', $this->gedcom, $matches, PREG_SET_ORDER);
+ preg_match_all('/\n1 (?:' . implode('|', Gedcom::BIRTH_EVENTS) . ').*(?:\n[2-9].*)*(?:\n2 DATE (.+))/', $this->gedcom, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$date = new Date($match[1]);
if ($date->isOK() && $date->gregorianYear() + $KEEP_ALIVE_YEARS_BIRTH > date('Y')) {
@@ -140,7 +140,7 @@ class Individual extends GedcomRecord
}
$KEEP_ALIVE_YEARS_DEATH = (int) $this->tree->getPreference('KEEP_ALIVE_YEARS_DEATH');
if ($KEEP_ALIVE_YEARS_DEATH) {
- preg_match_all('/\n1 (?:' . WT_EVENTS_DEAT . ').*(?:\n[2-9].*)*(?:\n2 DATE (.+))/', $this->gedcom, $matches, PREG_SET_ORDER);
+ preg_match_all('/\n1 (?:' . implode('|', Gedcom::DEATH_EVENTS) . ').*(?:\n[2-9].*)*(?:\n2 DATE (.+))/', $this->gedcom, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$date = new Date($match[1]);
if ($date->isOK() && $date->gregorianYear() + $KEEP_ALIVE_YEARS_DEATH > date('Y')) {
@@ -183,7 +183,7 @@ class Individual extends GedcomRecord
0 => [$user_individual],
1 => [],
];
- foreach ($user_individual->facts('FAM[CS]', false, Auth::PRIV_HIDE) as $fact) {
+ foreach ($user_individual->facts(['FAMC', 'FAMS'], false, Auth::PRIV_HIDE) as $fact) {
$family = $fact->target();
if ($family instanceof Family) {
$cache[1][] = $family;
@@ -211,7 +211,7 @@ class Individual extends GedcomRecord
if ($n % 2 == 0) {
// Add FAM->INDI links
foreach ($cache[$n - 1] as $family) {
- foreach ($family->facts('HUSB|WIFE|CHIL', false, Auth::PRIV_HIDE) as $fact) {
+ foreach ($family->facts(['HUSB', 'WIFE', 'CHIL'], false, Auth::PRIV_HIDE) as $fact) {
$individual = $fact->target();
// Don’t backtrack
if ($individual instanceof Individual && !in_array($individual, $cache[$n - 2], true)) {
@@ -225,7 +225,7 @@ class Individual extends GedcomRecord
} else {
// Add INDI->FAM links
foreach ($cache[$n - 1] as $individual) {
- foreach ($individual->facts('FAM[CS]', false, Auth::PRIV_HIDE) as $fact) {
+ foreach ($individual->facts(['FAMC', 'FAMS'], false, Auth::PRIV_HIDE) as $fact) {
$family = $fact->target();
// Don’t backtrack
if ($family instanceof Family && !in_array($family, $cache[$n - 2], true)) {
@@ -254,12 +254,12 @@ class Individual extends GedcomRecord
$rec = '0 @' . $this->xref . '@ INDI';
if ($this->tree->getPreference('SHOW_LIVING_NAMES') >= $access_level) {
// Show all the NAME tags, including subtags
- foreach ($this->facts('NAME') as $fact) {
+ foreach ($this->facts(['NAME']) as $fact) {
$rec .= "\n" . $fact->gedcom();
}
}
// Just show the 1 FAMC/FAMS tag, not any subtags, which may contain private data
- preg_match_all('/\n1 (?:FAMC|FAMS) @(' . WT_REGEX_XREF . ')@/', $this->gedcom, $matches, PREG_SET_ORDER);
+ preg_match_all('/\n1 (?:FAMC|FAMS) @(' . Gedcom::REGEX_XREF . ')@/', $this->gedcom, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$rela = Family::getInstance($match[1], $this->tree);
if ($rela && ($SHOW_PRIVATE_RELATIONSHIPS || $rela->canShow($access_level))) {
@@ -329,7 +329,7 @@ class Individual extends GedcomRecord
$MAX_ALIVE_AGE = (int) $this->tree->getPreference('MAX_ALIVE_AGE');
// "1 DEAT Y" or "1 DEAT/2 DATE" or "1 DEAT/2 PLAC"
- if (preg_match('/\n1 (?:' . WT_EVENTS_DEAT . ')(?: Y|(?:\n[2-9].+)*\n2 (DATE|PLAC) )/', $this->gedcom)) {
+ if (preg_match('/\n1 (?:' . implode('|', Gedcom::DEATH_EVENTS) . ')(?: Y|(?:\n[2-9].+)*\n2 (DATE|PLAC) )/', $this->gedcom)) {
return true;
}
@@ -422,7 +422,7 @@ class Individual extends GedcomRecord
*/
public function findHighlightedMediaFile()
{
- foreach ($this->facts('OBJE') as $fact) {
+ foreach ($this->facts(['OBJE']) as $fact) {
$media = $fact->target();
if ($media instanceof Media) {
foreach ($media->mediaFiles() as $media_file) {
@@ -575,8 +575,8 @@ class Individual extends GedcomRecord
*/
public function getAllBirthDates(): array
{
- foreach (explode('|', WT_EVENTS_BIRT) as $event) {
- $tmp = $this->getAllEventDates($event);
+ foreach (Gedcom::BIRTH_EVENTS as $event) {
+ $tmp = $this->getAllEventDates([$event]);
if ($tmp) {
return $tmp;
}
@@ -592,8 +592,8 @@ class Individual extends GedcomRecord
*/
public function getAllBirthPlaces(): array
{
- foreach (explode('|', WT_EVENTS_BIRT) as $event) {
- $places = $this->getAllEventPlaces($event);
+ foreach (Gedcom::BIRTH_EVENTS as $event) {
+ $places = $this->getAllEventPlaces([$event]);
if (!empty($places)) {
return $places;
}
@@ -609,8 +609,8 @@ class Individual extends GedcomRecord
*/
public function getAllDeathDates(): array
{
- foreach (explode('|', WT_EVENTS_DEAT) as $event) {
- $tmp = $this->getAllEventDates($event);
+ foreach (Gedcom::DEATH_EVENTS as $event) {
+ $tmp = $this->getAllEventDates([$event]);
if ($tmp) {
return $tmp;
}
@@ -626,8 +626,8 @@ class Individual extends GedcomRecord
*/
public function getAllDeathPlaces(): array
{
- foreach (explode('|', WT_EVENTS_DEAT) as $event) {
- $places = $this->getAllEventPlaces($event);
+ foreach (Gedcom::DEATH_EVENTS as $event) {
+ $places = $this->getAllEventPlaces([$event]);
if (!empty($places)) {
return $places;
}
@@ -822,7 +822,7 @@ class Individual extends GedcomRecord
$SHOW_PRIVATE_RELATIONSHIPS = (bool) $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS');
$families = [];
- foreach ($this->facts('FAMS', false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) {
+ foreach ($this->facts(['FAMS'], false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) {
$family = $fact->target();
if ($family instanceof Family && ($SHOW_PRIVATE_RELATIONSHIPS || $family->canShow($access_level))) {
$families[] = $family;
@@ -888,7 +888,7 @@ class Individual extends GedcomRecord
$SHOW_PRIVATE_RELATIONSHIPS = (bool) $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS');
$families = [];
- foreach ($this->facts('FAMC', false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) {
+ foreach ($this->facts(['FAMC'], false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) {
$family = $fact->target();
if ($family instanceof Family && ($SHOW_PRIVATE_RELATIONSHIPS || $family->canShow($access_level))) {
$families[] = $family;
@@ -1318,7 +1318,7 @@ class Individual extends GedcomRecord
1,
'NAME',
$this->facts(
- 'NAME',
+ ['NAME'],
false,
Auth::accessLevel($this->tree),
$this->canShowName()
@@ -1335,7 +1335,7 @@ class Individual extends GedcomRecord
public function formatListDetails(): string
{
return
- $this->formatFirstMajorFact(WT_EVENTS_BIRT, 1) .
- $this->formatFirstMajorFact(WT_EVENTS_DEAT, 1);
+ $this->formatFirstMajorFact(Gedcom::BIRTH_EVENTS, 1) .
+ $this->formatFirstMajorFact(Gedcom::DEATH_EVENTS, 1);
}
}
diff --git a/app/Media.php b/app/Media.php
index 4251492f04..7262528888 100644
--- a/app/Media.php
+++ b/app/Media.php
@@ -105,7 +105,7 @@ class Media extends GedcomRecord
{
$media_files = [];
- foreach ($this->facts('FILE') as $fact) {
+ foreach ($this->facts(['FILE']) as $fact) {
$media_files[] = new MediaFile($fact->gedcom(), $this);
}
diff --git a/app/Module.php b/app/Module.php
index c9198ae246..0f1427101e 100644
--- a/app/Module.php
+++ b/app/Module.php
@@ -237,7 +237,7 @@ class Module
$modules = [];
foreach ($module_names as $module_name) {
try {
- $module = self::loadModule(WT_ROOT . WT_MODULES_DIR . $module_name . '/module.php');
+ $module = self::loadModule(WT_ROOT . Webtrees::MODULES_PATH . $module_name . '/module.php');
if ($module instanceof ModuleInterface) {
$modules[$module->getName()] = $module;
} else {
@@ -490,7 +490,7 @@ class Module
{
$modules = [];
- foreach (glob(WT_ROOT . WT_MODULES_DIR . '*/module.php') as $file) {
+ foreach (glob(WT_ROOT . Webtrees::MODULES_PATH . '*/module.php') as $file) {
try {
$module = self::loadModule($file);
if ($module instanceof ModuleInterface) {
diff --git a/app/Module/AlbumModule.php b/app/Module/AlbumModule.php
index 242dfd31e7..942284c944 100644
--- a/app/Module/AlbumModule.php
+++ b/app/Module/AlbumModule.php
@@ -17,6 +17,7 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Media;
@@ -123,7 +124,7 @@ class AlbumModule extends AbstractModule implements ModuleTabInterface
foreach ($facts as $fact) {
// Don't show pending edits, as the user just sees duplicates
if (!$fact->isPendingDeletion()) {
- preg_match_all('/(?:^1|\n\d) OBJE @(' . WT_REGEX_XREF . ')@/', $fact->gedcom(), $matches);
+ preg_match_all('/(?:^1|\n\d) OBJE @(' . Gedcom::REGEX_XREF . ')@/', $fact->gedcom(), $matches);
foreach ($matches[1] as $match) {
$media = Media::getInstance($match, $individual->tree());
if ($media && $media->canShow()) {
@@ -136,7 +137,7 @@ class AlbumModule extends AbstractModule implements ModuleTabInterface
$this->media_list = array_unique($this->media_list);
// Sort these using _WT_OBJE_SORT
$wt_obje_sort = [];
- foreach ($individual->facts('_WT_OBJE_SORT') as $fact) {
+ foreach ($individual->facts(['_WT_OBJE_SORT']) as $fact) {
$wt_obje_sort[] = trim($fact->value(), '@');
}
usort($this->media_list, function (Media $x, Media $y) use ($wt_obje_sort): int {
diff --git a/app/Module/BatchUpdate/BatchUpdateMissingDeathPlugin.php b/app/Module/BatchUpdate/BatchUpdateMissingDeathPlugin.php
index 2e7af5c801..b26a3d27cb 100644
--- a/app/Module/BatchUpdate/BatchUpdateMissingDeathPlugin.php
+++ b/app/Module/BatchUpdate/BatchUpdateMissingDeathPlugin.php
@@ -17,10 +17,10 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module\BatchUpdate;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
-use const WT_EVENTS_DEAT;
/**
* Class BatchUpdateMissingDeathPlugin Batch Update plugin: add missing 1 BIRT/DEAT Y
@@ -56,7 +56,7 @@ class BatchUpdateMissingDeathPlugin extends BatchUpdateBasePlugin
*/
public function doesRecordNeedUpdate(GedcomRecord $record): bool
{
- return $record instanceof Individual && $record->getFirstFact(WT_EVENTS_DEAT) === null && $record->isDead();
+ return $record instanceof Individual && $record->getFirstFact('DEAT') === null && $record->isDead();
}
/**
diff --git a/app/Module/ChartsBlockModule.php b/app/Module/ChartsBlockModule.php
index e2f8f1d1a4..35b619920a 100644
--- a/app/Module/ChartsBlockModule.php
+++ b/app/Module/ChartsBlockModule.php
@@ -23,6 +23,7 @@ use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Module\InteractiveTree\TreeView;
use Fisharebest\Webtrees\Tree;
+use Fisharebest\Webtrees\Webtrees;
use Symfony\Component\HttpFoundation\Request;
/**
@@ -119,7 +120,7 @@ class ChartsBlockModule extends AbstractModule implements ModuleBlockInterface
break;
case 'treenav':
$title = I18N::translate('Interactive tree of %s', $person->getFullName());
- $mod = new InteractiveTreeModule(WT_MODULES_DIR . 'tree');
+ $mod = new InteractiveTreeModule(Webtrees::MODULES_PATH . 'tree');
$tv = new TreeView();
$content .= '<script>$("head").append(\'<link rel="stylesheet" href="' . $mod->css() . '" type="text/css" />\');</script>';
$content .= '<script src="' . $mod->js() . '"></script>';
diff --git a/app/Module/ClippingsCartModule.php b/app/Module/ClippingsCartModule.php
index 15b346197d..5b2ef13f07 100644
--- a/app/Module/ClippingsCartModule.php
+++ b/app/Module/ClippingsCartModule.php
@@ -222,19 +222,19 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface
if ($object) {
$record = $object->privatizeGedcom($access_level);
// Remove links to objects that aren't in the cart
- preg_match_all('/\n1 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[2-9].*)*/', $record, $matches, PREG_SET_ORDER);
+ preg_match_all('/\n1 ' . Gedcom::REGEX_TAG . ' @(' . Gedcom::REGEX_XREF . ')@(\n[2-9].*)*/', $record, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
if (!array_key_exists($match[1], $xrefs)) {
$record = str_replace($match[0], '', $record);
}
}
- preg_match_all('/\n2 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[3-9].*)*/', $record, $matches, PREG_SET_ORDER);
+ preg_match_all('/\n2 ' . Gedcom::REGEX_TAG . ' @(' . Gedcom::REGEX_XREF . ')@(\n[3-9].*)*/', $record, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
if (!array_key_exists($match[1], $xrefs)) {
$record = str_replace($match[0], '', $record);
}
}
- preg_match_all('/\n3 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[4-9].*)*/', $record, $matches, PREG_SET_ORDER);
+ preg_match_all('/\n3 ' . Gedcom::REGEX_TAG . ' @(' . Gedcom::REGEX_XREF . ')@(\n[4-9].*)*/', $record, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
if (!array_key_exists($match[1], $xrefs)) {
$record = str_replace($match[0], '', $record);
@@ -958,7 +958,7 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface
$cart[$tree_name][$record->xref()] = true;
// Add directly linked media, notes, repositories and sources.
- preg_match_all('/\n\d (?:OBJE|NOTE|SOUR|REPO) @(' . WT_REGEX_XREF . ')@/', $record->gedcom(), $matches);
+ preg_match_all('/\n\d (?:OBJE|NOTE|SOUR|REPO) @(' . Gedcom::REGEX_XREF . ')@/', $record->gedcom(), $matches);
foreach ($matches[1] as $match) {
$cart[$tree_name][$match] = true;
diff --git a/app/Module/IndividualFactsTabModule.php b/app/Module/IndividualFactsTabModule.php
index c62981b368..8ab3dcb0a2 100644
--- a/app/Module/IndividualFactsTabModule.php
+++ b/app/Module/IndividualFactsTabModule.php
@@ -21,6 +21,7 @@ use Fisharebest\Webtrees\Date;
use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\Functions\Functions;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Module;
@@ -175,7 +176,7 @@ class IndividualFactsTabModule extends AbstractModule implements ModuleTabInterf
$facts = [];
if (strstr($SHOW_RELATIVES_EVENTS, '_DEAT_SPOU')) {
- foreach ($spouse->facts(WT_EVENTS_DEAT) as $fact) {
+ foreach ($spouse->facts(Gedcom::DEATH_EVENTS) as $fact) {
if (self::includeFact($fact, $min_date, $max_date)) {
// Convert the event to a close relatives event.
$rela_fact = clone($fact);
@@ -242,7 +243,7 @@ class IndividualFactsTabModule extends AbstractModule implements ModuleTabInterf
}
// add child’s birth
if (strpos($SHOW_RELATIVES_EVENTS, '_BIRT' . str_replace('_HSIB', '_SIBL', $option)) !== false) {
- foreach ($child->facts(WT_EVENTS_BIRT) as $fact) {
+ foreach ($child->facts(Gedcom::BIRTH_EVENTS) as $fact) {
// Always show _BIRT_CHIL, even if the dates are not known
if ($option == '_CHIL' || self::includeFact($fact, $min_date, $max_date)) {
if ($option == '_GCHI' && $relation == 'dau') {
@@ -266,7 +267,7 @@ class IndividualFactsTabModule extends AbstractModule implements ModuleTabInterf
}
// add child’s death
if (strpos($SHOW_RELATIVES_EVENTS, '_DEAT' . str_replace('_HSIB', '_SIBL', $option)) !== false) {
- foreach ($child->facts(WT_EVENTS_DEAT) as $fact) {
+ foreach ($child->facts(Gedcom::DEATH_EVENTS) as $fact) {
if (self::includeFact($fact, $min_date, $max_date)) {
if ($option == '_GCHI' && $relation == 'dau') {
// Convert the event to a close relatives event.
@@ -290,7 +291,7 @@ class IndividualFactsTabModule extends AbstractModule implements ModuleTabInterf
// add child’s marriage
if (strstr($SHOW_RELATIVES_EVENTS, '_MARR' . str_replace('_HSIB', '_SIBL', $option))) {
foreach ($child->getSpouseFamilies() as $sfamily) {
- foreach ($sfamily->facts('MARR') as $fact) {
+ foreach ($sfamily->facts(['MARR']) as $fact) {
if (self::includeFact($fact, $min_date, $max_date)) {
if ($option == '_GCHI' && $relation == 'dau') {
// Convert the event to a close relatives event.
@@ -358,7 +359,7 @@ class IndividualFactsTabModule extends AbstractModule implements ModuleTabInterf
if (strstr($SHOW_RELATIVES_EVENTS, '_MARR_PARE')) {
// add father/mother marriages
foreach ($person->getChildFamilies() as $sfamily) {
- foreach ($sfamily->facts('MARR') as $fact) {
+ foreach ($sfamily->facts(['MARR']) as $fact) {
if (self::includeFact($fact, $min_date, $max_date)) {
// marriage of parents (to each other)
$rela_fact = clone($fact);
@@ -368,7 +369,7 @@ class IndividualFactsTabModule extends AbstractModule implements ModuleTabInterf
}
}
foreach ($person->getChildStepFamilies() as $sfamily) {
- foreach ($sfamily->facts('MARR') as $fact) {
+ foreach ($sfamily->facts(['MARR']) as $fact) {
if (self::includeFact($fact, $min_date, $max_date)) {
// marriage of a parent (to another spouse)
// Convert the event to a close relatives event
@@ -384,7 +385,7 @@ class IndividualFactsTabModule extends AbstractModule implements ModuleTabInterf
foreach ($person->getChildFamilies() as $family) {
foreach ($family->getSpouses() as $parent) {
if (strstr($SHOW_RELATIVES_EVENTS, '_DEAT' . ($sosa == 1 ? '_PARE' : '_GPAR'))) {
- foreach ($parent->facts(WT_EVENTS_DEAT) as $fact) {
+ foreach ($parent->facts(Gedcom::DEATH_EVENTS) as $fact) {
if (self::includeFact($fact, $min_date, $max_date)) {
switch ($sosa) {
case 1:
diff --git a/app/Module/InteractiveTree/TreeView.php b/app/Module/InteractiveTree/TreeView.php
index 220248e70a..35e1fba06f 100644
--- a/app/Module/InteractiveTree/TreeView.php
+++ b/app/Module/InteractiveTree/TreeView.php
@@ -18,6 +18,7 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module\InteractiveTree;
use Fisharebest\Webtrees\Family;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Tree;
@@ -152,15 +153,15 @@ class TreeView
$hmtl = $this->getThumbnail($individual);
$hmtl .= '<a class="tv_link" href="' . e($individual->url()) . '">' . $individual->getFullName() . '</a> <a href="' . e($chart_url) . '" title="' . I18N::translate('Interactive tree of %s', strip_tags($individual->getFullName())) . '" class="wt-icon-individual tv_link tv_treelink"></a>';
- foreach ($individual->facts(WT_EVENTS_BIRT, true) as $fact) {
+ foreach ($individual->facts(Gedcom::BIRTH_EVENTS, true) as $fact) {
$hmtl .= $fact->summary();
}
if ($family) {
- foreach ($family->facts(WT_EVENTS_MARR, true) as $fact) {
+ foreach ($family->facts(Gedcom::MARRIAGE_EVENTS, true) as $fact) {
$hmtl .= $fact->summary();
}
}
- foreach ($individual->facts(WT_EVENTS_DEAT, true) as $fact) {
+ foreach ($individual->facts(Gedcom::DEATH_EVENTS, true) as $fact) {
$hmtl .= $fact->summary();
}
diff --git a/app/Module/InteractiveTreeModule.php b/app/Module/InteractiveTreeModule.php
index 606bfafa99..78eafd50c3 100644
--- a/app/Module/InteractiveTreeModule.php
+++ b/app/Module/InteractiveTreeModule.php
@@ -19,11 +19,13 @@ namespace Fisharebest\Webtrees\Module;
use Fisharebest\Webtrees\Exceptions\IndividualAccessDeniedException;
use Fisharebest\Webtrees\Exceptions\IndividualNotFoundException;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Menu;
use Fisharebest\Webtrees\Module\InteractiveTree\TreeView;
use Fisharebest\Webtrees\Tree;
+use Fisharebest\Webtrees\Webtrees;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -72,7 +74,7 @@ class InteractiveTreeModule extends AbstractModule implements ModuleTabInterface
*/
public function css(): string
{
- return WT_MODULES_DIR . $this->getName() . '/css/treeview.css';
+ return Webtrees::MODULES_PATH . $this->getName() . '/css/treeview.css';
}
/**
@@ -80,7 +82,7 @@ class InteractiveTreeModule extends AbstractModule implements ModuleTabInterface
*/
public function js(): string
{
- return WT_MODULES_DIR . $this->getName() . '/js/treeview.js';
+ return Webtrees::MODULES_PATH . $this->getName() . '/js/treeview.js';
}
/** {@inheritdoc} */
@@ -178,7 +180,7 @@ class InteractiveTreeModule extends AbstractModule implements ModuleTabInterface
*/
public function getDetailsAction(Request $request, Tree $tree): Response
{
- $pid = $request->get('pid', WT_REGEX_XREF);
+ $pid = $request->get('pid', Gedcom::REGEX_XREF);
$individual = Individual::getInstance($pid, $tree);
if ($individual === null) {
diff --git a/app/Module/MediaTabModule.php b/app/Module/MediaTabModule.php
index 35dcadb2c4..19d072c855 100644
--- a/app/Module/MediaTabModule.php
+++ b/app/Module/MediaTabModule.php
@@ -19,6 +19,7 @@ namespace Fisharebest\Webtrees\Module;
use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Functions\Functions;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
@@ -92,7 +93,7 @@ class MediaTabModule extends AbstractModule implements ModuleTabInterface
}
$this->facts = [];
foreach ($facts as $fact) {
- if (preg_match('/(?:^1|\n\d) OBJE @' . WT_REGEX_XREF . '@/', $fact->gedcom())) {
+ if (preg_match('/(?:^1|\n\d) OBJE @' . Gedcom::REGEX_XREF . '@/', $fact->gedcom())) {
$this->facts[] = $fact;
}
}
diff --git a/app/Module/OnThisDayModule.php b/app/Module/OnThisDayModule.php
index 13f1480d08..98ed1fbce7 100644
--- a/app/Module/OnThisDayModule.php
+++ b/app/Module/OnThisDayModule.php
@@ -18,6 +18,7 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
use Fisharebest\Webtrees\Auth;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomTag;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Services\CalendarService;
@@ -120,8 +121,7 @@ class OnThisDayModule extends AbstractModule implements ModuleBlockInterface
// If we are only showing living individuals, then we don't need to search for DEAT events.
if ($filter) {
- $death_events = explode('|', WT_EVENTS_DEAT);
- $event_array = array_diff($event_array, $death_events);
+ $event_array = array_diff($event_array, Gedcom::DEATH_EVENTS);
}
$events_filter = implode('|', $event_array);
diff --git a/app/Module/PedigreeMapModule.php b/app/Module/PedigreeMapModule.php
index 367e7c520a..3d69b19a38 100644
--- a/app/Module/PedigreeMapModule.php
+++ b/app/Module/PedigreeMapModule.php
@@ -27,6 +27,7 @@ use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Menu;
use Fisharebest\Webtrees\Tree;
+use Fisharebest\Webtrees\Webtrees;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -228,7 +229,7 @@ class PedigreeMapModule extends AbstractModule implements ModuleChartInterface
private function getMapProviderData(Request $request)
{
if (self::$map_providers === null) {
- $providersFile = WT_ROOT . WT_MODULES_DIR . 'openstreetmap/providers/providers.xml';
+ $providersFile = WT_ROOT . Webtrees::MODULES_PATH . 'openstreetmap/providers/providers.xml';
self::$map_selections = [
'provider' => $this->getPreference('provider', 'openstreetmap'),
'style' => $this->getPreference('provider_style', 'mapnik'),
diff --git a/app/Module/PlacesModule.php b/app/Module/PlacesModule.php
index d7ae6458b0..47c5dbad73 100644
--- a/app/Module/PlacesModule.php
+++ b/app/Module/PlacesModule.php
@@ -24,6 +24,7 @@ use Fisharebest\Webtrees\FactLocation;
use Fisharebest\Webtrees\Functions\Functions;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Webtrees;
use stdClass;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
@@ -183,7 +184,7 @@ class PlacesModule extends AbstractModule implements ModuleTabInterface
private function getMapProviderData(Request $request)
{
if (self::$map_providers === null) {
- $providersFile = WT_ROOT . WT_MODULES_DIR . 'openstreetmap/providers/providers.xml';
+ $providersFile = WT_ROOT . Webtrees::MODULES_PATH . 'openstreetmap/providers/providers.xml';
self::$map_selections = [
'provider' => $this->getPreference('provider', 'openstreetmap'),
'style' => $this->getPreference('provider_style', 'mapnik'),
diff --git a/app/Module/ResearchTaskModule.php b/app/Module/ResearchTaskModule.php
index a2014406ab..7214afac20 100644
--- a/app/Module/ResearchTaskModule.php
+++ b/app/Module/ResearchTaskModule.php
@@ -85,7 +85,7 @@ class ResearchTaskModule extends AbstractModule implements ModuleBlockInterface
$tasks = [];
foreach ($records as $record) {
- foreach ($record->facts('_TODO') as $task) {
+ foreach ($record->facts(['_TODO']) as $task) {
$user_name = $task->getAttribute('_WT_USER');
if ($user_name === Auth::user()->getUserName() || empty($user_name) && $show_unassigned || !empty($user_name) && $show_other) {
diff --git a/app/Module/UpcomingAnniversariesModule.php b/app/Module/UpcomingAnniversariesModule.php
index 8631e94c04..a5f26a63b6 100644
--- a/app/Module/UpcomingAnniversariesModule.php
+++ b/app/Module/UpcomingAnniversariesModule.php
@@ -18,6 +18,7 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
use Fisharebest\Webtrees\Auth;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomTag;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Services\CalendarService;
@@ -131,8 +132,7 @@ class UpcomingAnniversariesModule extends AbstractModule implements ModuleBlockI
// If we are only showing living individuals, then we don't need to search for DEAT events.
if ($filter) {
- $death_events = explode('|', WT_EVENTS_DEAT);
- $event_array = array_diff($event_array, $death_events);
+ $event_array = array_diff($event_array, Gedcom::DEATH_EVENTS);
}
$events_filter = implode('|', $event_array);
diff --git a/app/Note.php b/app/Note.php
index b2613e62ff..7a0420acaf 100644
--- a/app/Note.php
+++ b/app/Note.php
@@ -56,7 +56,7 @@ class Note extends GedcomRecord
*/
public function getNote()
{
- if (preg_match('/^0 @' . WT_REGEX_XREF . '@ NOTE ?(.*(?:\n1 CONT ?.*)*)/', $this->gedcom . $this->pending, $match)) {
+ if (preg_match('/^0 @' . Gedcom::REGEX_XREF . '@ NOTE ?(.*(?:\n1 CONT ?.*)*)/', $this->gedcom . $this->pending, $match)) {
return preg_replace("/\n1 CONT ?/", "\n", $match[1]);
}
diff --git a/app/Report/AbstractReport.php b/app/Report/AbstractReport.php
index 616db2c14e..1fa8a5ec71 100644
--- a/app/Report/AbstractReport.php
+++ b/app/Report/AbstractReport.php
@@ -20,6 +20,7 @@ namespace Fisharebest\Webtrees\Report;
use DomainException;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\MediaFile;
+use Fisharebest\Webtrees\Webtrees;
/**
* Class AbstractReport - base for PDF and HTML reports
@@ -29,9 +30,6 @@ abstract class AbstractReport
/** User measure unit. */
const UNITS = 'pt';
- /** webtrees URL */
- const WT_URL = WT_WEBTREES_URL;
-
/** @var float Left Margin (expressed in points) Default: 17.99 mm, 0.7083 inch */
public $left_margin = 51.0;
@@ -87,7 +85,7 @@ abstract class AbstractReport
public $title = '';
/** @var string Author of the report, the users full name */
- public $rauthor = WT_WEBTREES . ' ' . WT_VERSION;
+ public $rauthor = Webtrees::NAME . ' ' . Webtrees::VERSION;
/** @var string Keywords */
public $rkeywords = '';
@@ -269,7 +267,7 @@ abstract class AbstractReport
$this->rkeywords = '';
// Generated By...text
// I18N: This is a report footer. %s is the name of the application.
- $this->generated_by = I18N::translate('Generated by %s', WT_WEBTREES . ' ' . WT_VERSION);
+ $this->generated_by = I18N::translate('Generated by %s', Webtrees::NAME . ' ' . Webtrees::VERSION);
// For known size pages
if ($this->page_width == 0 && $this->page_height == 0) {
diff --git a/app/Report/ReportHtml.php b/app/Report/ReportHtml.php
index 1acb553f28..05bd4d6381 100644
--- a/app/Report/ReportHtml.php
+++ b/app/Report/ReportHtml.php
@@ -20,6 +20,7 @@ namespace Fisharebest\Webtrees\Report;
use Fisharebest\Webtrees\Functions\FunctionsRtl;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\MediaFile;
+use Fisharebest\Webtrees\Webtrees;
/**
* Class ReportHtml
@@ -162,7 +163,7 @@ class ReportHtml extends AbstractReport
// The default style name for Generated by.... is 'genby'
$element = new ReportHtmlCell(0, 10, 0, 'C', '', 'genby', 1, ReportBaseElement::CURRENT_POSITION, ReportBaseElement::CURRENT_POSITION, 0, 0, '', '', true);
$element->addText($this->generated_by);
- $element->setUrl(parent::WT_URL);
+ $element->setUrl(Webtrees::VERSION);
$this->footerElements[] = $element;
}
}
diff --git a/app/Report/ReportParserGenerate.php b/app/Report/ReportParserGenerate.php
index 3eee391d0e..5f636f7165 100644
--- a/app/Report/ReportParserGenerate.php
+++ b/app/Report/ReportParserGenerate.php
@@ -24,6 +24,7 @@ use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\Filter;
use Fisharebest\Webtrees\Functions\Functions;
use Fisharebest\Webtrees\Functions\FunctionsDate;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\GedcomTag;
use Fisharebest\Webtrees\I18N;
@@ -35,7 +36,6 @@ use Fisharebest\Webtrees\Place;
use Fisharebest\Webtrees\Tree;
use stdClass;
use Symfony\Component\Cache\Adapter\NullAdapter;
-use Symfony\Component\ExpressionLanguage\ExpressionFunction;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
/**
@@ -1108,7 +1108,7 @@ class ReportParserGenerate extends ReportParserBase
$i++;
// Privacy check - is this a link, and are we allowed to view the linked object?
$subrecord = Functions::getSubRecord($level, "$level $t", $subrec, $i);
- if (preg_match('/^\d ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@/', $subrecord, $xref_match)) {
+ if (preg_match('/^\d ' . Gedcom::REGEX_TAG . ' @(' . Gedcom::REGEX_XREF . ')@/', $subrecord, $xref_match)) {
$linked_object = GedcomRecord::getInstance($xref_match[1], $this->tree);
if ($linked_object && !$linked_object->canShow()) {
continue;
@@ -1530,7 +1530,7 @@ class ReportParserGenerate extends ReportParserBase
$level++;
$value = $this->getGedcomValue($id, $level, $this->gedrec);
}
- $value = preg_replace('/^@(' . WT_REGEX_XREF . ')@$/', '$1', $value);
+ $value = preg_replace('/^@(' . Gedcom::REGEX_XREF . ')@$/', '$1', $value);
$value = '"' . addslashes($value) . '"';
}
$condition = str_replace("@$id", $value, $condition);
diff --git a/app/Report/ReportPdf.php b/app/Report/ReportPdf.php
index b239d78770..49b1ced5e1 100644
--- a/app/Report/ReportPdf.php
+++ b/app/Report/ReportPdf.php
@@ -17,8 +17,8 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Report;
-use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\MediaFile;
+use Fisharebest\Webtrees\Webtrees;
/**
* Class ReportPdf
@@ -89,12 +89,7 @@ class ReportPdf extends AbstractReport
// Setup RTL support
$this->pdf->setRTL($this->rtl);
// Set the document information
- // Only admin should see the version number
- $appversion = WT_WEBTREES;
- if (Auth::isAdmin()) {
- $appversion .= ' ' . WT_VERSION;
- }
- $this->pdf->SetCreator($appversion . ' (' . parent::WT_URL . ')');
+ $this->pdf->SetCreator(Webtrees::NAME . ' ' . Webtrees::VERSION);
$this->pdf->SetAuthor($this->rauthor);
$this->pdf->SetTitle($this->title);
$this->pdf->SetSubject($this->rsubject);
@@ -106,7 +101,7 @@ class ReportPdf extends AbstractReport
// The default style name for Generated by.... is 'genby'
$element = new ReportPdfCell(0, 10, 0, 'C', '', 'genby', 1, ReportBaseElement::CURRENT_POSITION, ReportBaseElement::CURRENT_POSITION, 0, 0, '', '', true);
$element->addText($this->generated_by);
- $element->setUrl(parent::WT_URL);
+ $element->setUrl(Webtrees::NAME . ' ' . Webtrees::VERSION);
$this->pdf->addFooter($element);
}
}
diff --git a/app/Repository.php b/app/Repository.php
index c9f8b1b77e..d1dfe7abd3 100644
--- a/app/Repository.php
+++ b/app/Repository.php
@@ -86,6 +86,6 @@ class Repository extends GedcomRecord
*/
public function extractNames()
{
- parent::extractNamesFromFacts(1, 'NAME', $this->facts('NAME'));
+ parent::extractNamesFromFacts(1, 'NAME', $this->facts(['NAME']));
}
}
diff --git a/app/Schema/Migration30.php b/app/Schema/Migration30.php
index 744774b690..09ef074ff4 100644
--- a/app/Schema/Migration30.php
+++ b/app/Schema/Migration30.php
@@ -19,6 +19,7 @@ namespace Fisharebest\Webtrees\Schema;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Database;
+use Fisharebest\Webtrees\Webtrees;
/**
* Upgrade the database schema from version 30 to version 31.
@@ -124,7 +125,7 @@ class Migration30 implements MigrationInterface
"(-1, 'WORD_WRAPPED_NOTES', '0')"
)->execute([
'MEDIA_UPLOAD' => Auth::PRIV_USER,
- 'META_TITLE' => WT_WEBTREES,
+ 'META_TITLE' => Webtrees::NAME,
'SHOW_DEAD_PEOPLE' => Auth::PRIV_PRIVATE,
'SHOW_LIVING_NAMES' => Auth::PRIV_USER,
'SHOW_NO_WATERMARK' => Auth::PRIV_USER,
diff --git a/app/Select2.php b/app/Select2.php
index 783af64fd7..81fee83b55 100644
--- a/app/Select2.php
+++ b/app/Select2.php
@@ -164,7 +164,7 @@ class Select2 extends Html
*/
public static function flagValue($flag): string
{
- return '<img src="' . WT_MODULES_DIR . 'googlemap/places/flags/' . $flag . '"> ' . $flag;
+ return '<img src="' . Webtrees::MODULES_PATH . 'googlemap/places/flags/' . $flag . '"> ' . $flag;
}
/**
@@ -180,7 +180,7 @@ class Select2 extends Html
$offset = $page * self::RESULTS_PER_PAGE;
$more = false;
$results = [];
- $directory = WT_ROOT . WT_MODULES_DIR . 'googlemap/places/flags/';
+ $directory = WT_ROOT . Webtrees::MODULES_PATH . 'googlemap/places/flags/';
$di = new RecursiveDirectoryIterator($directory);
$it = new RecursiveIteratorIterator($di);
diff --git a/app/Services/UpgradeService.php b/app/Services/UpgradeService.php
index 090d7e9d91..a559c2d14a 100644
--- a/app/Services/UpgradeService.php
+++ b/app/Services/UpgradeService.php
@@ -20,6 +20,7 @@ namespace Fisharebest\Webtrees\Services;
use Fisharebest\Webtrees\Database;
use Fisharebest\Webtrees\DebugBar;
use Fisharebest\Webtrees\Site;
+use Fisharebest\Webtrees\Webtrees;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use Symfony\Component\HttpFoundation\Response;
@@ -49,7 +50,7 @@ class UpgradeService
{
// If the latest version is unavailable, we will have an empty sting which equates to version 0.
- return version_compare(WT_VERSION, $this->fetchLatestVersion()) < 0;
+ return version_compare(Webtrees::VERSION, $this->fetchLatestVersion()) < 0;
}
/**
@@ -125,7 +126,7 @@ class UpgradeService
$operating_system = DIRECTORY_SEPARATOR === '/' ? 'u' : 'w';
return [
- 'w' => WT_VERSION,
+ 'w' => Webtrees::VERSION,
'p' => PHP_VERSION,
'm' => $mysql_version->value,
'o' => $operating_system,
diff --git a/app/Source.php b/app/Source.php
index 5c56844f87..8147c502ea 100644
--- a/app/Source.php
+++ b/app/Source.php
@@ -108,6 +108,6 @@ class Source extends GedcomRecord
*/
public function extractNames()
{
- parent::extractNamesFromFacts(1, 'TITL', $this->facts('TITL'));
+ parent::extractNamesFromFacts(1, 'TITL', $this->facts(['TITL']));
}
}
diff --git a/app/Stats.php b/app/Stats.php
index f210429a69..c34cc13f5c 100644
--- a/app/Stats.php
+++ b/app/Stats.php
@@ -750,7 +750,7 @@ class Stats
*/
public function totalEventsBirth(): string
{
- return $this->totalEvents(explode('|', WT_EVENTS_BIRT));
+ return $this->totalEvents(Gedcom::BIRTH_EVENTS);
}
/**
@@ -770,7 +770,7 @@ class Stats
*/
public function totalEventsDeath(): string
{
- return $this->totalEvents(explode('|', WT_EVENTS_DEAT));
+ return $this->totalEvents(Gedcom::DEATH_EVENTS);
}
/**
@@ -790,7 +790,7 @@ class Stats
*/
public function totalEventsMarriage(): string
{
- return $this->totalEvents(explode('|', WT_EVENTS_MARR));
+ return $this->totalEvents(Gedcom::MARRIAGE_EVENTS);
}
/**
@@ -810,7 +810,7 @@ class Stats
*/
public function totalEventsDivorce(): string
{
- return $this->totalEvents(explode('|', WT_EVENTS_DIV));
+ return $this->totalEvents(Gedcom::DIVORCE_EVENTS);
}
/**
@@ -830,7 +830,7 @@ class Stats
*/
public function totalEventsOther(): string
{
- $facts = array_merge(explode('|', WT_EVENTS_BIRT . '|' . WT_EVENTS_MARR . '|' . WT_EVENTS_DIV . '|' . WT_EVENTS_DEAT));
+ $facts = array_merge(Gedcom::BIRTH_EVENTS, Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS, Gedcom::DEATH_EVENTS);
$no_facts = [];
foreach ($facts as $fact) {
$fact = '!' . str_replace('\'', '', $fact);
@@ -1020,7 +1020,7 @@ class Stats
private function totalLivingQuery(): int
{
return (int) Database::prepare(
- "SELECT COUNT(*) FROM `##individuals` WHERE i_file = :tree_id AND i_gedcom NOT REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")'"
+ "SELECT COUNT(*) FROM `##individuals` WHERE i_file = :tree_id AND i_gedcom NOT REGEXP '\\n1 (" . implode('|', Gedcom::DEATH_EVENTS) . ")'"
)->execute([
'tree_id' => $this->tree->id(),
])->fetchOne();
@@ -1054,7 +1054,7 @@ class Stats
private function totalDeceasedQuery(): int
{
return (int) Database::prepare(
- "SELECT COUNT(*) FROM `##individuals` WHERE i_file = :tree_id AND i_gedcom REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")'"
+ "SELECT COUNT(*) FROM `##individuals` WHERE i_file = :tree_id AND i_gedcom REGEXP '\\n1 (" . implode('|', Gedcom::DEATH_EVENTS) . ")'"
)->execute([
'tree_id' => $this->tree->id(),
])->fetchOne();
@@ -2482,7 +2482,7 @@ class Stats
" `##individuals` AS indi" .
" WHERE" .
" indi.i_id=birth.d_gid AND" .
- " indi.i_gedcom NOT REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")' AND" .
+ " indi.i_gedcom NOT REGEXP '\\n1 (" . implode('|', Gedcom::DEATH_EVENTS) . ")' AND" .
" birth.d_file={$this->tree->id()} AND" .
" birth.d_fact='BIRT' AND" .
" birth.d_file=indi.i_file AND" .
@@ -3006,13 +3006,13 @@ class Stats
/**
* Events
*
- * @param string $type
- * @param string $direction
- * @param string $facts
+ * @param string $type
+ * @param string $direction
+ * @param string[] $facts
*
* @return string
*/
- private function eventQuery($type, $direction, $facts): string
+ private function eventQuery(string $type, string $direction, array $facts): string
{
$eventTypes = [
'BIRT' => I18N::translate('birth'),
@@ -3023,7 +3023,7 @@ class Stats
'CENS' => I18N::translate('census added'),
];
- $fact_query = "IN ('" . str_replace('|', "','", $facts) . "')";
+ $fact_query = "IN ('" . implode(',', $facts) . "')";
if ($direction != 'ASC') {
$direction = 'DESC';
@@ -3092,7 +3092,7 @@ class Stats
*/
public function firstEvent(): string
{
- return $this->eventQuery('full', 'ASC', WT_EVENTS_BIRT . '|' . WT_EVENTS_MARR . '|' . WT_EVENTS_DIV . '|' . WT_EVENTS_DEAT);
+ return $this->eventQuery('full', 'ASC', array_merge(Gedcom::BIRTH_EVENTS, Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS, Gedcom::DEATH_EVENTS));
}
/**
@@ -3102,7 +3102,7 @@ class Stats
*/
public function firstEventYear(): string
{
- return $this->eventQuery('year', 'ASC', WT_EVENTS_BIRT . '|' . WT_EVENTS_MARR . '|' . WT_EVENTS_DIV . '|' . WT_EVENTS_DEAT);
+ return $this->eventQuery('year', 'ASC', array_merge(Gedcom::BIRTH_EVENTS, Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS, Gedcom::DEATH_EVENTS));
}
/**
@@ -3112,7 +3112,7 @@ class Stats
*/
public function firstEventType(): string
{
- return $this->eventQuery('type', 'ASC', WT_EVENTS_BIRT . '|' . WT_EVENTS_MARR . '|' . WT_EVENTS_DIV . '|' . WT_EVENTS_DEAT);
+ return $this->eventQuery('type', 'ASC', array_merge(Gedcom::BIRTH_EVENTS, Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS, Gedcom::DEATH_EVENTS));
}
/**
@@ -3122,7 +3122,7 @@ class Stats
*/
public function firstEventName(): string
{
- return $this->eventQuery('name', 'ASC', WT_EVENTS_BIRT . '|' . WT_EVENTS_MARR . '|' . WT_EVENTS_DIV . '|' . WT_EVENTS_DEAT);
+ return $this->eventQuery('name', 'ASC', array_merge(Gedcom::BIRTH_EVENTS, Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS, Gedcom::DEATH_EVENTS));
}
/**
@@ -3132,7 +3132,7 @@ class Stats
*/
public function firstEventPlace(): string
{
- return $this->eventQuery('place', 'ASC', WT_EVENTS_BIRT . '|' . WT_EVENTS_MARR . '|' . WT_EVENTS_DIV . '|' . WT_EVENTS_DEAT);
+ return $this->eventQuery('place', 'ASC', array_merge(Gedcom::BIRTH_EVENTS, Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS, Gedcom::DEATH_EVENTS));
}
/**
@@ -3142,7 +3142,7 @@ class Stats
*/
public function lastEvent(): string
{
- return $this->eventQuery('full', 'DESC', WT_EVENTS_BIRT . '|' . WT_EVENTS_MARR . '|' . WT_EVENTS_DIV . '|' . WT_EVENTS_DEAT);
+ return $this->eventQuery('full', 'DESC', array_merge(Gedcom::BIRTH_EVENTS, Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS, Gedcom::DEATH_EVENTS));
}
/**
@@ -3152,7 +3152,7 @@ class Stats
*/
public function lastEventYear(): string
{
- return $this->eventQuery('year', 'DESC', WT_EVENTS_BIRT . '|' . WT_EVENTS_MARR . '|' . WT_EVENTS_DIV . '|' . WT_EVENTS_DEAT);
+ return $this->eventQuery('year', 'DESC', array_merge(Gedcom::BIRTH_EVENTS, Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS, Gedcom::DEATH_EVENTS));
}
/**
@@ -3162,7 +3162,7 @@ class Stats
*/
public function lastEventType(): string
{
- return $this->eventQuery('type', 'DESC', WT_EVENTS_BIRT . '|' . WT_EVENTS_MARR . '|' . WT_EVENTS_DIV . '|' . WT_EVENTS_DEAT);
+ return $this->eventQuery('type', 'DESC', array_merge(Gedcom::BIRTH_EVENTS, Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS, Gedcom::DEATH_EVENTS));
}
/**
@@ -3172,7 +3172,7 @@ class Stats
*/
public function lastEventName(): string
{
- return $this->eventQuery('name', 'DESC', WT_EVENTS_BIRT . '|' . WT_EVENTS_MARR . '|' . WT_EVENTS_DIV . '|' . WT_EVENTS_DEAT);
+ return $this->eventQuery('name', 'DESC', array_merge(Gedcom::BIRTH_EVENTS, Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS, Gedcom::DEATH_EVENTS));
}
/**
@@ -3182,7 +3182,7 @@ class Stats
*/
public function lastEventPlace(): string
{
- return $this->eventQuery('place', 'DESC', WT_EVENTS_BIRT . '|' . WT_EVENTS_MARR . '|' . WT_EVENTS_DIV . '|' . WT_EVENTS_DEAT);
+ return $this->eventQuery('place', 'DESC', array_merge(Gedcom::BIRTH_EVENTS, Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS, Gedcom::DEATH_EVENTS));
}
/**
@@ -6463,7 +6463,7 @@ class Stats
*/
public function webtreesVersion(): string
{
- return WT_VERSION;
+ return Webtrees::VERSION;
}
/**
@@ -6644,7 +6644,7 @@ class Stats
$module = Module::getModuleByName('gedcom_favorites');
if ($module instanceof FamilyTreeFavoritesModule) {
- $block = new FamilyTreeFavoritesModule(WT_MODULES_DIR . 'gedcom_favorites');
+ $block = new FamilyTreeFavoritesModule(Webtrees::MODULES_PATH . 'gedcom_favorites');
return $block->getBlock($this->tree, 0, false);
}
@@ -6660,7 +6660,7 @@ class Stats
public function userFavorites(): string
{
if (Auth::check() && Module::getModuleByName('user_favorites')) {
- $block = new UserFavoritesModule(WT_MODULES_DIR . 'gedcom_favorites');
+ $block = new UserFavoritesModule(Webtrees::MODULES_PATH . 'gedcom_favorites');
return $block->getBlock($this->tree, 0, false);
}
diff --git a/app/Theme/AbstractTheme.php b/app/Theme/AbstractTheme.php
index 8d9d25f81c..62ab431cb9 100644
--- a/app/Theme/AbstractTheme.php
+++ b/app/Theme/AbstractTheme.php
@@ -20,6 +20,7 @@ namespace Fisharebest\Webtrees\Theme;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Database;
use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\GedcomTag;
use Fisharebest\Webtrees\I18N;
@@ -33,6 +34,7 @@ use Fisharebest\Webtrees\Site;
use Fisharebest\Webtrees\Theme;
use Fisharebest\Webtrees\Tree;
use Fisharebest\Webtrees\User;
+use Fisharebest\Webtrees\Webtrees;
use stdClass;
use Symfony\Component\HttpFoundation\Request;
@@ -854,7 +856,7 @@ abstract class AbstractTheme
$opt_tags = preg_split('/\W/', $individual->tree()->getPreference('CHART_BOX_TAGS'), 0, PREG_SPLIT_NO_EMPTY);
// Show BIRT or equivalent event
- foreach (explode('|', WT_EVENTS_BIRT) as $birttag) {
+ foreach (Gedcom::BIRTH_EVENTS as $birttag) {
if (!in_array($birttag, $opt_tags)) {
$event = $individual->getFirstFact($birttag);
if ($event) {
@@ -865,7 +867,7 @@ abstract class AbstractTheme
}
// Show optional events (before death)
foreach ($opt_tags as $key => $tag) {
- if (!preg_match('/^(' . WT_EVENTS_DEAT . ')$/', $tag)) {
+ if (!in_array($tag, Gedcom::DEATH_EVENTS)) {
$event = $individual->getFirstFact($tag);
if ($event !== null) {
$html .= $event->summary();
@@ -874,7 +876,7 @@ abstract class AbstractTheme
}
}
// Show DEAT or equivalent event
- foreach (explode('|', WT_EVENTS_DEAT) as $deattag) {
+ foreach (Gedcom::DEATH_EVENTS as $deattag) {
$event = $individual->getFirstFact($deattag);
if ($event) {
$html .= $event->summary();
@@ -905,13 +907,13 @@ abstract class AbstractTheme
public function individualBoxLdsSummary(Individual $individual)
{
if ($individual->tree()->getPreference('SHOW_LDS_AT_GLANCE')) {
- $BAPL = $individual->facts('BAPL') ? 'B' : '_';
- $ENDL = $individual->facts('ENDL') ? 'E' : '_';
- $SLGC = $individual->facts('SLGC') ? 'C' : '_';
+ $BAPL = $individual->facts(['BAPL']) ? 'B' : '_';
+ $ENDL = $individual->facts(['ENDL']) ? 'E' : '_';
+ $SLGC = $individual->facts(['SLGC']) ? 'C' : '_';
$SLGS = '_';
foreach ($individual->getSpouseFamilies() as $family) {
- if ($family->facts('SLGS')) {
+ if ($family->facts(['SLGS'])) {
$SLGS = '';
}
}
@@ -1024,7 +1026,7 @@ abstract class AbstractTheme
*/
public function logoPoweredBy(): string
{
- return '<a href="' . WT_WEBTREES_URL . '" class="wt-powered-by-webtrees" title="' . WT_WEBTREES_URL . '" dir="ltr">' . WT_WEBTREES_URL . '</a>';
+ return '<a href="' . e(Webtrees::URL) . '" class="wt-powered-by-webtrees" dir="ltr">' . e(Webtrees::NAME) . '</a>';
}
/**
diff --git a/app/View.php b/app/View.php
index 92f62c8fdc..c3f57b489a 100644
--- a/app/View.php
+++ b/app/View.php
@@ -194,9 +194,9 @@ class View
if (empty($paths)) {
// Module views
// @TODO - this includes disabled modules.
- $paths = glob(WT_ROOT . WT_MODULES_DIR . '*/' . self::TEMPLATE_PATH);
+ $paths = glob(WT_ROOT . Webtrees::MODULES_PATH . '*/' . self::TEMPLATE_PATH);
// Theme views
- $paths[] = WT_ROOT . WT_THEMES_DIR . Theme::theme()->themeId() . self::TEMPLATE_PATH;
+ $paths[] = WT_ROOT . Webtrees::THEMES_PATH . Theme::theme()->themeId() . self::TEMPLATE_PATH;
// Core views
$paths[] = WT_ROOT . self::TEMPLATE_PATH;
diff --git a/app/Webtrees.php b/app/Webtrees.php
new file mode 100644
index 0000000000..8f8f619f98
--- /dev/null
+++ b/app/Webtrees.php
@@ -0,0 +1,90 @@
+<?php
+/**
+ * webtrees: online genealogy
+ * Copyright (C) 2018 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
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+declare(strict_types=1);
+
+namespace Fisharebest\Webtrees;
+
+use ErrorException;
+use function date_default_timezone_set;
+use function error_reporting;
+use function set_error_handler;
+
+/**
+ * Definitions for the webtrees application.
+ */
+class Webtrees
+{
+ // Location of the file containing the database connection details.
+ const CONFIG_FILE = __DIR__ . '/../data/config.ini.php';
+
+ // Enable debugging on development builds.
+ const DEBUG = self::STABILITY !== '';
+
+ // We want to know about all PHP errors during development, and fewer in production.
+ const ERROR_REPORTING = self::DEBUG ? E_ALL | E_STRICT | E_NOTICE | E_DEPRECATED : E_ALL;
+
+ // The name of the application.
+ const NAME = 'webtrees';
+
+ // Required version of database tables/columns/indexes/etc.
+ const SCHEMA_VERSION = 40;
+
+ // e.g. "dev", "alpha", "beta.3", etc.
+ const STABILITY = 'dev';
+
+ // Project website.
+ const URL = 'https://www.webtrees.net/';
+
+ // Version number
+ const VERSION = '2.0.0' . (self::STABILITY === '' ? '' : '-') . self::STABILITY;
+
+ // Location of our modules and themes. These are used as URLs and folder paths.
+ const MODULES_PATH = 'modules_v3/';
+
+ // Location of themes (core and custom).
+ const THEMES_PATH = 'themes/';
+
+ // Location of CSS/JS/etc. assets. See also webpack.mix.js.
+ const ASSETS_PATH = 'public/assets-2.0.0/';
+
+ // Location of our installation of CK editor.
+ const CKEDITOR_PATH = 'public/ckeditor-4.5.2-custom/';
+
+ /**
+ * Initialise the application.
+ *
+ * @return void
+ */
+ public static function init()
+ {
+ // Show all errors and warnings in development, fewer in production.
+ error_reporting(self::ERROR_REPORTING);
+
+ // PHP requires a time zone to be set. We'll set a better one later on.
+ date_default_timezone_set('UTC');
+
+ // Convert PHP warnings/notices into exceptions
+ set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline): bool {
+ // Ignore errors that are silenced with '@'
+ if (error_reporting() & $errno) {
+ throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
+ }
+
+ return true;
+ });
+
+ }
+}