xref: /webtrees/resources/views/admin/locations.phtml (revision 341c7ed203e722b68334fa88c1138c765eb580f8)
11e653452SGreg Roach<?php
21e653452SGreg Roach
394e35917SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\MapDataDelete;
494e35917SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\MapDataList;
51e653452SGreg Roachuse Fisharebest\Webtrees\I18N;
694e35917SGreg Roachuse Fisharebest\Webtrees\Module\PlaceHierarchyListModule;
71e653452SGreg Roachuse Fisharebest\Webtrees\Webtrees;
81e653452SGreg Roach
994e35917SGreg Roach/**
1094e35917SGreg Roach * @var array<stdClass>      $active
1194e35917SGreg Roach * @var array<string,string> $breadcrumbs
1294e35917SGreg Roach * @var int                  $parent_id
1394e35917SGreg Roach * @var array<mixed>         $placelist
1494e35917SGreg Roach * @var string               $title
1594e35917SGreg Roach */
1694e35917SGreg Roach
171e653452SGreg Roach?>
18dd6b2bfcSGreg Roach
19dd6b2bfcSGreg Roach<?= view('components/breadcrumbs', ['links' => $breadcrumbs]) ?>
20dd6b2bfcSGreg Roach
21dd6b2bfcSGreg Roach<h1><?= $title ?></h1>
22dd6b2bfcSGreg Roach
23dd6b2bfcSGreg Roach<table class="table table-bordered table-striped table-sm table-hover">
24dd6b2bfcSGreg Roach    <thead class="thead-dark">
25dd6b2bfcSGreg Roach        <tr>
26dd6b2bfcSGreg Roach            <th><?= I18N::translate('Place') ?></th>
27dd6b2bfcSGreg Roach            <th><?= I18N::translate('Latitude') ?></th>
28dd6b2bfcSGreg Roach            <th><?= I18N::translate('Longitude') ?></th>
29e340fe65SGreg Roach            <!--
30dd6b2bfcSGreg Roach            <th><?= I18N::translate('Flag') ?> </th>
31e340fe65SGreg Roach            -->
32dd6b2bfcSGreg Roach            <th><?= I18N::translate('Edit') ?></th>
3394e35917SGreg Roach            <th><?= I18N::translate('Facts and events') ?></th>
34dd6b2bfcSGreg Roach            <th><?= I18N::translate('Delete') ?></th>
35dd6b2bfcSGreg Roach        </tr>
36dd6b2bfcSGreg Roach    </thead>
37dd6b2bfcSGreg Roach
387039fd97SGreg Roach    <tbody>
39dd6b2bfcSGreg Roach    <?php foreach ($placelist as $place) : ?>
40dd6b2bfcSGreg Roach        <tr>
41dd6b2bfcSGreg Roach            <th scope="row">
4294e35917SGreg Roach                <a href="<?= e(route(MapDataList::class, ['parent_id' => $place->pl_id])) ?>">
43dd6b2bfcSGreg Roach                    <?= e($place->pl_place) ?>
4494e35917SGreg Roach                    <?php if ($place->no_coord > 0): ?>
4594e35917SGreg Roach                        <span class="badge badge-pill badge-secondary">
4694e35917SGreg Roach                            <?= view('icons/warning') ?>
4794e35917SGreg Roach                            <?= I18N::number($place->no_coord) ?>
4894e35917SGreg Roach                            /
49dd6b2bfcSGreg Roach                            <?= I18N::number($place->child_count) ?>
50dd6b2bfcSGreg Roach                        </span>
5194e35917SGreg Roach                    <?php elseif ($place->child_count > 0): ?>
5294e35917SGreg Roach                        <span class="badge badge-pill badge-secondary">
5394e35917SGreg Roach                            <?= I18N::number($place->child_count) ?>
5494e35917SGreg Roach                        </span>
5594e35917SGreg Roach                    <?php endif ?>
56dd6b2bfcSGreg Roach                </a>
57dd6b2bfcSGreg Roach            </th>
58d993d560SGreg Roach
590e7a2d23SGreg Roach            <td dir="ltr">
6035661a57SGreg Roach                <?php if ((string) $place->pl_lati === '') : ?>
61d993d560SGreg Roach                    <?= view('icons/warning') ?>
62d993d560SGreg Roach                <?php else : ?>
63d993d560SGreg Roach                    <?= strtr($place->pl_lati, ['N' => '', 'S' => '-', ',' => '.']) ?>
64d993d560SGreg Roach                <?php endif ?>
65dd6b2bfcSGreg Roach            </td>
66d993d560SGreg Roach
670e7a2d23SGreg Roach            <td dir="ltr">
6835661a57SGreg Roach                <?php if ((string) $place->pl_long === '') : ?>
69d993d560SGreg Roach                    <?= view('icons/warning') ?>
70d993d560SGreg Roach                <?php else : ?>
71d993d560SGreg Roach                    <?= strtr($place->pl_long, ['E' => '', 'W' => '-', ',' => '.']) ?>
72d993d560SGreg Roach                <?php endif ?>
73dd6b2bfcSGreg Roach            </td>
74d993d560SGreg Roach
75e340fe65SGreg Roach            <!--
76dd6b2bfcSGreg Roach            <td>
778d0ebef0SGreg Roach                <?php if (is_file(Webtrees::MODULES_PATH . 'openstreetmap/' . $place->pl_icon)) : ?>
78b2c011d7SGreg Roach                    <img src="<?= e(Webtrees::MODULES_PATH . 'openstreetmap/' . $place->pl_icon) ?>" width="25" height="15" alt="<?= I18N::translate('Flag of %s', $place->pl_place) ?>">
79dd6b2bfcSGreg Roach                <?php endif ?>
80dd6b2bfcSGreg Roach            </td>
81e340fe65SGreg Roach            -->
82d993d560SGreg Roach
83dd6b2bfcSGreg Roach            <td>
8439b853a7SGreg Roach                <a class="btn btn-primary" href="<?= e(route('map-data-edit', ['place_id'  => $place->pl_id, 'parent_id' => $place->pl_parent_id])) ?>" title="<?= I18N::translate('Edit') ?>">
8539b853a7SGreg Roach                    <?= view('icons/edit') ?>
8639b853a7SGreg Roach                    <span class="sr-only">
8739b853a7SGreg Roach                        <?= I18N::translate('Edit') ?>
8839b853a7SGreg Roach                    </span>
8939b853a7SGreg Roach                </a>
90dd6b2bfcSGreg Roach            </td>
91d993d560SGreg Roach
92dd6b2bfcSGreg Roach            <td>
9394e35917SGreg Roach                <?php if (array_key_exists($place->pl_place, $active)): ?>
9494e35917SGreg Roach                    <?php if (count($active[$place->pl_place]) === 1): ?>
9594e35917SGreg Roach                        <a class="btn btn-link" href="<?= e(route(PlaceHierarchyListModule::class, ['tree' => $active[$place->pl_place][0]->tree_name, 'place_id' => $active[$place->pl_place][0]->p_id, 'action2' => 'hierarchy-e'])) ?>">
9694e35917SGreg Roach                            <?= e($active[$place->pl_place][0]->tree_title) ?>
9794e35917SGreg Roach                        </a>
9894e35917SGreg Roach                    <?php else: ?>
9994e35917SGreg Roach                        <div class="dropdown">
10094e35917SGreg Roach                            <a class="btn btn-link dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
101*341c7ed2SGreg Roach                                <?= I18N::plural('%s family tree', '%s family trees', count($active[$place->pl_place]), I18N::number(count($active[$place->pl_place]))) ?>
10294e35917SGreg Roach                            </a>
10394e35917SGreg Roach
10494e35917SGreg Roach                            <div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
10594e35917SGreg Roach                                <?php foreach ($active[$place->pl_place] as $link): ?>
10694e35917SGreg Roach                                    <a class="dropdown-item" href="<?= e(route(PlaceHierarchyListModule::class, ['tree' => $link->tree_name, 'place_id' => $link->p_id])) ?>">
10794e35917SGreg Roach                                        <?= e($link->tree_title) ?>
10894e35917SGreg Roach                                    </a>
10994e35917SGreg Roach                                <?php endforeach ?>
11094e35917SGreg Roach                            </div>
11194e35917SGreg Roach                        </div>
11294e35917SGreg Roach                    <?php endif ?>
11394e35917SGreg Roach                <?php endif ?>
11494e35917SGreg Roach            </td>
11594e35917SGreg Roach
11694e35917SGreg Roach            <td>
11794e35917SGreg Roach                <?php if (!array_key_exists($place->pl_place, $active)): ?>
11894e35917SGreg Roach                    <form method="post" action="<?= e(route(MapDataDelete::class, ['place_id' => $place->pl_id])) ?>">
119dd6b2bfcSGreg Roach                        <?= csrf_field() ?>
12094e35917SGreg Roach                        <button type="submit" class="btn btn-danger" aria-label="<?= I18N::translate('delete') ?>" data-confirm="<?= I18N::translate('Remove this location?') ?>">
1216a83cfe8SGreg Roach                            <?= view('icons/delete') ?>
122dd6b2bfcSGreg Roach                        </button>
123dd6b2bfcSGreg Roach                    </form>
124dd6b2bfcSGreg Roach                <?php endif ?>
125dd6b2bfcSGreg Roach            </td>
126dd6b2bfcSGreg Roach        </tr>
127dd6b2bfcSGreg Roach    <?php endforeach ?>
128dd6b2bfcSGreg Roach    </tbody>
1297039fd97SGreg Roach
130dd6b2bfcSGreg Roach    <tfoot>
131dd6b2bfcSGreg Roach        <tr>
132dd6b2bfcSGreg Roach            <td colspan="7">
13356a34df1SGreg Roach                <a class="btn btn-primary" href="<?= e(route('map-data-edit', ['place_id' => '0', 'parent_id' => $parent_id])) ?>">
134d993d560SGreg Roach                    <?= view('icons/add') ?>
135dd6b2bfcSGreg Roach                    <?= /* I18N: A button label. */
136dd6b2bfcSGreg Roach                    I18N::translate('add place') ?>
137dd6b2bfcSGreg Roach                </a>
138dd6b2bfcSGreg Roach                <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton"
139dd6b2bfcSGreg Roach                        data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
140d993d560SGreg Roach                    <?= view('icons/download') ?>
141dd6b2bfcSGreg Roach                    <?= /* I18N: A button label. */
142dd6b2bfcSGreg Roach                    I18N::translate('export file') ?>
143dd6b2bfcSGreg Roach                </button>
144dd6b2bfcSGreg Roach                <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
145dd6b2bfcSGreg Roach                    <a class="dropdown-item" href="<?= e(route('locations-export', ['parent_id' => $parent_id, 'format' => 'csv'])) ?>">
146dd6b2bfcSGreg Roach                        csv
147dd6b2bfcSGreg Roach                    </a>
148dd6b2bfcSGreg Roach                    <a class="dropdown-item" href="<?= e(route('locations-export', ['parent_id' => $parent_id, 'format' => 'geojson'])) ?>">
149dd6b2bfcSGreg Roach                        geoJSON
150dd6b2bfcSGreg Roach                    </a>
151dd6b2bfcSGreg Roach                </div>
152dd6b2bfcSGreg Roach                <a class="btn btn-primary" href="<?= e(route('locations-import', ['parent_id' => $parent_id])) ?>">
153d993d560SGreg Roach                    <?= view('icons/upload') ?>
154dd6b2bfcSGreg Roach                    <?= /* I18N: A button label. */
155dd6b2bfcSGreg Roach                    I18N::translate('import file') ?>
156dd6b2bfcSGreg Roach                </a>
157dd6b2bfcSGreg Roach            </td>
158dd6b2bfcSGreg Roach        </tr>
159dd6b2bfcSGreg Roach    </tfoot>
160dd6b2bfcSGreg Roach</table>
161