xref: /webtrees/resources/views/admin/locations.phtml (revision 0e7a2d236900b65ce66b14620acab98473f496e5)
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
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            <td dir="ltr">
35                <?= ($place->pl_lati === null) ? FontAwesome::decorativeIcon('warning') : strtr($place->pl_lati, ['N' => '', 'S' => '-', ',' => '.']) ?>
36            </td>
37            <td dir="ltr">
38                <?= ($place->pl_long === null) ? FontAwesome::decorativeIcon('warning') : strtr($place->pl_long, ['E' => '', 'W' => '-', ',' => '.']) ?>
39            </td>
40            <td>
41                <?= $place->pl_long === null ? FontAwesome::decorativeIcon('warning') : $place->pl_zoom ?>
42            </td>
43            <td>
44                <?php if (is_file(WT_MODULES_DIR . 'openstreetmap' . '/' . $place->pl_icon)) : ?>
45                    <img src="<?= e(WT_MODULES_DIR . 'openstreetmap' . '/' . $place->pl_icon) ?>" width="25" height="15" alt="<?= I18N::translate("Flag of %s", $place->pl_place) ?>">
46                <?php endif ?>
47            </td>
48            <td>
49                <?= 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']) ?>
50            </td>
51            <td>
52                <?php if ($place->child_count === 0) : ?>
53                    <form method="POST" action="<?= e(route('map-data-delete', ['parent_id' => $parent_id, 'place_id' => $place->pl_id])) ?>"
54                          data-confirm="<?= I18N::translate('Remove this location?') ?>"
55                          onsubmit="return confirm(this.dataset.confirm)">
56                        <?= csrf_field() ?>
57                        <button type="submit" class="btn btn-danger">
58                            <?= FontAwesome::semanticIcon('delete', I18N::translate('delete')) ?>
59                        </button>
60                    </form>
61                <?php else : ?>
62                    <button type="button" class="btn btn-danger" disabled>
63                        <?= FontAwesome::decorativeIcon('delete') ?>
64                    </button>
65                <?php endif ?>
66            </td>
67        </tr>
68    <?php endforeach ?>
69    </tbody>
70    <tfoot>
71    <tr>
72        <td colspan="7">
73            <a class="btn btn-primary" href="<?= e(route('map-data', ['parent_id' => $parent_id])) ?>">
74                <?= FontAwesome::decorativeIcon('add') ?>
75                <?= /* I18N: A button label. */
76                I18N::translate('add place') ?>
77            </a>
78            <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton"
79                    data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
80                <?= FontAwesome::decorativeIcon('download') ?>
81                <?= /* I18N: A button label. */
82                I18N::translate('export file') ?>
83            </button>
84            <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
85                <a class="dropdown-item" href="<?= e(route('locations-export', ['parent_id' => $parent_id, 'format' => 'csv'])) ?>">
86                    csv
87                </a>
88                <a class="dropdown-item" href="<?= e(route('locations-export', ['parent_id' => $parent_id, 'format' => 'geojson'])) ?>">
89                    geoJSON
90                </a>
91            </div>
92            <a class="btn btn-primary" href="<?= e(route('locations-import', ['parent_id' => $parent_id])) ?>">
93                <?= FontAwesome::decorativeIcon('upload') ?>
94                <?= /* I18N: A button label. */
95                I18N::translate('import file') ?>
96            </a>
97        </td>
98    </tr>
99    </tfoot>
100</table>
101
102<form method="POST" action="<?= e(route('locations-import-from-tree')) ?>">
103    <?= csrf_field() ?>
104
105    <div class="form-group row">
106        <label class="form-control-plaintext col-sm-4" for="ged">
107            <?= I18N::translate('Import all places from a family tree') ?>
108        </label>
109        <div class="col-sm-6">
110            <?= Bootstrap4::select(
111                Tree::getNameList(),
112                '',
113                ['id' => 'ged', 'name' => 'ged']
114            ) ?>
115        </div>
116        <div class="col-sm-2">
117            <button type="submit" class="btn btn-primary">
118                <?= view('icons/upload') ?>
119                <?= /* I18N: A button label. */
120                I18N::translate('import') ?>
121            </button>
122        </div>
123    </div>
124</form>
125