mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
Separate admin views from controllers — move HTML to templates/admin/
All admin pages refactored to thin controllers + pure view templates, mirroring the public-page pattern: Controllers (public/admin/*.php): auth, data loading, include template Views (templates/admin/*.php): pure HTML/PHP output Fragment partials (templates/admin/partials/): toast, system-log-panel, system-nginx-config-panel Pages migrated: login, tags, contenus, contenus-edit, account, acces-etudiante, thanks, add, edit, parametres, system, index Fragment endpoints refactored: system-fragment.php, toast-fragment.php Skipped (pure redirects): logout, logs, status, import
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
<?php
|
||||
// Bootstrap application
|
||||
require_once __DIR__ . "/../../bootstrap.php";
|
||||
require_once __DIR__ . '/../../src/AdminAuth.php';
|
||||
|
||||
// Configure error reporting
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_log', 'error.log');
|
||||
@@ -15,7 +13,6 @@ if (!$studentMode) {
|
||||
|
||||
require_once __DIR__ . '/../../src/Database.php';
|
||||
|
||||
// Security: Validate thesis ID parameter
|
||||
$thesisId = null;
|
||||
$thesis = null;
|
||||
$files = [];
|
||||
@@ -27,8 +24,6 @@ if (isset($_GET['id'])) {
|
||||
if ($thesisId !== false && $thesisId > 0) {
|
||||
try {
|
||||
$db = new Database();
|
||||
|
||||
// Get thesis data
|
||||
$thesis = $db->getThesis($thesisId);
|
||||
|
||||
if (!$thesis) {
|
||||
@@ -48,7 +43,6 @@ if (isset($_GET['id'])) {
|
||||
$error = "Aucun identifiant spécifié.";
|
||||
}
|
||||
|
||||
// Helper function to format file size
|
||||
function formatFileSize($bytes) {
|
||||
if ($bytes >= 1073741824) {
|
||||
return number_format($bytes / 1073741824, 2) . ' GB';
|
||||
@@ -61,135 +55,12 @@ function formatFileSize($bytes) {
|
||||
}
|
||||
}
|
||||
|
||||
// Set page title for header
|
||||
$pageTitle = "Récapitulatif TFE";
|
||||
?>
|
||||
<?php
|
||||
$isAdmin = true;
|
||||
if ($studentMode) {
|
||||
$bodyClass = 'admin-body student-body';
|
||||
require_once APP_ROOT . '/templates/head.php';
|
||||
} else {
|
||||
$bodyClass = 'admin-body';
|
||||
require_once APP_ROOT . '/templates/head.php';
|
||||
$bodyClass = $studentMode ? 'admin-body student-body' : 'admin-body';
|
||||
require_once APP_ROOT . '/templates/head.php';
|
||||
if (!$studentMode) {
|
||||
include APP_ROOT . '/templates/header.php';
|
||||
}
|
||||
?>
|
||||
|
||||
<main id="main-content">
|
||||
<?php if ($studentMode): ?>
|
||||
<!-- ═══════════════════ STUDENT MODE: Thank you page ═══════════════════ -->
|
||||
<div class="thanks-student-page">
|
||||
<?php if ($error): ?>
|
||||
<div class="thanks-error">
|
||||
<h1>⚠ Oups…</h1>
|
||||
<p><?= htmlspecialchars($error) ?></p>
|
||||
<a href="/admin/add.php?mode=student" class="btn-new-form">← Retour au formulaire</a>
|
||||
</div>
|
||||
|
||||
<?php elseif ($thesis): ?>
|
||||
<div class="thanks-success">
|
||||
<h1>Merci 🎉</h1>
|
||||
<p class="thanks-message">
|
||||
Ton TFE <strong><?= htmlspecialchars($thesis['title']) ?></strong> a bien été soumis.
|
||||
</p>
|
||||
<a href="/admin/add.php?mode=student" class="btn-new-form">+ Ajouter un nouveau TFE</a>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="thanks-error">
|
||||
<h1>Erreur</h1>
|
||||
<p>Aucune donnée à afficher.</p>
|
||||
<a href="/admin/add.php?mode=student" class="btn-new-form">← Retour au formulaire</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
<!-- ═══════════════════ ADMIN MODE: Recap page ═══════════════════ -->
|
||||
<h1>Récapitulatif TFE</h1>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<p class="toast" role="alert" data-type="error">⚠ <?= htmlspecialchars($error) ?></p>
|
||||
<p><a href="/admin/add.php" class="admin-btn-secondary">Retour au formulaire</a></p>
|
||||
|
||||
<?php elseif ($thesis): ?>
|
||||
<section>
|
||||
<h2>Informations de base</h2>
|
||||
<dl>
|
||||
<dt>Identifiant</dt><dd><?= htmlspecialchars($thesis['identifier']) ?></dd>
|
||||
<dt>Titre</dt><dd><?= htmlspecialchars($thesis['title']) ?></dd>
|
||||
<?php if ($thesis['subtitle']): ?>
|
||||
<dt>Sous-titre</dt><dd><?= htmlspecialchars($thesis['subtitle']) ?></dd>
|
||||
<?php endif; ?>
|
||||
<dt>Auteur·ice(s)</dt><dd><?= htmlspecialchars($thesis['authors']) ?></dd>
|
||||
<dt>Année</dt><dd><?= htmlspecialchars($thesis['year']) ?></dd>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Détails académiques</h2>
|
||||
<dl>
|
||||
<dt>Orientation</dt><dd><?= htmlspecialchars($thesis['orientation'] ?? '–') ?></dd>
|
||||
<dt>Atelier pratique</dt><dd><?= htmlspecialchars($thesis['ap_program'] ?? '–') ?></dd>
|
||||
<dt>Finalité</dt><dd><?= htmlspecialchars($thesis['finality_type'] ?? '–') ?></dd>
|
||||
<?php if ($thesis['supervisors']): ?>
|
||||
<dt>Promoteur·ice(s)</dt><dd><?= htmlspecialchars($thesis['supervisors']) ?></dd>
|
||||
<?php endif; ?>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Contenu</h2>
|
||||
<dl>
|
||||
<?php if ($thesis['languages']): ?>
|
||||
<dt>Langue(s)</dt><dd><?= htmlspecialchars($thesis['languages']) ?></dd>
|
||||
<?php endif; ?>
|
||||
<?php if ($thesis['formats']): ?>
|
||||
<dt>Format(s)</dt><dd><?= htmlspecialchars($thesis['formats']) ?></dd>
|
||||
<?php endif; ?>
|
||||
<?php if ($thesis['keywords']): ?>
|
||||
<dt>Mots-clés</dt><dd><?= htmlspecialchars($thesis['keywords']) ?></dd>
|
||||
<?php endif; ?>
|
||||
<?php if ($thesis['file_size_info']): ?>
|
||||
<dt>Durée / Taille</dt><dd><?= htmlspecialchars($thesis['file_size_info']) ?></dd>
|
||||
<?php endif; ?>
|
||||
<?php if ($thesis['baiu_link']): ?>
|
||||
<dt>Lien</dt><dd><a href="<?= htmlspecialchars($thesis['baiu_link']) ?>" target="_blank" rel="noopener"><?= htmlspecialchars($thesis['baiu_link']) ?></a></dd>
|
||||
<?php endif; ?>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<?php if (!empty($files)): ?>
|
||||
<section>
|
||||
<h2>Fichiers</h2>
|
||||
<table>
|
||||
<thead><tr><th scope="col">Type</th><th scope="col">Fichier</th><th scope="col">Taille</th><th scope="col">Date</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($files as $f): ?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($f['file_type']) ?></td>
|
||||
<td><?= htmlspecialchars($f['file_name']) ?></td>
|
||||
<td><?= formatFileSize($f['file_size']) ?></td>
|
||||
<td><?= date('d/m/Y H:i', strtotime($f['uploaded_at'])) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="admin-action-bar">
|
||||
<a href="/admin/edit.php?id=<?= $thesisId ?>" class="admin-btn">Modifier</a>
|
||||
<a href="/admin/add.php" class="admin-btn-secondary">Ajouter un autre TFE</a>
|
||||
<a href="/admin/" class="admin-btn-secondary">Retour à la liste</a>
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
<p class="admin-muted">Aucune donnée à afficher.</p>
|
||||
<p><a href="/admin/add.php" class="admin-btn-secondary">Retour au formulaire</a></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
</main>
|
||||
|
||||
<?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>
|
||||
include APP_ROOT . '/templates/admin/thanks.php';
|
||||
require_once APP_ROOT . '/templates/admin/footer.php';
|
||||
|
||||
Reference in New Issue
Block a user