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