xref: /webtrees/resources/views/admin/modules.phtml (revision ab2c91523aeb171fd76225844c6c3c0d2440dda3)
1<?php
2
3use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
4use Fisharebest\Webtrees\Http\RequestHandlers\ModuleDeleteSettings;
5use Fisharebest\Webtrees\Http\RequestHandlers\ModulesAllAction;
6use Fisharebest\Webtrees\I18N;
7use Fisharebest\Webtrees\Module\ModuleAnalyticsInterface;
8use Fisharebest\Webtrees\Module\ModuleBlockInterface;
9use Fisharebest\Webtrees\Module\ModuleChartInterface;
10use Fisharebest\Webtrees\Module\ModuleConfigInterface;
11use Fisharebest\Webtrees\Module\ModuleCustomInterface;
12use Fisharebest\Webtrees\Module\ModuleDataFixInterface;
13use Fisharebest\Webtrees\Module\ModuleExternalUrlInterface;
14use Fisharebest\Webtrees\Module\ModuleFooterInterface;
15use Fisharebest\Webtrees\Module\ModuleHistoricEventsInterface;
16use Fisharebest\Webtrees\Module\ModuleInterface;
17use Fisharebest\Webtrees\Module\ModuleLanguageInterface;
18use Fisharebest\Webtrees\Module\ModuleListInterface;
19use Fisharebest\Webtrees\Module\ModuleMenuInterface;
20use Fisharebest\Webtrees\Module\ModuleReportInterface;
21use Fisharebest\Webtrees\Module\ModuleSidebarInterface;
22use Fisharebest\Webtrees\Module\ModuleTabInterface;
23use Fisharebest\Webtrees\Module\ModuleThemeInterface;
24use Fisharebest\Webtrees\View;
25use Illuminate\Support\Collection;
26
27/**
28 * @var Collection<int,string>          $deleted_modules
29 * @var Collection<int,ModuleInterface> $modules
30 * @var string                          $title
31 */
32
33?>
34
35<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?>
36
37<h1><?= $title ?></h1>
38
39<?php foreach ($deleted_modules as $module_name) : ?>
40    <div class="alert alert-warning" role="alert">
41        <form method="post" action="<?= e(route(ModuleDeleteSettings::class)) ?>">
42            <input type="hidden" name="module_name" value="<?= $module_name ?>">
43
44            <?= I18N::translate('Preferences exist for the module “%s”, but this module no longer exists.', $module_name) ?>
45
46            <button type="submit" class="btn btn-secondary">
47                <?= I18N::translate('Delete the preferences for this module.') ?>
48            </button>
49
50            <?= csrf_field() ?>
51        </form>
52    </div>
53<?php endforeach ?>
54
55<form method="post" action="<?= e(route(ModulesAllAction::class)) ?>">
56    <table class="table table-bordered table-hover table-sm table-module-administration"
57        <?= view('lists/datatables-attributes') ?>
58        data-info="false"
59        data-paging="false"
60        data-filter="false"
61    >
62        <caption class="visually-hidden">
63            <?= I18N::translate('Module administration') ?>
64        </caption>
65        <thead>
66            <tr>
67                <th>
68                    <?= I18N::translate('Module') ?>
69                </th>
70                <th>
71                    <?= I18N::translate('Enabled') ?>
72                </th>
73                <th data-orderable="false">
74                    <?= I18N::translate('Description') ?>
75                </th>
76                <th title="<?= I18N::translate('Preferences') ?>">
77                    <?= view('icons/preferences') ?>
78                    <span class="visually-hidden"><?= I18N::translate('Preferences') ?></span>
79                </th>
80                <th title="<?= I18N::translate('Menus') ?>">
81                    <?= view('icons/menu') ?>
82                    <span class="visually-hidden"><?= I18N::translate('Menus') ?></span>
83                </th>
84                <th title="<?= I18N::translate('Tabs') ?>">
85                    <?= view('icons/tab') ?>
86                    <span class="visually-hidden"><?= I18N::translate('Tabs') ?></span>
87                </th>
88                <th title="<?= I18N::translate('Sidebars') ?>">
89                    <?= view('icons/sidebar') ?>
90                    <span class="visually-hidden"><?= I18N::translate('Sidebars') ?></span>
91                </th>
92                <th title="<?= I18N::translate('Blocks') ?>">
93                    <?= view('icons/block') ?>
94                    <span class="visually-hidden"><?= I18N::translate('Blocks') ?></span>
95                </th>
96                <th title="<?= I18N::translate('Data fixes') ?>">
97                    <?= view('icons/data-fix') ?>
98                    <span class="visually-hidden"><?= I18N::translate('Data fixes') ?></span>
99                </th>
100                <th title="<?= I18N::translate('Charts') ?>">
101                    <?= view('icons/chart') ?>
102                    <span class="visually-hidden"><?= I18N::translate('Charts') ?></span>
103                </th>
104                <th title="<?= I18N::translate('Lists') ?>">
105                    <?= view('icons/list') ?>
106                    <span class="visually-hidden"><?= I18N::translate('Lists') ?></span>
107                </th>
108                <th title="<?= I18N::translate('Reports') ?>">
109                    <?= view('icons/report') ?>
110                    <span class="visually-hidden"><?= I18N::translate('Reports') ?></span>
111                </th>
112                <th title="<?= I18N::translate('Footers') ?>">
113                    <?= view('icons/footer') ?>
114                    <span class="visually-hidden"><?= I18N::translate('Footers') ?></span>
115                </th>
116                <th title="<?= I18N::translate('Tracking and analytics') ?>">
117                    <?= view('icons/analytics') ?>
118                    <span class="visually-hidden"><?= I18N::translate('Tracking and analytics') ?></span>
119                </th>
120                <th title="<?= I18N::translate('Historic events') ?>">
121                    <?= view('icons/history') ?>
122                    <span class="visually-hidden"><?= I18N::translate('Historic events') ?></span>
123                </th>
124                <th title="<?= I18N::translate('Themes') ?>">
125                    <?= view('icons/theme') ?>
126                    <span class="visually-hidden"><?= I18N::translate('Themes') ?></span>
127                </th>
128                <th title="<?= I18N::translate('Languages') ?>">
129                    <?= view('icons/language') ?>
130                    <span class="visually-hidden"><?= I18N::translate('Languages') ?></span>
131                </th>
132            </tr>
133        </thead>
134
135        <tbody>
136            <?php foreach ($modules as $module) : ?>
137                <tr>
138                    <th scope="row" dir="auto">
139                        <?= $module instanceof ModuleCustomInterface ? $module->customTranslations(I18N::languageTag())[$module->title()] ?? $module->title() : $module->title() ?>
140                    </th>
141                    <td class="text-center" data-sort="<?= $module->isEnabled() ?>">
142                        <?= view('components/checkbox', ['label' => '', 'name' => 'status-' . $module->name(), 'checked' => $module->isEnabled()]) ?>
143                    </td>
144                    <td>
145                        <?= $module instanceof ModuleCustomInterface ? $module->customTranslations(I18N::languageTag())[$module->description()] ?? $module->description() : $module->description() ?>
146                        <?php if ($module instanceof ModuleCustomInterface) : ?>
147                            <?= view('admin/custom-module-info', ['module' => $module]) ?>
148                        <?php endif ?>
149                        <?php if ($module instanceof ModuleExternalUrlInterface) : ?>
150                            <?= view('admin/external-module-info', ['module' => $module]) ?>
151                        <?php endif ?>
152                    </td>
153                    <td class="text-center text-muted" title="<?= I18N::translate('Preferences') ?>">
154                        <?php if ($module instanceof ModuleConfigInterface) : ?>
155                            <?php if ($module->isEnabled()) : ?>
156                                <a href="<?= e($module->getConfigLink()) ?>" title="<?= I18N::translate('Preferences') ?>">
157                                    <?= view('icons/preferences') ?>
158                                    <span class="visually-hidden">
159                                        <?= I18N::translate('Preferences') ?>
160                                    </span>
161                                </a>
162                            <?php else : ?>
163                                <?= view('icons/preferences') ?>
164                            <?php endif ?>
165                        <?php endif ?>
166                    </td>
167                    <td class="text-center text-muted" title="<?= I18N::translate('Menu') ?>">
168                        <?php if ($module instanceof ModuleMenuInterface) : ?>
169                            <?= view('icons/menu') ?>
170                            <span class="visually-hidden"><?= I18N::translate('Menu') ?></span>
171                        <?php else : ?>
172                            -
173                        <?php endif ?>
174                    </td>
175                    <td class="text-center text-muted" title="<?= I18N::translate('Tab') ?>">
176                        <?php if ($module instanceof ModuleTabInterface) : ?>
177                            <?= view('icons/tab') ?>
178                            <span class="visually-hidden"><?= I18N::translate('Tab') ?></span>
179                        <?php else : ?>
180                            -
181                        <?php endif ?>
182                    </td>
183                    <td class="text-center text-muted" title="<?= I18N::translate('Sidebar') ?>">
184                        <?php if ($module instanceof ModuleSidebarInterface) : ?>
185                            <?= view('icons/sidebar') ?>
186                            <span class="visually-hidden"><?= I18N::translate('Sidebar') ?></span>
187                        <?php else : ?>
188                            -
189                        <?php endif ?>
190                    </td>
191                    <td class="text-center text-muted">
192                        <?php if ($module instanceof ModuleBlockInterface) : ?>
193                            <?php if ($module->isUserBlock()) : ?>
194                                <span title="<?= I18N::translate('My page') ?>">
195                                    <?= view('icons/block-user') ?>
196                                </span>
197                                <span class="visually-hidden">
198                                    <?= I18N::translate('My page') ?>
199                                </span>
200                            <?php endif ?>
201
202                            <?php if ($module->isTreeBlock()) : ?>
203                                <span title="<?= I18N::translate('Home page') ?>">
204                                    <?= view('icons/block-tree') ?>
205                                </span>
206                                <span class="visually-hidden">
207                                    <?= I18N::translate('Home page') ?>
208                                </span>
209                            <?php endif ?>
210                        <?php else : ?>
211                            -
212                        <?php endif ?>
213                    </td>
214                    <td class="text-center text-muted" title="<?= I18N::translate('Data fix') ?>">
215                        <?php if ($module instanceof ModuleDataFixInterface) : ?>
216                            <?= view('icons/data-fix') ?>
217                            <span class="visually-hidden"><?= I18N::translate('Data fix') ?></span>
218                        <?php else : ?>
219                            -
220                        <?php endif ?>
221                    </td>
222                    <td class="text-center text-muted" title="<?= I18N::translate('Chart') ?>">
223                        <?php if ($module instanceof ModuleChartInterface) : ?>
224                            <?= view('icons/chart') ?>
225                            <span class="visually-hidden"><?= I18N::translate('Chart') ?></span>
226                        <?php else : ?>
227                            -
228                        <?php endif ?>
229                    </td>
230                    <td class="text-center text-muted" title="<?= I18N::translate('List') ?>">
231                        <?php if ($module instanceof ModuleListInterface) : ?>
232                            <?= view('icons/list') ?>
233                            <span class="visually-hidden"><?= I18N::translate('List') ?></span>
234                        <?php else : ?>
235                            -
236                        <?php endif ?>
237                    </td>
238                    <td class="text-center text-muted" title="<?= I18N::translate('Report') ?>">
239                        <?php if ($module instanceof ModuleReportInterface) : ?>
240                            <?= view('icons/report') ?>
241                            <span class="visually-hidden"><?= I18N::translate('Report') ?></span>
242                        <?php else : ?>
243                            -
244                        <?php endif ?>
245                    </td>
246                    <td class="text-center text-muted" title="<?= I18N::translate('Footer') ?>">
247                        <?php if ($module instanceof ModuleFooterInterface) : ?>
248                            <?= view('icons/footer') ?>
249                            <span class="visually-hidden"><?= I18N::translate('Footer') ?></span>
250                        <?php else : ?>
251                            -
252                        <?php endif ?>
253                    </td>
254                    <td class="text-center text-muted" title="<?= I18N::translate('Tracking and analytics') ?>">
255                        <?php if ($module instanceof ModuleAnalyticsInterface) : ?>
256                            <?= view('icons/analytics') ?>
257                            <span class="visually-hidden"><?= I18N::translate('Tracking and analytics') ?></span>
258                        <?php else : ?>
259                            -
260                        <?php endif ?>
261                    </td>
262                    <td class="text-center text-muted" title="<?= I18N::translate('Historic events') ?>">
263                        <?php if ($module instanceof ModuleHistoricEventsInterface) : ?>
264                            <?= view('icons/history') ?>
265                            <span class="visually-hidden"><?= I18N::translate('Historic events') ?></span>
266                        <?php else : ?>
267                            -
268                        <?php endif ?>
269                    </td>
270                    <td class="text-center text-muted" title="<?= I18N::translate('Theme') ?>">
271                        <?php if ($module instanceof ModuleThemeInterface) : ?>
272                            <?= view('icons/theme') ?>
273                            <span class="visually-hidden"><?= I18N::translate('Theme') ?></span>
274                        <?php else : ?>
275                            -
276                        <?php endif ?>
277                    </td>
278                    <td class="text-center text-muted" title="<?= I18N::translate('Language') ?>">
279                        <?php if ($module instanceof ModuleLanguageInterface) : ?>
280                            <?= view('icons/language') ?>
281                            <span class="visually-hidden"><?= I18N::translate('Language') ?></span>
282                        <?php else : ?>
283                            -
284                        <?php endif ?>
285                    </td>
286                </tr>
287            <?php endforeach ?>
288        </tbody>
289    </table>
290
291    <button class="btn btn-primary" type="submit">
292        <?= view('icons/save') ?>
293        <?= I18N::translate('save') ?>
294    </button>
295
296    <?= csrf_field() ?>
297</form>
298
299<?php View::push('javascript') ?>
300<script>
301  'use strict';
302
303  $(".table-module-administration").dataTable();
304</script>
305<?php View::endpush() ?>
306