xref: /webtrees/resources/views/admin/components.phtml (revision c9e11c2a4bb055d724ccdbad6b9c595dd26c8975)
11bfef740SGreg Roach<?php
21bfef740SGreg Roach
31bfef740SGreg Roachuse Fisharebest\Webtrees\Functions\FunctionsEdit;
41bfef740SGreg Roachuse Fisharebest\Webtrees\I18N;
51bfef740SGreg Roachuse Fisharebest\Webtrees\Module\ModuleConfigInterface;
61bfef740SGreg Roachuse Fisharebest\Webtrees\Module\ModuleCustomInterface;
71bfef740SGreg Roachuse Fisharebest\Webtrees\Module\ModuleExternalUrlInterface;
81bfef740SGreg Roachuse Fisharebest\Webtrees\View;
91bfef740SGreg Roach
101bfef740SGreg Roach?>
110cb66f86SGreg Roach
1209fbf3e5SGreg Roach<?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), route('modules') => I18N::translate('All modules'), $title]]) ?>
130cb66f86SGreg Roach
140cb66f86SGreg Roach<h1><?= $title ?></h1>
150cb66f86SGreg Roach
168e5c5efeSGreg Roach<p><?= $description ?></p>
178e5c5efeSGreg Roach
180cb66f86SGreg Roach<form method="post">
190cb66f86SGreg Roach    <?= csrf_field() ?>
200cb66f86SGreg Roach    <table class="table table-bordered wt-table-menu">
210cb66f86SGreg Roach        <thead>
220cb66f86SGreg Roach            <tr>
23510d3f2fSGreg Roach                <th><?= I18N::translate('Module') ?></th>
240cb66f86SGreg Roach                <th class="text-center"><?= I18N::translate('Enabled') ?></th>
2533c34396SGreg Roach                <?php if ($uses_access) : ?>
260cb66f86SGreg Roach                    <th class="text-center"><?= I18N::translate('Access level') ?></th>
2733c34396SGreg Roach                <?php endif ?>
2833c34396SGreg Roach                <?php if ($uses_sorting) : ?>
290cb66f86SGreg Roach                    <th class="text-center"><?= I18N::translate('Move up') ?></th>
300cb66f86SGreg Roach                    <th class="text-center"><?= I18N::translate('Move down') ?></th>
310cb66f86SGreg Roach                <?php endif ?>
320cb66f86SGreg Roach            </tr>
330cb66f86SGreg Roach        </thead>
340cb66f86SGreg Roach
350cb66f86SGreg Roach        <tbody>
360cb66f86SGreg Roach            <?php foreach ($modules as $module_name => $module) : ?>
370cb66f86SGreg Roach                <tr>
380cb66f86SGreg Roach                    <th scope="col">
390cb66f86SGreg Roach                        <input type="hidden" name="order[]" value="<?= e($module->name()) ?>"?>
4033c34396SGreg Roach                        <span title="<?= e($module->description()) ?>">
410cb66f86SGreg Roach                            <?= $module->title() ?>
4233c34396SGreg Roach                        </span>
436b32f095SGreg Roach                        <?php if ($module instanceof ModuleConfigInterface && $module->isEnabled()) : ?>
440cb66f86SGreg Roach                            <a href="<?= e($module->getConfigLink()) ?>" title="<?= I18N::translate('Preferences') ?>">
450cb66f86SGreg Roach                                <?= view('icons/preferences') ?>
460cb66f86SGreg Roach                                <span class="sr-only">
470cb66f86SGreg Roach                                    <?= I18N::translate('Preferences') ?>
480cb66f86SGreg Roach                                </span>
490cb66f86SGreg Roach                            </a>
500cb66f86SGreg Roach                        <?php endif ?>
511bfef740SGreg Roach                        <?php if ($module instanceof ModuleCustomInterface) : ?>
521bfef740SGreg Roach                            <?= view('admin/custom-module-info', ['module' => $module]) ?>
531bfef740SGreg Roach                        <?php endif ?>
548e5c5efeSGreg Roach                        <?php if ($module instanceof ModuleExternalUrlInterface) : ?>
551bfef740SGreg Roach                            <?= view('admin/external-module-info', ['module' => $module]) ?>
568e5c5efeSGreg Roach                        <?php endif ?>
570cb66f86SGreg Roach                    </th>
580cb66f86SGreg Roach
590cb66f86SGreg Roach                    <td class="text-center">
600cb66f86SGreg Roach                        <label class="d-block">
610cb66f86SGreg Roach                            <input type="checkbox" name="status-<?= e($module->name()) ?>" id="status-<?= e($module->name()) ?>" <?= $module->isEnabled() ? 'checked' : '' ?>>
620cb66f86SGreg Roach                            <span class="sr-only">
630cb66f86SGreg Roach                                <?= I18N::translate('Enabled') ?>
640cb66f86SGreg Roach                            </span>
650cb66f86SGreg Roach                        </label>
660cb66f86SGreg Roach                    </td>
670cb66f86SGreg Roach
6833c34396SGreg Roach                    <?php if ($uses_access) : ?>
690cb66f86SGreg Roach                        <td class="text-center">
700cb66f86SGreg Roach                        <div class="modal fade" id="access-level-<?= $module->name() ?>" tabindex="-1" role="dialog">
710cb66f86SGreg Roach                            <div class="modal-dialog" role="document">
720cb66f86SGreg Roach                                <div class="modal-content">
730cb66f86SGreg Roach                                    <div class="modal-header">
740cb66f86SGreg Roach                                        <h2 class="modal-title">
750cb66f86SGreg Roach                                            <?= e($module->title()) ?><?= I18N::translate('Access level') ?>
760cb66f86SGreg Roach                                        </h2>
770cb66f86SGreg Roach                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
780cb66f86SGreg Roach                                            <span aria-hidden="true">&times;</span>
790cb66f86SGreg Roach                                        </button>
800cb66f86SGreg Roach                                    </div>
810cb66f86SGreg Roach                                    <div class="modal-body">
820cb66f86SGreg Roach                                        <table class="table table-sm">
830cb66f86SGreg Roach                                            <tbody>
840cb66f86SGreg Roach                                                <?php foreach ($trees as $tree) : ?>
850cb66f86SGreg Roach                                                    <tr>
860cb66f86SGreg Roach                                                        <td>
870cb66f86SGreg Roach                                                            <?= e($tree->title()) ?>
880cb66f86SGreg Roach                                                        </td>
890cb66f86SGreg Roach                                                        <td>
90*c9e11c2aSGreg Roach                                                            <?= view('components/select', ['name' => 'access-' . $module->name() . '-' . $tree->id(), 'selected' => $module->accessLevel($tree, $interface), 'options' => FunctionsEdit::optionsAccessLevels()]) ?>
910cb66f86SGreg Roach                                                    </tr>
920cb66f86SGreg Roach                                                <?php endforeach ?>
930cb66f86SGreg Roach                                            </tbody>
940cb66f86SGreg Roach                                        </table>
950cb66f86SGreg Roach                                    </div>
960cb66f86SGreg Roach                                    <div class="modal-footer">
970cb66f86SGreg Roach                                        <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
980cb66f86SGreg Roach                                    </div>
990cb66f86SGreg Roach                                </div>
1000cb66f86SGreg Roach                            </div>
1010cb66f86SGreg Roach                        </div>
1020cb66f86SGreg Roach
1030cb66f86SGreg Roach                        <button type="button" class="btn btn-link" data-toggle="modal" data-target="#access-level-<?= $module->name() ?>">
1040cb66f86SGreg Roach                            <?= view('icons/edit') ?>
1050cb66f86SGreg Roach                            <span class="sr-only">
1060cb66f86SGreg Roach                                 <?= I18N::translate('edit') ?>
1070cb66f86SGreg Roach                            </span>
1080cb66f86SGreg Roach                        </button>
1090cb66f86SGreg Roach                    </td>
11033c34396SGreg Roach                    <?php endif ?>
1110cb66f86SGreg Roach
11233c34396SGreg Roach                    <?php if ($uses_sorting) : ?>
1130cb66f86SGreg Roach                        <td class="move up text-center">
1140cb66f86SGreg Roach                            <a href="#" title="<?= I18N::translate('Move up') ?>">
1150cb66f86SGreg Roach                                <?= view('icons/arrow-up') ?>
1160cb66f86SGreg Roach                            </a>
1170cb66f86SGreg Roach                        </td>
1180cb66f86SGreg Roach
1190cb66f86SGreg Roach                        <td class="move down text-center">
1200cb66f86SGreg Roach                            <a href="#" title="<?= I18N::translate('Move down') ?>">
1210cb66f86SGreg Roach                                <?= view('icons/arrow-down') ?>
1220cb66f86SGreg Roach                            </a>
1230cb66f86SGreg Roach                        </td>
1240cb66f86SGreg Roach                    <?php endif ?>
1250cb66f86SGreg Roach                </tr>
1260cb66f86SGreg Roach            <?php endforeach ?>
1270cb66f86SGreg Roach        </tbody>
1280cb66f86SGreg Roach    </table>
1290cb66f86SGreg Roach
1300cb66f86SGreg Roach    <button class="btn btn-primary" type="submit">
1310cb66f86SGreg Roach        <?= view('icons/save') ?>
1320cb66f86SGreg Roach        <?= I18N::translate('save') ?>
1330cb66f86SGreg Roach    </button>
1340cb66f86SGreg Roach
1350cb66f86SGreg Roach    <a class="btn btn-secondary" href="<?= e(route('admin-control-panel')) ?>">
1360cb66f86SGreg Roach        <?= view('icons/cancel') ?>
1370cb66f86SGreg Roach        <?= I18N::translate('cancel') ?>
1380cb66f86SGreg Roach    </a>
1390cb66f86SGreg Roach</form>
1400cb66f86SGreg Roach
1410cb66f86SGreg Roach
1420cb66f86SGreg Roach<?php View::push('javascript') ?>
1430cb66f86SGreg Roach<script>
1440cb66f86SGreg Roach    $('.wt-table-menu td.move').click(function() {
1450cb66f86SGreg Roach        var row = $(this).closest('tr');
1460cb66f86SGreg Roach
1470cb66f86SGreg Roach        if ($(this).hasClass('up')) {
1480cb66f86SGreg Roach            row.prev().before(row);
1490cb66f86SGreg Roach        } else {
1500cb66f86SGreg Roach            row.next().after(row);
1510cb66f86SGreg Roach        }
1520cb66f86SGreg Roach
1530cb66f86SGreg Roach        return false;
1540cb66f86SGreg Roach    });
1550cb66f86SGreg Roach</script>
1560cb66f86SGreg Roach<?php View::endpush() ?>
1570cb66f86SGreg Roach
1580cb66f86SGreg Roach<?php View::push('styles') ?>
1590cb66f86SGreg Roach<style>
1600cb66f86SGreg Roach    .wt-table-menu tr:first-child .wt-icon-arrow-up {
1610cb66f86SGreg Roach        display:none;
1620cb66f86SGreg Roach    }
1630cb66f86SGreg Roach    .wt-table-menu tr:last-child .wt-icon-arrow-down {
1640cb66f86SGreg Roach        display:none;
1650cb66f86SGreg Roach    }
1660cb66f86SGreg Roach</style>
1670cb66f86SGreg Roach<?php View::endpush() ?>
168