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