refactor: extract templates from public/

- Created /templates for main site (header.php, footer.php)
- Created /templates/admin for admin section (head.php, footer.php)
- Removed /public/includes and /public/admin/inc
- Updated all references in code and docs
- Tests passing 

Cleaner separation: /public only contains web-accessible files (PHP entry points + assets)
This commit is contained in:
Théophile Gervreau-Mercier
2026-02-12 12:15:41 +01:00
parent 7fca85d1c1
commit 87971f9c23
15 changed files with 21 additions and 21 deletions

View File

@@ -25,7 +25,7 @@ if (php_sapi_name() === 'cli-server') {
// Simple helper function for including templates
function include_template($name) {
$path = APP_ROOT . '/public/includes/' . $name;
$path = APP_ROOT . '/templates/' . $name;
if (file_exists($path)) {
include $path;
}

View File

@@ -254,7 +254,7 @@ ini_set('error_log', '/var/log/posterg/error.log');
### 10. External CDN Stylesheet Without Subresource Integrity (SRI)
**File:** `public/admin/inc/head.php`
**File:** `templates/admin/head.php`
```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">

View File

@@ -57,7 +57,7 @@ function wasSelected($key, $value)
return $formData[$key] == $value;
}
?>
<?php require_once __DIR__ . "/inc/head.php"; ?>
<?php require_once APP_ROOT . '/templates/admin/head.php'; ?>
<main>
<?php if ($error): ?>
<div class="error-message">
@@ -260,4 +260,4 @@ function wasSelected($key, $value)
</form>
</main>
<?php require_once __DIR__ . "/inc/footer.php"; ?>
<?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>

View File

@@ -173,7 +173,7 @@ try {
die("Erreur lors du chargement: " . $e->getMessage());
}
?>
<?php require_once __DIR__ . '/inc/head.php'; ?>
<?php require_once APP_ROOT . '/templates/admin/head.php'; ?>
<main>
<?php if ($error): ?>
@@ -318,4 +318,4 @@ try {
</form>
</main>
<?php require_once __DIR__ . '/inc/footer.php'; ?>
<?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>

View File

@@ -277,7 +277,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['csv_file'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
}
?>
<?php require_once __DIR__ . '/inc/head.php'; ?>
<?php require_once APP_ROOT . '/templates/admin/head.php'; ?>
<main>
<h2>Importer des TFE depuis un fichier CSV</h2>
@@ -347,4 +347,4 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['csv_file'])) {
<p>Voir: <code>../db/Database_TFE_test.csv</code></p>
</main>
<?php require_once __DIR__ . "/inc/footer.php"; ?>
<?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>

View File

@@ -77,7 +77,7 @@ try {
}
?>
<?php require_once __DIR__ . "/inc/head.php"; ?>
<?php require_once APP_ROOT . '/templates/admin/head.php'; ?>
<script>
function toggleAll(source) {
const checkboxes = document.querySelectorAll('input[name="selected_theses[]"]');
@@ -285,4 +285,4 @@ try {
<?php endif; ?>
</main>
<?php require_once __DIR__ . "/inc/footer.php"; ?>
<?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>

View File

@@ -71,7 +71,7 @@ function formatFileSize($bytes) {
// Set page title for header
$pageTitle = "Merci";
?>
<?php require_once __DIR__ . '/inc/head.php'; ?>
<?php require_once APP_ROOT . '/templates/admin/head.php'; ?>
<main>
<?php if ($error): ?>
@@ -198,4 +198,4 @@ $pageTitle = "Merci";
<?php endif; ?>
</main>
<?php require_once __DIR__ . '/inc/footer.php'; ?>
<?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>

View File

@@ -19,7 +19,7 @@ try {
$totalPages = 0;
}
include APP_ROOT . '/public/includes/header.php';
include APP_ROOT . '/templates/header.php';
?>
<main>
@@ -54,4 +54,4 @@ include APP_ROOT . '/public/includes/header.php';
</nav>
<?php endif; ?>
<?php include APP_ROOT . '/public/includes/footer.php'; ?>
<?php include APP_ROOT . '/templates/footer.php'; ?>

View File

@@ -29,7 +29,7 @@ if (isset($_GET['id'])) {
}
// Include the header template
include APP_ROOT . '/public/includes/header.php'; ?>
include APP_ROOT . '/templates/header.php'; ?>
<main>
<div class="item">
<div class="card-content">
@@ -151,4 +151,4 @@ include APP_ROOT . '/public/includes/header.php'; ?>
</main>
<!-- Include the footer template -->
<?php include APP_ROOT . '/public/includes/footer.php'; ?>
<?php include APP_ROOT . '/templates/footer.php'; ?>

View File

@@ -16,7 +16,7 @@ if (!$rateLimit->check()) {
$rateLimit->sendHeaders();
// Display error page
include APP_ROOT . '/public/includes/header.php';
include APP_ROOT . '/templates/header.php';
echo '<section class="section">';
echo ' <div class="container">';
echo ' <div class="notification is-danger">';
@@ -26,7 +26,7 @@ if (!$rateLimit->check()) {
echo ' </div>';
echo ' </div>';
echo '</section>';
include APP_ROOT . '/public/includes/footer.php';
include APP_ROOT . '/templates/footer.php';
exit;
}
@@ -122,7 +122,7 @@ try {
$languages = [];
}
include APP_ROOT . '/public/includes/header.php'; ?>
include APP_ROOT . '/templates/header.php'; ?>
<section class="section">
<div class="container">
@@ -415,4 +415,4 @@ include APP_ROOT . '/public/includes/header.php'; ?>
</div>
</section>
<?php include APP_ROOT . '/public/includes/footer.php'; ?>
<?php include APP_ROOT . '/templates/footer.php'; ?>

View File

@@ -1 +1 @@
[1770894771]
[1770894924]