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