xref: /webtrees/resources/views/admin/components.phtml (revision 54c1ab5ea4e2eb9e21dbacd6aa33a0f25550ac18)
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 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 class="text-center">
71                        <div class="modal fade" id="access-level-<?= $module->name() ?>" tabindex="-1" role="dialog">
72                            <div class="modal-dialog" role="document">
73                                <div class="modal-content">
74                                    <div class="modal-header">
75                                        <h2 class="modal-title">
76                                            <?= e($module->title()) ?><?= I18N::translate('Access level') ?>
77                                        </h2>
78                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
79                                            <span aria-hidden="true">&times;</span>
80                                        </button>
81                                    </div>
82                                    <div class="modal-body">
83                                        <table class="table table-sm">
84                                            <tbody>
85                                                <?php foreach ($trees as $tree) : ?>
86                                                    <tr>
87                                                        <td>
88                                                            <?= e($tree->title()) ?>
89                                                        </td>
90                                                        <td>
91                                                            <?= view('components/select', ['name' => 'access-' . $module->name() . '-' . $tree->id(), 'selected' => $module->accessLevel($tree, $interface), 'options' => FunctionsEdit::optionsAccessLevels()]) ?>
92                                                    </tr>
93                                                <?php endforeach ?>
94                                            </tbody>
95                                        </table>
96                                    </div>
97                                    <div class="modal-footer">
98                                        <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
99                                    </div>
100                                </div>
101                            </div>
102                        </div>
103
104                        <button type="button" class="btn btn-link" data-toggle="modal" data-target="#access-level-<?= $module->name() ?>">
105                            <?= view('icons/edit') ?>
106                            <span class="sr-only">
107                                 <?= I18N::translate('edit') ?>
108                            </span>
109                        </button>
110                    </td>
111                    <?php endif ?>
112
113                    <?php if ($uses_sorting) : ?>
114                        <td class="move up text-center">
115                            <a href="#" title="<?= I18N::translate('Move up') ?>">
116                                <?= view('icons/arrow-up') ?>
117                            </a>
118                        </td>
119
120                        <td class="move down text-center">
121                            <a href="#" title="<?= I18N::translate('Move down') ?>">
122                                <?= view('icons/arrow-down') ?>
123                            </a>
124                        </td>
125                    <?php endif ?>
126                </tr>
127            <?php endforeach ?>
128        </tbody>
129    </table>
130
131    <button class="btn btn-primary" type="submit">
132        <?= view('icons/save') ?>
133        <?= I18N::translate('save') ?>
134    </button>
135
136    <a class="btn btn-secondary" href="<?= e(route(ControlPanel::class)) ?>">
137        <?= view('icons/cancel') ?>
138        <?= I18N::translate('cancel') ?>
139    </a>
140</form>
141
142
143<?php View::push('javascript') ?>
144<script>
145    $('.wt-table-menu td.move').click(function() {
146        var row = $(this).closest('tr');
147
148        if ($(this).hasClass('up')) {
149            row.prev().before(row);
150        } else {
151            row.next().after(row);
152        }
153
154        return false;
155    });
156</script>
157<?php View::endpush() ?>
158
159<?php View::push('styles') ?>
160<style>
161    .wt-table-menu tr:first-child .wt-icon-arrow-up {
162        display:none;
163    }
164    .wt-table-menu tr:last-child .wt-icon-arrow-down {
165        display:none;
166    }
167</style>
168<?php View::endpush() ?>
169