From eaf05ae2d51d95f177f0b165fac58f992d355ffc Mon Sep 17 00:00:00 2001 From: Repellent Date: Tue, 2 Dec 2025 11:54:38 +0500 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=20=D0=BA=D0=BE=D0=B4=D0=B0=20=D0=B2?= =?UTF-8?q?=D0=BD=D1=83=D1=82=D1=80=D0=B5=D0=BD=D0=BD=D0=B5=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D1=83=D0=B7=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/lang/ru/scripts.js | 4 + admin/templates/browser/browser_2frames.tpl | 179 ++++++-------------- admin/templates/js/browser_logic.js | 118 +++++++++++++ admin/templates/js/main.js | 25 ++- 4 files changed, 190 insertions(+), 136 deletions(-) create mode 100644 admin/templates/js/browser_logic.js diff --git a/admin/lang/ru/scripts.js b/admin/lang/ru/scripts.js index c059494..9610e4a 100644 --- a/admin/lang/ru/scripts.js +++ b/admin/lang/ru/scripts.js @@ -27,6 +27,10 @@ var delCascadConfirm = "Вы уверены что хотите удалить?" var saveMessageOk = "Данные сохранены"; var DOC_REV_DEL_FROM = "Ревизия от "; var DOC_REV_DEL_SUCCESS = " удалена!"; +var MAIN_MP_PLEASE_SELECT = "Пожалуйста, выберите файл!"; +var MAIN_MP_CREATE_FOLDER = "Создать папку"; +var MAIN_ADD_FOLDER = "Имя папки"; +var MAIN_NO_ADD_FOLDER = "Папка не добавлена!"; //===== Date & Time Pickers =====// $.datepicker.regional['ru'] = { diff --git a/admin/templates/browser/browser_2frames.tpl b/admin/templates/browser/browser_2frames.tpl index a73621a..5e5c68e 100644 --- a/admin/templates/browser/browser_2frames.tpl +++ b/admin/templates/browser/browser_2frames.tpl @@ -9,9 +9,8 @@ - + - @@ -19,7 +18,6 @@ - {include file="../scripts.tpl"} @@ -27,23 +25,45 @@ - + - - + + + + + + + + + + + - -
- + +
@@ -127,114 +156,6 @@
- - - - - + + \ No newline at end of file diff --git a/admin/templates/js/browser_logic.js b/admin/templates/js/browser_logic.js new file mode 100644 index 0000000..82be1c4 --- /dev/null +++ b/admin/templates/js/browser_logic.js @@ -0,0 +1,118 @@ +// browser_logic.js +// Этот файл использует глобальные константы, определенные в шаблоне +// (IS_MULTILINK, REQUEST_ID, TARGET, TARGET_ID, MEDIA_PATH, REQUEST_TARGET, th_folder) + +window.getUrlParam = function(paramName) { + let reParam = new RegExp('(?:[\\?&]|&)' + paramName + '=([^&]+)', 'i'); + let match = window.location.search.match(reParam); + return (match && match.length > 1) ? match[1] : ''; +} + +window.getImgPreview = function(url) { + let parts = url.split('/'); + let fileName = parts.pop(); + let fileExt = fileName.split('.').pop(); + + // th_folder определен в шаблоне + let thumb = th_folder + '/' + fileName.substr(0, fileName.lastIndexOf(".")) + '-t128x128.' + fileExt; + + parts.push(thumb); + return parts.join('/'); +} + +window.submitTheForm = function() { + var bDirName = document.bForm.bDirName.value; + if (bDirName && !bDirName.endsWith('/')) { + document.bForm.bDirName.value = bDirName + '/'; + } + + if (document.bForm.bFileName.value == '' && (TARGET != 'dir' && TARGET != 'directory' && TARGET != 'cascad')) { + alert(MAIN_MP_PLEASE_SELECT); + } else { + + if (IS_MULTILINK) { + let fullPath = MEDIA_PATH + document.bForm.bDirName.value + document.bForm.bFileName.value; + // Убедимся, что путь начинается со слэша, если MEDIA_PATH его не содержит + if (!fullPath.startsWith('/')) { + fullPath = '/' + fullPath; + } + window.opener.document.getElementById(REQUEST_ID).value = fullPath; + } + + else { + if (TARGET == 'link') { + var funcNum = window.getUrlParam('CKEditorFuncNum'); + var fileUrl = MEDIA_PATH + document.bForm.bDirName.value + document.bForm.bFileName.value; + window.opener.CKEDITOR.tools.callFunction(funcNum, fileUrl); + + } else if (TARGET == 'link_image') { + window.opener.document.getElementById('txtLnkUrl').value = '/' + MEDIA_PATH + document.bForm.bDirName.value + document.bForm.bFileName.value; + + } else if (TARGET == 'txtUrl') { + var funcNum = window.getUrlParam('CKEditorFuncNum'); + var fileUrl = '/' + MEDIA_PATH + document.bForm.bDirName.value + document.bForm.bFileName.value + window.opener.CKEDITOR.tools.callFunction(funcNum, fileUrl); + + } else if (TARGET == 'navi') { + window.opener.document.getElementById(REQUEST_ID).value = '/' + MEDIA_PATH + document.bForm.bDirName.value + document.bForm.bFileName.value; + + } else if (TARGET == 'img_feld') { + let imgSource = '/' + MEDIA_PATH + document.bForm.bDirName.value + document.bForm.bFileName.value; + window.opener.document.getElementById('img_feld__' + TARGET_ID).value = '/' + MEDIA_PATH + document.bForm.bDirName.value + document.bForm.bFileName.value; + window.opener.document.getElementById('_img_feld__' + TARGET_ID).src = window.getImgPreview(imgSource); + window.opener.$('.preview__' + TARGET_ID).attr("href", window.getImgPreview(imgSource)); + + } else if (TARGET != '' && TARGET_ID != '' && TARGET_ID != null) { + + if (TARGET == 'image') { + let imgSource = '/' + MEDIA_PATH + document.bForm.bDirName.value + document.bForm.bFileName.value; + window.opener.$('#preview__' + TARGET_ID).attr('src', window.getImgPreview(imgSource)); + window.opener.$('.preview__' + TARGET_ID).attr('href', '/' + MEDIA_PATH + document.bForm.bDirName.value + document.bForm.bFileName.value); + window.opener.$('#' + TARGET + '__' + TARGET_ID).val('/' + MEDIA_PATH + document.bForm.bDirName.value + document.bForm.bFileName.value); + } + + if (TARGET == 'dir') { + var bdn = document.bForm.bDirName.value.split('/').reverse(); + window.opener.document.getElementById(TARGET + '__' + TARGET_ID).value = bdn[1]; + } + + if (TARGET == 'directory') { + window.opener.$.fn.myPlugin('/' + MEDIA_PATH + document.bForm.bDirName.value, TARGET_ID); + } + + if (TARGET == 'cascad') { + var data_parts = TARGET_ID.split('_'); + var data_id_0 = data_parts[0]; + var data_id_1 = data_parts[1]; + window.opener.$.fn.myPlugin('/' + MEDIA_PATH + document.bForm.bDirName.value, data_id_0, data_id_1); + } + + } + + else if (TARGET != 'all') { + if (REQUEST_TARGET != '') { + window.opener.document.getElementById(REQUEST_TARGET).value = '/' + MEDIA_PATH + document.bForm.bDirName.value + document.bForm.bFileName.value; + } + } + } + + setTimeout("self.close();", 100); + } +} + +window.NewFolder = function() { + var title = MAIN_MP_CREATE_FOLDER; + var text = MAIN_ADD_FOLDER; + jPrompt(text, '', title, function(b) { + if (b) { + $.alerts._overlay('hide'); + $.alerts._overlay('show'); + // используем REQUEST_TARGET (значение, полученное из TARGET) + window.parent.frames['zf'].location.href = 'index.php?do=browser&type=' + REQUEST_TARGET + '&target=' + TARGET + '&action=list&dir=' + document.bForm.bDirName.value + '&newdir=' + b; + $.alerts._overlay('hide'); + } else { + $.alerts._overlay('hide'); + $.jGrowl(MAIN_NO_ADD_FOLDER); + } + }); +} \ No newline at end of file diff --git a/admin/templates/js/main.js b/admin/templates/js/main.js index c676b29..340a105 100644 --- a/admin/templates/js/main.js +++ b/admin/templates/js/main.js @@ -88,14 +88,23 @@ function openLinkWindow(target, doc, document_alias) { window.open('index.php?doc=' + doc + '&target=' + target + '&document_alias=' + document_alias + '&do=docs&action=showsimple&cp=' + sess + '&pop=1', 'pop', 'left=' + left + ',top=' + top + ',width=' + width + ',height=' + height + ',scrollbars=' + scrollbar + ',resizable=1'); } -function openFileWindow(target, id, document_alias) { - if (typeof width == 'undefined' || width == '') var width = screen.width * 0.6; - if (typeof height == 'undefined' || height == '') var height = screen.height * 0.6; - if (typeof doc == 'undefined') var doc = 'Title'; - if (typeof scrollbar == 'undefined') var scrollbar = 1; - var left = (screen.width - width) / 2; - var top = (screen.height - height) / 2; - window.open('index.php?do=browser&id=' + id + '&type=file&target=navi&cp=' + sess, 'pop', 'left=' + left + ',top=' + top + ',width=' + width + ',height=' + height + ',scrollbars=' + scrollbar + ',resizable=1'); +function openFileWindow(id, type, target) { + if (typeof width == 'undefined' || width == '') var width = screen.width * 0.6; + if (typeof height == 'undefined' || height == '') var height = screen.height * 0.6; + if (typeof doc == 'undefined') var doc = 'Title'; + if (typeof scrollbar == 'undefined') var scrollbar = 1; + var left = (screen.width - width) / 2; + var top = (screen.height - height) / 2; + + // Передаем id и target в URL + var url = 'index.php?do=browser&id=' + id + '&type=' + type + '&target=' + target + '&cp=' + sess; + + // Добавляем флаг для Мультиссылки, если ID начинается с 'links_' + if (typeof id === 'string' && id.startsWith('links_')) { + url += '&is_multilink=1'; + } + + window.open(url, 'pop', 'left=' + left + ',top=' + top + ',width=' + width + ',height=' + height + ',scrollbars=' + scrollbar + ',resizable=1'); } // Функция-плагин для включения tipsy сразу для всех классов внутри элемента