fix #29 : envoyer le lien magique par email (envoyer_mail_smtp)
This commit is contained in:
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
ob_start();
|
||||
|
||||
$isPdf = ($step2Meta['mime'] ?? '') === 'application/pdf';
|
||||
$isHtml = str_starts_with($step2Meta['mime'] ?? '', 'text/html');
|
||||
|
||||
// Ordre + labels contextuels
|
||||
$metaRows = [
|
||||
'mime' => 'Type',
|
||||
'size' => 'Taille',
|
||||
// PDF
|
||||
'pages' => 'Pages',
|
||||
'page_size' => 'Format',
|
||||
'pdf_version' => 'Version PDF',
|
||||
// Image
|
||||
'width' => 'Dimensions',
|
||||
'camera' => 'Appareil',
|
||||
// HTML
|
||||
'site_name' => 'Site',
|
||||
'og_type' => 'Type',
|
||||
'language' => 'Langue',
|
||||
// Commun
|
||||
'author' => $isHtml ? 'Auteur' : ($isPdf ? 'Auteur' : 'Auteur EXIF'),
|
||||
'date' => $isPdf ? 'Créé le' : ($isHtml ? 'Publié le' : 'Prise de vue'),
|
||||
'description' => 'Description',
|
||||
'subject' => 'Sujet',
|
||||
'keywords' => 'Mots-clés',
|
||||
'copyright' => 'Copyright',
|
||||
// PDF logiciel
|
||||
'creator' => 'Créé avec',
|
||||
'producer' => 'Produit par',
|
||||
// HTML liens
|
||||
'canonical' => 'URL canonique',
|
||||
'og_image' => 'Image OG',
|
||||
];
|
||||
|
||||
$hasTitle = !empty($step2Meta['title']);
|
||||
$preAuthor = $step2Meta['author'] ?? $step2Meta['credit'] ?? '';
|
||||
$preSource = $step2Meta['canonical'] ?? $step2Meta['source'] ?? $step2Url;
|
||||
?>
|
||||
|
||||
<div class="d-flex align-items-center gap-3 mb-4">
|
||||
<a href="/import/<?= rawurlencode($step2Article['uuid']) ?>" class="btn btn-secondary btn-sm">← Retour</a>
|
||||
<h1 class="h4 mb-0">Importer un fichier</h1>
|
||||
</div>
|
||||
|
||||
<p class="text-muted small mb-4">
|
||||
Article : <strong><?= htmlspecialchars($step2Article['title']) ?></strong>
|
||||
</p>
|
||||
|
||||
<?php if ($step2Meta['blocked'] ?? false): ?>
|
||||
<div class="alert alert-warning small mb-4">
|
||||
Le site a bloqué la récupération automatique des métadonnées (protection anti-bot).
|
||||
Renseignez le titre manuellement ci-dessous.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($step2Screenshot ?? null): ?>
|
||||
<!-- Aperçu screenshot -->
|
||||
<div class="mb-4">
|
||||
<p class="fw-semibold small mb-2">Aperçu de la page</p>
|
||||
<?php
|
||||
$previewMtime = @filemtime(BASE_PATH . '/data/' . $step2Article['uuid'] . '/files/' . $step2Screenshot) ?: time();
|
||||
?>
|
||||
<img src="/file?uuid=<?= rawurlencode($step2Article['uuid']) ?>&name=<?= rawurlencode($step2Screenshot) ?>&v=<?= $previewMtime ?>"
|
||||
class="img-fluid rounded shadow-sm d-block"
|
||||
style="max-height:320px;object-fit:cover;object-position:top"
|
||||
alt="Aperçu">
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Résumé métadonnées -->
|
||||
<?php
|
||||
$visibleRows = array_filter($metaRows, fn ($label, $key) => !empty($step2Meta[$key]), ARRAY_FILTER_USE_BOTH);
|
||||
if ($visibleRows): ?>
|
||||
<div class="card mb-4" style="max-width:640px">
|
||||
<div class="card-header small fw-semibold">Métadonnées du fichier</div>
|
||||
<div class="card-body p-0">
|
||||
<table class="table table-sm table-borderless mb-0 small">
|
||||
<tbody>
|
||||
<?php foreach ($visibleRows as $key => $label): ?>
|
||||
<?php
|
||||
$val = $step2Meta[$key];
|
||||
$cellHtml = match($key) {
|
||||
'size' => htmlspecialchars(round($val / 1024) . ' Ko'),
|
||||
'width' => htmlspecialchars($val . ' × ' . ($step2Meta['height'] ?? '?') . ' px'),
|
||||
'og_image' => '<img src="' . htmlspecialchars((string)$val) . '" style="max-height:72px;max-width:200px;border-radius:4px" alt="">',
|
||||
'canonical' => '<a href="' . htmlspecialchars((string)$val) . '" target="_blank" rel="noopener" class="small text-break">' . htmlspecialchars((string)$val) . '</a>',
|
||||
default => htmlspecialchars((string)$val),
|
||||
};
|
||||
?>
|
||||
<tr>
|
||||
<th class="text-muted fw-normal ps-3 pe-3 text-nowrap align-top" style="width:130px"><?= $label ?></th>
|
||||
<td class="pe-3"><?= $cellHtml ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Formulaire -->
|
||||
<div class="card" style="max-width:640px">
|
||||
<div class="card-body">
|
||||
<form method="POST" action="/?action=add_file_from_url&uuid=<?= rawurlencode($step2Article['uuid']) ?>">
|
||||
<input type="hidden" name="image_url" value="<?= htmlspecialchars($step2Url) ?>">
|
||||
<?php if ($step2Screenshot ?? null): ?>
|
||||
<input type="hidden" name="screenshot_file" value="<?= htmlspecialchars($step2Screenshot) ?>">
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
$metaToStore = array_filter(
|
||||
array_diff_key($step2Meta, array_flip(['ok', 'height'])),
|
||||
fn ($v) => $v !== null && $v !== ''
|
||||
);
|
||||
?>
|
||||
<input type="hidden" name="meta_json"
|
||||
value="<?= htmlspecialchars(json_encode($metaToStore, JSON_UNESCAPED_UNICODE)) ?>">
|
||||
|
||||
<!-- Titre (obligatoire) -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">
|
||||
Titre <span class="text-danger">*</span>
|
||||
</label>
|
||||
<input type="text" name="img_title" class="form-control"
|
||||
placeholder="ex. Compte rendu du conseil municipal"
|
||||
value="<?= htmlspecialchars($step2Meta['title'] ?? '') ?>"
|
||||
required autofocus>
|
||||
<?php if (!$hasTitle): ?>
|
||||
<div class="form-text text-warning small">
|
||||
Titre non trouvé dans les métadonnées — saisie requise.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Mode -->
|
||||
<div class="mb-4">
|
||||
<p class="form-label fw-semibold mb-2">Mode</p>
|
||||
<div class="form-check mb-1">
|
||||
<input class="form-check-input" type="radio" name="mode" id="mode_link" value="link" checked>
|
||||
<label class="form-check-label" for="mode_link">
|
||||
<strong>Lien externe</strong>
|
||||
<span class="text-muted small"> — insère une référence, le fichier reste chez l'hôte</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="mode" id="mode_download" value="download">
|
||||
<label class="form-check-label" for="mode_download">
|
||||
<strong>Télécharger sur le serveur</strong>
|
||||
<span class="text-muted small"> — copie locale du fichier</span>
|
||||
</label>
|
||||
</div>
|
||||
<?php if ($step2Screenshot ?? null): ?>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="mode" id="mode_screenshot" value="screenshot">
|
||||
<label class="form-check-label" for="mode_screenshot">
|
||||
<strong>Enregistrer la capture d'écran</strong>
|
||||
<span class="text-muted small"> — sauvegarde l'aperçu comme image</span>
|
||||
</label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div id="copyright-warning" class="alert alert-warning mt-3 mb-0 small" style="display:none">
|
||||
<strong>Droits d'auteur.</strong> Une page de confirmation légale vous sera
|
||||
présentée avant le téléchargement.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Auteur / source : toujours visibles pour les pages web, download-only sinon -->
|
||||
<div id="download-fields" <?= $isHtml ? '' : 'style="display:none"' ?>>
|
||||
<?php if ($preAuthor || $isHtml): ?>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Auteur / crédit</label>
|
||||
<input type="text" name="img_author" class="form-control"
|
||||
placeholder="ex. Jane Doe"
|
||||
value="<?= htmlspecialchars($preAuthor) ?>">
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">URL source</label>
|
||||
<input type="url" name="img_source" class="form-control font-monospace"
|
||||
placeholder="https://…"
|
||||
value="<?= htmlspecialchars($preSource) ?>">
|
||||
<div class="form-text">Laissé vide → URL du fichier utilisée comme source.</div>
|
||||
</div>
|
||||
|
||||
<?php if (!$isHtml || ($step2Screenshot ?? null)): ?>
|
||||
<div class="mb-4">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="is_cover" id="is_cover">
|
||||
<label class="form-check-label" for="is_cover">
|
||||
Définir comme image de couverture
|
||||
<span class="text-muted small">(images uniquement, sera nommée <code>cover.jpg</code>)</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn btn-primary">Valider</button>
|
||||
<a href="/edit/<?= rawurlencode($step2Article['uuid']) ?>"
|
||||
class="btn btn-outline-secondary">Annuler</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$content = ob_get_clean();
|
||||
$title = 'Importer un fichier — ' . htmlspecialchars($step2Article['title']);
|
||||
include __DIR__ . '/layout.php';
|
||||
Reference in New Issue
Block a user