xref: /webtrees/resources/views/admin/trees-check.phtml (revision bd29d468ac3a5ed7a23d7dd8f300504dda83fc72)
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<object> $errors
11 * @var array<object> $infos
12 * @var string        $more_url
13 * @var string        $title
14 * @var Tree          $tree
15 * @var array<object> $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            <div class="row">
32                <div class="col-auto"><?= $error->message ?></div>
33
34                <?php if ($error->tag !== '') : ?>
35                    <div class="col-auto ms-auto">
36                        <button type="button" class="btn btn-link p-0 border-0">
37                            <?= I18N::translate('Hide these errors') ?><?= e($error->tag) ?>
38                        </button>
39                    </div>
40                <?php endif ?>
41            </div>
42        </li>
43    <?php endforeach ?>
44
45    <?php foreach ($warnings as $warning) : ?>
46        <li class="list-group-item list-group-item-warning" data-wt-tag="<?= e($warning->tag) ?>">
47            <div class="row">
48                <div class="col-auto"><?= $warning->message ?></div>
49
50                <?php if ($warning->tag !== '') : ?>
51                    <div class="col-auto ms-auto">
52                        <button type="button" class="btn btn-link p-0 border-0">
53                            <?= I18N::translate('Hide these errors') ?><?= e($warning->tag) ?>
54                        </button>
55                    </div>
56                <?php endif ?>
57            </div>
58        </li>
59    <?php endforeach ?>
60
61    <?php foreach ($infos as $info) : ?>
62        <li class="list-group-item list-group-item-info" data-wt-tag="<?= e($info->tag) ?>">
63            <div class="row">
64                <div class="col-auto"><?= $info->message ?></div>
65
66                <?php if ($info->tag !== '') : ?>
67                    <div class="col-auto">
68                        <button type="button" class="btn btn-link p-0 border-0">
69                            <?= I18N::translate('Hide these errors') ?><?= e($info->tag) ?>
70                        </button>
71                    </div>
72                <?php endif ?>
73            </div>
74        </li>
75    <?php endforeach ?>
76
77    <?php if ($errors === [] && $warnings === []) : ?>
78        <li class="list-group-item"><?= I18N::translate('No errors have been found.') ?></li>
79    <?php endif ?>
80</ul>
81
82<?php if ($more_url !== '') : ?>
83    <p>
84        <?= I18N::translate('The server’s time limit has been reached.') ?>
85        <a class="btn btn-primary" href="<?= e($more_url) ?>">
86            <?= I18N::translate('show more') ?>
87        </a>
88    </p>
89<?php endif ?>
90
91<?php View::push('javascript') ?>
92<script>
93  'use strict';
94
95  document.querySelector('ul.list-group').addEventListener('click', (event) => {
96    if (event.target.matches('button')) {
97      event.preventDefault();
98      event.stopPropagation();
99
100      // Much quicker to hide elements than remove them.
101      document
102        .querySelectorAll('[data-wt-tag=' + CSS.escape(event.target.closest('li').dataset.wtTag) + ']')
103        .forEach((element) => { element.style.display = 'none'; });
104    }
105  });
106</script>
107<?php View::endpush() ?>
108