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