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