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