Обновлена логика центральных блоков: теперь поддерживается несколько блоков
This commit is contained in:
@@ -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<contents.length; i++) combined += "<![CDATA[" + contents[i].innerHTML + "]]>";
|
||||
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(/<!\[CDATA\[(.*?)\]\]>/gs);
|
||||
if (split) {
|
||||
for (let i=0; i<contents.length; i++) {
|
||||
if (split[i]) contents[i].innerHTML = split[i].replace(/<!\[CDATA\[|\]\]>/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 += "<![CDATA[" + contents[i].innerHTML.trim() + "]]>";
|
||||
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 => `<![CDATA[${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 = "<i>{{new_file}}!</i>";
|
||||
removePluginDom("manager")
|
||||
removePluginDom("manager");
|
||||
});
|
||||
window.newPageFunValue = "";
|
||||
}
|
||||
|
||||
|
||||
//обьявление функции для того, чтобы обращатся к ней из других файлов
|
||||
window.getPage = getPage;
|
||||
window.managerData = managerData;
|
||||
|
||||
@@ -3,5 +3,13 @@
|
||||
<sitename>RaspberryqePi</sitename>
|
||||
<slogan>Raspberry Pi</slogan>
|
||||
<index url='content/index' title='Sākuma lapa' name='index' template='rpi' PageMenu='0,1,2' users='' group=''>
|
||||
<page1 url="content/rpi/index" title="Новый ф6нрцуеыкеа" name="page1" template="MedWait" PageMenu="0,1,2" users="" group="" news="" plugins="">
|
||||
<underpage1 url="content/rpi/index" title="Загловок" name="underpage1" template="rpi" PageMenu="0,1,2" users="" group="" news="" plugins="">
|
||||
</underpage1>
|
||||
<underpage2 url="content/rpi/index" title="Загловок" name="underpage2" template="rpi" PageMenu="0,1,2" users="" group="" news="" plugins="SvgEditorM">
|
||||
</underpage2>
|
||||
<createSite url="data/createSite" title="Страница создание нового сайта" name="createSite" template="MedWait" PageMenu="0,1,2" users="" group="" news="" plugins="dgrm">
|
||||
</createSite>
|
||||
</page1>
|
||||
</index>
|
||||
</site>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<sitename>site</sitename>
|
||||
<slogan>site</slogan>
|
||||
<index url="content/index" title="Новый ф6нрцуеыке" name="index" template="start" PageMenu="0,0" users="" group="" news="" plugins="">
|
||||
<page1 url="content/rpi/index" title="Новый ф6нрцуеыкеа" name="page1" template="MedWait" PageMenu="0,1,2" users="" group="" news="" plugins="">
|
||||
<page1 url="content/rpi/index" title="Новый файл" name="page1" template="MedWait" PageMenu="0,1,2" users="" group="" news="" plugins="dgrm,SvgEditorM,form_editor">
|
||||
<underpage1 url="content/rpi/index" title="Загловок" name="underpage1" template="rpi" PageMenu="0,1,2" users="" group="" news="" plugins="">
|
||||
</underpage1>
|
||||
<underpage2 url="content/rpi/index" title="Загловок" name="underpage2" template="rpi" PageMenu="0,1,2" users="" group="" news="" plugins="SvgEditorM">
|
||||
|
||||
@@ -307,17 +307,6 @@ function GetBlock ($BlockVar, $side) {
|
||||
}
|
||||
}
|
||||
return $Block;
|
||||
|
||||
// $Block.='<div class="'.$BlockVar[$i]['bclass'].'"><div class="bcont">ku ku</div></div>';
|
||||
/*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;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user