From 5c3e28fd55cd27d9383bac658c54e81deed3db34 Mon Sep 17 00:00:00 2001 From: Slava Date: Sat, 15 Nov 2025 21:33:38 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20=D1=86?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D1=80=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D1=85=20?= =?UTF-8?q?=D0=B1=D0=BB=D0=BE=D0=BA=D0=BE=D0=B2:=20=D1=82=D0=B5=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D1=8C=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6?= =?UTF-8?q?=D0=B8=D0=B2=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D0=BD=D0=B5=D1=81?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=B1=D0=BB=D0=BE=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/access.page.php | 74 +------ content/index.page.php | 18 +- content/rpi/index.page.php | 95 +------- data/Basic_functions.js | 77 +++++-- data/filepath.lv.php | 8 + data/filepath.ru.php | 2 +- data/func.php | 16 +- error.txt | 29 +++ index.php | 17 +- main_plugin/dgrm/dgrm.css | 4 +- main_plugin/editor/editor.js | 311 ++++++++++++++------------- main_plugin/editor/func.editor.php | 68 +++--- main_plugin/manager/func.manager.php | 14 +- main_plugin/site_tree/site_tree.js | 2 +- template/MedWait/css.php | 11 +- template/MedWait/page.php | 4 +- template/default/page.php | 4 +- template/default1/page.php | 4 +- template/default2/page.php | 4 +- template/default3/page.php | 4 +- template/default4/page.php | 4 +- template/error.php | 4 +- template/kip/page.php | 4 +- template/rpi/page.php | 4 +- template/temp/new/page.php | 4 +- template/test/page.php | 4 +- 26 files changed, 355 insertions(+), 435 deletions(-) diff --git a/content/access.page.php b/content/access.page.php index 0429d55..4f19396 100644 --- a/content/access.page.php +++ b/content/access.page.php @@ -15,81 +15,11 @@ -текст текст текст текст текст текст текст текст текст текст текст тексритчрсотат текст текст текст текст  -
- текст текст текст текст текыККПАФЦКАКПАМст текст текст текст текст текст текст текст урпкцуептекст текст текст +test1цыкцып
- текст текст текст текст текст текст текст текст текст текст текст текст текст текст текст текст текст +test2
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

-
]]>
Uz šo brīdi šeit ne kā nav

diff --git a/content/index.page.php b/content/index.page.php index d5301b6..aff41f8 100644 --- a/content/index.page.php +++ b/content/index.page.php @@ -8,24 +8,12 @@ - - - - - + - - - + - -text -]]> + diff --git a/content/rpi/index.page.php b/content/rpi/index.page.php index 0fa9800..d71c80f 100644 --- a/content/rpi/index.page.php +++ b/content/rpi/index.page.php @@ -8,95 +8,18 @@ - - - - - + - - - + - -текст текст текст текст текст текст текст текст текст текст текст тексритчрсотат текст текст текст текст  -
- текст текст текст текст текыККПАФЦКАКПАМст текст текст текст текст текст текст текст урпкцуептекст текст текст -
-
- текст текст текст текст текст текст текст текст текст текст текст текст текст текст текст текст текст -
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

-
-]]>
+ + +test1цыуквацыфавп +]]> +test2 +]]> +   cb bbvcdjyfdyhyhdывепиwstdg

]]>
diff --git a/data/Basic_functions.js b/data/Basic_functions.js index f226cb5..5dfbfe5 100644 --- a/data/Basic_functions.js +++ b/data/Basic_functions.js @@ -533,12 +533,12 @@ if(isPhone){ /** @brief Флаг, указывающий, были ли изменения в контенте */ window.contentIsEdit = false; -if (document.getElementById("content")) { - document.getElementById("content").addEventListener("input", function() { - window.contentIsEdit = true; +if (document.querySelectorAll(".content").length) { + document.querySelectorAll(".content").forEach(el => { + el.addEventListener("input", () => window.contentIsEdit = true); + const observer = new MutationObserver(() => window.contentIsEdit = true); + observer.observe(el, { childList: true, subtree: true }); }); - const observer = new MutationObserver(() => window.contentIsEdit = true); - observer.observe(document.getElementById("content"), { childList: true, subtree: true }); } /** @brief Очередь сообщений для отображения */ @@ -738,8 +738,11 @@ let cou=1; * @brief Показать/скрыть HTML-код страницы в textarea */ function showHtmlCode() { + let contents = document.getElementsByClassName("content"); if (cou==1) { - document.getElementById("tex").value=document.getElementById("content").innerHTML; + let combined = ""; + for (let i=0; i"; + document.getElementById("tex").value = combined; document.getElementById("tex").value = decodeHtmlEntities(document.getElementById("tex").value); document.getElementById("tex").value = formatHTML(document.getElementById("tex").value); let sbe=document.getElementsByClassName("sb"); @@ -754,11 +757,18 @@ function showHtmlCode() { } cou=2; } else { - document.getElementById("content").innerHTML=document.getElementById("tex").value; + let text = document.getElementById("tex").value; + let split = text.match(//gs); + if (split) { + for (let i=0; i/g, ''); + } + } document.getElementById("tex").style.visibility="hidden"; cou=1; } } + window.showHtmlCode = showHtmlCode; /** @brief Флаг нового состояния страницы при сохранении */ @@ -783,8 +793,10 @@ window.saveChanges = saveChanges; */ function saveContentId() { if(cou==1) { - document.getElementById("content").innerHTML = decodeHtmlEntities(document.getElementById("content").innerHTML); - document.getElementById("tex").value=document.getElementById("content").innerHTML; + let contents = document.getElementsByClassName("content"); + let combined = ""; + for (let i = 0; i < contents.length; i++) combined += ""; + document.getElementById("tex").value = combined; } document.getElementById("tex").value = decodeHtmlEntities(document.getElementById("tex").value); let saveContentIdData = document.getElementById("tex").value.trim(); @@ -796,8 +808,8 @@ function saveContentId() { messageFunction("{{main_block_not_saved}}"); } }); - } - +} + /** * @brief Сохраняет данные подключённых плагинов (левой и правой колонок) */ @@ -897,11 +909,10 @@ function formatHTML(html) { */ window.saveContentIdHow = async function (currentPath) { if (cou == 1) { - document.getElementById("content").innerHTML = decodeHtmlEntities(document.getElementById("content").innerHTML); - document.getElementById("tex").value = document.getElementById("content").innerHTML; + let contents = Array.from(document.getElementsByClassName("content")).map(el => el.innerHTML.trim()); + document.getElementById("tex").value = contents.map(c => ``).join(''); } - document.getElementById("tex").value = decodeHtmlEntities(document.getElementById("tex").value); - let saveContentIdData = document.getElementById("tex").value.trim(); + let saveContentIdData = decodeHtmlEntities(document.getElementById("tex").value).trim(); let nameFile = document.getElementById('saveHowName').value; if (!nameFile.endsWith('.page.php')) { nameFile += '.page.php'; @@ -1315,17 +1326,47 @@ window.functionOpenPage = false; function getPage(newPath) { window.functionOpenPage = true; jsonrpcRequest("getPage", { newPath }).then(page => { + const centerFloat = document.querySelector('.center-float'); + const oldBlocks = centerFloat.querySelectorAll('.bfloat'); + + oldBlocks.forEach(b => { + if (b.querySelector('.content')) { + const next = b.nextSibling; + if (next && next.nodeType === 1 && next.tagName === 'BR') next.remove(); + if (next && next.nodeType === 3 && next.textContent.trim() === '') { + const next2 = next.nextSibling; + if (next2 && next2.nodeType === 1 && next2.tagName === 'BR') next2.remove(); + } + b.remove(); + } + }); + + page.content.forEach((c, i) => { + const placeholder = document.getElementById('news-placeholder'); + if (i > 0) { + const br = document.createElement('br'); + centerFloat.insertBefore(br, placeholder); + } + const block = document.createElement('div'); + block.className = 'bfloat' + (i === 0 ? ' content1' : ''); + block.style.fontSize = '1em'; + const inner = document.createElement('div'); + inner.className = 'content'; + inner.innerHTML = c; + block.appendChild(inner); + centerFloat.insertBefore(block, placeholder); + }); + document.getElementById("right-float").innerHTML = page.right; document.getElementById("left-float").innerHTML = page.left; - document.getElementById("content").innerHTML = page.content; document.getElementById("managerDiv").style.visibility = "hidden"; - // history.pushState(null, '', page.pagePath); document.getElementById("mainTitle").innerHTML = "{{new_file}}!"; - removePluginDom("manager") + removePluginDom("manager"); }); window.newPageFunValue = ""; } + //обьявление функции для того, чтобы обращатся к ней из других файлов window.getPage = getPage; window.managerData = managerData; diff --git a/data/filepath.lv.php b/data/filepath.lv.php index ad01772..652f30b 100644 --- a/data/filepath.lv.php +++ b/data/filepath.lv.php @@ -3,5 +3,13 @@ RaspberryqePi Raspberry Pi + + + + + + + + diff --git a/data/filepath.ru.php b/data/filepath.ru.php index 6aa3697..3011d5c 100644 --- a/data/filepath.ru.php +++ b/data/filepath.ru.php @@ -3,7 +3,7 @@ site site - + diff --git a/data/func.php b/data/func.php index 33d8a6b..fe61722 100644 --- a/data/func.php +++ b/data/func.php @@ -307,17 +307,6 @@ function GetBlock ($BlockVar, $side) { } } return $Block; - - // $Block.='
ku ku
'; - /*is_countable($$BlockVar) && count($BlockVar) - $Block = ""; - if (is_countable($$BlockVar) && count($BlockVar) > 0){ - $Block = "true"; - } - else{ - $Block = "false"; - } - $Block = count($BlockVar);*/ } @@ -769,14 +758,14 @@ if ($RURLstr!='error'){ function loadPluginsInCenterBlock() { global $_SESSION, $path, $config; if ($_SESSION['Login'] == 'true') { - $availablePlugins = ['dgrm', 'SvgEditorM']; + $availablePlugins = ['dgrm', 'SvgEditorM', 'form_editor']; $pluginDir = $path . 'main_plugin/'; if (is_dir($pluginDir)) { $dirs = array_diff(scandir($pluginDir), ['.', '..']); foreach ($dirs as $dir) { if (is_dir($pluginDir . $dir)) { if (!in_array($dir, $availablePlugins) || strpos($config['page_plugins'] ?? '', $dir) !== false) { - if ($dir === 'SvgEditorM' || $dir === 'dgrm') { + if ($dir === 'SvgEditorM' || $dir === 'dgrm' || $dir === 'form_editor') { $html .= includePlugin(['plugin' => $dir]); } } @@ -784,7 +773,6 @@ function loadPluginsInCenterBlock() { } } } - $html .= includePlugin(['plugin' => 'form_editor']); return $html; } ?> \ No newline at end of file diff --git a/error.txt b/error.txt index e69de29..f4d2b86 100644 --- a/error.txt +++ b/error.txt @@ -0,0 +1,29 @@ + +test1цыкцып +]]> +test2 +]]> + +test1цыкцып +]]> +test2 +]]> +Array +( + [0] =>
+test1цыкцып +
+ [1] =>
+test2 +
+) + + +test1цыкцып +]]> +test2 +]]> diff --git a/index.php b/index.php index 3100012..de62596 100644 --- a/index.php +++ b/index.php @@ -7,7 +7,7 @@ /** @brief Путь к текущей директории */ $path = dirname(__FILE__) . '/'; -/* if(isset($_SESSION)) { file_put_contents($path . '/error.txt', "" . PHP_EOL, FILE_APPEND); }*/ +/* file_put_contents($path . '/error.txt', "" . PHP_EOL, FILE_APPEND); */ session_start(); @@ -150,7 +150,7 @@ if ($access) { $config['right'] = "
" . $config['right'] . "
"; $center = '
' . GetBlock($xmlstr->cblock->block, 'center') . '
'; - $config['content'] = $xmlstr->content->{$config['lng']}; + /* $config['content'] = $xmlstr->content->{$config['lng']}; */ } else { if ($_SESSION['log_in']) { $xmlstr = simplexml_load_file($path . 'content/adm/user.page.php'); @@ -161,7 +161,18 @@ if ($access) { $config['left'] = ''; $config['right'] = ''; $center = '
' . GetBlock($xmlstr->cblock->block, 'center') . '
'; - $config['content'] = $xmlstr->content->$config['lng']; + /* $config['content'] = $xmlstr->content->{$config['lng']}; */ +} + +$xmlString = file_get_contents($path . $config['page_url'] . ".page.php"); +preg_match('#<' . $config['lng'] . '>(.*?)#s', $xmlString, $tagMatch); +$config['content'] = ''; +if (preg_match_all('##s', $tagMatch[1], $matches)) { + foreach ($matches[1] as $i => $cdata) { + if ($i > 0) + $config['content'] .= "
"; + $config['content'] .= '
' . $cdata . '
'; + } } foreach ($config as $key=>$value) if ($key!="request_url") $config['content'] =str_replace('%'.$key.'%', $value, $config['content']); diff --git a/main_plugin/dgrm/dgrm.css b/main_plugin/dgrm/dgrm.css index d186549..8f3ec68 100644 --- a/main_plugin/dgrm/dgrm.css +++ b/main_plugin/dgrm/dgrm.css @@ -57,7 +57,7 @@ a { } textarea { - text-align: center; + /* text-align: center; border: none;; padding: 10px; padding-top: 0.8em; @@ -69,7 +69,7 @@ a { overflow: hidden; resize: none; line-height: 1em; - caret-color: #fff; + caret-color: #fff; */ } [data-connect] { display: none; } diff --git a/main_plugin/editor/editor.js b/main_plugin/editor/editor.js index 931a13a..f88fa2b 100644 --- a/main_plugin/editor/editor.js +++ b/main_plugin/editor/editor.js @@ -54,13 +54,13 @@ function basisVis() { editableElementsFun(); let basis3 = document.getElementById('basis3'); let sideFloatClass = basis3 ? basis3.querySelectorAll('[style*="visibility: visible;"]') : null; - if (!basis3 || !sideFloatClass || !editableElements || editableElements.length === 0) return; - elementsСhecked = [basis3, ...sideFloatClass, ...editableElements]; - + if (!basis3 || !sideFloatClass || !window.editableElements || window.editableElements.length === 0) return; + let elementsСhecked = [basis3, ...sideFloatClass, ...window.editableElements]; + if (basis3.style.visibility === "visible") { basis3.style.visibility = "hidden"; sessionStorage.setItem('basis3_visibility', 'hidden'); - editableElements.forEach(function(element) { + window.editableElements.forEach(function(element) { if (element) { element.setAttribute("contenteditable", false); } @@ -69,18 +69,18 @@ function basisVis() { sideFloatClass.forEach(function(element) { element.style.visibility = "hidden"; }); - for (let i = 0; i < editId.length; i++) { + for (let i = 0; i < editId.length; i++) { editMode = -1; if (document.getElementById(editId[i])) { document.getElementById(editId[i]).classList.remove('active'); } } document.getElementById('bcbody').style.top = '0px'; - document.querySelectorAll('.bfloat').forEach(e=>e.style.fontSize='') + document.querySelectorAll('.bfloat').forEach(e => e.style.fontSize = '') } else { basis3.style.visibility = "visible"; sessionStorage.setItem('basis3_visibility', 'visible'); - editableElements.forEach(function(element) { + window.editableElements.forEach(function(element) { if (element) { element.setAttribute("contenteditable", true); } @@ -90,20 +90,20 @@ function basisVis() { basis3.style.top = '20%'; basis3.style.transform = 'translate(0%, -20%)'; document.getElementById('bcbody').style.top = '30px'; - document.querySelectorAll('.bfloat').forEach(e=>e.style.fontSize='1em') - + document.querySelectorAll('.bfloat').forEach(e => e.style.fontSize = '1em') } } window.basisVis = basisVis; /** @brief Сбор всех редактируемых элементов */ function editableElementsFun() { - let content = document.getElementById('content'); - editableElements = document.querySelectorAll('.pluginEditable'); - editableElements = Array.from(editableElements); - editableElements.push(content); + window.editableElements = []; + let contents = document.querySelectorAll('.content'); + let pluginEls = document.querySelectorAll('.pluginEditable'); + pluginEls = Array.from(pluginEls); + window.editableElements.push(...pluginEls, ...contents); - editableElements.forEach(function(element) { + window.editableElements.forEach(function(element) { if (!element) { console.log("Element " + element + " not found."); return; @@ -111,31 +111,28 @@ function editableElementsFun() { }); } - addEventListener("LoadeditorJs", function() { let te=document.getElementById("tex"); // Ссылка на текстовое поле let tex=document.getElementById("tex"); // Ссылка на стили текстового поля -if (document.getElementById("content") == "") { -te.value=document.getElementById("content").innerHTML; // Передача данных из области контента в текстовое поле -} +// Передаём содержимое пустых блоков в поле +document.querySelectorAll('.content').forEach(el => { + if (!el.innerHTML) te.value = el.innerHTML; +}); // Символы клавиш со знаками препинания или перевода строки let symb = ["Enter", "!", "?", ";", ":", ",", ".", " ", "-", "'", "\"", "(", ")", "{", "}", "[", "]", "_", "&", "/", "\\", "*"]; // Запись в память введенного текста при нажатии клавиши со знаком препинания или перевода строки -if (document.getElementById("content")) { - document.getElementById("content").addEventListener("keyup", function(ev) - { - for(let i=0; i { + el.addEventListener('keyup', ev => { + for (let i = 0; i < symb.length; i++) { + if (symb[i] == ev.key) inter(); + } + }); +}); let sel = document.getSelection(); function selInContenteditable(insertType) { @@ -497,69 +494,74 @@ document.getElementById("newPage").addEventListener("click", newPageFun); function newPageFun() { document.getElementById("right-float").innerHTML = ""; document.getElementById("left-float").innerHTML = ""; - document.getElementById("content").innerHTML = ""; + document.querySelectorAll('.content').forEach(el => el.innerHTML = ""); document.getElementById("mainTitle").innerHTML = "{{new_file}}!"; window.newPageFunValue = "newPage"; document.getElementById("settingsMain_d").style.visibility="hidden"; } // Сохранение выделение - document.addEventListener('selectionchange', () => { - const content = document.getElementById('content'); + const contents = document.querySelectorAll('.content'); + if (!contents || contents.length === 0) return; const sel = window.getSelection(); if (!sel.rangeCount) return; const range = sel.getRangeAt(0); const startNode = range.startContainer; - if (content.contains(startNode)) { - saveSelection(); + for (let content of contents) { + if (content.contains(startNode)) { + saveSelection(); + break; + } } }); let savedSel = null; function saveSelection() { - const content = document.getElementById('content'); + const contents = document.querySelectorAll('.content'); const sel = window.getSelection(); if (!sel.rangeCount) return; const range = sel.getRangeAt(0); - if (!content.contains(range.commonAncestorContainer)) return; - const pre = range.cloneRange(); - pre.selectNodeContents(content); - pre.setEnd(range.startContainer, range.startOffset); - const start = pre.toString().length; - const end = start + range.toString().length; - savedSel = { start, end }; + for (let content of contents) { + if (content.contains(range.commonAncestorContainer)) { + const pre = range.cloneRange(); + pre.selectNodeContents(content); + pre.setEnd(range.startContainer, range.startOffset); + const start = pre.toString().length; + const end = start + range.toString().length; + savedSel = { start, end }; + break; + } + } } function restoreSelection() { - if (!savedSel) return; - const content = document.getElementById('content'); - const { start, end } = savedSel; - let charIndex = 0; - const range = document.createRange(); - range.setStart(content, 0); - range.collapse(true); - try { - (function traverse(node) { - if (node.nodeType === Node.TEXT_NODE) { - const next = charIndex + node.length; - if (charIndex <= start && next >= start) { - range.setStart(node, start - charIndex); - } - if (charIndex <= end && next >= end) { - range.setEnd(node, end - charIndex); - throw 'done'; - } - charIndex = next; - } else { - node.childNodes.forEach(traverse); - } - })(content); - } catch (e) {} - const sel = window.getSelection(); - sel.removeAllRanges(); - sel.addRange(range); + if (!savedSel) return; + const contents = document.querySelectorAll('.content'); + const { start, end } = savedSel; + let charIndex = 0; + const range = document.createRange(); + try { + for (const content of contents) { + range.setStart(content, 0); + range.collapse(true); + (function traverse(node) { + if (node.nodeType === Node.TEXT_NODE) { + const next = charIndex + node.length; + if (charIndex <= start && next >= start) range.setStart(node, start - charIndex); + if (charIndex <= end && next >= end) { + range.setEnd(node, end - charIndex); + throw 'done'; + } + charIndex = next; + } else node.childNodes.forEach(traverse); + })(content); + } + } catch (e) {} + const sel = window.getSelection(); + sel.removeAllRanges(); + sel.addRange(range); } // Взаимодействие с плагинами @@ -1457,14 +1459,14 @@ const singleFormats = [ const specialFormats = ['butlink', 'linkdel', 'forma', 'col', 'backgr']; addEventListener("LoadeditorJs", function() { -const content = document.getElementById('content'); +const content = document.querySelectorAll('.content'); simpleFormats.forEach(f => { document.getElementById(f.id).addEventListener('click', () => { const sel = window.getSelection(); if (!sel.rangeCount) return; const range = sel.getRangeAt(0); - if (!content.contains(range.commonAncestorContainer)) return; + if (![...document.querySelectorAll('.content')].some(c => c.contains(range.commonAncestorContainer))) return; let all = true; const it = document.createNodeIterator( range.commonAncestorContainer, @@ -1495,7 +1497,7 @@ divFormats.forEach(f => { const sel = window.getSelection(); if (!sel.rangeCount) return; const range = sel.getRangeAt(0); - if (!content.contains(range.commonAncestorContainer)) return; + if (![...document.querySelectorAll('.content')].some(c => c.contains(range.commonAncestorContainer))) return; divApplyformat(range, f); inter(); }); @@ -1506,7 +1508,7 @@ listFormats.forEach(f => { const sel = window.getSelection(); if (!sel.rangeCount) return; const range = sel.getRangeAt(0); - if (!content.contains(range.commonAncestorContainer)) return; + if (![...document.querySelectorAll('.content')].some(c => c.contains(range.commonAncestorContainer))) return; listApplyformat(range, f); inter(); }); @@ -1523,7 +1525,7 @@ singleFormats.forEach(f => { const sel = window.getSelection() if (!sel.rangeCount) return const range = sel.getRangeAt(0) - if (!content.contains(range.commonAncestorContainer)) return + if (![...document.querySelectorAll('.content')].some(c => c.contains(range.commonAncestorContainer))) return; singleApplyformat(range, f) inter() }) @@ -1534,7 +1536,7 @@ specialFormats.forEach(f => { const sel = window.getSelection(); if (!sel.rangeCount) return; const range = sel.getRangeAt(0); - if (!content.contains(range.commonAncestorContainer)) return; + if (![...content].some(c => c.contains(range.commonAncestorContainer))) return; if (typeof document[f + 'Fun'] === 'function') document[f + 'Fun'](range); else window[f + 'Fun'](range); inter(); @@ -1543,10 +1545,13 @@ specialFormats.forEach(f => { const events = ['pointerup','keyup','input','focus','blur','click']; events.forEach(evt => { - if (!content) return; - content.addEventListener(evt, () => { - updateToolbarStyles(); - updateSingleSelectors(); + const contents = document.querySelectorAll('.content'); + if (!contents || contents.length === 0) return; + contents.forEach(content => { + content.addEventListener(evt, () => { + updateToolbarStyles(); + updateSingleSelectors(); + }); }); }); @@ -1561,36 +1566,42 @@ let currentIndex = 0 /** @brief Сохраняет текущее состояние контента, если оно изменилось */ function inter() { - const editable = document.getElementById("content") - if (editable) { - let currentContent = editable.innerHTML - if (currentContent !== arr[currentIndex]) { - currentIndex++ - arr = arr.slice(0, currentIndex) - arr.push(currentContent) + const editables = document.querySelectorAll(".content") + editables.forEach(editable => { + if (editable) { + let currentContent = editable.innerHTML + if (currentContent !== arr[currentIndex]) { + currentIndex++ + arr = arr.slice(0, currentIndex) + arr.push(currentContent) + } } - } + }) } -if (document.getElementById("content")) { - arr[0] = document.getElementById("content").innerHTML -} +document.querySelectorAll(".content").forEach((editable, i) => { + if (i === 0) arr[0] = editable.innerHTML +}) document.getElementById("forw").addEventListener("click", function() { if (currentIndex < arr.length - 1) { currentIndex++ - const editable = document.getElementById("content") - editable.innerHTML = arr[currentIndex] - editable.setAttribute("contenteditable", "true") + const editables = document.querySelectorAll(".content") + editables.forEach(editable => { + editable.innerHTML = arr[currentIndex] + editable.setAttribute("contenteditable", "true") + }) } }) document.getElementById("bac").addEventListener("click", function() { if (currentIndex > 0) { currentIndex-- - const editable = document.getElementById("content") - editable.innerHTML = arr[currentIndex] - editable.setAttribute("contenteditable", "true") + const editables = document.querySelectorAll(".content") + editables.forEach(editable => { + editable.innerHTML = arr[currentIndex] + editable.setAttribute("contenteditable", "true") + }) } }) @@ -1785,8 +1796,10 @@ function divApplyformat(range, format) { range.compareBoundaryPoints(Range.START_TO_END, er) > 0; }; - Array.from(content.children).forEach(child => { - if (intersects(child)) externals.add(child); + Array.from(document.querySelectorAll('.content')).forEach(content => { + Array.from(content.children).forEach(child => { + if (intersects(child)) externals.add(child); + }); }); externals.forEach(div => { @@ -1811,8 +1824,10 @@ function listApplyformat(range, format) { if (type === 'listNone') { const lists = new Set(); - Array.from(content.querySelectorAll('li')).forEach(li => { - if (intersects(li)) lists.add(li.parentNode); + Array.from(document.querySelectorAll('.content')).forEach(content => { + Array.from(content.querySelectorAll('li')).forEach(li => { + if (intersects(li)) lists.add(li.parentNode); + }); }); lists.forEach(list => { @@ -1849,31 +1864,33 @@ function listApplyformat(range, format) { parent.removeChild(list); }); } else { - const items = Array.from(content.children).filter(child => intersects(child)); - if (!items.length) return; + Array.from(document.querySelectorAll('.content')).forEach(content => { + const items = Array.from(content.children).filter(child => intersects(child)); + if (!items.length) return; - let listEl; - if (type === 'listNumbers' || type === 'listLetters') { - listEl = document.createElement('ol'); - listEl.style.listStyleType = format.style.listStyleType; - } else { - listEl = document.createElement('ul'); - listEl.style.listStyleType = format.style.listStyleType; - } - content.insertBefore(listEl, items[0]); - - items.forEach(node => { - if (node.tagName === 'UL' || node.tagName === 'OL') { - Array.from(node.children).forEach(li => { - listEl.appendChild(li); - }); - content.removeChild(node); + let listEl; + if (type === 'listNumbers' || type === 'listLetters') { + listEl = document.createElement('ol'); + listEl.style.listStyleType = format.style.listStyleType; } else { - const li = document.createElement('li'); - content.removeChild(node); - li.appendChild(node); - listEl.appendChild(li); + listEl = document.createElement('ul'); + listEl.style.listStyleType = format.style.listStyleType; } + content.insertBefore(listEl, items[0]); + + items.forEach(node => { + if (node.tagName === 'UL' || node.tagName === 'OL') { + Array.from(node.children).forEach(li => { + listEl.appendChild(li); + }); + content.removeChild(node); + } else { + const li = document.createElement('li'); + content.removeChild(node); + li.appendChild(node); + listEl.appendChild(li); + } + }); }); } } @@ -1959,32 +1976,36 @@ function formaFun(range) { return range.compareBoundaryPoints(Range.END_TO_START, er) < 0 && range.compareBoundaryPoints(Range.START_TO_END, er) > 0; }; - Array.from(content.children).forEach(child => { - if (intersects(child)) externals.add(child); + Array.from(document.querySelectorAll('.content')).forEach(content => { + Array.from(content.children).forEach(child => { + if (intersects(child)) externals.add(child); + }); }); externals.forEach(el => { el.style.textAlign = ''; }); - const itList = document.createNodeIterator( - content, - NodeFilter.SHOW_ELEMENT, - { - acceptNode: n => - (n.tagName === 'UL' || n.tagName === 'OL') && - range.intersectsNode(n) - ? NodeFilter.FILTER_ACCEPT - : NodeFilter.FILTER_REJECT + Array.from(document.querySelectorAll('.content')).forEach(content => { + const itList = document.createNodeIterator( + content, + NodeFilter.SHOW_ELEMENT, + { + acceptNode: n => + (n.tagName === 'UL' || n.tagName === 'OL') && + range.intersectsNode(n) + ? NodeFilter.FILTER_ACCEPT + : NodeFilter.FILTER_REJECT + } + ); + let listEl; + while (listEl = itList.nextNode()) { + const parent = listEl.parentNode; + Array.from(listEl.children).forEach(li => { + while (li.firstChild) parent.insertBefore(li.firstChild, listEl); + }); + parent.removeChild(listEl); } - ); - let listEl; - while (listEl = itList.nextNode()) { - const parent = listEl.parentNode; - Array.from(listEl.children).forEach(li => { - while (li.firstChild) parent.insertBefore(li.firstChild, listEl); - }); - parent.removeChild(listEl); - } + }); function unwrapAllSpansAndLinks(node) { const frag = document.createDocumentFragment(); @@ -2079,7 +2100,7 @@ function detectFormatState(format) { const sel = window.getSelection(); if (!sel.rangeCount) return 'none'; const range = sel.getRangeAt(0); - if (!content.contains(range.commonAncestorContainer)) return 'none'; + if (![...document.querySelectorAll('.content')].some(c => c.contains(range.commonAncestorContainer))) return 'none'; const it = document.createNodeIterator( range.commonAncestorContainer, NodeFilter.SHOW_TEXT, @@ -2091,7 +2112,7 @@ function detectFormatState(format) { if (!text) continue; total++; let cur = node.parentElement, ok = false; - while (cur && cur !== content) { + while (cur && ![...document.querySelectorAll('.content')].includes(cur)) { const fmt = simpleFormats.find(f => f.id === format); const v = fmt ? getComputedStyle(cur)[fmt.prop] || '' : ''; if (fmt && fmt.test(v)) { ok = true; break; } @@ -2128,7 +2149,7 @@ function detectSingleState(format) { const sel = window.getSelection(); if (!sel.rangeCount) return ''; const range = sel.getRangeAt(0); - if (!content.contains(range.commonAncestorContainer)) return ''; + if (![...document.querySelectorAll('.content')].some(c => c.contains(range.commonAncestorContainer))) return ''; const it = document.createNodeIterator( range.commonAncestorContainer, NodeFilter.SHOW_TEXT, @@ -2263,7 +2284,7 @@ document.querySelectorAll('.align-dropdown-text').forEach(dropdown => { const sel = window.getSelection() if (sel.rangeCount) { const range = sel.getRangeAt(0) - if (content.contains(range.commonAncestorContainer)) { + if ([...document.querySelectorAll('.content')].some(c => c.contains(range.commonAncestorContainer))) { singleApplyformat(range, f) inter() } diff --git a/main_plugin/editor/func.editor.php b/main_plugin/editor/func.editor.php index 958b175..32aa158 100644 --- a/main_plugin/editor/func.editor.php +++ b/main_plugin/editor/func.editor.php @@ -15,22 +15,19 @@ function savePageCenterBlock($params) { $saveContentIdXml = $path . $_SESSION['page_url'] . ".page.php"; $saveContentIdData = $params['saveContentIdData'] ?? ''; - $file = @simplexml_load_file($saveContentIdXml); - $node = $file->content->{$_SESSION['lng']}; - $file->content->{$_SESSION['lng']} = ''; - $node = dom_import_simplexml($node); - $doc = $node->ownerDocument; - $appended = $node->appendChild($doc->createCDATASection("\n" . $saveContentIdData . "\n")); - $saved = $file->asXML($saveContentIdXml); + $xml = file_get_contents($saveContentIdXml); + $xml = preg_replace('#<' . $_SESSION['lng'] . '>.*?#s', '<' . $_SESSION['lng'] . '>', $xml); - if ($appended && $saved) { - return 'true'; + if (preg_match('#<' . $_SESSION['lng'] . '>#', $xml, $pos)) { + $xml = preg_replace('#(<' . $_SESSION['lng'] . '>)#', '$1' . "\n" . $saveContentIdData . "\n", $xml, 1); } + if (file_put_contents($saveContentIdXml, $xml) !== false) return 'true'; throw new Exception("Problem saving content", -32003); } + /** * @brief Сохраняет левый и правый блоки страницы * @param array $params Массив с данными блоков, ключ 'floatsBlock' содержит массив левых и правых блоков @@ -130,39 +127,33 @@ function saveHowPageContent($params) { $_SESSION['page_url'] = $params['page_url'] . str_replace('.page.php', '', $params['nameFile']); $filePath = $path . $params['page_url'] . $params['nameFile']; - $contentData = $params['saveContentIdData'] ?? ''; - $file = simplexml_load_file($filePath); - $langNode = $file->content->{$_SESSION['lng']}; - $file->content->{$_SESSION['lng']} = ''; - $node = dom_import_simplexml($langNode); - $doc = $node->ownerDocument; - $node->appendChild($doc->createCDATASection("\n" . $contentData . "\n")); + $contentData = html_entity_decode($params['saveContentIdData'] ?? '', ENT_QUOTES, 'UTF-8'); + + $xml = file_get_contents($filePath); + $xml = preg_replace('#<' . $_SESSION['lng'] . '>.*?#s', '<' . $_SESSION['lng'] . '>', $xml); + $xml = preg_replace('#(<' . $_SESSION['lng'] . '>)#', "$1\n" . $contentData . "\n", $xml, 1); + + $xml = preg_replace('#.*?#s', '', $xml); + $xml = preg_replace('#.*?#s', '', $xml); - $file->rblock = ''; - $file->lblock = ''; $blocks = $params['floatsBlock'] ?? []; $titles = $params['title'] ?? []; $urls = $params['pluginUrl'] ?? []; $tclasses = $params['tclass'] ?? []; $bclasses = $params['bclass'] ?? []; + foreach ($blocks as $i => $blockName) { - $newBlock = $file->$blockName->addChild('block'); - $newBlock->addAttribute('url', htmlspecialchars($urls[$i] ?? '', ENT_QUOTES,'UTF-8')); - $newBlock->addAttribute('title', htmlspecialchars($titles[$i] ?? '', ENT_QUOTES,'UTF-8')); - $newBlock->addAttribute('tclass',htmlspecialchars($tclasses[$i] ?? '',ENT_QUOTES,'UTF-8')); - $newBlock->addAttribute('bclass',htmlspecialchars($bclasses[$i] ?? '',ENT_QUOTES,'UTF-8')); + $url = htmlspecialchars($urls[$i] ?? '', ENT_QUOTES, 'UTF-8'); + $title = htmlspecialchars($titles[$i] ?? '', ENT_QUOTES, 'UTF-8'); + $tclass = htmlspecialchars($tclasses[$i] ?? '', ENT_QUOTES, 'UTF-8'); + $bclass = htmlspecialchars($bclasses[$i] ?? '', ENT_QUOTES, 'UTF-8'); + + $blockXml = ''; + $xml = preg_replace('#<' . $blockName . '>#', '<' . $blockName . '>' . "\n" . $blockXml, $xml, 1); } - $dom = new DOMDocument('1.0','UTF-8'); - $dom->preserveWhiteSpace = false; - $dom->formatOutput = true; - $dom->loadXML($file->asXML()); - - $saved = $dom->save($filePath); - if ($saved === false) { - throw new Exception("Failed to save content", -32003); - } - return 'true'; + if (file_put_contents($filePath, $xml) !== false) return 'true'; + throw new Exception("Failed to save content", -32003); } /** @@ -184,11 +175,12 @@ function createNewPage($params) { } $file = simplexml_load_file($saveContentIdXml); - $node = $file->content->{$_SESSION['lng']}; - $file->content->{$_SESSION['lng']} = ''; - $node = dom_import_simplexml($node); - $no = $node->ownerDocument; - $node->appendChild($no->createCDATASection("\n" . $saveContentIdData . "\n")); + foreach ($file->content->{$_SESSION['lng']} as $node) { + $node = dom_import_simplexml($node); + $no = $node->ownerDocument; + while ($node->firstChild) $node->removeChild($node->firstChild); + $node->appendChild($no->createCDATASection("\n" . $saveContentIdData . "\n")); + } $saved = $file->asXML($saveContentIdXml); if ($saved === false) { diff --git a/main_plugin/manager/func.manager.php b/main_plugin/manager/func.manager.php index 748b0ed..ab5d730 100644 --- a/main_plugin/manager/func.manager.php +++ b/main_plugin/manager/func.manager.php @@ -252,9 +252,17 @@ function getPage($params) { } $page = []; - $page['right'] = GetBlock($pageXml->rblock->block, 'right'); - $page['left'] = GetBlock($pageXml->lblock->block, 'left'); - $page['content'] = (string)$pageXml->content->{$_SESSION['lng']}; + $page['right'] = GetBlock($pageXml->rblock->block, 'right'); + $page['left'] = GetBlock($pageXml->lblock->block, 'left'); + + $xmlContent = file_get_contents($file); + $lng = $_SESSION['lng']; + preg_match('#<' . $lng . '>(.*?)#s', $xmlContent, $block); + $langBlock = $block[1] ?? ''; + preg_match_all('##s', $langBlock, $matches); + $contents = $matches[1] ?? []; + $page['content'] = $contents; + $_SESSION['page_url'] = $rel; session_write_close(); return $page; diff --git a/main_plugin/site_tree/site_tree.js b/main_plugin/site_tree/site_tree.js index 27b9898..0709b73 100644 --- a/main_plugin/site_tree/site_tree.js +++ b/main_plugin/site_tree/site_tree.js @@ -993,7 +993,7 @@ function treePropertiesDiv() { inputHtml = ``; } else if (key.toLowerCase() === "plugins") { let plugins = (value || '').split(','); - let allPlugins = ['dgrm','SvgEditorM']; + let allPlugins = ['dgrm','SvgEditorM', 'form_editor']; inputHtml = allPlugins.map(p => `` ).join(' '); diff --git a/template/MedWait/css.php b/template/MedWait/css.php index 10471c7..78424b7 100644 --- a/template/MedWait/css.php +++ b/template/MedWait/css.php @@ -187,12 +187,15 @@ ul, ol { .bfloat { overflow-x: hidden; left: -1px; - top: -1px; position: relative; - border-radius: 0 0 10px 10px; + border-radius: 10px; padding: 10px; font-size: 1em; } +.content1 { + top: -1px; + border-radius: 0 0 10px 10px; +} .cfloat { left: -1px; @@ -228,11 +231,11 @@ ul, ol { font-weight: bold; } -#content { +#content, .content { overflow-x: hidden; overflow-y: hidden; } -#content td { +#content td, .content td { height: 19px; } #editor a { diff --git a/template/MedWait/page.php b/template/MedWait/page.php index 8bde895..c13bedc 100644 --- a/template/MedWait/page.php +++ b/template/MedWait/page.php @@ -14,9 +14,7 @@
%title%
-
-
%content%
-
+ %content%
%left% %right% diff --git a/template/default/page.php b/template/default/page.php index 817fdaa..8600a35 100644 --- a/template/default/page.php +++ b/template/default/page.php @@ -27,8 +27,6 @@
%title%
-
-
%content%
-
+ %content%
diff --git a/template/default1/page.php b/template/default1/page.php index 005fe3f..e541b53 100644 --- a/template/default1/page.php +++ b/template/default1/page.php @@ -27,8 +27,6 @@
%title%
-
-
%content%
-
+ %content%
diff --git a/template/default2/page.php b/template/default2/page.php index a6dc22d..6949f0e 100644 --- a/template/default2/page.php +++ b/template/default2/page.php @@ -27,8 +27,6 @@
%title%
-
-
%content%
-
+ %content% diff --git a/template/default3/page.php b/template/default3/page.php index a6dc22d..6949f0e 100644 --- a/template/default3/page.php +++ b/template/default3/page.php @@ -27,8 +27,6 @@
%title%
-
-
%content%
-
+ %content% diff --git a/template/default4/page.php b/template/default4/page.php index 2e8686a..1e7e2f2 100644 --- a/template/default4/page.php +++ b/template/default4/page.php @@ -27,8 +27,6 @@
%title%
-
-
%content%
-
+ %content% diff --git a/template/error.php b/template/error.php index d0e5029..95234d3 100644 --- a/template/error.php +++ b/template/error.php @@ -23,7 +23,5 @@
%title%
-
-
%content%
-
+ %content% diff --git a/template/kip/page.php b/template/kip/page.php index e3978c6..0cbbc92 100644 --- a/template/kip/page.php +++ b/template/kip/page.php @@ -49,9 +49,7 @@
%title%
-
-
%content%
-
+ %content% diff --git a/template/rpi/page.php b/template/rpi/page.php index 7052dc2..6514483 100644 --- a/template/rpi/page.php +++ b/template/rpi/page.php @@ -28,9 +28,7 @@
%title%
-
-
%content%
-
+ %content% diff --git a/template/temp/new/page.php b/template/temp/new/page.php index 2fa5c2c..71a4bd8 100644 --- a/template/temp/new/page.php +++ b/template/temp/new/page.php @@ -49,9 +49,7 @@
%title%
-
-
%content%
-
+ %content% diff --git a/template/test/page.php b/template/test/page.php index 0a1c3d3..6ba1f80 100644 --- a/template/test/page.php +++ b/template/test/page.php @@ -26,9 +26,7 @@
%title%
-
-
%content%
-
+ %content%