mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Refactor about.php
- Hardcode source code URL and credits in about template, remove from DB/admin interface; only contacts remains editable - Merge apropos editables into one À propos section, remove charte, add editable source code URL
This commit is contained in:
@@ -21,15 +21,12 @@ class AboutController
|
||||
if (empty(trim($rawContent)) || trim($rawContent) === 'Contenu à venir') {
|
||||
$rawContent = $this->defaultContent;
|
||||
}
|
||||
$contacts = $db->getAproposContent('contacts');
|
||||
$credits = $db->getAproposContent('credits');
|
||||
$contacts = is_array($contacts) && !empty($contacts) ? $contacts : null;
|
||||
$credits = is_array($credits) && !empty($credits) ? $credits : null;
|
||||
$contacts = $db->getAproposContent('contacts');
|
||||
$contacts = is_array($contacts) && !empty($contacts) ? $contacts : null;
|
||||
} catch (Exception $e) {
|
||||
error_log('Error loading about page: ' . $e->getMessage());
|
||||
$rawContent = $this->defaultContent;
|
||||
$contacts = null;
|
||||
$credits = null;
|
||||
}
|
||||
|
||||
$pd = new Parsedown();
|
||||
@@ -39,7 +36,6 @@ class AboutController
|
||||
'currentNav' => 'apropos',
|
||||
'aboutHtml' => $pd->text($rawContent),
|
||||
'contacts' => $contacts,
|
||||
'credits' => $credits,
|
||||
'pageTitle' => 'À Propos – XAMXAM',
|
||||
'metaDescription' => "À propos de XAMXAM, le répertoire des mémoires de fin d'études de l'erg – École de Recherches Graphiques de Bruxelles.",
|
||||
'extraCss' => ['/assets/css/apropos.css'],
|
||||
|
||||
@@ -2239,31 +2239,21 @@ class Database
|
||||
return null;
|
||||
}
|
||||
|
||||
$value = $row['value'];
|
||||
if ($key === 'erg_url') {
|
||||
return $value;
|
||||
}
|
||||
$decoded = json_decode($value, true);
|
||||
$decoded = json_decode($row['value'], true);
|
||||
return is_array($decoded) ? $decoded : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save an apropos content value by key.
|
||||
* @param string $key
|
||||
* @param mixed $value array for contacts/credits, string for erg_url
|
||||
* Save an apropos content value by key (contacts JSON).
|
||||
*/
|
||||
public function saveAproposContent(string $key, $value): void
|
||||
public function saveAproposContent(string $key, array $value): void
|
||||
{
|
||||
$stmt = $this->pdo->prepare('SELECT id FROM apropos_contents WHERE key = ?');
|
||||
$stmt->execute([$key]);
|
||||
if (!$stmt->fetch()) {
|
||||
throw new Exception("Apropos key not found: $key");
|
||||
}
|
||||
$storedValue = is_array($value) ? json_encode($value, JSON_UNESCAPED_UNICODE) : (string)$value;
|
||||
$storedValue = json_encode($value, JSON_UNESCAPED_UNICODE);
|
||||
$stmt = $this->pdo->prepare(
|
||||
'UPDATE apropos_contents SET value = ?, updated_at = CURRENT_TIMESTAMP WHERE key = ?'
|
||||
'INSERT INTO apropos_contents (key, value, updated_at) VALUES (?, ?, CURRENT_TIMESTAMP)
|
||||
ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = CURRENT_TIMESTAMP'
|
||||
);
|
||||
$stmt->execute([$storedValue, $key]);
|
||||
$stmt->execute([$key, $storedValue]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user