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