Gestion des pieces jointes dans edition + SEO par article
This commit is contained in:
+32
-14
@@ -26,19 +26,22 @@ switch ($action) {
|
||||
case 'create':
|
||||
requireAuth();
|
||||
|
||||
$title = $_POST['title'] ?? '';
|
||||
$content = $_POST['content'] ?? '';
|
||||
$postSlug = $_POST['slug'] ?? '';
|
||||
$published = isset($_POST['published']);
|
||||
$published_at = str_replace('T', ' ', $_POST['published_at'] ?? date('Y-m-d H:i:s'));
|
||||
$errors = [];
|
||||
$title = $_POST['title'] ?? '';
|
||||
$content = $_POST['content'] ?? '';
|
||||
$postSlug = $_POST['slug'] ?? '';
|
||||
$published = isset($_POST['published']);
|
||||
$published_at = str_replace('T', ' ', $_POST['published_at'] ?? date('Y-m-d H:i:s'));
|
||||
$seoTitle = $_POST['seo_title'] ?? '';
|
||||
$seoDescription = $_POST['seo_description'] ?? '';
|
||||
$ogImage = $_POST['og_image'] ?? '';
|
||||
$errors = [];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (trim($title) === '') {
|
||||
$errors[] = 'Le titre est obligatoire.';
|
||||
}
|
||||
if (empty($errors)) {
|
||||
$newUuid = $articles->create($title, $content, $published, $postSlug, $published_at, currentUserEmail() ?? '');
|
||||
$newUuid = $articles->create($title, $content, $published, $postSlug, $published_at, currentUserEmail() ?? '', $seoTitle, $seoDescription, $ogImage);
|
||||
|
||||
foreach ($_FILES['files']['tmp_name'] ?? [] as $i => $tmpName) {
|
||||
if ($_FILES['files']['error'][$i] === UPLOAD_ERR_OK) {
|
||||
@@ -105,13 +108,16 @@ switch ($action) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$title = $_POST['title'] ?? $article['title'];
|
||||
$content = $_POST['content'] ?? $article['content'];
|
||||
$postSlug = $_POST['slug'] ?? $article['slug'];
|
||||
$published = isset($_POST['published']) ? true : $article['published'];
|
||||
$published_at = $_POST['published_at']
|
||||
$title = $_POST['title'] ?? $article['title'];
|
||||
$content = $_POST['content'] ?? $article['content'];
|
||||
$postSlug = $_POST['slug'] ?? $article['slug'];
|
||||
$published = isset($_POST['published']) ? true : $article['published'];
|
||||
$published_at = $_POST['published_at']
|
||||
?? date('Y-m-d\TH:i', strtotime((string)($article['published_at'] ?? 'now')));
|
||||
$errors = [];
|
||||
$seoTitle = $_POST['seo_title'] ?? ($article['seo_title'] ?? '');
|
||||
$seoDescription = $_POST['seo_description'] ?? ($article['seo_description'] ?? '');
|
||||
$ogImage = $_POST['og_image'] ?? ($article['og_image'] ?? '');
|
||||
$errors = [];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (trim($title) === '') {
|
||||
@@ -125,7 +131,10 @@ switch ($action) {
|
||||
$published,
|
||||
$_POST['slug'] ?? '',
|
||||
str_replace('T', ' ', $_POST['published_at'] ?? ''),
|
||||
$_POST['revision_comment'] ?? ''
|
||||
$_POST['revision_comment'] ?? '',
|
||||
$_POST['seo_title'] ?? '',
|
||||
$_POST['seo_description'] ?? '',
|
||||
$_POST['og_image'] ?? ''
|
||||
);
|
||||
|
||||
foreach ($_FILES['files']['tmp_name'] ?? [] as $i => $tmpName) {
|
||||
@@ -150,6 +159,15 @@ switch ($action) {
|
||||
include BASE_PATH . '/templates/post_form.php';
|
||||
break;
|
||||
|
||||
case 'delete_file':
|
||||
requireAuth();
|
||||
$fileName = basename($_POST['name'] ?? '');
|
||||
if ($uuid !== '' && $fileName !== '' && $fileName[0] !== '.') {
|
||||
$articles->deleteFile($uuid, $fileName);
|
||||
}
|
||||
header('Location: /?action=edit&uuid=' . rawurlencode($uuid));
|
||||
exit;
|
||||
|
||||
case 'delete':
|
||||
requireAuth();
|
||||
if ($uuid !== '') {
|
||||
|
||||
Reference in New Issue
Block a user