mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
style: normalize headers, overtype editor rounded corners, remove duplicate cover preview, thesis-add-header grid layout, subtitle below header with top gradient
This commit is contained in:
@@ -2209,27 +2209,16 @@ class Database
|
||||
'partage_intro',
|
||||
'fieldset_tfe_info',
|
||||
'fieldset_synopsis',
|
||||
'fieldset_jury',
|
||||
'fieldset_languages',
|
||||
'fieldset_keywords',
|
||||
'fieldset_academic',
|
||||
'fieldset_jury',
|
||||
'fieldset_files',
|
||||
'fieldset_metadata',
|
||||
'fieldset_access',
|
||||
'fieldset_email',
|
||||
];
|
||||
|
||||
/**
|
||||
* Human-readable labels for each block key (used in the admin UI).
|
||||
*/
|
||||
public const FORM_HELP_LABELS = [
|
||||
'partage_intro' => 'Introduction du formulaire',
|
||||
'fieldset_tfe_info' => 'Informations du TFE — note d\'introduction',
|
||||
'fieldset_synopsis' => 'Synopsis — explication',
|
||||
'fieldset_jury' => 'Composition du jury — note',
|
||||
'fieldset_academic' => 'Cadre académique — note',
|
||||
'fieldset_files' => 'Fichiers — note',
|
||||
'fieldset_access' => 'Visibilité / Accès — explication',
|
||||
'fieldset_email' => 'E-mail de confirmation — note',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get a single form help block by key. Returns '' when missing.
|
||||
*/
|
||||
@@ -2244,7 +2233,7 @@ class Database
|
||||
}
|
||||
|
||||
/**
|
||||
* Upsert a form help block.
|
||||
* Upsert a form help block (content only).
|
||||
*/
|
||||
public function setFormHelpBlock(string $key, string $content): void
|
||||
{
|
||||
@@ -2260,41 +2249,57 @@ class Database
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all form help blocks ordered by sort_order, as [ key => ['content' => ..., 'updated_at' => ..., 'sort_order' => ...] ].
|
||||
* Update a form help block's name.
|
||||
*/
|
||||
public function setFormHelpBlockName(string $key, string $name): void
|
||||
{
|
||||
if (!in_array($key, self::FORM_HELP_KEYS, true)) {
|
||||
throw new Exception("Unknown form help block key: $key");
|
||||
}
|
||||
$this->pdo->prepare(
|
||||
'UPDATE form_help_blocks SET name = ?, updated_at = CURRENT_TIMESTAMP WHERE key = ?'
|
||||
)->execute([$name, $key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle a form help block's enabled state. Returns the new state (0 or 1).
|
||||
*/
|
||||
public function toggleFormHelpBlock(string $key): int
|
||||
{
|
||||
if (!in_array($key, self::FORM_HELP_KEYS, true)) {
|
||||
throw new Exception("Unknown form help block key: $key");
|
||||
}
|
||||
$this->pdo->prepare(
|
||||
'UPDATE form_help_blocks SET enabled = CASE enabled WHEN 1 THEN 0 ELSE 1 END,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE key = ?'
|
||||
)->execute([$key]);
|
||||
$stmt = $this->pdo->prepare('SELECT enabled FROM form_help_blocks WHERE key = ?');
|
||||
$stmt->execute([$key]);
|
||||
return (int)$stmt->fetchColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all form help blocks, keyed by their key.
|
||||
*/
|
||||
public function getAllFormHelpBlocks(): array
|
||||
{
|
||||
$stmt = $this->pdo->query(
|
||||
'SELECT key, content, updated_at, sort_order FROM form_help_blocks ORDER BY sort_order, key'
|
||||
'SELECT key, name, content, enabled, updated_at FROM form_help_blocks'
|
||||
);
|
||||
$rows = $stmt->fetchAll();
|
||||
$out = [];
|
||||
foreach ($rows as $r) {
|
||||
$out[$r['key']] = [
|
||||
'name' => $r['name'],
|
||||
'content' => $r['content'],
|
||||
'enabled' => (int)$r['enabled'],
|
||||
'updated_at' => $r['updated_at'],
|
||||
'sort_order' => (int)$r['sort_order'],
|
||||
];
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist a new sort order for all form help blocks.
|
||||
* $keys must be an ordered array of known block keys.
|
||||
*/
|
||||
public function reorderFormHelpBlocks(array $keys): void
|
||||
{
|
||||
$stmt = $this->pdo->prepare(
|
||||
'UPDATE form_help_blocks SET sort_order = ? WHERE key = ?'
|
||||
);
|
||||
foreach ($keys as $i => $key) {
|
||||
if (in_array($key, self::FORM_HELP_KEYS, true)) {
|
||||
$stmt->execute([$i, $key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// SINGLETON PATTERN ENFORCEMENT
|
||||
// ========================================================================
|
||||
|
||||
Reference in New Issue
Block a user