xref: /webtrees/resources/views/admin/trees.phtml (revision eb7fd1955daa5bdd6e100b0a93366d3ed1fae2d6)
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\DataFixChoose;
11use Fisharebest\Webtrees\Http\RequestHandlers\DeleteTreeAction;
12use Fisharebest\Webtrees\Http\RequestHandlers\ExportGedcomPage;
13use Fisharebest\Webtrees\Http\RequestHandlers\MergeRecordsPage;
14use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesLogPage;
15use Fisharebest\Webtrees\Http\RequestHandlers\SelectDefaultTree;
16use Fisharebest\Webtrees\Http\RequestHandlers\TreePage;
17use Fisharebest\Webtrees\Http\RequestHandlers\UnconnectedPage;
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                                    <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
56                                        <?= I18N::translate('Calculating…') ?>
57                                    </div>
58                                </div>
59                            </div>
60                            <?php View::push('javascript'); ?>
61                                <script>
62                                    $("#import<?= $managed_tree->id() ?>").load("<?= route('import', ['tree' => $managed_tree->name()]) ?>", {});
63                                </script>
64                                <?php View::endpush() ?>
65                        <?php endif ?>
66                        <div class="row<?= $importing ? ' d-none' : '' ?>" id="actions<?= $managed_tree->id() ?>">
67                            <div class="col-sm-6 col-md-3">
68                                <h3>
69                                    <?= I18N::translate('Family tree') ?>
70                                </h3>
71                                <ul class="fa-ul">
72                                    <li>
73                                        <span class="fa-li"><?= view('icons/tree') ?></span>
74                                        <a href="<?= e(route(TreePage::class, ['tree' => $managed_tree->name()])) ?>">
75                                            <?= I18N::translate('Home page') ?>
76                                        </a>
77                                    </li>
78                                </ul>
79                                <ul class="fa-ul">
80                                    <!-- PREFERENCES -->
81                                    <li>
82                                        <span class="fa-li"><?= view('icons/preferences') ?></span>
83                                        <a href="<?= e(route('admin-trees-preferences', ['tree' => $managed_tree->name()])) ?>">
84                                            <?= I18N::translate('Preferences') ?>
85                                            <span class="sr-only"><?= e($managed_tree->title()) ?></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"><?= e($managed_tree->title()) ?></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
129                                <ul class="fa-ul">
130                                    <!-- DATA FIXES -->
131                                    <li>
132                                        <span class="fa-li"><?= view('icons/data-fix') ?></span>
133                                        <a href="<?= e(route(DataFixChoose::class, ['tree' => $managed_tree->name()])) ?>">
134                                            <?= I18N::translate('Data fixes') ?>
135                                            <span class="sr-only"><?= e($managed_tree->title()) ?></span>
136                                        </a>
137                                    </li>
138                                </ul>
139                            </div>
140                            <div class="col-sm-6 col-md-3">
141                                <h3>
142                                    <?= /* I18N: Individuals, sources, dates, places, etc. */
143                                    I18N::translate('Genealogy data') ?>
144                                </h3>
145                                <ul class="fa-ul">
146                                    <!-- FIND DUPLICATES -->
147                                    <li>
148                                        <span class="fa-li"><?= view('icons/copy') ?></span>
149                                        <a href="<?= e(route('admin-trees-duplicates', ['tree' => $managed_tree->name()])) ?>">
150                                            <?= I18N::translate('Find duplicates') ?>
151                                            <span class="sr-only"><?= e($managed_tree->title()) ?></span>
152                                        </a>
153                                    </li>
154                                    <!-- MERGE -->
155                                    <li>
156                                        <span class="fa-li"><?= view('icons/merge') ?></span>
157                                        <a href="<?= e(route(MergeRecordsPage::class, ['tree' => $managed_tree->name()])) ?>">
158                                            <?= I18N::translate('Merge records') ?>
159                                            <span class="sr-only"><?= e($managed_tree->title()) ?></span>
160                                        </a>
161                                    </li>
162                                    <!-- CHECK FOR ERRORS -->
163                                    <li>
164                                        <span class="fa-li"><?= view('icons/warning') ?></span>
165                                        <a href="<?= e(route('admin-trees-check', ['tree' => $managed_tree->name()])) ?>">
166                                            <?= I18N::translate('Check for errors') ?>
167                                            <span class="sr-only"><?= e($managed_tree->title()) ?></span>
168                                        </a>
169                                    </li>
170                                    <!-- UNCONNECTED INDIVIDUALS -->
171                                    <li>
172                                        <span class="fa-li"><?= view('icons/unlink') ?></span>
173                                        <a href="<?= e(route(UnconnectedPage::class, ['tree' => $managed_tree->name()])) ?>">
174                                            <?= I18N::translate('Find unrelated individuals') ?>
175                                            <span class="sr-only"><?= e($managed_tree->title()) ?></span>
176                                        </a>
177                                    </li>
178                                    <!-- RENUMBER -->
179                                    <li>
180                                        <span class="fa-li"><?= view('icons/sort') ?></span>
181                                        <a href="<?= e(route('admin-trees-renumber', ['tree' => $managed_tree->name()])) ?>">
182                                            <?= I18N::translate('Renumber') ?>
183                                            <span class="sr-only">
184                                        <?= e($managed_tree->title()) ?>
185                                    </span>
186                                        </a>
187                                    </li>
188                                    <!-- CHANGES -->
189                                    <li>
190                                        <span class="fa-li"><?= view('icons/edit') ?></span>
191                                        <a href="<?= route(PendingChangesLogPage::class, ['tree' => $managed_tree->name()]) ?>">
192                                            <?= I18N::translate('Changes log') ?>
193                                            <span class="sr-only"><?= e($managed_tree->title()) ?></span>
194                                        </a>
195                                    </li>
196                                </ul>
197                            </div>
198                            <div class="clearfix visible-sm-block"></div>
199                            <div class="col-sm-6 col-md-3">
200                                <h3>
201                                    <?= I18N::translate('Add unlinked records') ?>
202                                </h3>
203                                <ul class="fa-ul">
204                                    <!-- UNLINKED INDIVIDUAL -->
205                                    <li>
206                                        <span class="fa-li"><?= view('icons/individual') ?></span>
207                                        <a href="<?= e(route('add-unlinked-individual', ['tree' => $managed_tree->name()])) ?>">
208                                            <?= I18N::translate('Individual') ?>
209                                            <span class="sr-only"><?= e($managed_tree->title()) ?></span>
210                                        </a>
211                                    </li>
212                                    <!-- UNLINKED SOURCE -->
213                                    <li>
214                                        <span class="fa-li"><?= view('icons/source') ?></span>
215                                        <a href="#" data-href="<?= e(route(CreateSourceModal::class, ['tree' => $managed_tree->name()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal">
216                                            <?= I18N::translate('Source') ?>
217                                            <span class="sr-only"><?= e($managed_tree->title()) ?></span>
218                                        </a>
219                                    </li>
220                                    <!-- UNLINKED REPOSITORY -->
221                                    <li>
222                                        <span class="fa-li"><?= view('icons/repository') ?></span>
223                                        <a href="#" data-href="<?= e(route(CreateRepositoryModal::class, ['tree' => $managed_tree->name()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal">
224                                            <?= I18N::translate('Repository') ?>
225                                            <span class="sr-only"><?= e($managed_tree->title()) ?></span>
226                                        </a>
227                                    </li>
228                                    <!-- UNLINKED MEDIA OBJECT -->
229                                    <li>
230                                        <span class="fa-li"><?= view('icons/media') ?></span>
231                                        <a href="#" data-href="<?= e(route(CreateMediaObjectModal::class, ['tree' => $managed_tree->name()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal">
232
233                                            <?= I18N::translate('Media object') ?>
234                                            <span class="sr-only"><?= e($managed_tree->title()) ?></span>
235                                        </a>
236                                    </li>
237                                    <!-- UNLINKED NOTE -->
238                                    <li>
239                                        <span class="fa-li"><?= view('icons/note') ?></span>
240                                        <a href="#" data-href="<?= e(route(CreateNoteModal::class, ['tree' => $managed_tree->name()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal">
241                                            <?= I18N::translate('Shared note') ?>
242                                            <span class="sr-only"><?= e($managed_tree->title()) ?></span>
243                                        </a>
244                                    </li>
245                                    <!-- UNLINKED SUBMITTER -->
246                                    <li>
247                                        <span class="fa-li"><?= view('icons/submitter') ?></span>
248                                        <a href="#" data-href="<?= e(route(CreateSubmitterModal::class, ['tree' => $managed_tree->name()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal">
249                                            <?= I18N::translate('Submitter') ?>
250                                            <span class="sr-only"><?= e($managed_tree->title()) ?></span>
251                                        </a>
252                                    </li>
253                                </ul>
254                            </div>
255                            <div class="col-sm-6 col-md-3">
256                                <h3>
257                                    <?= I18N::translate('GEDCOM file') ?>
258                                </h3>
259                                <ul class="fa-ul">
260                                    <!-- DOWNLOAD/Export -->
261                                    <li>
262                                        <span class="fa-li"><?= view('icons/download') ?></span>
263                                        <a href="<?= e(route(ExportGedcomPage::class, ['tree' => $managed_tree->name()])) ?>">
264                                            <?= I18N::translate('Export') ?>
265                                            <span class="sr-only"><?= e($managed_tree->title()) ?></span>
266                                        </a>
267                                    </li>
268                                    <!-- UPLOAD/IMPORT -->
269                                    <li>
270                                        <span class="fa-li"><?= view('icons/upload') ?></span>
271                                        <a href="<?= e(route('admin-trees-import', ['tree' => $managed_tree->name()])) ?>">
272                                            <?= I18N::translate('Import') ?>
273                                            <span class="sr-only"><?= e($managed_tree->title()) ?></span>
274                                        </a>
275                                    </li>
276                                </ul>
277                            </div>
278                        </div>
279                    </div>
280                </div>
281            </div>
282        <?php endif ?>
283    <?php endforeach ?>
284
285    <!-- BULK LOAD/SYNCHRONISE GEDCOM FILES -->
286    <?php if (count($gedcom_files) >= $multiple_tree_threshold) : ?>
287        <div class="card">
288            <div class="card-header" id="card-tree-create-header">
289                <h2 class="mb-0">
290                    <?= view('icons/sync') ?>
291                    <a data-toggle="collapse" data-parent="#accordion" href="#synchronize-gedcom-files">
292                        <?= I18N::translate('Synchronize family trees with GEDCOM files') ?>
293                    </a>
294                </h2>
295            </div>
296
297            <div id="synchronize-gedcom-files" class="panel-collapse collapse">
298                <div class="card-body">
299                    <p>
300                        <?= I18N::translate('Create, update, and delete a family tree for every GEDCOM file in the data folder.') ?>
301                    </p>
302                    <form method="post" action="<?= e(route('admin-trees-sync')) ?>" class="form form-horizontal">
303                        <?= csrf_field() ?>
304                        <button type="submit" class="btn btn-danger">
305                            <?= view('icons/save') ?>
306                            <?= /* I18N: A button label. */
307                            I18N::translate('continue') ?>
308                        </button>
309                        <p class="small text-muted">
310                            <?= I18N::translate('Caution! This may take a long time. Be patient.') ?>
311                        </p>
312                    </form>
313                </div>
314            </div>
315        </div>
316    <?php endif ?>
317</div>
318
319<?= view('modals/ajax') ?>
320