mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
This commit introduces a complete thesis management interface and migrates the system from YAML-based storage to SQLite: Core Changes: - Add Database.php helper class with PDO connection and entity management - Add list.php for viewing all theses with filtering and sorting - Add edit.php for modifying existing thesis records - Add import.php for migrating legacy YAML data to SQLite - Add justfile with development tasks (serve, init-test-db, etc.) Documentation: - Add MIGRATION.md with complete migration guide and architecture docs - Update README.md with database setup and Just recipe instructions - Update .gitignore to exclude test databases and error logs Modified Forms: - Enhanced formulaire.php with transaction-based SQLite processing - Updated index.php with database-driven form options - Improved thanks.php to read from database views The new architecture provides: - Normalized database schema (19 tables, 2 views) - Transaction safety and referential integrity - CRUD operations for thesis management - Filtering by year, orientation, AP program, publication status - Secure file handling with metadata tracking 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
87 lines
2.8 KiB
PHP
87 lines
2.8 KiB
PHP
<?php
|
|
ini_set('display_errors', 0);
|
|
ini_set('log_errors', 1);
|
|
ini_set('error_log', 'error.log');
|
|
|
|
require_once 'Database.php';
|
|
|
|
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
|
$itemsPerPage = 10;
|
|
|
|
try {
|
|
$db = Database::getInstance();
|
|
$offset = ($page - 1) * $itemsPerPage;
|
|
$itemsToLoad = $db->getPublishedTheses($itemsPerPage, $offset);
|
|
$totalItems = $db->countPublishedTheses();
|
|
$totalPages = ceil($totalItems / $itemsPerPage);
|
|
} catch (Exception $e) {
|
|
error_log("Error loading theses: " . $e->getMessage());
|
|
$itemsToLoad = [];
|
|
$totalPages = 0;
|
|
}
|
|
|
|
include 'inc/header.php'; ?>
|
|
|
|
<section class="section">
|
|
<div class="container">
|
|
<div class="columns is-multiline">
|
|
|
|
<?php foreach ($itemsToLoad as $item): ?>
|
|
<div class="column is-one-fifth">
|
|
<a href="memoire.php?id=<?= $item['id']; ?>" class="card-link">
|
|
<div class="card">
|
|
<?php
|
|
// Get cover image from thesis_files if available
|
|
$coverImage = null;
|
|
if (!empty($item['id'])) {
|
|
$files = $db->getThesisFiles($item['id']);
|
|
foreach ($files as $file) {
|
|
$ext = strtolower(pathinfo($file['file_path'], PATHINFO_EXTENSION));
|
|
if (in_array($ext, ['jpg', 'jpeg', 'png', 'gif']) && $file['file_type'] === 'main') {
|
|
$coverImage = $file['file_path'];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
<?php if ($coverImage): ?>
|
|
<div class="card-image">
|
|
<figure class="image ">
|
|
<img src="<?= htmlspecialchars($coverImage); ?>" alt="Image preview">
|
|
</figure>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div class="card-content">
|
|
<h4 class="title is-4">
|
|
<?= htmlspecialchars($item['title']); ?>
|
|
</h4>
|
|
<h2 class="subtitle">
|
|
<?= htmlspecialchars($item['authors'] ?? 'Auteur inconnu'); ?>
|
|
</h2>
|
|
<h3 class="tag title is-6 is-link is-light">
|
|
<?= htmlspecialchars($item['year']); ?>
|
|
</h3>
|
|
<p class="block content">
|
|
<?php
|
|
$excerpt_length = 150;
|
|
$synopsis = $item['synopsis'] ?? '';
|
|
$description_excerpt = strlen($synopsis) > $excerpt_length
|
|
? substr($synopsis, 0, $excerpt_length) . '...'
|
|
: $synopsis;
|
|
?>
|
|
<?= htmlspecialchars($description_excerpt); ?>
|
|
</p>
|
|
</div>
|
|
|
|
</div>
|
|
</a>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<?php
|
|
include 'inc/footer.php';
|
|
?>
|