From 25aae39bd8fc691631fbb548703cd579ec3190f8 Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Sat, 21 Feb 2026 11:35:33 +0300 Subject: [PATCH] Admin: modal comments and async photo rotation Open per-photo comments in a modal overlay from the photo table instead of navigating away, and keep deletion inline. Make rotate controls submit via AJAX so preview updates without page reload or scroll jump, while tightening button layout for cleaner action groups. --- admin.php | 363 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 345 insertions(+), 18 deletions(-) diff --git a/admin.php b/admin.php index a478aeb..a0b34ea 100644 --- a/admin.php +++ b/admin.php @@ -19,6 +19,33 @@ if ($tokenExpected === '' || !hash_equals($tokenExpected, $tokenIncoming)) { exit('Forbidden'); } +$requestAction = (string)($_REQUEST['action'] ?? ''); +if ($_SERVER['REQUEST_METHOD'] === 'GET' && $requestAction === 'photo_comments') { + $photoId = (int)($_GET['photo_id'] ?? 0); + if ($photoId < 1) { + http_response_code(400); + header('Content-Type: application/json; charset=utf-8'); + echo json_encode(['ok' => false, 'message' => 'Некорректный photo_id'], JSON_UNESCAPED_UNICODE); + exit; + } + + $photo = photoById($photoId); + if (!$photo) { + http_response_code(404); + header('Content-Type: application/json; charset=utf-8'); + echo json_encode(['ok' => false, 'message' => 'Фото не найдено'], JSON_UNESCAPED_UNICODE); + exit; + } + + header('Content-Type: application/json; charset=utf-8'); + echo json_encode([ + 'ok' => true, + 'photo' => ['id' => (int)$photo['id'], 'code_name' => (string)$photo['code_name']], + 'comments' => commentsByPhoto($photoId), + ], JSON_UNESCAPED_UNICODE); + exit; +} + $message = ''; $errors = []; @@ -149,6 +176,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $st->execute(['pid' => $photoId, 'kind' => $kind]); $message = 'Изображение повернуто'; + if ($isAjax) { + header('Content-Type: application/json; charset=utf-8'); + echo json_encode(['ok' => true, 'message' => $message, 'photo_id' => $photoId, 'kind' => $kind], JSON_UNESCAPED_UNICODE); + exit; + } } if ($action === 'create_commenter') { @@ -181,6 +213,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($id > 0) { commentDelete($id); $message = 'Комментарий удалён'; + if ($isAjax) { + header('Content-Type: application/json; charset=utf-8'); + echo json_encode(['ok' => true, 'message' => $message], JSON_UNESCAPED_UNICODE); + exit; + } } } } catch (Throwable $e) { @@ -481,7 +518,38 @@ function nextUniqueCodeName(string $base): string Админка - +

Админка

@@ -596,13 +664,13 @@ function nextUniqueCodeName(string $base): string - -
-
+ +
+ -
+
@@ -611,13 +679,13 @@ function nextUniqueCodeName(string $base): string - -
-
+ +
+ -
+
@@ -635,15 +703,19 @@ function nextUniqueCodeName(string $base): string - 0): ?> -

Комментарии ()

- -

Комментариев нет

- -
- - -
+
+
+ 0): ?> + + + Комментариев нет + +
+
+ + +
+
@@ -728,6 +800,16 @@ function nextUniqueCodeName(string $base): string
+