diff --git a/class/comment.php b/class/comment.php index 38ac646..503ca30 100644 --- a/class/comment.php +++ b/class/comment.php @@ -111,7 +111,7 @@ class Comment /** * Редактирование Авторской оценки (1-разрешено, 0-запрещено) */ - private $_edit_avtor_rating = 1; + private $_edit_avtor_rating = 0; /** * Конструктор класса @@ -1750,16 +1750,6 @@ $AVE_Template->assign([ $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . $this->_admin_comments_tpl)); } - - - - - - - - - - /** * Метод, предназначенный для редактирования комментариев в Административной части. * @@ -1773,22 +1763,24 @@ function commentAdminPostEdit($tpl_dir) $request_id = (int)($_REQUEST['Id'] ?? 0); $is_ajax = isset($_REQUEST['ajax']); - // 1. Получаем данные и настройки одним запросом - $row = $AVE_DB->Query(" - SELECT - msg.*, - cmnt.comment_allowed_extensions, - cmnt.comment_max_file_size, - cmnt.comment_max_files, - cmnt.comment_allow_files, - cmnt.comment_show_f1, - cmnt.comment_show_f2, - cmnt.comment_show_user_rating - FROM " . PREFIX . "_module_comment_info AS msg - JOIN " . PREFIX . "_module_comments AS cmnt ON cmnt.Id = 1 - WHERE msg.Id = '" . (int)$request_id . "' - LIMIT 1 - ")->FetchAssocArray(); +// 1. Получаем данные и настройки одним запросом +$row = $AVE_DB->Query(" + SELECT + msg.*, + cmnt.comment_allowed_extensions, + cmnt.comment_max_file_size, + cmnt.comment_max_files, + cmnt.comment_allow_files, + cmnt.comment_show_f1, + cmnt.comment_show_f2, + cmnt.comment_name_f1, + cmnt.comment_name_f2, + cmnt.comment_show_user_rating + FROM " . PREFIX . "_module_comment_info AS msg + JOIN " . PREFIX . "_module_comments AS cmnt ON cmnt.Id = 1 + WHERE msg.Id = '" . (int)$request_id . "' + LIMIT 1 +")->FetchAssocArray(); if ($post_sub == 'send' && $row) { @@ -1806,12 +1798,11 @@ function commentAdminPostEdit($tpl_dir) if (file_exists($upload_dir . $rem_file)) { @unlink($upload_dir . $rem_file); } - // Используем стрелочную функцию (PHP 7.4+) $current_files = array_filter($current_files, fn($v) => trim($v) !== $rem_file); } } - // --- Б. Загрузка новых файлов --- + // Загрузка новых файлов --- if ($row['comment_allow_files'] == 1 && isset($_FILES['comment_image']) && is_array($_FILES['comment_image']['name'])) { if (!is_dir($upload_dir)) { @@ -1828,7 +1819,7 @@ function commentAdminPostEdit($tpl_dir) foreach ($_FILES['comment_image']['name'] as $k => $fname) { if ($_FILES['comment_image']['error'][$k] == UPLOAD_ERR_OK) { - // Важно: проверяем лимит на каждой итерации + // проверяем лимит на каждой итерации if (count($current_files) >= $max_limit) break; $tmp_name = $_FILES['comment_image']['tmp_name'][$k]; @@ -1859,7 +1850,7 @@ function commentAdminPostEdit($tpl_dir) // Финальная строка файлов для базы $final_files_str = implode(',', array_unique(array_filter($current_files))); - // --- В. Рейтинг --- + // --- Рейтинг --- $new_rating = ($this->_edit_avtor_rating == 1 && isset($_POST['user_rating'])) ? (int)$_POST['user_rating'] : (int)($row['user_rating'] ?? 0); @@ -1906,14 +1897,6 @@ function commentAdminPostEdit($tpl_dir) $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . $this->_admin_edit_link_tpl)); } - - - - - - - - /** * Метод, предназначенный для управления настройками модуля * diff --git a/lang/ru.txt b/lang/ru.txt index d110127..ffc1b2b 100644 --- a/lang/ru.txt +++ b/lang/ru.txt @@ -254,3 +254,5 @@ COMMENT_TABLE_TEXT_COMM = "Текст комментария" COMMENT_TABLE_FILES = "Файлы" COMMENT_TABLE_ACTIONS = "Действия" COMMENT_RATING_ADMIN = "Рейтинг комментариев" +COMMENT_RATING_TITEL = "Авторская оценка" +COMMENT_RATING_RESET = "Сбросить" diff --git a/templates/admin_edit.tpl b/templates/admin_edit.tpl index 66adb33..e68c388 100644 --- a/templates/admin_edit.tpl +++ b/templates/admin_edit.tpl @@ -1,7 +1,7 @@ @@ -169,6 +227,36 @@ $(document).ready(function(){ .upload-info-box { margin-top:10px; padding: 10px; border: 1px dashed #ccc; background: #fcfcfc; } .overlimit { color: #dc3545; font-weight: bold; } + + /* Стили для новых превью */ + .new-file-preview { position: relative; width: 60px; text-align: center; } + .new-file-preview img { width: 60px; height: 60px; object-fit: cover; border-radius: 4px; border: 1px solid #0d6efd; } + .new-file-preview .ext-placeholder { background: #0d6efd; } /* Синий цвет для новых файлов */ + + /* Кнопка отмены для НОВОГО файла */ + .cancel-new-file { + position: absolute; top: -5px; right: -5px; background: #000; color: #fff; + border-radius: 50%; width: 18px; height: 18px; cursor: pointer; + line-height: 17px; text-align: center; font-size: 12px; border: 1px solid #fff; z-index: 11; + } + + .file-limit-alert { + transition: opacity 0.5s ease-in-out; + animation: slideDown 0.3s ease-out; + border-radius: 4px; + font-family: Tahoma, sans-serif; + line-height: 1.4; + z-index: 5; + } + .file-limit-alert i { + font-style: normal; + font-weight: bold; + margin-right: 5px; + } + @keyframes slideDown { + from { transform: translateY(-10px); opacity: 0; } + to { transform: translateY(0); opacity: 1; } + } {/literal} @@ -189,19 +277,25 @@ $(document).ready(function(){