xref: /webtrees/resources/views/admin/trees-check.phtml (revision 44f4e696ded7e52c5d9b98999b1061282427687d)
1<?php
2
3use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
4use Fisharebest\Webtrees\Http\RequestHandlers\ManageTrees;
5use Fisharebest\Webtrees\I18N;
6use Fisharebest\Webtrees\Tree;
7use Fisharebest\Webtrees\View;
8
9/**
10 * @var array<string> $errors
11 * @var array<string> $infos
12 * @var string        $more_url
13 * @var string        $title
14 * @var Tree          $tree
15 * @var array<string> $warnings
16 */
17
18?>
19
20<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), route(ManageTrees::class, ['tree' => $tree->name()]) => I18N::translate('Manage family trees'), $title]]) ?>
21
22<h1><?= $title ?></h1>
23
24<h2>
25    <?= I18N::translate('GEDCOM errors') ?>
26</h2>
27
28<ul class="list-group">
29    <?php foreach ($errors as $error) : ?>
30        <li class="list-group-item list-group-item-danger" data-wt-tag="<?= e($error->tag) ?>">
31            <?php if ($error->tag !== '') : ?>
32                <button type="button" class="btn btn-sm btn-link float-end" title="<?= e($error->tag) ?>">
33                    <?= I18N::translate('Hide these errors') ?>
34                </button>
35            <?php endif ?>
36
37            <?= $error->message ?>
38        </li>
39    <?php endforeach ?>
40
41    <?php foreach ($warnings as $warning) : ?>
42        <li class="list-group-item list-group-item-warning" data-wt-tag="<?= e($warning->tag) ?>">
43            <?php if ($error->tag !== '') : ?>
44            <button type="button" class="btn btn-sm btn-link float-end" title="<?= e($warning->tag) ?>">
45                <?= I18N::translate('Hide these errors') ?>
46            </button>
47            <?php endif ?>
48
49            <?= $warning->message ?>
50        </li>
51    <?php endforeach ?>
52
53    <?php foreach ($infos as $info) : ?>
54        <li class="list-group-item list-group-item-info" data-wt-tag="<?= e($info->tag) ?>">
55            <?php if ($info->tag !== '') : ?>
56            <button type="button" class="btn btn-sm btn-link float-end" title="<?= e($info->tag) ?>">
57                <?= I18N::translate('Hide these errors') ?>
58            </button>
59            <?php endif ?>
60
61            <?= $info->message ?>
62        </li>
63    <?php endforeach ?>
64
65    <?php if ($errors === [] && $warnings === []) : ?>
66        <li class="list-group-item"><?= I18N::translate('No errors have been found.') ?></li>
67    <?php endif ?>
68</ul>
69
70<?php if ($more_url !== '') : ?>
71    <p>
72        <?= I18N::translate('The server’s time limit has been reached.') ?>
73        <a class="btn btn-primary" href="<?= e($more_url) ?>">
74            <?= I18N::translate('show more') ?>
75        </a>
76    </p>
77<?php endif ?>
78
79<?php View::push('javascript') ?>
80<script>
81  'use strict';
82
83  document.querySelector('ul.list-group').addEventListener('click', (event) => {
84    if (event.target.matches('button')) {
85      event.preventDefault();
86      event.stopPropagation();
87
88      // Much quicker to hide elements than remove them.
89      document
90        .querySelectorAll('[data-wt-tag=' + CSS.escape(event.target.closest('li').dataset.wtTag) + ']')
91        .forEach((element) => { element.style.display = 'none'; });
92    }
93  });
94</script>
95<?php View::endpush() ?>
96