summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Gedcom.php3
-rw-r--r--app/Http/Controllers/AdminLocationController.php15
-rw-r--r--app/Http/Controllers/PlaceHierarchyController.php3
-rw-r--r--app/Location.php2
-rw-r--r--app/Place.php14
-rw-r--r--app/Stats.php2
6 files changed, 21 insertions, 18 deletions
diff --git a/app/Gedcom.php b/app/Gedcom.php
index a28567c152..1010ac936c 100644
--- a/app/Gedcom.php
+++ b/app/Gedcom.php
@@ -48,4 +48,7 @@ class Gedcom
// UTF-8 encoded files may begin with an optional byte-order-mark (U+FEFF).
public const UTF8_BOM = "\xEF\xBB\xBF";
+
+ // Separates parts of a place name.
+ public const PLACE_SEPARATOR = ', ';
}
diff --git a/app/Http/Controllers/AdminLocationController.php b/app/Http/Controllers/AdminLocationController.php
index 155b119a36..36c770ba14 100644
--- a/app/Http/Controllers/AdminLocationController.php
+++ b/app/Http/Controllers/AdminLocationController.php
@@ -19,6 +19,7 @@ namespace Fisharebest\Webtrees\Http\Controllers;
use Exception;
use Fisharebest\Webtrees\FlashMessages;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Location;
use Fisharebest\Webtrees\Place;
@@ -233,7 +234,7 @@ class AdminLocationController extends AbstractBaseController
// Create the file name
$place_name = empty($hierarchy) ? 'Global' : $hierarchy[0]->fqpn; // $hierarchy[0] always holds the full placename
- $place_name = str_replace(Place::GEDCOM_SEPARATOR, '-', $place_name);
+ $place_name = str_replace(Gedcom::PLACE_SEPARATOR, '-', $place_name);
$filename = 'Places-' . preg_replace('/[^a-zA-Z0-9\-\.]/', '', $place_name);
// Fill in the place names for the starting conditions
@@ -369,7 +370,7 @@ class AdminLocationController extends AbstractBaseController
$fields = count($row);
// convert separate place fields into a comma separated placename
- $fqdn = implode(Place::GEDCOM_SEPARATOR, array_filter(array_reverse(array_slice($row, 1, $fields - 5))));
+ $fqdn = implode(Gedcom::PLACE_SEPARATOR, array_filter(array_reverse(array_slice($row, 1, $fields - 5))));
$places[] = [
'pl_level' => $row[0],
@@ -410,13 +411,13 @@ class AdminLocationController extends AbstractBaseController
$updated++;
} elseif (!$valid && $options !== 'update') {
//add
- $place_parts = explode(Place::GEDCOM_SEPARATOR, $place['fqpn']);
+ $place_parts = explode(Gedcom::PLACE_SEPARATOR, $place['fqpn']);
// work throught the place parts starting at level 0,
// looking for a record in the database, if not found then add it
$parent_id = 0;
for ($i = count($place_parts) - 1; $i >= 0; $i--) {
$new_parts = array_slice($place_parts, $i);
- $new_fqpn = implode(Place::GEDCOM_SEPARATOR, $new_parts);
+ $new_fqpn = implode(Gedcom::PLACE_SEPARATOR, $new_parts);
$new_location = new Location($new_fqpn, [
'fqpn' => $new_fqpn,
'pl_id' => 0,
@@ -604,7 +605,7 @@ class AdminLocationController extends AbstractBaseController
];
foreach ($rows as $place) {
$fqpn = implode(
- Place::GEDCOM_SEPARATOR,
+ Gedcom::PLACE_SEPARATOR,
array_reverse(
array_filter(
array_slice($place, 1, $maxlevel + 1)
@@ -680,7 +681,7 @@ class AdminLocationController extends AbstractBaseController
->first();
$fqpn[] = $row->pl_place;
- $row->fqpn = implode(Place::GEDCOM_SEPARATOR, $fqpn);
+ $row->fqpn = implode(Gedcom::PLACE_SEPARATOR, $fqpn);
$id = (int) $row->pl_parent_id;
$arr[] = $row;
}
@@ -745,7 +746,7 @@ class AdminLocationController extends AbstractBaseController
*/
private function isLocationActive(string $place_name): bool
{
- $places = explode(Place::GEDCOM_SEPARATOR, $place_name);
+ $places = explode(Gedcom::PLACE_SEPARATOR, $place_name);
$query = DB::table('places AS p0')
->where('p0.p_place', '=', $places[0])
diff --git a/app/Http/Controllers/PlaceHierarchyController.php b/app/Http/Controllers/PlaceHierarchyController.php
index cf7ddaa1bf..467df990b5 100644
--- a/app/Http/Controllers/PlaceHierarchyController.php
+++ b/app/Http/Controllers/PlaceHierarchyController.php
@@ -18,6 +18,7 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Http\Controllers;
use Fisharebest\Webtrees\Family;
+use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Location;
@@ -53,7 +54,7 @@ class PlaceHierarchyController extends AbstractBaseController
{
$action = $request->query->get('action', 'hierarchy');
$parent = $request->query->get('parent', []);
- $fqpn = implode(Place::GEDCOM_SEPARATOR, array_reverse($parent));
+ $fqpn = implode(Gedcom::PLACE_SEPARATOR, array_reverse($parent));
$place = new Place($fqpn, $tree);
$content = '';
$showmap = Site::getPreference('map-provider') !== '';
diff --git a/app/Location.php b/app/Location.php
index 0c701639a7..3e83dffb96 100644
--- a/app/Location.php
+++ b/app/Location.php
@@ -235,7 +235,7 @@ class Location
*/
private function getRecordFromName(string $gedcomName)
{
- $places = explode(Place::GEDCOM_SEPARATOR, $gedcomName);
+ $places = explode(Gedcom::PLACE_SEPARATOR, $gedcomName);
$query = DB::table('placelocation AS pl0')
->where('pl0.pl_place', '=', $places[0])
diff --git a/app/Place.php b/app/Place.php
index 806e15cc52..de97ebc3dd 100644
--- a/app/Place.php
+++ b/app/Place.php
@@ -24,8 +24,6 @@ use Illuminate\Database\Capsule\Manager as DB;
*/
class Place
{
- public const GEDCOM_SEPARATOR = ', ';
-
/** @var string[] e.g. array('Westminster', 'London', 'England') */
private $gedcom_place;
@@ -43,7 +41,7 @@ class Place
if ($gedcom_place === '') {
$this->gedcom_place = [];
} else {
- $this->gedcom_place = explode(self::GEDCOM_SEPARATOR, $gedcom_place);
+ $this->gedcom_place = explode(Gedcom::PLACE_SEPARATOR, $gedcom_place);
}
$this->tree = $tree;
}
@@ -85,7 +83,7 @@ class Place
*/
public function getParentPlace(): Place
{
- return new self(implode(self::GEDCOM_SEPARATOR, array_slice($this->gedcom_place, 1)), $this->tree);
+ return new self(implode(Gedcom::PLACE_SEPARATOR, array_slice($this->gedcom_place, 1)), $this->tree);
}
/**
@@ -96,7 +94,7 @@ class Place
public function getChildPlaces(): array
{
if ($this->getPlaceId()) {
- $parent_text = self::GEDCOM_SEPARATOR . $this->getGedcomName();
+ $parent_text = Gedcom::PLACE_SEPARATOR . $this->getGedcomName();
} else {
$parent_text = '';
}
@@ -132,7 +130,7 @@ class Place
*/
public function getGedcomName(): string
{
- return implode(self::GEDCOM_SEPARATOR, $this->gedcom_place);
+ return implode(Gedcom::PLACE_SEPARATOR, $this->gedcom_place);
}
/**
@@ -197,10 +195,10 @@ class Place
// Abbreviate the place name, for lists
if ($this->tree->getPreference('SHOW_PEDIGREE_PLACES_SUFFIX')) {
// The *last* $SHOW_PEDIGREE_PLACES components
- $short_name = implode(self::GEDCOM_SEPARATOR, array_slice($this->gedcom_place, -$SHOW_PEDIGREE_PLACES));
+ $short_name = implode(Gedcom::PLACE_SEPARATOR, array_slice($this->gedcom_place, -$SHOW_PEDIGREE_PLACES));
} else {
// The *first* $SHOW_PEDIGREE_PLACES components
- $short_name = implode(self::GEDCOM_SEPARATOR, array_slice($this->gedcom_place, 0, $SHOW_PEDIGREE_PLACES));
+ $short_name = implode(Gedcom::PLACE_SEPARATOR, array_slice($this->gedcom_place, 0, $SHOW_PEDIGREE_PLACES));
}
// Add a tool-tip showing the full name
diff --git a/app/Stats.php b/app/Stats.php
index e68d40ccd6..aa986a3fe7 100644
--- a/app/Stats.php
+++ b/app/Stats.php
@@ -1567,7 +1567,7 @@ class Stats
foreach ($rows as $row) {
if (preg_match('/\n1 ' . $fact . '(?:\n[2-9].*)*\n2 PLAC (.+)/', $row->ged, $match)) {
if ($country) {
- $tmp = explode(Place::GEDCOM_SEPARATOR, $match[1]);
+ $tmp = explode(Gedcom::PLACE_SEPARATOR, $match[1]);
$place = end($tmp);
} else {
$place = $match[1];