mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Add website-type TFE support: URLs stored as thesis_files rows, HTMX-toggle on Site web format
This commit is contained in:
@@ -216,6 +216,9 @@ class ThesisCreateController
|
||||
$this->db->handleBannerUpload($thesisId, $files['banner'] ?? null);
|
||||
$this->handleThesisFiles($thesisId, $data['annee'], $identifier, $files['files'] ?? null, $authorSlug, $post);
|
||||
|
||||
// ── 6. Website URL — stored as thesis_files row ──────────────────────
|
||||
$this->handleWebsiteUrl($thesisId, $post);
|
||||
|
||||
return $thesisId;
|
||||
}
|
||||
|
||||
@@ -813,4 +816,41 @@ class ThesisCreateController
|
||||
}
|
||||
return $candidate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a website URL as a thesis_files row (file_type = 'website').
|
||||
*
|
||||
* The URL is stored in file_path; no filesystem operation is performed.
|
||||
* label and sort_order from the POST are preserved.
|
||||
*/
|
||||
private function handleWebsiteUrl(int $thesisId, array $post): void
|
||||
{
|
||||
$websiteUrl = trim($post['website_url'] ?? '');
|
||||
if ($websiteUrl === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate URL
|
||||
$websiteUrl = filter_var($websiteUrl, FILTER_VALIDATE_URL);
|
||||
if ($websiteUrl === false) {
|
||||
error_log('ThesisCreateController: invalid website URL, skipping');
|
||||
return;
|
||||
}
|
||||
|
||||
$label = trim($post['website_label'] ?? '');
|
||||
$sortOrder = isset($post['website_order']) ? (int)$post['website_order'] : null;
|
||||
$fileName = rtrim(preg_replace('#^https?://#i', '', $websiteUrl), '/');
|
||||
|
||||
$this->db->insertThesisFile(
|
||||
$thesisId,
|
||||
'website',
|
||||
$websiteUrl,
|
||||
$fileName,
|
||||
0,
|
||||
'text/html',
|
||||
$label !== '' ? $label : null,
|
||||
$sortOrder
|
||||
);
|
||||
error_log("ThesisCreateController: website stored → $websiteUrl");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user