1<?php 2 3use Fisharebest\Webtrees\I18N; 4use Fisharebest\Webtrees\Individual; 5use Fisharebest\Webtrees\Tree; 6use Illuminate\Support\Collection; 7 8/** 9 * @var int $block_id 10 * @var bool $can_edit 11 * @var Collection<stdClass> $favorites 12 * @var string $module_name 13 * @var Tree $tree 14 */ 15?> 16 17<?php foreach ($favorites as $favorite) : ?> 18 <div class="person_box action_header<?= $favorite->record instanceof Individual ? $favorite->record->sex() : '' ?>"> 19 <?php if ($favorite->favorite_type === 'URL') : ?> 20 <a href="<?= e($favorite->url) ?>"><b><?= e($favorite->title) ?></b></a> 21 <?php elseif ($favorite->record instanceof Individual) : ?> 22 <?= view('chart-box', ['individual' => $favorite->record]) ?> 23 <?php elseif ($favorite->record !== null) : ?> 24 <?= $favorite->record->formatList() ?> 25 <?php endif ?> 26 27 <div class="wt-favorites-block-note"> 28 <?= e((string) $favorite->note) ?> 29 </div> 30 </div> 31 32 <?php if ($can_edit) : ?> 33 <form method="post" action="<?= e(route('module', ['module' => $module_name, 'action' => 'DeleteFavorite', 'tree' => $tree->name(), 'favorite_id' => $favorite->favorite_id])) ?>"> 34 <?= csrf_field() ?> 35 <button type="submit" class="btn btn-link" data-confirm="<?= I18N::translate('Are you sure you want to remove this item from your list of favorites?') ?>" onclick="return confirm(this.dataset.confirm);"> 36 <?= I18N::translate('Remove') ?> 37 </button> 38 </form> 39 <?php endif ?> 40<?php endforeach ?> 41 42<?php if ($can_edit) : ?> 43 <button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-backdrop="static" data-bs-target="#favorite-form-<?= e($block_id) ?>"> 44 <?= I18N::translate('Add a favorite') ?> 45 </button> 46 47 <div class="modal fade" id="favorite-form-<?= e($block_id) ?>" tabindex="-1" role="dialog" aria-labelledby="favorite-form-<?= e($block_id) ?>-label" aria-hidden="true"> 48 <div class="modal-dialog modal-xl" role="document"> 49 <div class="modal-content"> 50 <form method="post" action="<?= e(route('module', ['module' => $module_name, 'action' => 'AddFavorite', 'tree' => $tree->name()])) ?>"> 51 <?= csrf_field() ?> 52 <div class="modal-header"> 53 <h5 class="modal-title" id="favorite-form-<?= e($block_id) ?>-label"> 54 <?= I18N::translate('Add a favorite') ?> 55 </h5> 56 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="<?= I18N::translate('close') ?>""> 57 </button> 58 </div> 59 <div class="modal-body"> 60 <div class="row form-group"> 61 <div class="col-sm-4 col-md-3"> 62 <div class="form-check"> 63 <input class="form-check-input" type="radio" name="type" value="indi" id="fav-indi-<?= e($block_id) ?>" checked> 64 <label class="form-check-label" for="fav-indi-<?= e($block_id) ?>"> 65 <?= I18N::translate('Individual') ?> 66 </label> 67 </div> 68 </div> 69 <div class="col-sm-8 col-md-9"> 70 <?= view('components/select-individual', ['name' => 'indi-xref', 'tree' => $tree]) ?> 71 </div> 72 </div> 73 74 <div class="row form-group"> 75 <div class="col-sm-4 col-md-3"> 76 <div class="form-check"> 77 <input class="form-check-input" type="radio" name="type" value="fam" id="fav-fam-<?= e($block_id) ?>"> 78 <label class="form-check-label" for="fav-fam-<?= e($block_id) ?>"> 79 <?= I18N::translate('Family') ?> 80 </label> 81 </div> 82 </div> 83 <div class="col-sm-8 col-md-9"> 84 <?= view('components/select-family', ['name' => 'fam-xref', 'tree' => $tree]) ?> 85 </div> 86 </div> 87 88 <div class="row form-group"> 89 <div class="col-sm-4 col-md-3"> 90 <div class="form-check"> 91 <input class="form-check-input" type="radio" name="type" value="obje" id="fav-obje-<?= e($block_id) ?>"> 92 <label class="form-check-label" for="fav-obje-<?= e($block_id) ?>"> 93 <?= I18N::translate('Media object') ?> 94 </label> 95 </div> 96 </div> 97 <div class="col-sm-8 col-md-9"> 98 <?= view('components/select-media', ['name' => 'obje-xref', 'tree' => $tree]) ?> 99 </div> 100 </div> 101 102 <div class="row form-group"> 103 <div class="col-sm-4 col-md-3"> 104 <div class="form-check"> 105 <input class="form-check-input" type="radio" name="type" value="sour" id="fav-sour-<?= e($block_id) ?>"> 106 <label class="form-check-label" for="fav-sour-<?= e($block_id) ?>"> 107 <?= I18N::translate('Source') ?> 108 </label> 109 </div> 110 </div> 111 <div class="col-sm-8 col-md-9"> 112 <?= view('components/select-source', ['name' => 'sour-xref', 'tree' => $tree]) ?> 113 </div> 114 </div> 115 116 <div class="row form-group"> 117 <div class="col-sm-4 col-md-3"> 118 <div class="form-check"> 119 <input class="form-check-input" type="radio" name="type" value="repo" id="fav-repo-<?= e($block_id) ?>"> 120 <label class="form-check-label" for="fav-repo-<?= e($block_id) ?>"> 121 <?= I18N::translate('Repository') ?> 122 </label> 123 </div> 124 </div> 125 <div class="col-sm-8 col-md-9"> 126 <?= view('components/select-repository', ['name' => 'repo-xref', 'tree' => $tree]) ?> 127 </div> 128 </div> 129 130 <div class="row form-group"> 131 <div class="col-sm-4 col-md-3"> 132 <div class="form-check"> 133 <input class="form-check-input" type="radio" name="type" value="url" id="fav-url-<?= e($block_id) ?>"> 134 <label class="form-check-label" for="fav-url-<?= e($block_id) ?>"> 135 <?= I18N::translate('URL') ?> 136 </label> 137 </div> 138 </div> 139 <div class="col-sm-8 col-md-9"> 140 <label> 141 <span class="visually-hidden"> 142 <?= I18N::translate('URL') ?> 143 </span> 144 <input type="text" class="form-control" name="url" id="url" value="" placeholder="<?= I18N::translate('URL') ?>"> 145 </label> 146 <label> 147 <span class="visually-hidden"> 148 <?= I18N::translate('Title') ?> 149 </span> 150 <input type="text" class="form-control" name="title" id="title" value="" placeholder="<?= I18N::translate('Title') ?>"> 151 </label> 152 </div> 153 </div> 154 155 <div class="row form-group"> 156 <div class="col-sm-4 col-md-3"> 157 <label for="fav-note-<?= e($block_id) ?>"> 158 <?= I18N::translate('Note') ?> 159 </label> 160 </div> 161 <div class="col-sm-8 col-md-9"> 162 <textarea name="note" id="fav-note-<?= e($block_id) ?>" class="form-control" placeholder="<?= I18N::translate('Enter an optional note about this favorite') ?>" rows="3" dir="auto"></textarea> 163 </div> 164 </div> 165 </div> 166 167 <div class="modal-footer"> 168 <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"> 169 <?= view('icons/cancel') ?> 170 <?= I18N::translate('cancel') ?> 171 </button> 172 <button type="submit" class="btn btn-primary"> 173 <?= view('icons/save') ?> 174 <?= I18N::translate('save') ?> 175 </button> 176 </div> 177 </form> 178 </div> 179 </div> 180 </div> 181<?php endif ?> 182