xref: /webtrees/resources/views/admin/locations.phtml (revision 94e359174878c0eebf102ead543b66cb58a757d0)
1<?php
2
3use Fisharebest\Webtrees\Http\RequestHandlers\MapDataDelete;
4use Fisharebest\Webtrees\Http\RequestHandlers\MapDataList;
5use Fisharebest\Webtrees\I18N;
6use Fisharebest\Webtrees\Module\PlaceHierarchyListModule;
7use Fisharebest\Webtrees\Webtrees;
8
9/**
10 * @var array<stdClass>      $active
11 * @var array<string,string> $breadcrumbs
12 * @var int                  $parent_id
13 * @var array<mixed>         $placelist
14 * @var string               $title
15 */
16
17?>
18
19<?= view('components/breadcrumbs', ['links' => $breadcrumbs]) ?>
20
21<h1><?= $title ?></h1>
22
23<table class="table table-bordered table-striped table-sm table-hover">
24    <thead class="thead-dark">
25        <tr>
26            <th><?= I18N::translate('Place') ?></th>
27            <th><?= I18N::translate('Latitude') ?></th>
28            <th><?= I18N::translate('Longitude') ?></th>
29            <!--
30            <th><?= I18N::translate('Flag') ?> </th>
31            -->
32            <th><?= I18N::translate('Edit') ?></th>
33            <th><?= I18N::translate('Facts and events') ?></th>
34            <th><?= I18N::translate('Delete') ?></th>
35        </tr>
36    </thead>
37
38    <tbody>
39    <?php foreach ($placelist as $place) : ?>
40        <tr>
41            <th scope="row">
42                <a href="<?= e(route(MapDataList::class, ['parent_id' => $place->pl_id])) ?>">
43                    <?= e($place->pl_place) ?>
44                    <?php if ($place->no_coord > 0): ?>
45                        <span class="badge badge-pill badge-secondary">
46                            <?= view('icons/warning') ?>
47                            <?= I18N::number($place->no_coord) ?>
48                            /
49                            <?= I18N::number($place->child_count) ?>
50                        </span>
51                    <?php elseif ($place->child_count > 0): ?>
52                        <span class="badge badge-pill badge-secondary">
53                            <?= I18N::number($place->child_count) ?>
54                        </span>
55                    <?php endif ?>
56                </a>
57            </th>
58
59            <td dir="ltr">
60                <?php if ((string) $place->pl_lati === '') : ?>
61                    <?= view('icons/warning') ?>
62                <?php else : ?>
63                    <?= strtr($place->pl_lati, ['N' => '', 'S' => '-', ',' => '.']) ?>
64                <?php endif ?>
65            </td>
66
67            <td dir="ltr">
68                <?php if ((string) $place->pl_long === '') : ?>
69                    <?= view('icons/warning') ?>
70                <?php else : ?>
71                    <?= strtr($place->pl_long, ['E' => '', 'W' => '-', ',' => '.']) ?>
72                <?php endif ?>
73            </td>
74
75            <!--
76            <td>
77                <?php if (is_file(Webtrees::MODULES_PATH . 'openstreetmap/' . $place->pl_icon)) : ?>
78                    <img src="<?= e(Webtrees::MODULES_PATH . 'openstreetmap/' . $place->pl_icon) ?>" width="25" height="15" alt="<?= I18N::translate('Flag of %s', $place->pl_place) ?>">
79                <?php endif ?>
80            </td>
81            -->
82
83            <td>
84                <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') ?>">
85                    <?= view('icons/edit') ?>
86                    <span class="sr-only">
87                        <?= I18N::translate('Edit') ?>
88                    </span>
89                </a>
90            </td>
91
92            <td>
93                <?php if (array_key_exists($place->pl_place, $active)): ?>
94                    <?php if (count($active[$place->pl_place]) === 1): ?>
95                        <a class="btn btn-link" href="<?= e(route(PlaceHierarchyListModule::class, ['tree' => $active[$place->pl_place][0]->tree_name, 'place_id' => $active[$place->pl_place][0]->p_id, 'action2' => 'hierarchy-e'])) ?>">
96                            <?= e($active[$place->pl_place][0]->tree_title) ?>
97                        </a>
98                    <?php else: ?>
99                        <div class="dropdown">
100                            <a class="btn btn-link dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
101                                <?= I18N::plural('%s tree', '%s trees', count($active[$place->pl_place]), I18N::number(count($active[$place->pl_place]))) ?>
102                            </a>
103
104                            <div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
105                                <?php foreach ($active[$place->pl_place] as $link): ?>
106                                    <a class="dropdown-item" href="<?= e(route(PlaceHierarchyListModule::class, ['tree' => $link->tree_name, 'place_id' => $link->p_id])) ?>">
107                                        <?= e($link->tree_title) ?>
108                                    </a>
109                                <?php endforeach ?>
110                            </div>
111                        </div>
112                    <?php endif ?>
113                <?php endif ?>
114            </td>
115
116            <td>
117                <?php if (!array_key_exists($place->pl_place, $active)): ?>
118                    <form method="post" action="<?= e(route(MapDataDelete::class, ['place_id' => $place->pl_id])) ?>">
119                        <?= csrf_field() ?>
120                        <button type="submit" class="btn btn-danger" aria-label="<?= I18N::translate('delete') ?>" data-confirm="<?= I18N::translate('Remove this location?') ?>">
121                            <?= view('icons/delete') ?>
122                        </button>
123                    </form>
124                <?php endif ?>
125            </td>
126        </tr>
127    <?php endforeach ?>
128    </tbody>
129
130    <tfoot>
131        <tr>
132            <td colspan="7">
133                <a class="btn btn-primary" href="<?= e(route('map-data-edit', ['place_id' => '0', 'parent_id' => $parent_id])) ?>">
134                    <?= view('icons/add') ?>
135                    <?= /* I18N: A button label. */
136                    I18N::translate('add place') ?>
137                </a>
138                <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton"
139                        data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
140                    <?= view('icons/download') ?>
141                    <?= /* I18N: A button label. */
142                    I18N::translate('export file') ?>
143                </button>
144                <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
145                    <a class="dropdown-item" href="<?= e(route('locations-export', ['parent_id' => $parent_id, 'format' => 'csv'])) ?>">
146                        csv
147                    </a>
148                    <a class="dropdown-item" href="<?= e(route('locations-export', ['parent_id' => $parent_id, 'format' => 'geojson'])) ?>">
149                        geoJSON
150                    </a>
151                </div>
152                <a class="btn btn-primary" href="<?= e(route('locations-import', ['parent_id' => $parent_id])) ?>">
153                    <?= view('icons/upload') ?>
154                    <?= /* I18N: A button label. */
155                    I18N::translate('import file') ?>
156                </a>
157            </td>
158        </tr>
159    </tfoot>
160</table>
161