xref: /webtrees/resources/views/admin/locations.phtml (revision cab242e7d7a773b0a6dab130048696e26fd6612c)
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                <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') ?>">
67                    <?= view('icons/edit') ?>
68                    <span class="sr-only">
69                        <?= I18N::translate('Edit') ?>
70                    </span>
71                </a>
72            </td>
73
74            <td>
75                <?php if ($place->child_count === 0) : ?>
76                    <form method="POST" action="<?= e(route('map-data-delete', ['parent_id' => $parent_id, 'place_id' => $place->pl_id])) ?>"
77                          data-confirm="<?= I18N::translate('Remove this location?') ?>"
78                          onsubmit="return confirm(this.dataset.confirm)">
79                        <?= csrf_field() ?>
80                        <button type="submit" class="btn btn-danger" aria-label="<?= I18N::translate('delete') ?>">
81                            <?= view('icons/delete') ?>
82                        </button>
83                    </form>
84                <?php else : ?>
85                    <button type="button" class="btn btn-danger" disabled>
86                        <?= view('icons/delete') ?>
87                    </button>
88                <?php endif ?>
89            </td>
90        </tr>
91    <?php endforeach ?>
92    </tbody>
93    <tfoot>
94    <tr>
95        <td colspan="7">
96            <a class="btn btn-primary" href="<?= e(route('map-data', ['parent_id' => $parent_id])) ?>">
97                <?= view('icons/add') ?>
98                <?= /* I18N: A button label. */
99                I18N::translate('add place') ?>
100            </a>
101            <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton"
102                    data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
103                <?= view('icons/download') ?>
104                <?= /* I18N: A button label. */
105                I18N::translate('export file') ?>
106            </button>
107            <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
108                <a class="dropdown-item" href="<?= e(route('locations-export', ['parent_id' => $parent_id, 'format' => 'csv'])) ?>">
109                    csv
110                </a>
111                <a class="dropdown-item" href="<?= e(route('locations-export', ['parent_id' => $parent_id, 'format' => 'geojson'])) ?>">
112                    geoJSON
113                </a>
114            </div>
115            <a class="btn btn-primary" href="<?= e(route('locations-import', ['parent_id' => $parent_id])) ?>">
116                <?= view('icons/upload') ?>
117                <?= /* I18N: A button label. */
118                I18N::translate('import file') ?>
119            </a>
120        </td>
121    </tr>
122    </tfoot>
123</table>
124
125<form method="POST" action="<?= e(route('locations-import-from-tree')) ?>">
126    <?= csrf_field() ?>
127
128    <div class="form-group row">
129        <label class="form-control-plaintext col-sm-4" for="ged">
130            <?= I18N::translate('Import all places from a family tree') ?>
131        </label>
132        <div class="col-sm-6">
133            <?= Bootstrap4::select(
134                Tree::getNameList(),
135                '',
136                ['id' => 'ged', 'name' => 'ged']
137            ) ?>
138        </div>
139        <div class="col-sm-2">
140            <button type="submit" class="btn btn-primary">
141                <?= view('icons/upload') ?>
142                <?= /* I18N: A button label. */
143                I18N::translate('import') ?>
144            </button>
145        </div>
146    </div>
147</form>
148