<?php

use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Http\RequestHandlers\DeleteRecord;
use Fisharebest\Webtrees\Http\RequestHandlers\EditRawRecordPage;
use Fisharebest\Webtrees\I18N;

?>

<div class="dropdown wt-page-menu">
    <button class="btn btn-primary dropdown-toggle wt-page-menu-button" type="button" id="page-menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        <?= view('icons/edit') ?>
        <?= I18N::translate('edit') ?>
    </button>

    <div class="dropdown-menu dropdown-menu-right wt-page-menu-items" aria-labelledby="page-menu">
        <a class="dropdown-item" href="#" data-href="<?= e(route('link-media-to-individual', ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal" data-backdrop="static">
            <?= view('icons/link') ?>
            <?= I18N::translate('Link this media object to an individual') ?>
        </a>

        <a class="dropdown-item" href="#" data-href="<?= e(route('link-media-to-family', ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal" data-backdrop="static">
            <?= view('icons/link') ?>
            <?= I18N::translate('Link this media object to a family') ?>
        </a>

        <a class="dropdown-item" href="#" data-href="<?= e(route('link-media-to-source', ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal" data-backdrop="static">
            <?= view('icons/link') ?>
            <?= I18N::translate('Link this media object to a source') ?>
        </a>

        <div class="dropdown-divider"></div>

        <a class="dropdown-item" href="#" data-confirm="<?= I18N::translate('Are you sure you want to delete “%s”?', strip_tags($record->fullName())) ?>" data-post-url="<?= e(route(DeleteRecord::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>">
            <?= view('icons/delete') ?>
            <?= I18N::translate('Delete') ?>
        </a>

        <?php if (Auth::isAdmin() || $record->tree()->getPreference('SHOW_GEDCOM_RECORD')) : ?>
            <a class="dropdown-item" href="<?= e(route(EditRawRecordPage::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>">
                <?= view('icons/edit') ?>
                <?= I18N::translate('Edit the raw GEDCOM') ?>
            </a>
        <?php endif ?>
    </div>
</div>
