xref: /webtrees/resources/views/fact-place.phtml (revision 24931b29a0237a5f5f1b8620af661ea530451af0)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Date;
6use Fisharebest\Webtrees\Fact;
7use Fisharebest\Webtrees\GedcomRecord;
8use Fisharebest\Webtrees\I18N;
9use Fisharebest\Webtrees\Module\ModuleMapLinkInterface;
10use Fisharebest\Webtrees\Place;
11use Fisharebest\Webtrees\Registry;
12use Fisharebest\Webtrees\Services\ModuleService;
13
14/**
15 * @var bool         $cal_link
16 * @var Fact         $fact
17 * @var GedcomRecord $record
18 * @var bool         $time
19 */
20
21?>
22<div class="wt-fact-place">
23    <?php if (preg_match('/\n(2 PLAC.*(?:\n[3-9].*)*)/', $fact->gedcom(), $match) === 1) : ?>
24        <?php $placerec = $match[1]; ?>
25        <?= $fact->place()->fullName($fact->id() !== 'histo') ?>
26
27        <?php if (preg_match_all('/\n3 (?:_HEB|ROMN|FONE) (.+)/', $placerec, $matches) === 1) : ?>
28            <?php foreach ($matches[1] as $match) : ?>
29<?= (new Place($match, $record->tree()))->fullName() ?>
30            <?php endforeach ?>
31        <?php endif ?>
32
33        <?php if ($fact->latitude() !== null && $fact->longitude() !== null) : ?>
34            <div class="wt-fact-coordinates">
35                <span class="label"><?= I18N::translate('Latitude') ?>: </span><?= $fact->latitude() ?>
36                <span class="label"><?= I18N::translate('Longitude') ?>: </span><?= $fact->longitude()?>
37                <?= Registry::container()->get(ModuleService::class)->findByInterface(ModuleMapLinkInterface::class)->map(fn (ModuleMapLinkInterface $module): string => ' ' . $module->mapLink($fact))->implode('') ?>
38            </div>
39        <?php endif ?>
40
41        <?php if (preg_match_all('/\n(3 NOTE\b.*(?:\n[^3].*)*)/', $placerec, $matches, PREG_SET_ORDER) > 0) : ?>
42            <?php foreach ($matches as $match) : ?>
43                <?= view('fact-gedcom-fields', ['gedcom' => $match[1], 'parent' => $fact->tag() . ':PLAC:NOTE', 'tree' => $record->tree()]) ?>
44            <?php endforeach ?>
45        <?php endif ?>
46    <?php endif ?>
47
48    <?php if (preg_match('/2 TEMP (.+)/', $fact->gedcom(), $match)) : ?>
49        <?= Registry::elementFactory()->make($fact->tag() . ':TEMP')->labelValue($match[1], $record->tree()) ?>
50    <?php endif ?>
51
52    <?php if (preg_match('/2 STAT (.+)/', $fact->gedcom(), $match)) : ?>
53        <?= Registry::elementFactory()->make($fact->tag() . ':STAT')->labelValue($match[1], $record->tree()) ?>
54
55        <?php if (preg_match('/3 DATE (.+)/', $fact->gedcom(), $match)) : ?>
56            <?= Registry::elementFactory()->make($fact->tag() . ':STAT:DATE')->labelValue((new Date($match[1]))->display(), $record->tree()) ?>
57        <?php endif ?>
58    <?php endif ?>
59</div>
60