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