xref: /webtrees/resources/views/admin/trees.phtml (revision 2b47189bb11817638683564e5058e5019f413146)
1<?php use Fisharebest\Webtrees\Auth;
2use Fisharebest\Webtrees\I18N;
3use Fisharebest\Webtrees\Site;
4use Fisharebest\Webtrees\View;
5use Illuminate\Database\Capsule\Manager as DB; ?>
6<?php ?>
7<?php ?>
8<?php ?>
9<?php ?>
10
11<?php if (!empty($all_trees)): ?>
12    <?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), $title]]) ?>
13<?php endif ?>
14
15<h1><?= $title ?></h1>
16
17<?php if (empty($all_trees)) : ?>
18    <div class="alert alert-info">
19        <?= I18N::translate('You need to create a family tree.') ?>
20    </div>
21<?php endif ?>
22
23<div id="accordion" role="tablist" aria-multiselectable="true">
24    <?php foreach ($all_trees as $managed_tree) : ?>
25        <?php if (Auth::isManager($managed_tree)) : ?>
26            <div class="card">
27                <div class="card-header" role="tab" id="card-tree-header-<?= $managed_tree->id() ?>">
28                    <h2 class="mb-0">
29                        <?= view('icons/tree') ?>
30                        <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() ?>">
31                            <?= e($managed_tree->name()) ?><?= e($managed_tree->title()) ?>
32                        </a>
33                    </h2>
34                </div>
35                <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() ?>">
36                    <div class="card-body">
37                        <?php $importing = DB::table('gedcom_chunk')->where('gedcom_id', '=', $managed_tree->id())->where('imported', '=', 0)->exists() ?>
38                        <?php if ($importing) : ?>
39                            <div id="import<?= $managed_tree->id() ?>" class="col-xs-12">
40                                <div class="progress">
41                                    <?= I18N::translate('Calculating…') ?>
42                                </div>
43                            </div>
44                            <?php View::push('javascript'); ?>
45                                <script>
46                                    $("#import<?= $managed_tree->id() ?>").load("<?= route('import', ['ged' => $managed_tree->name()]) ?>", {});
47                                </script>
48                                <?php View::endpush() ?>
49                            <?php endif ?>
50                        <div class="row<?= $importing ? ' d-none' : '' ?>" id="actions<?= $managed_tree->id() ?>">
51                            <div class="col-sm-6 col-md-3">
52                                <h3>
53                                    <a href="<?= e(route('tree-page', ['ged' => $managed_tree->name()])) ?>">
54                                        <?= I18N::translate('Family tree') ?>
55                                    </a>
56                                </h3>
57                                <ul class="fa-ul">
58                                    <!-- PREFERENCES -->
59                                    <li>
60                                        <span class="fa-li"><?= view('icons/preferences') ?></span>
61                                        <a href="<?= e(route('admin-trees-preferences', ['ged' => $managed_tree->name()])) ?>">
62                                            <?= I18N::translate('Preferences') ?>
63                                            <span class="sr-only">
64                                        <?= e($managed_tree->title()) ?>
65                                    </span>
66                                        </a>
67                                    </li>
68                                    <!-- PRIVACY -->
69                                    <li>
70                                        <span class="fa-li"><?= view('icons/lock') ?></span>
71                                        <a href="<?= e(route('tree-privacy', ['ged' => $managed_tree->name()])) ?>">
72                                            <?= I18N::translate('Privacy') ?>
73                                            <span class="sr-only">
74                                        <?= e($managed_tree->title()) ?>
75                                    </span>
76                                        </a>
77                                    </li>
78                                    <!-- HOME PAGE BLOCKS-->
79                                    <li>
80                                        <span class="fa-li"><?= view('icons/block') ?></span>
81                                        <a href="<?= e(route('tree-page-edit', ['ged' => $managed_tree->name()])) ?>">
82                                            <?= I18N::translate('Change the “Home page” blocks') ?>
83                                            <span class="sr-only">
84                                        <?= e($managed_tree->title()) ?>
85                                    </span>
86                                        </a>
87                                    </li>
88                                    <!-- DELETE -->
89                                    <?php if (count($all_trees) > 1 && Auth::isAdmin()) : ?>
90                                        <li>
91                                            <span class="fa-li"><?= view('icons/delete') ?></span>
92                                            <a href="#" data-confirm="<?= I18N::translate('Are you sure you want to delete “%s”?', e($managed_tree->title())) ?>" onclick="if (confirm(this.dataset.confirm)) { document.delete_form<?= $managed_tree->id() ?>.submit(); } return false;">
93                                                <?= I18N::translate('Delete') ?>
94                                                <span class="sr-only">
95                                                <?= e($managed_tree->title()) ?>
96                                            </span>
97                                            </a>
98                                            <form name="delete_form<?= $managed_tree->id() ?>" method="post" action="<?= route('admin-trees-delete', ['ged' => $managed_tree->name()]) ?>">
99                                                <?= csrf_field() ?>
100                                                <!-- A11Y - forms need submit buttons, but they look ugly here -->
101                                                <button class="sr-only" data-confirm="<?= I18N::translate('Are you sure you want to delete “%s”?', e($managed_tree->title())) ?>" onclick="return confirm(this.dataset.confirm)" type="submit">
102                                                    <?= I18N::translate('Delete') ?>
103                                                </button>
104                                            </form>
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 name="defaultform<?= $managed_tree->id() ?>" method="post" action="<?= route('admin-trees-default', ['ged' => $managed_tree->name()]) ?>">
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', ['ged' => $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('merge-records', ['ged' => $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('admin-trees-places', ['ged' => $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', ['ged' => $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('admin-trees-unconnected', ['ged' => $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', ['ged' => $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('admin-changes-log', ['ged' => $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', ['ged' => $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('create-source', ['ged' => $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('create-repository', ['ged' => $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('create-media-object', ['ged' => $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('create-note-object', ['ged' => $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('create-submitter', ['ged' => $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('admin-trees-export', ['ged' => $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', ['ged' => $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    <?php if (Auth::isAdmin()) : ?>
313        <div class="card">
314            <div class="card-header" id="card-tree-create-header">
315                <h2 class="mb-0">
316                    <?= view('icons/add') ?>
317                    <a data-toggle="collapse" data-parent="#accordion" href="#card-tree-create-content" aria-controls="card-tree-create-content">
318                        <?= I18N::translate('Create a family tree') ?>
319                    </a>
320                </h2>
321            </div>
322            <div id="card-tree-create-content" class="collapse<?= empty($all_trees) ? ' show' : '' ?>" role="tabpanel" aria-labelledby="card-tree-create-header">
323                <div class="card-body">
324                    <form class="form-horizontal" method="post" action="<?= e(route('admin-trees-create')) ?>">
325                        <?= csrf_field() ?>
326                        <div class="row form-group">
327                            <label for="tree_title" class="col-sm-2 col-form-label">
328                                <?= I18N::translate('Family tree title') ?>
329                            </label>
330                            <div class="col-sm-10">
331                                <input class="form-control" id="tree_title" maxlength="255" name="tree_title" required type="text" placeholder="<?= $default_tree_title ?>">
332                            </div>
333                        </div>
334                        <div class="row form-group">
335                            <label for="tree_name" class="col-sm-2 col-form-label">
336                                <?= I18N::translate('URL') ?>
337                            </label>
338                            <div class="col-sm-10">
339                                <div class="input-group" dir="ltr">
340                                    <div class="input-group-prepend">
341                                        <span class="input-group-text" dir="ltr">
342                                            <?= e($base_url) ?>?ged=
343                                        </span>
344                                    </div>
345                                    <input class="form-control" id="tree_name" maxlength="31" name="tree_name" pattern="[^&lt;&gt;&amp;&quot;#^$*?{}()\[\]/\\]*" required type="text" value="<?= $default_tree_name ?>" dir="ltr">
346                                </div>
347                                <p class="small text-muted">
348                                    <?= I18N::translate('Avoid spaces and punctuation. A family name might be a good choice.') ?>
349                                </p>
350                            </div>
351                        </div>
352                        <div class="row form-group">
353                            <div class="offset-sm-2 col-sm-10">
354                                <button type="submit" class="btn btn-primary">
355                                    <?= view('icons/save') ?>
356                                    <?= /* I18N: A button label. */
357                                    I18N::translate('create') ?>
358                                </button>
359                                <p class="small text-muted">
360                                    <?= I18N::translate('After creating the family tree, you will be able to import data from a GEDCOM file.') ?>
361                                </p>
362                            </div>
363                        </div>
364                    </form>
365                </div>
366            </div>
367        </div>
368    <?php endif ?>
369
370    <!-- BULK LOAD/SYNCHRONISE GEDCOM FILES -->
371    <?php if (count($gedcom_files) >= $multiple_tree_threshold) : ?>
372        <div class="card">
373            <div class="card-header" id="card-tree-create-header">
374                <h2 class="mb-0">
375                    <?= view('icons/sync') ?>
376                    <a data-toggle="collapse" data-parent="#accordion" href="#synchronize-gedcom-files">
377                        <?= I18N::translate('Synchronize family trees with GEDCOM files') ?>
378                    </a>
379                </h2>
380            </div>
381
382            <div id="synchronize-gedcom-files" class="panel-collapse collapse">
383                <div class="card-body">
384                    <p>
385                        <?= I18N::translate('Create, update, and delete a family tree for every GEDCOM file in the data folder.') ?>
386                    </p>
387                    <form method="post" class="form form-horizontal" action="<?= e(route('admin-trees-sync', ['ged' => $tree->name()])) ?>">
388                        <?= csrf_field() ?>
389                        <button type="submit" class="btn btn-danger">
390                            <?= view('icons/save') ?>
391                            <?= /* I18N: A button label. */
392                            I18N::translate('continue') ?>
393                        </button>
394                        <p class="small text-muted">
395                            <?= I18N::translate('Caution! This may take a long time. Be patient.') ?>
396                        </p>
397                    </form>
398                </div>
399            </div>
400        </div>
401    <?php endif ?>
402</div>
403
404<?= view('modals/ajax') ?>
405