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