11bfef740SGreg Roach<?php 21bfef740SGreg Roach 310e06497SGreg Roachdeclare(strict_types=1); 410e06497SGreg Roach 5870365fbSGreg Roachuse Fisharebest\Webtrees\Auth; 60c0910bfSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel; 79f667ff2SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ModulesAllPage; 81bfef740SGreg Roachuse Fisharebest\Webtrees\I18N; 91bfef740SGreg Roachuse Fisharebest\Webtrees\Module\ModuleConfigInterface; 101bfef740SGreg Roachuse Fisharebest\Webtrees\Module\ModuleCustomInterface; 111bfef740SGreg Roachuse Fisharebest\Webtrees\Module\ModuleExternalUrlInterface; 129f667ff2SGreg Roachuse Fisharebest\Webtrees\Module\ModuleInterface; 139f667ff2SGreg Roachuse Fisharebest\Webtrees\Tree; 141bfef740SGreg Roachuse Fisharebest\Webtrees\View; 159f667ff2SGreg Roachuse Illuminate\Support\Collection; 169f667ff2SGreg Roach 179f667ff2SGreg Roach/** 189f667ff2SGreg Roach * @var array<string,array<string,string>> $access_summary 199f667ff2SGreg Roach * @var string $description 200acf1b4bSGreg Roach * @var class-string<ModuleInterface> $interface 2136779af1SGreg Roach * @var Collection<int,ModuleInterface> $modules 229f667ff2SGreg Roach * @var string $title 2336779af1SGreg Roach * @var Collection<int,Tree> $trees 249f667ff2SGreg Roach * @var bool $uses_access 259f667ff2SGreg Roach * @var bool $uses_sorting 269f667ff2SGreg Roach */ 271bfef740SGreg Roach 281bfef740SGreg Roach?> 290cb66f86SGreg Roach 309f667ff2SGreg Roach<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), route(ModulesAllPage::class) => I18N::translate('All modules'), $title]]) ?> 310cb66f86SGreg Roach 320cb66f86SGreg Roach<h1><?= $title ?></h1> 330cb66f86SGreg Roach 348e5c5efeSGreg Roach<p><?= $description ?></p> 358e5c5efeSGreg Roach 360cb66f86SGreg Roach<form method="post"> 37abdaad0dSGreg Roach <table class="table table-bordered wt-table-components"> 380cb66f86SGreg Roach <thead> 390cb66f86SGreg Roach <tr> 40510d3f2fSGreg Roach <th><?= I18N::translate('Module') ?></th> 410cb66f86SGreg Roach <th class="text-center"><?= I18N::translate('Enabled') ?></th> 4233c34396SGreg Roach <?php if ($uses_access) : ?> 43745968f0SGreg Roach <th colspan="2" class="text-center"><?= I18N::translate('Access level') ?></th> 4433c34396SGreg Roach <?php endif ?> 4533c34396SGreg Roach <?php if ($uses_sorting) : ?> 460cb66f86SGreg Roach <th class="text-center"><?= I18N::translate('Move up') ?></th> 470cb66f86SGreg Roach <th class="text-center"><?= I18N::translate('Move down') ?></th> 480cb66f86SGreg Roach <?php endif ?> 490cb66f86SGreg Roach </tr> 500cb66f86SGreg Roach </thead> 510cb66f86SGreg Roach 520cb66f86SGreg Roach <tbody> 53*c5402244SGreg Roach <?php foreach ($modules as $module) : ?> 540cb66f86SGreg Roach <tr> 550cb66f86SGreg Roach <th scope="col"> 560f180719SGreg Roach <input type="hidden" name="order[]" value="<?= e($module->name()) ?>"> 573c5c6f56SGreg Roach <span title="<?= e(strip_tags($module->description())) ?>"> 587b30610bSGreg Roach <?= $module instanceof ModuleCustomInterface ? $module->customTranslations(I18N::languageTag())[$module->title()] ?? $module->title() : $module->title() ?> 5933c34396SGreg Roach </span> 603c5c6f56SGreg Roach <?php if ($module instanceof ModuleConfigInterface) : ?> 613c5c6f56SGreg Roach <?php if ($module->isEnabled()) : ?> 620cb66f86SGreg Roach <a href="<?= e($module->getConfigLink()) ?>" title="<?= I18N::translate('Preferences') ?>"> 630cb66f86SGreg Roach <?= view('icons/preferences') ?> 64315eb316SGreg Roach <span class="visually-hidden"> 650cb66f86SGreg Roach <?= I18N::translate('Preferences') ?> 660cb66f86SGreg Roach </span> 670cb66f86SGreg Roach </a> 683c5c6f56SGreg Roach <?php else : ?> 693c5c6f56SGreg Roach <span class="text-muted"> 703c5c6f56SGreg Roach <?= view('icons/preferences') ?> 713c5c6f56SGreg Roach </span> 723c5c6f56SGreg Roach <?php endif ?> 730cb66f86SGreg Roach <?php endif ?> 741bfef740SGreg Roach <?php if ($module instanceof ModuleCustomInterface) : ?> 751bfef740SGreg Roach <?= view('admin/custom-module-info', ['module' => $module]) ?> 761bfef740SGreg Roach <?php endif ?> 778e5c5efeSGreg Roach <?php if ($module instanceof ModuleExternalUrlInterface) : ?> 781bfef740SGreg Roach <?= view('admin/external-module-info', ['module' => $module]) ?> 798e5c5efeSGreg Roach <?php endif ?> 800cb66f86SGreg Roach </th> 810cb66f86SGreg Roach 820cb66f86SGreg Roach <td class="text-center"> 830cb66f86SGreg Roach <label class="d-block"> 849f667ff2SGreg Roach <input type="checkbox" name="status-<?= e($module->name()) ?>" 859f667ff2SGreg Roach id="status-<?= e($module->name()) ?>" <?= $module->isEnabled() ? 'checked' : '' ?>> 86315eb316SGreg Roach <span class="visually-hidden"> 870cb66f86SGreg Roach <?= I18N::translate('Enabled') ?> 880cb66f86SGreg Roach </span> 890cb66f86SGreg Roach </label> 900cb66f86SGreg Roach </td> 910cb66f86SGreg Roach 9233c34396SGreg Roach <?php if ($uses_access) : ?> 93745968f0SGreg Roach <td> 94745968f0SGreg Roach <ul class="list-unstyled"> 95745968f0SGreg Roach <?php foreach ($access_summary[$module->name()] as $level) : ?> 96745968f0SGreg Roach <li><?= $level ?></li> 97745968f0SGreg Roach <?php endforeach ?> 98745968f0SGreg Roach </ul> 99745968f0SGreg Roach 1009f667ff2SGreg Roach <div class="modal fade" id="access-level-<?= $module->name() ?>" tabindex="-1" 1019f667ff2SGreg Roach role="dialog"> 1020cb66f86SGreg Roach <div class="modal-dialog" role="document"> 1030cb66f86SGreg Roach <div class="modal-content"> 1040cb66f86SGreg Roach <div class="modal-header"> 1050cb66f86SGreg Roach <h2 class="modal-title"> 1060cb66f86SGreg Roach <?= e($module->title()) ?> – <?= I18N::translate('Access level') ?> 1070cb66f86SGreg Roach </h2> 108b854e1f1SGreg Roach <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="<?= I18N::translate('close') ?>"> 1090cb66f86SGreg Roach </button> 1100cb66f86SGreg Roach </div> 1110cb66f86SGreg Roach <div class="modal-body"> 1120cb66f86SGreg Roach <table class="table table-sm"> 1130cb66f86SGreg Roach <tbody> 1140cb66f86SGreg Roach <?php foreach ($trees as $tree) : ?> 1150cb66f86SGreg Roach <tr> 1160cb66f86SGreg Roach <td> 1170cb66f86SGreg Roach <?= e($tree->title()) ?> 1180cb66f86SGreg Roach </td> 1190cb66f86SGreg Roach <td> 120870365fbSGreg Roach <?= view('components/select', ['name' => 'access-' . $module->name() . '-' . $tree->id(), 'selected' => $module->accessLevel($tree, $interface), 'options' => Auth::accessLevelNames()]) ?> 1210cb66f86SGreg Roach </tr> 1220cb66f86SGreg Roach <?php endforeach ?> 1230cb66f86SGreg Roach </tbody> 1240cb66f86SGreg Roach </table> 1250cb66f86SGreg Roach </div> 1260cb66f86SGreg Roach <div class="modal-footer"> 12780e6d949SGreg Roach <button type="button" class="btn btn-primary" data-bs-dismiss="modal"> 12880e6d949SGreg Roach <?= view('icons/cancel') ?> 12980e6d949SGreg Roach <?= I18N::translate('close') ?> 1309f667ff2SGreg Roach </button> 1310cb66f86SGreg Roach </div> 1320cb66f86SGreg Roach </div> 1330cb66f86SGreg Roach </div> 1340cb66f86SGreg Roach </div> 135745968f0SGreg Roach </td> 1360cb66f86SGreg Roach 137745968f0SGreg Roach <td> 138315eb316SGreg Roach <button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-backdrop="static" 139315eb316SGreg Roach data-bs-target="#access-level-<?= $module->name() ?>"> 1400cb66f86SGreg Roach <?= view('icons/edit') ?> 141315eb316SGreg Roach <span class="visually-hidden"><?= I18N::translate('edit') ?></span> 1420cb66f86SGreg Roach </button> 1430cb66f86SGreg Roach </td> 14433c34396SGreg Roach <?php endif ?> 1450cb66f86SGreg Roach 14633c34396SGreg Roach <?php if ($uses_sorting) : ?> 1470cb66f86SGreg Roach <td class="move up text-center"> 1480cb66f86SGreg Roach <a href="#" title="<?= I18N::translate('Move up') ?>"> 1490cb66f86SGreg Roach <?= view('icons/arrow-up') ?> 1500cb66f86SGreg Roach </a> 1510cb66f86SGreg Roach </td> 1520cb66f86SGreg Roach 1530cb66f86SGreg Roach <td class="move down text-center"> 1540cb66f86SGreg Roach <a href="#" title="<?= I18N::translate('Move down') ?>"> 1550cb66f86SGreg Roach <?= view('icons/arrow-down') ?> 1560cb66f86SGreg Roach </a> 1570cb66f86SGreg Roach </td> 1580cb66f86SGreg Roach <?php endif ?> 1590cb66f86SGreg Roach </tr> 1600cb66f86SGreg Roach <?php endforeach ?> 1610cb66f86SGreg Roach </tbody> 1620cb66f86SGreg Roach </table> 1630cb66f86SGreg Roach 1640cb66f86SGreg Roach <button class="btn btn-primary" type="submit"> 1650cb66f86SGreg Roach <?= view('icons/save') ?> 1660cb66f86SGreg Roach <?= I18N::translate('save') ?> 1670cb66f86SGreg Roach </button> 1680cb66f86SGreg Roach 1690c0910bfSGreg Roach <a class="btn btn-secondary" href="<?= e(route(ControlPanel::class)) ?>"> 1700cb66f86SGreg Roach <?= view('icons/cancel') ?> 1710cb66f86SGreg Roach <?= I18N::translate('cancel') ?> 1720cb66f86SGreg Roach </a> 17381443e3cSGreg Roach 17481443e3cSGreg Roach <?= csrf_field() ?> 1750cb66f86SGreg Roach</form> 1760cb66f86SGreg Roach 1770cb66f86SGreg Roach<?php View::push('javascript') ?> 1780cb66f86SGreg Roach<script> 179abdaad0dSGreg Roach $('.wt-table-components td.move').click(function () { 1809f667ff2SGreg Roach let row = $(this).closest('tr'); 1810cb66f86SGreg Roach 1820cb66f86SGreg Roach if ($(this).hasClass('up')) { 1830cb66f86SGreg Roach row.prev().before(row); 1840cb66f86SGreg Roach } else { 1850cb66f86SGreg Roach row.next().after(row); 1860cb66f86SGreg Roach } 1870cb66f86SGreg Roach 1880cb66f86SGreg Roach return false; 1890cb66f86SGreg Roach }); 1900cb66f86SGreg Roach</script> 1910cb66f86SGreg Roach<?php View::endpush() ?> 192