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