-
Logo du site
-
-
-
+
-
-
Enregistrer les modifications
-
+
+
+ Description du site
+
+
+
+
+
+
+
Page "À propos"
+
+
+ Titre de la page
+
+
+
+
+
+
+
+
Enregistrer les modifications
+
+
+
+
+
diff --git a/assets/css/public.css b/assets/css/public.css
index 8df7c4d..5d528f5 100644
--- a/assets/css/public.css
+++ b/assets/css/public.css
@@ -101,6 +101,26 @@ body {
line-height: 1.6;
}
+.header-actions {
+ position: absolute;
+ top: var(--spacing-md);
+ right: var(--spacing-md);
+}
+
+.about-button {
+ display: inline-block;
+ padding: var(--spacing-sm) var(--spacing-md);
+ background-color: var(--accent-primary);
+ color: var(--text-tertiary);
+ text-decoration: none;
+ border-radius: var(--radius-sm);
+ transition: var(--transition);
+}
+
+.about-button:hover {
+ background-color: var(--accent-secondary);
+}
+
/* Conteneur principal */
.main-content {
max-width: var(--content-width);
diff --git a/config.json b/config.json
index b6e055b..81f7fb1 100644
--- a/config.json
+++ b/config.json
@@ -3,6 +3,11 @@
"name": "Nom du Site",
"description": "Description du site"
},
+ "about": {
+ "title": "À propos",
+ "content": "",
+ "background": "assets/images/site/about-bg.jpg"
+ },
"users": [
{
"id": "admin",
diff --git a/includes/site-upload.php b/includes/site-upload.php
index 835bc77..f0c5999 100644
--- a/includes/site-upload.php
+++ b/includes/site-upload.php
@@ -1,8 +1,8 @@
uploadDir = __DIR__ . '/../assets/images/site/';
@@ -18,11 +18,11 @@ class SiteUploadHandler {
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mimeType = $finfo->file($file['tmp_name']);
if (!in_array($mimeType, $this->allowedTypes)) {
- throw new Exception('Type de fichier non autorisé. Types acceptés : JPG, PNG, GIF, SVG');
+ throw new Exception('Type de fichier non autorisé. Types acceptés : JPG, PNG, GIF, WEBP');
}
if ($file['size'] > $this->maxFileSize) {
- throw new Exception('Fichier trop volumineux. Taille maximum : 2MB');
+ throw new Exception('Fichier trop volumineux. Taille maximum : 5MB');
}
$extension = $this->getExtensionFromMimeType($mimeType);
@@ -46,6 +46,103 @@ class SiteUploadHandler {
throw $e;
}
}
+
+ public function handleBackgroundUpload($file) {
+ try {
+ if ($file['error'] !== UPLOAD_ERR_OK) {
+ throw new Exception($this->getUploadErrorMessage($file['error']));
+ }
+
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
+ $mimeType = $finfo->file($file['tmp_name']);
+ if (!in_array($mimeType, $this->allowedTypes)) {
+ throw new Exception('Type de fichier non autorisé. Types acceptés : JPG, PNG, GIF, WEBP');
+ }
+
+ if ($file['size'] > $this->maxFileSize) {
+ throw new Exception('Fichier trop volumineux. Taille maximum : 5MB');
+ }
+
+ // Vérifier les dimensions de l'image
+ list($width, $height) = getimagesize($file['tmp_name']);
+ $minWidth = 1200;
+ $minHeight = 600;
+
+ if ($width < $minWidth || $height < $minHeight) {
+ throw new Exception("L'image doit faire au moins {$minWidth}x{$minHeight} pixels");
+ }
+
+ $extension = $this->getExtensionFromMimeType($mimeType);
+ $filename = 'about-bg.' . $extension;
+ $targetPath = $this->uploadDir . $filename;
+
+ // Supprimer l'ancien background s'il existe
+ $this->removeOldBackground();
+
+ // Redimensionner l'image si nécessaire
+ $maxWidth = 1920;
+ $maxHeight = 1080;
+
+ if ($width > $maxWidth || $height > $maxHeight) {
+ $this->resizeImage(
+ $file['tmp_name'],
+ $targetPath,
+ $mimeType,
+ $maxWidth,
+ $maxHeight
+ );
+ } else {
+ if (!move_uploaded_file($file['tmp_name'], $targetPath)) {
+ throw new Exception('Erreur lors du déplacement du fichier uploadé');
+ }
+ }
+
+ return 'assets/images/site/' . $filename;
+
+ } catch (Exception $e) {
+ throw $e;
+ }
+ }
+
+ private function removeOldBackground() {
+ foreach (glob($this->uploadDir . 'about-bg.*') as $file) {
+ unlink($file);
+ }
+ }
+
+ private function resizeImage($sourcePath, $targetPath, $mimeType, $maxWidth, $maxHeight) {
+ list($width, $height) = getimagesize($sourcePath);
+
+ // Calculer les nouvelles dimensions en conservant le ratio
+ $ratio = min($maxWidth / $width, $maxHeight / $height);
+ $newWidth = round($width * $ratio);
+ $newHeight = round($height * $ratio);
+
+ // Créer la nouvelle image
+ $sourceImage = $this->createImageFromFile($sourcePath, $mimeType);
+ $newImage = imagecreatetruecolor($newWidth, $newHeight);
+
+ // Préserver la transparence pour PNG
+ if ($mimeType === 'image/png') {
+ imagealphablending($newImage, false);
+ imagesavealpha($newImage, true);
+ }
+
+ // Redimensionner
+ imagecopyresampled(
+ $newImage, $sourceImage,
+ 0, 0, 0, 0,
+ $newWidth, $newHeight,
+ $width, $height
+ );
+
+ // Sauvegarder l'image redimensionnée
+ $this->saveImage($newImage, $targetPath, $mimeType);
+
+ // Libérer la mémoire
+ imagedestroy($sourceImage);
+ imagedestroy($newImage);
+ }
private function ensureUploadDirectory() {
if (!file_exists($this->uploadDir)) {
@@ -113,8 +210,25 @@ class SiteUploadHandler {
return imagecreatefrompng($file);
case 'image/gif':
return imagecreatefromgif($file);
+ case 'image/webp':
+ return imagecreatefromwebp($file);
default:
- throw new Exception('Type d\'image non supporté pour le favicon');
+ throw new Exception('Type d\'image non supporté');
+ }
+ }
+
+ private function saveImage($image, $path, $mimeType) {
+ switch ($mimeType) {
+ case 'image/jpeg':
+ return imagejpeg($image, $path, 85);
+ case 'image/png':
+ return imagepng($image, $path, 9);
+ case 'image/gif':
+ return imagegif($image, $path);
+ case 'image/webp':
+ return imagewebp($image, $path, 85);
+ default:
+ throw new Exception('Type d\'image non supporté');
}
}
@@ -123,9 +237,9 @@ class SiteUploadHandler {
'image/jpeg' => 'jpg',
'image/png' => 'png',
'image/gif' => 'gif',
- 'image/svg+xml' => 'svg'
+ 'image/webp' => 'webp'
];
- return $map[$mimeType] ?? 'png';
+ return $map[$mimeType] ?? 'jpg';
}
private function getUploadErrorMessage($error) {
diff --git a/index.php b/index.php
index e3f73f0..6fc832b 100644
--- a/index.php
+++ b/index.php
@@ -61,6 +61,10 @@ function formatDate($date) {
= htmlspecialchars($config['site']['name']) ?>
= nl2br(htmlspecialchars($config['site']['description'])) ?>
+
+