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