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