1<?php 2 3declare(strict_types=1); 4 5use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel; 6use Fisharebest\Webtrees\Http\RequestHandlers\ManageMediaAction; 7use Fisharebest\Webtrees\Http\RequestHandlers\ManageMediaData; 8use Fisharebest\Webtrees\I18N; 9use Fisharebest\Webtrees\View; 10use Illuminate\Support\Collection; 11 12/** 13 * @var string $data_folder 14 * @var string $files 15 * @var string $media_folder 16 * @var Collection<int,string> $media_folders 17 * @var array<string> $media_types 18 * @var string $subfolders 19 * @var string $title 20 */ 21?> 22 23<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?> 24 25<h1><?= $title ?></h1> 26 27<form method="post" action="<?= e(route(ManageMediaAction::class)) ?>" id="admin-media-form"> 28 <table class="table table-bordered table-sm"> 29 <thead> 30 <tr> 31 <th><?= I18N::translate('Media files') ?></th> 32 <th><?= I18N::translate('Media folders') ?></th> 33 </tr> 34 </thead> 35 <tbody> 36 <tr> 37 <td> 38 <label> 39 <input type="radio" name="files" value="local" <?= $files === 'local' ? 'checked' : '' ?>> 40 <?= /* I18N: “Local files” are stored on this computer */ I18N::translate('Local files') ?> 41 </label> 42 <br> 43 <label> 44 <input type="radio" name="files" value="external" <?= $files === 'external' ? 'checked' : '' ?>> 45 <?= /* I18N: “External files” are stored on other computers */ I18N::translate('External files') ?> 46 </label> 47 <br> 48 <label> 49 <input type="radio" name="files" value="unused" <?= $files === 'unused' ? 'checked' : '' ?>> 50 <?= I18N::translate('Unused files') ?> 51 </label> 52 </td> 53 <td> 54 <?php if ($files === 'local' || $files === 'unused') : ?> 55 <div class="input-group mb-2" dir="ltr"> 56 <div class="input-group-text"><?= e($data_folder) ?></div> 57 58 <?php if ($media_folders->count() > 1) : ?> 59 <?= view('components/select', ['name' => 'media_folder', 'selected' => $media_folder, 'options' => $media_folders]) ?> 60 <?php else : ?> 61 <input aria-label="<?= I18N::translate('Media folder') ?>" 62 type="text" class="form-control" name="media_folder" value="<?= e($media_folder) ?>" readonly> 63 <?php endif ?> 64 </div> 65 66 <label> 67 <input type="radio" name="subfolders" value="include" <?= $subfolders === 'include' ? 'checked' : '' ?>> 68 <?= I18N::translate('Include subfolders') ?> 69 </label> 70 <br> 71 <label> 72 <input type="radio" name="subfolders" value="exclude" <?= $subfolders === 'exclude' ? ' checked' : '' ?>> 73 <?= I18N::translate('Exclude subfolders') ?> 74 </label> 75 76 <?php elseif ($files === 'external') : ?> 77 <?= I18N::translate('External media files have a URL instead of a filename.') ?> 78 <input type="hidden" name="media_folder" value="<?= e($media_folder) ?>"> 79 <input type="hidden" name="subfolders" value="<?= e($subfolders) ?>"> 80 <?php endif ?> 81 </td> 82 </tr> 83 </tbody> 84 </table> 85 86 <?= csrf_field() ?> 87</form> 88<br> 89<br> 90 91<table 92 class="table table-bordered table-sm datatables d-none" 93 <?= view('lists/datatables-attributes') ?> 94 data-ajax="<?= e(route(ManageMediaData::class, ['files' => $files, 'media_folder' => $media_folder, 'subfolders' => $subfolders])) ?>" 95 data-server-side="true" 96> 97 <thead> 98 <tr> 99 <th> 100 <?= I18N::translate('Media file') ?> 101 </th> 102 103 <th data-sortable="false"> 104 <?= I18N::translate('Media') ?> 105 </th> 106 107 <th data-sortable="<?= $files === 'unused' ? 'false' : 'true' ?>"> 108 <?= I18N::translate('Media object') ?> 109 </th> 110 </tr> 111 </thead> 112</table> 113<?= view('modals/create-media-from-file', ['media_types' => $media_types]) ?> 114 115<?php View::push('javascript') ?> 116<script> 117 $("#admin-media-form input, #admin-media-form select").change(function () { 118 $("#admin-media-form").submit(); 119 }); 120</script> 121<?php View::endpush() ?> 122