xref: /webtrees/resources/views/admin/trees.phtml (revision 96716c4735cd29561cdf33f324c111f41c544214)
1<?php
2
3use Fisharebest\Webtrees\Auth;
4use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
5use Fisharebest\Webtrees\Http\RequestHandlers\CreateMediaObjectModal;
6use Fisharebest\Webtrees\Http\RequestHandlers\CreateNoteModal;
7use Fisharebest\Webtrees\Http\RequestHandlers\CreateRepositoryModal;
8use Fisharebest\Webtrees\Http\RequestHandlers\CreateSourceModal;
9use Fisharebest\Webtrees\Http\RequestHandlers\CreateSubmitterModal;
10use Fisharebest\Webtrees\Http\RequestHandlers\DeleteTreeAction;
11use Fisharebest\Webtrees\Http\RequestHandlers\ExportGedcomPage;
12use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesLogPage;
13use Fisharebest\Webtrees\Http\RequestHandlers\SelectDefaultTree;
14use Fisharebest\Webtrees\Http\RequestHandlers\UnconnectedPage;
15use Fisharebest\Webtrees\I18N;
16use Fisharebest\Webtrees\Site;
17use Fisharebest\Webtrees\View;
18use Illuminate\Database\Capsule\Manager as DB;
19
20?>
21
22<?php if (!empty($all_trees)): ?>
23    <?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?>
24<?php endif ?>
25
26<h1><?= $title ?></h1>
27
28<?php if (empty($all_trees)) : ?>
29    <div class="alert alert-info">
30        <?= I18N::translate('You need to create a family tree.') ?>
31    </div>
32<?php endif ?>
33
34<div id="accordion" role="tablist" aria-multiselectable="true">
35    <?php foreach ($all_trees as $managed_tree) : ?>
36        <?php if (Auth::isManager($managed_tree)) : ?>
37            <div class="card">
38                <div class="card-header" role="tab" id="card-tree-header-<?= $managed_tree->id() ?>">
39                    <h2 class="mb-0">
40                        <?= view('icons/tree') ?>
41                        <a data-toggle="collapse" data-parent="#accordion" href="#card-tree-content-<?= $managed_tree->id() ?>" <?= $managed_tree == $tree || $managed_tree->getPreference('imported') === '0' ? 'aria-expanded="true"' : '' ?> aria-controls="card-tree-content-<?= $managed_tree->id() ?>">
42                            <?= e($managed_tree->name()) ?><?= e($managed_tree->title()) ?>
43                        </a>
44                    </h2>
45                </div>
46                <div id="card-tree-content-<?= $managed_tree->id() ?>" class="collapse<?= $managed_tree == $tree || $managed_tree->getPreference('imported') === '0' ? ' show' : '' ?>" role="tabpanel" aria-labelledby="panel-tree-header-<?= $managed_tree->id() ?>">
47                    <div class="card-body">
48                        <?php $importing = DB::table('gedcom_chunk')->where('gedcom_id', '=', $managed_tree->id())->where('imported', '=', 0)->exists() ?>
49                        <?php if ($importing) : ?>
50                            <div id="import<?= $managed_tree->id() ?>" class="col-xs-12">
51                                <div class="progress">
52                                    <?= I18N::translate('Calculating…') ?>
53                                </div>
54                            </div>
55                            <?php View::push('javascript'); ?>
56                                <script>
57                                    $("#import<?= $managed_tree->id() ?>").load("<?= route('import', ['tree' => $managed_tree->name()]) ?>", {});
58                                </script>
59                                <?php View::endpush() ?>
60                            <?php endif ?>
61                        <div class="row<?= $importing ? ' d-none' : '' ?>" id="actions<?= $managed_tree->id() ?>">
62                            <div class="col-sm-6 col-md-3">
63                                <h3>
64                                    <?= I18N::translate('Family tree') ?>
65                                </h3>
66                                <ul class="fa-ul">
67                                    <li>
68                                        <span class="fa-li"><?= view('icons/tree') ?></span>
69                                        <a href="<?= e(route('tree-page', ['tree' => $managed_tree->name()])) ?>">
70                                            <?= I18N::translate('Home page') ?>
71                                        </a>
72                                    </li>
73                                </ul>
74                                <ul class="fa-ul">
75                                    <!-- PREFERENCES -->
76                                    <li>
77                                        <span class="fa-li"><?= view('icons/preferences') ?></span>
78                                        <a href="<?= e(route('admin-trees-preferences', ['tree' => $managed_tree->name()])) ?>">
79                                            <?= I18N::translate('Preferences') ?>
80                                            <span class="sr-only">
81                                        <?= e($managed_tree->title()) ?>
82                                    </span>
83                                        </a>
84                                    </li>
85                                    <!-- PRIVACY -->
86                                    <li>
87                                        <span class="fa-li"><?= view('icons/lock') ?></span>
88                                        <a href="<?= e(route('tree-privacy', ['tree' => $managed_tree->name()])) ?>">
89                                            <?= I18N::translate('Privacy') ?>
90                                            <span class="sr-only">
91                                        <?= e($managed_tree->title()) ?>
92                                    </span>
93                                        </a>
94                                    </li>
95                                    <!-- DELETE -->
96                                    <?php if (count($all_trees) > 1 && Auth::isAdmin()) : ?>
97                                        <li>
98                                            <span class="fa-li"><?= view('icons/delete') ?></span>
99                                            <a href="#" data-post-url="<?= e(route(DeleteTreeAction::class, ['tree' => $managed_tree->name()])) ?>" data-confirm="<?= I18N::translate('Are you sure you want to delete “%s”?', e($managed_tree->title())) ?>">
100                                                <?= I18N::translate('Delete') ?>
101                                            </a>
102                                        </li>
103                                    <?php endif ?>
104
105                                    <!-- SET AS DEFAULT -->
106                                    <?php if (count($all_trees) > 1 && Auth::isAdmin()) : ?>
107                                        <li>
108                                            <span class="fa-li"><?= view('icons/favorite') ?></span>
109                                            <?php if ($managed_tree->name() === Site::getPreference('DEFAULT_GEDCOM')) : ?>
110                                                <?= I18N::translate('Default family tree') ?>
111                                            <?php else : ?>
112                                                <a href="#" onclick="document.defaultform<?= $managed_tree->id() ?>.submit();">
113                                                    <?= I18N::translate('Set as default') ?>
114                                                    <span class="sr-only"><?= e($managed_tree->title()) ?></span>
115                                                </a>
116                                                <form method="post" action="<?= route(SelectDefaultTree::class, ['tree' => $managed_tree->name()]) ?>" name="defaultform<?= $managed_tree->id() ?>">
117                                                    <?= csrf_field() ?>
118                                                    <!-- A11Y - forms need submit buttons, but they look ugly here -->
119                                                    <button class="sr-only" type="submit">
120                                                        <?= I18N::translate('Set as default') ?>
121                                                    </button>
122                                                </form>
123                                            <?php endif ?>
124                                        </li>
125                                    <?php endif ?>
126                                </ul>
127                            </div>
128                            <div class="col-sm-6 col-md-3">
129                                <h3>
130                                    <?= /* I18N: Individuals, sources, dates, places, etc. */
131                                    I18N::translate('Genealogy data') ?>
132                                </h3>
133                                <ul class="fa-ul">
134                                    <!-- FIND DUPLICATES -->
135                                    <li>
136                                        <span class="fa-li"><?= view('icons/copy') ?></span>
137                                        <a href="<?= e(route('admin-trees-duplicates', ['tree' => $managed_tree->name()])) ?>">
138                                            <?= I18N::translate('Find duplicates') ?>
139                                            <span class="sr-only">
140                                              <?= e($managed_tree->title()) ?>
141                                            </span>
142                                        </a>
143                                    </li>
144                                    <!-- MERGE -->
145                                    <li>
146                                        <span class="fa-li"><?= view('icons/merge') ?></span>
147                                        <a href="<?= e(route('merge-records', ['tree' => $managed_tree->name()])) ?>">
148                                            <?= I18N::translate('Merge records') ?>
149                                            <span class="sr-only">
150                                                <?= e($managed_tree->title()) ?>
151                                          </span>
152                                        </a>
153                                    </li>
154                                    <!-- UPDATE PLACE NAMES -->
155                                    <li>
156                                        <span class="fa-li"><?= view('icons/location') ?></span>
157                                        <a href="<?= e(route('admin-trees-places', ['tree' => $managed_tree->name()])) ?>">
158                                            <?= I18N::translate('Update place names') ?>
159                                            <span class="sr-only">
160                                                <?= e($managed_tree->title()) ?>
161                                            </span>
162                                        </a>
163                                    </li>
164                                    <!-- CHECK FOR ERRORS -->
165                                    <li>
166                                        <span class="fa-li"><?= view('icons/warning') ?></span>
167                                        <a href="<?= e(route('admin-trees-check', ['tree' => $managed_tree->name()])) ?>">
168                                            <?= I18N::translate('Check for errors') ?>
169                                            <span class="sr-only">
170                                                <?= e($managed_tree->title()) ?>
171                                            </span>
172                                        </a>
173                                    </li>
174                                    <!-- UNCONNECTED INDIVIDUALS -->
175                                    <li>
176                                        <span class="fa-li"><?= view('icons/unlink') ?></span>
177                                        <a href="<?= e(route(UnconnectedPage::class, ['tree' => $managed_tree->name()])) ?>">
178                                            <?= I18N::translate('Find unrelated individuals') ?>
179                                            <span class="sr-only">
180                                                <?= e($managed_tree->title()) ?>
181                                            </span>
182                                        </a>
183                                    </li>
184                                    <!-- RENUMBER -->
185                                    <li>
186                                        <span class="fa-li"><?= view('icons/sort') ?></span>
187                                        <a href="<?= e(route('admin-trees-renumber', ['tree' => $managed_tree->name()])) ?>">
188                                            <?= I18N::translate('Renumber') ?>
189                                            <span class="sr-only">
190                                        <?= e($managed_tree->title()) ?>
191                                    </span>
192                                        </a>
193                                    </li>
194                                    <!-- CHANGES -->
195                                    <li>
196                                        <span class="fa-li"><?= view('icons/edit') ?></span>
197                                        <a href="<?= route(PendingChangesLogPage::class, ['tree' => $managed_tree->name()]) ?>">
198                                            <?= I18N::translate('Changes log') ?>
199                                            <span class="sr-only">
200                                                <?= e($managed_tree->title()) ?>
201                                            </span>
202                                        </a>
203                                    </li>
204                                </ul>
205                            </div>
206                            <div class="clearfix visible-sm-block"></div>
207                            <div class="col-sm-6 col-md-3">
208                                <h3>
209                                    <?= I18N::translate('Add unlinked records') ?>
210                                </h3>
211                                <ul class="fa-ul">
212                                    <!-- UNLINKED INDIVIDUAL -->
213                                    <li>
214                                        <span class="fa-li"><?= view('icons/individual') ?></span>
215                                        <a href="<?= e(route('add-unlinked-individual', ['tree' => $managed_tree->name()])) ?>">
216                                            <?= I18N::translate('Individual') ?>
217                                            <span class="sr-only">
218                                                <?= e($managed_tree->title()) ?>
219                                            </span>
220                                        </a>
221                                    </li>
222                                    <!-- UNLINKED SOURCE -->
223                                    <li>
224                                        <span class="fa-li"><?= view('icons/source') ?></span>
225                                        <a href="#" data-href="<?= e(route(CreateSourceModal::class, ['tree' => $managed_tree->name()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal">
226                                            <?= I18N::translate('Source') ?>
227                                            <span class="sr-only">
228                                                <?= e($managed_tree->title()) ?>
229                                            </span>
230                                        </a>
231                                    </li>
232                                    <!-- UNLINKED REPOSITORY -->
233                                    <li>
234                                        <span class="fa-li"><?= view('icons/repository') ?></span>
235                                        <a href="#" data-href="<?= e(route(CreateRepositoryModal::class, ['tree' => $managed_tree->name()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal">
236                                            <?= I18N::translate('Repository') ?>
237                                            <span class="sr-only">
238                                                <?= e($managed_tree->title()) ?>
239                                            </span>
240                                        </a>
241                                    </li>
242                                    <!-- UNLINKED MEDIA OBJECT -->
243                                    <li>
244                                        <span class="fa-li"><?= view('icons/media') ?></span>
245                                        <a href="#" data-href="<?= e(route(CreateMediaObjectModal::class, ['tree' => $managed_tree->name()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal">
246
247                                            <?= I18N::translate('Media object') ?>
248                                            <span class="sr-only">
249                                                <?= e($managed_tree->title()) ?>
250                                            </span>
251                                        </a>
252                                    </li>
253                                    <!-- UNLINKED NOTE -->
254                                    <li>
255                                        <span class="fa-li"><?= view('icons/note') ?></span>
256                                        <a href="#" data-href="<?= e(route(CreateNoteModal::class, ['tree' => $managed_tree->name()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal">
257                                            <span class="sr-only">
258                                                <?= e($managed_tree->title()) ?>
259                                            </span>
260                                            <?= I18N::translate('Shared note') ?>
261                                        </a>
262                                    </li>
263                                    <!-- UNLINKED SUBMITTER -->
264                                    <li>
265                                        <span class="fa-li"><?= view('icons/submitter') ?></span>
266                                        <a href="#" data-href="<?= e(route(CreateSubmitterModal::class, ['tree' => $managed_tree->name()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal">
267                                            <span class="sr-only">
268                                                <?= e($managed_tree->title()) ?>
269                                            </span>
270                                            <?= I18N::translate('Submitter') ?>
271                                        </a>
272                                    </li>
273                                </ul>
274                            </div>
275                            <div class="col-sm-6 col-md-3">
276                                <h3>
277                                    <?= I18N::translate('GEDCOM file') ?>
278                                </h3>
279                                <ul class="fa-ul">
280                                    <!-- DOWNLOAD/Export -->
281                                    <li>
282                                        <span class="fa-li"><?= view('icons/download') ?></span>
283                                        <a href="<?= e(route(ExportGedcomPage::class, ['tree' => $managed_tree->name()])) ?>">
284                                            <?= I18N::translate('Export') ?>
285                                            <span class="sr-only">
286                                        <?= e($managed_tree->title()) ?>
287                                    </span>
288                                        </a>
289                                    </li>
290                                    <!-- UPLOAD/IMPORT -->
291                                    <li>
292                                        <span class="fa-li"><?= view('icons/upload') ?></span>
293                                        <a href="<?= e(route('admin-trees-import', ['tree' => $managed_tree->name()])) ?>">
294                                            <?= I18N::translate('Import') ?>
295                                            <span class="sr-only">
296                                        <?= e($managed_tree->title()) ?>
297                                    </span>
298                                        </a>
299                                    </li>
300                                </ul>
301                            </div>
302                        </div>
303                    </div>
304                </div>
305            </div>
306        <?php endif ?>
307    <?php endforeach ?>
308
309    <!-- BULK LOAD/SYNCHRONISE GEDCOM FILES -->
310    <?php if (count($gedcom_files) >= $multiple_tree_threshold) : ?>
311        <div class="card">
312            <div class="card-header" id="card-tree-create-header">
313                <h2 class="mb-0">
314                    <?= view('icons/sync') ?>
315                    <a data-toggle="collapse" data-parent="#accordion" href="#synchronize-gedcom-files">
316                        <?= I18N::translate('Synchronize family trees with GEDCOM files') ?>
317                    </a>
318                </h2>
319            </div>
320
321            <div id="synchronize-gedcom-files" class="panel-collapse collapse">
322                <div class="card-body">
323                    <p>
324                        <?= I18N::translate('Create, update, and delete a family tree for every GEDCOM file in the data folder.') ?>
325                    </p>
326                    <form method="post" action="<?= e(route('admin-trees-sync')) ?>" class="form form-horizontal">
327                        <?= csrf_field() ?>
328                        <button type="submit" class="btn btn-danger">
329                            <?= view('icons/save') ?>
330                            <?= /* I18N: A button label. */
331                            I18N::translate('continue') ?>
332                        </button>
333                        <p class="small text-muted">
334                            <?= I18N::translate('Caution! This may take a long time. Be patient.') ?>
335                        </p>
336                    </form>
337                </div>
338            </div>
339        </div>
340    <?php endif ?>
341</div>
342
343<?= view('modals/ajax') ?>
344