xref: /webtrees/resources/views/admin/components.phtml (revision 1afbbc50a65bb73de1d13dc18d669efe80119058)
1<?php
2
3use Fisharebest\Webtrees\Functions\FunctionsEdit;
4use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
5use Fisharebest\Webtrees\I18N;
6use Fisharebest\Webtrees\Module\ModuleConfigInterface;
7use Fisharebest\Webtrees\Module\ModuleCustomInterface;
8use Fisharebest\Webtrees\Module\ModuleExternalUrlInterface;
9use Fisharebest\Webtrees\View;
10
11?>
12
13<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), route('modules') => I18N::translate('All modules'), $title]]) ?>
14
15<h1><?= $title ?></h1>
16
17<p><?= $description ?></p>
18
19<form method="post">
20    <?= csrf_field() ?>
21    <table class="table table-bordered wt-table-menu">
22        <thead>
23            <tr>
24                <th><?= I18N::translate('Module') ?></th>
25                <th class="text-center"><?= I18N::translate('Enabled') ?></th>
26                <?php if ($uses_access) : ?>
27                    <th colspan="2" class="text-center"><?= I18N::translate('Access level') ?></th>
28                <?php endif ?>
29                <?php if ($uses_sorting) : ?>
30                    <th class="text-center"><?= I18N::translate('Move up') ?></th>
31                    <th class="text-center"><?= I18N::translate('Move down') ?></th>
32                <?php endif ?>
33            </tr>
34        </thead>
35
36        <tbody>
37            <?php foreach ($modules as $module_name => $module) : ?>
38                <tr>
39                    <th scope="col">
40                        <input type="hidden" name="order[]" value="<?= e($module->name()) ?>"?>
41                        <span title="<?= e($module->description()) ?>">
42                            <?= $module->title() ?>
43                        </span>
44                        <?php if ($module instanceof ModuleConfigInterface && $module->isEnabled()) : ?>
45                            <a href="<?= e($module->getConfigLink()) ?>" title="<?= I18N::translate('Preferences') ?>">
46                                <?= view('icons/preferences') ?>
47                                <span class="sr-only">
48                                    <?= I18N::translate('Preferences') ?>
49                                </span>
50                            </a>
51                        <?php endif ?>
52                        <?php if ($module instanceof ModuleCustomInterface) : ?>
53                            <?= view('admin/custom-module-info', ['module' => $module]) ?>
54                        <?php endif ?>
55                        <?php if ($module instanceof ModuleExternalUrlInterface) : ?>
56                            <?= view('admin/external-module-info', ['module' => $module]) ?>
57                        <?php endif ?>
58                    </th>
59
60                    <td class="text-center">
61                        <label class="d-block">
62                            <input type="checkbox" name="status-<?= e($module->name()) ?>" id="status-<?= e($module->name()) ?>" <?= $module->isEnabled() ? 'checked' : '' ?>>
63                            <span class="sr-only">
64                                <?= I18N::translate('Enabled') ?>
65                            </span>
66                        </label>
67                    </td>
68
69                    <?php if ($uses_access) : ?>
70                        <td>
71                            <ul class="list-unstyled">
72                                <?php foreach ($access_summary[$module->name()] as $level): ?>
73                                    <li><?= $level ?></li>
74                                <?php endforeach ?>
75                            </ul>
76
77                            <div class="modal fade" id="access-level-<?= $module->name() ?>" tabindex="-1" role="dialog">
78                                <div class="modal-dialog" role="document">
79                                    <div class="modal-content">
80                                        <div class="modal-header">
81                                            <h2 class="modal-title">
82                                                <?= e($module->title()) ?><?= I18N::translate('Access level') ?>
83                                            </h2>
84                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
85                                                <span aria-hidden="true">&times;</span>
86                                            </button>
87                                        </div>
88                                        <div class="modal-body">
89                                            <table class="table table-sm">
90                                                <tbody>
91                                                    <?php foreach ($trees as $tree) : ?>
92                                                        <tr>
93                                                            <td>
94                                                                <?= e($tree->title()) ?>
95                                                            </td>
96                                                            <td>
97                                                                <?= view('components/select', ['name' => 'access-' . $module->name() . '-' . $tree->id(), 'selected' => $module->accessLevel($tree, $interface), 'options' => FunctionsEdit::optionsAccessLevels()]) ?>
98                                                        </tr>
99                                                    <?php endforeach ?>
100                                                </tbody>
101                                            </table>
102                                        </div>
103                                        <div class="modal-footer">
104                                            <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
105                                        </div>
106                                    </div>
107                                </div>
108                            </div>
109                        </td>
110
111                        <td>
112                            <button type="button" class="btn btn-link" data-toggle="modal" data-target="#access-level-<?= $module->name() ?>">
113                                <?= view('icons/edit') ?>
114                                <span class="sr-only"><?= I18N::translate('edit') ?></span>
115                            </button>
116                        </td>
117                    <?php endif ?>
118
119                    <?php if ($uses_sorting) : ?>
120                        <td class="move up text-center">
121                            <a href="#" title="<?= I18N::translate('Move up') ?>">
122                                <?= view('icons/arrow-up') ?>
123                            </a>
124                        </td>
125
126                        <td class="move down text-center">
127                            <a href="#" title="<?= I18N::translate('Move down') ?>">
128                                <?= view('icons/arrow-down') ?>
129                            </a>
130                        </td>
131                    <?php endif ?>
132                </tr>
133            <?php endforeach ?>
134        </tbody>
135    </table>
136
137    <button class="btn btn-primary" type="submit">
138        <?= view('icons/save') ?>
139        <?= I18N::translate('save') ?>
140    </button>
141
142    <a class="btn btn-secondary" href="<?= e(route(ControlPanel::class)) ?>">
143        <?= view('icons/cancel') ?>
144        <?= I18N::translate('cancel') ?>
145    </a>
146</form>
147
148
149<?php View::push('javascript') ?>
150<script>
151    $('.wt-table-menu td.move').click(function() {
152        var row = $(this).closest('tr');
153
154        if ($(this).hasClass('up')) {
155            row.prev().before(row);
156        } else {
157            row.next().after(row);
158        }
159
160        return false;
161    });
162</script>
163<?php View::endpush() ?>
164
165<?php View::push('styles') ?>
166<style>
167    .wt-table-menu tr:first-child .wt-icon-arrow-up {
168        display:none;
169    }
170    .wt-table-menu tr:last-child .wt-icon-arrow-down {
171        display:none;
172    }
173</style>
174<?php View::endpush() ?>
175