mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
Refactor admin panel and add migration documentation
- Add comprehensive migration guides (DEPLOYMENT_MIGRATION.md, DIRECTORY_STRUCTURE.md, MIGRATION_CHECKLIST.md) - Refactor admin panel: split add.php, create reusable header/footer - Update styles: admin.css, common.css, main.css - Improve public pages: index.php, memoire.php - Reorganize database documentation into database/docs/ - Update .gitignore and justfile This prepares for migration to public/ directory structure
This commit is contained in:
148
admin/import.php
148
admin/import.php
@@ -11,6 +11,8 @@ if (empty($_SESSION['csrf_token'])) {
|
||||
|
||||
require_once __DIR__ . '/../lib/Database.php';
|
||||
|
||||
$pageTitle = "Import";
|
||||
|
||||
$message = '';
|
||||
$errors = [];
|
||||
$importedCount = 0;
|
||||
@@ -249,7 +251,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['csv_file'])) {
|
||||
$db->commit();
|
||||
$importedCount++;
|
||||
$importResults[] = "✓ Ligne $lineNumber: \"$title\" importé (ID: $thesisId)";
|
||||
|
||||
} catch (Exception $e) {
|
||||
$db->rollback();
|
||||
$skippedCount++;
|
||||
@@ -261,7 +262,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['csv_file'])) {
|
||||
fclose($handle);
|
||||
|
||||
$message = "Import terminé : $importedCount TFE importés, $skippedCount ignorés.";
|
||||
|
||||
} catch (Exception $e) {
|
||||
$errors[] = $e->getMessage();
|
||||
error_log("CSV import error: " . $e->getMessage());
|
||||
@@ -272,95 +272,81 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['csv_file'])) {
|
||||
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Import CSV - Post-ERG</title>
|
||||
<link rel="stylesheet" href="assets/normalize.css">
|
||||
<link rel="stylesheet" href="https://raw.githack.com/waldyrious/downstyler/master/downstyler.css" />
|
||||
<link rel="shortcut icon" href="assets/icon.svg" type="image/svg">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Import CSV - Post-ERG</h1>
|
||||
<nav>
|
||||
<a href="index.php">← Nouveau TFE</a> |
|
||||
<a href="list.php">📋 Liste des TFE</a>
|
||||
</nav>
|
||||
</header>
|
||||
// <title>Import CSV - Post-ERG</title>
|
||||
// <header>
|
||||
// <h1>Import CSV - Post-ERG</h1>
|
||||
// <nav>
|
||||
// <a href="index.php">← Nouveau TFE</a> |
|
||||
// <a href="list.php">📋 Liste des TFE</a>
|
||||
// </nav>
|
||||
// </header>
|
||||
|
||||
<main>
|
||||
<h2>Importer des TFE depuis un fichier CSV</h2>
|
||||
<main>
|
||||
<h2>Importer des TFE depuis un fichier CSV</h2>
|
||||
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div style="background: #fee; border: 2px solid #c00; padding: 1rem; margin-bottom: 1rem; border-radius: 4px; color: #c00;">
|
||||
<strong>⚠️ Erreurs:</strong>
|
||||
<ul>
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<li><?php echo htmlspecialchars($error); ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div style="background: #fee; border: 2px solid #c00; padding: 1rem; margin-bottom: 1rem; border-radius: 4px; color: #c00;">
|
||||
<strong>⚠️ Erreurs:</strong>
|
||||
<ul>
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<li><?php echo htmlspecialchars($error); ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($message): ?>
|
||||
<div style="background: #efe; border: 2px solid #0a0; padding: 1rem; margin-bottom: 1rem; border-radius: 4px; color: #0a0;">
|
||||
<strong>✓ <?php echo htmlspecialchars($message); ?></strong>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($message): ?>
|
||||
<div style="background: #efe; border: 2px solid #0a0; padding: 1rem; margin-bottom: 1rem; border-radius: 4px; color: #0a0;">
|
||||
<strong>✓ <?php echo htmlspecialchars($message); ?></strong>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form action="import.php" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($_SESSION['csrf_token']); ?>">
|
||||
<form action="import.php" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($_SESSION['csrf_token']); ?>">
|
||||
|
||||
<fieldset>
|
||||
<legend>Sélectionner un fichier CSV</legend>
|
||||
<fieldset>
|
||||
<legend>Sélectionner un fichier CSV</legend>
|
||||
|
||||
<p><strong>Format attendu:</strong></p>
|
||||
<ul>
|
||||
<li>Colonnes: Identifiant, Titre, Sous-titre, Auteur·ice(s), Contact, Promoteur·ice(s), Format, Année, AP, Orientation, Finalité, Mots-clés, Synopsis, Contexte, Remarques, Langue, Autorisation, License, taille, Points sur 20, lien BAIU</li>
|
||||
<li>Les deux premières lignes seront ignorées (entête)</li>
|
||||
<li>Séparateur: virgule</li>
|
||||
<li>Encodage: UTF-8</li>
|
||||
</ul>
|
||||
<p><strong>Format attendu:</strong></p>
|
||||
<ul>
|
||||
<li>Colonnes: Identifiant, Titre, Sous-titre, Auteur·ice(s), Contact, Promoteur·ice(s), Format, Année, AP, Orientation, Finalité, Mots-clés, Synopsis, Contexte, Remarques, Langue, Autorisation, License, taille, Points sur 20, lien BAIU</li>
|
||||
<li>Les deux premières lignes seront ignorées (entête)</li>
|
||||
<li>Séparateur: virgule</li>
|
||||
<li>Encodage: UTF-8</li>
|
||||
</ul>
|
||||
|
||||
<label for="csv_file">Fichier CSV:</label>
|
||||
<input type="file" id="csv_file" name="csv_file" accept=".csv" required>
|
||||
<label for="csv_file">Fichier CSV:</label>
|
||||
<input type="file" id="csv_file" name="csv_file" accept=".csv" required>
|
||||
|
||||
<button type="submit">Importer</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
<button type="submit">Importer</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<?php if (!empty($importResults)): ?>
|
||||
<h3>Résultats de l'import</h3>
|
||||
<div style="background: #f5f5f5; padding: 1rem; border-radius: 4px; max-height: 400px; overflow-y: auto;">
|
||||
<pre style="margin: 0; font-size: 0.9em;"><?php
|
||||
foreach ($importResults as $result) {
|
||||
echo htmlspecialchars($result) . "\n";
|
||||
}
|
||||
?></pre>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($importResults)): ?>
|
||||
<h3>Résultats de l'import</h3>
|
||||
<div style="background: #f5f5f5; padding: 1rem; border-radius: 4px; max-height: 400px; overflow-y: auto;">
|
||||
<pre style="margin: 0; font-size: 0.9em;"><?php
|
||||
foreach ($importResults as $result) {
|
||||
echo htmlspecialchars($result) . "\n";
|
||||
}
|
||||
?></pre>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<hr>
|
||||
<hr>
|
||||
|
||||
<h3>Notes importantes</h3>
|
||||
<ul>
|
||||
<li><strong>Codes orientation:</strong> SC (Sculpture), VI (Vidéographie), CA (Cinéma d'animation), IP (Installation-Performance), etc.</li>
|
||||
<li><strong>Codes AP:</strong> DPM, LIENS, APS (comme dans la base)</li>
|
||||
<li><strong>Auteurs multiples:</strong> Séparer par des virgules</li>
|
||||
<li><strong>Mots-clés:</strong> Maximum 10, séparés par des virgules</li>
|
||||
<li><strong>Formats:</strong> Séparer par des virgules</li>
|
||||
<li>Les lignes avec erreurs seront ignorées et loggées</li>
|
||||
</ul>
|
||||
<h3>Notes importantes</h3>
|
||||
<ul>
|
||||
<li><strong>Codes orientation:</strong> SC (Sculpture), VI (Vidéographie), CA (Cinéma d'animation), IP (Installation-Performance), etc.</li>
|
||||
<li><strong>Codes AP:</strong> DPM, LIENS, APS (comme dans la base)</li>
|
||||
<li><strong>Auteurs multiples:</strong> Séparer par des virgules</li>
|
||||
<li><strong>Mots-clés:</strong> Maximum 10, séparés par des virgules</li>
|
||||
<li><strong>Formats:</strong> Séparer par des virgules</li>
|
||||
<li>Les lignes avec erreurs seront ignorées et loggées</li>
|
||||
</ul>
|
||||
|
||||
<h3>Exemple de fichier CSV</h3>
|
||||
<p>Voir: <code>../db/Database_TFE_test.csv</code></p>
|
||||
</main>
|
||||
<h3>Exemple de fichier CSV</h3>
|
||||
<p>Voir: <code>../db/Database_TFE_test.csv</code></p>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<p>Import CSV - Post-ERG Database</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
<? include "inc/footer.php" ?>
|
||||
Reference in New Issue
Block a user