xref: /webtrees/resources/views/admin/locations.phtml (revision 6a83cfe82cf72deb988ef6a54a7440e72b1b45e5)
1<?php use Fisharebest\Webtrees\Bootstrap4; ?>
2<?php use Fisharebest\Webtrees\I18N; ?>
3<?php use Fisharebest\Webtrees\Tree; ?>
4<?php use Fisharebest\Webtrees\Webtrees; ?>
5
6<?= view('components/breadcrumbs', ['links' => $breadcrumbs]) ?>
7
8<h1><?= $title ?></h1>
9
10<table class="table table-bordered table-striped table-sm table-hover">
11    <thead class="thead-dark">
12    <tr>
13        <th><?= I18N::translate('Place') ?></th>
14        <th><?= I18N::translate('Latitude') ?></th>
15        <th><?= I18N::translate('Longitude') ?></th>
16        <th><?= I18N::translate('Zoom level') ?></th>
17        <th><?= I18N::translate('Flag') ?> </th>
18        <th><?= I18N::translate('Edit') ?></th>
19        <th><?= I18N::translate('Delete') ?></th>
20    </tr>
21    </thead>
22    <tbody>
23
24    <?php foreach ($placelist as $place) : ?>
25        <tr>
26            <th scope="row">
27                <a href="<?= e(route('map-data', ['parent_id' => $place->pl_id])) ?>">
28                    <?= e($place->pl_place) ?>
29                    <span class="badge badge-pill badge-<?= $place->badge ?>">
30                        <?= I18N::number($place->child_count) ?>
31                    </span>
32                </a>
33            </th>
34
35            <td dir="ltr">
36                <?php if ($place->pl_lati === null) : ?>
37                    <?= view('icons/warning') ?>
38                <?php else : ?>
39                    <?= strtr($place->pl_lati, ['N' => '', 'S' => '-', ',' => '.']) ?>
40                <?php endif ?>
41            </td>
42
43            <td dir="ltr">
44                <?php if ($place->pl_long === null) : ?>
45                    <?= view('icons/warning') ?>
46                <?php else : ?>
47                    <?= strtr($place->pl_long, ['E' => '', 'W' => '-', ',' => '.']) ?>
48                <?php endif ?>
49            </td>
50
51            <td dir="ltr">
52                <?php if ($place->pl_zoom === null) : ?>
53                    <?= view('icons/warning') ?>
54                <?php else : ?>
55                    <?= $place->pl_zoom ?>
56                <?php endif ?>
57            </td>
58
59            <td>
60                <?php if (is_file(Webtrees::MODULES_PATH . 'openstreetmap/' . $place->pl_icon)) : ?>
61                    <img src="<?= e(Webtrees::MODULES_PATH . 'openstreetmap/' . $place->pl_icon) ?>" width="25" height="15" alt="<?= I18N::translate("Flag of %s", $place->pl_place) ?>">
62                <?php endif ?>
63            </td>
64
65            <td>
66                <?= FontAwesome::linkIcon('edit', I18N::translate('Edit'), ['href' => route('map-data-edit', ['place_id'  => $place->pl_id, 'parent_id' => $place->pl_parent_id]), 'class' => 'btn btn-primary']) ?>
67            </td>
68
69            <td>
70                <?php if ($place->child_count === 0) : ?>
71                    <form method="POST" action="<?= e(route('map-data-delete', ['parent_id' => $parent_id, 'place_id' => $place->pl_id])) ?>"
72                          data-confirm="<?= I18N::translate('Remove this location?') ?>"
73                          onsubmit="return confirm(this.dataset.confirm)">
74                        <?= csrf_field() ?>
75                        <button type="submit" class="btn btn-danger" aria-label="<?= I18N::translate('delete') ?>">
76                            <?= view('icons/delete') ?>
77                        </button>
78                    </form>
79                <?php else : ?>
80                    <button type="button" class="btn btn-danger" disabled>
81                        <?= view('icons/delete') ?>
82                    </button>
83                <?php endif ?>
84            </td>
85        </tr>
86    <?php endforeach ?>
87    </tbody>
88    <tfoot>
89    <tr>
90        <td colspan="7">
91            <a class="btn btn-primary" href="<?= e(route('map-data', ['parent_id' => $parent_id])) ?>">
92                <?= view('icons/add') ?>
93                <?= /* I18N: A button label. */
94                I18N::translate('add place') ?>
95            </a>
96            <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton"
97                    data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
98                <?= view('icons/download') ?>
99                <?= /* I18N: A button label. */
100                I18N::translate('export file') ?>
101            </button>
102            <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
103                <a class="dropdown-item" href="<?= e(route('locations-export', ['parent_id' => $parent_id, 'format' => 'csv'])) ?>">
104                    csv
105                </a>
106                <a class="dropdown-item" href="<?= e(route('locations-export', ['parent_id' => $parent_id, 'format' => 'geojson'])) ?>">
107                    geoJSON
108                </a>
109            </div>
110            <a class="btn btn-primary" href="<?= e(route('locations-import', ['parent_id' => $parent_id])) ?>">
111                <?= view('icons/upload') ?>
112                <?= /* I18N: A button label. */
113                I18N::translate('import file') ?>
114            </a>
115        </td>
116    </tr>
117    </tfoot>
118</table>
119
120<form method="POST" action="<?= e(route('locations-import-from-tree')) ?>">
121    <?= csrf_field() ?>
122
123    <div class="form-group row">
124        <label class="form-control-plaintext col-sm-4" for="ged">
125            <?= I18N::translate('Import all places from a family tree') ?>
126        </label>
127        <div class="col-sm-6">
128            <?= Bootstrap4::select(
129                Tree::getNameList(),
130                '',
131                ['id' => 'ged', 'name' => 'ged']
132            ) ?>
133        </div>
134        <div class="col-sm-2">
135            <button type="submit" class="btn btn-primary">
136                <?= view('icons/upload') ?>
137                <?= /* I18N: A button label. */
138                I18N::translate('import') ?>
139            </button>
140        </div>
141    </div>
142</form>
143