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