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