Добавляем все файлы
This commit is contained in:
22
main_plugin/siteSettings/lang.js.php
Executable file
22
main_plugin/siteSettings/lang.js.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* @file lang.js.php
|
||||
* @brief Подготавливает языковые строки и подставляет их в JS-файл плагина siteSettings
|
||||
*/
|
||||
|
||||
global $path, $_SESSION;
|
||||
|
||||
/** @brief Языковой массив для siteSettings */
|
||||
$lang = include $path . 'lang.php';
|
||||
|
||||
/** @brief Текущий язык пользователя, по умолчанию 'en' */
|
||||
$lng = $_GET['lng'] ?? ($_SESSION['lng'] ?? 'en');
|
||||
|
||||
/** @brief Массив подстановок для шаблона JS */
|
||||
$placeholders = [];
|
||||
|
||||
foreach ($lang[$lng] as $key => $value) {
|
||||
$placeholders['{{' . $key . '}}'] = $value;
|
||||
}
|
||||
|
||||
echo strtr(file_get_contents($path . 'siteSettings.js'), $placeholders);
|
||||
77
main_plugin/siteSettings/lang.php
Executable file
77
main_plugin/siteSettings/lang.php
Executable file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
$lang = [
|
||||
'ru' => [
|
||||
'authorization' => 'Авторизация',
|
||||
'login_label' => 'Логин',
|
||||
'password_label' => 'Пароль',
|
||||
'incorrect_login_password' => 'Неверный логин или пароль!',
|
||||
'repeat_password_label' => 'Повторите пароль',
|
||||
'email_label' => 'Почта',
|
||||
'fill_all_fields' => 'Вы должны заполнить все поля!',
|
||||
'passwords_do_not_match' => 'Пароли не совпадают!',
|
||||
'account_creation_request_sent' => 'Запрос на создание аккаунта отправлен!',
|
||||
'user_exists' => 'Пользователь с таким логином уже существует!',
|
||||
'account_creation_error' => 'Ошибка при создании аккаунта!',
|
||||
'incorrect_email' => 'Вы ввели неправильную почту!',
|
||||
'account_creation_request_error' => 'Ошибка при отправке запроса на создание аккаунта!',
|
||||
'account_authorization' => 'Авторизация аккаунта',
|
||||
'login' => 'Войти',
|
||||
'register' => 'Зарегистрироваться',
|
||||
'logoff' => 'Выйти',
|
||||
'editor_page' => 'Редактор страницы',
|
||||
'file_manager' => 'Файловый менеджер',
|
||||
'site_tree' => 'Дерево сайта',
|
||||
'save_data_question' => 'Сохранить данные?',
|
||||
'save_new_page' => 'Сохраните новую страницу!',
|
||||
],
|
||||
'en' => [
|
||||
'authorization' => 'Authorization',
|
||||
'login_label' => 'Login',
|
||||
'password_label' => 'Password',
|
||||
'incorrect_login_password' => 'Incorrect login or password!',
|
||||
'repeat_password_label' => 'Repeat password',
|
||||
'email_label' => 'Email',
|
||||
'fill_all_fields' => 'You must fill out all fields!',
|
||||
'passwords_do_not_match' => 'Passwords do not match!',
|
||||
'account_creation_request_sent' => 'Account creation request sent!',
|
||||
'user_exists' => 'User with this login already exists!',
|
||||
'account_creation_error' => 'Error while creating the account!',
|
||||
'incorrect_email' => 'Incorrect email!',
|
||||
'account_creation_request_error' => 'Error sending account creation request!',
|
||||
'account_authorization' => 'Account authorization',
|
||||
'login' => 'Login',
|
||||
'register' => 'Register',
|
||||
'logoff' => 'Log out',
|
||||
'editor_page' => 'Page editor',
|
||||
'file_manager' => 'File manager',
|
||||
'site_tree' => 'Site tree',
|
||||
'save_data_question' => 'Save changes?',
|
||||
'save_new_page' => 'Save the new page!',
|
||||
],
|
||||
'lv' => [
|
||||
'authorization' => 'Autentifikācija',
|
||||
'login_label' => 'Lietotājvārds',
|
||||
'password_label' => 'Parole',
|
||||
'incorrect_login_password' => 'Nepareizs lietotājvārds vai parole!',
|
||||
'repeat_password_label' => 'Atkārtot paroli',
|
||||
'email_label' => 'E-pasts',
|
||||
'fill_all_fields' => 'Jums jāaizpilda visi lauki!',
|
||||
'passwords_do_not_match' => 'Paroles nesakrīt!',
|
||||
'account_creation_request_sent' => 'Pieprasījums par konta izveidi nosūtīts!',
|
||||
'user_exists' => 'Lietotājs ar šo lietotājvārdu jau pastāv!',
|
||||
'account_creation_error' => 'Kļūda, izveidojot kontu!',
|
||||
'incorrect_email' => 'Nepareizs e-pasts!',
|
||||
'account_creation_request_error' => 'Kļūda, nosūtot pieprasījumu par konta izveidi!',
|
||||
'account_authorization' => 'Konta autentifikācija',
|
||||
'login' => 'Ieiet',
|
||||
'register' => 'Reģistrēties',
|
||||
'logoff' => 'Iziet',
|
||||
'editor_page' => 'Lapas redaktors',
|
||||
'file_manager' => 'Failu pārvaldnieks',
|
||||
'site_tree' => 'Saites koks',
|
||||
'save_data_question' => 'Saglabāt datus?',
|
||||
'save_new_page' => 'Saglabājiet jauno lapu!',
|
||||
],
|
||||
];
|
||||
|
||||
return $lang;
|
||||
28
main_plugin/siteSettings/plug.php
Executable file
28
main_plugin/siteSettings/plug.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* @file plug.php
|
||||
* @brief Подключает плагин siteSettings для администраторов, подставляет языковые строки и выводит HTML-код страницы настроек сайта
|
||||
*/
|
||||
|
||||
global $path, $_SESSION, $configAdmins;
|
||||
|
||||
/** @brief Языковой массив для плагина siteSettings */
|
||||
$lang = include $path . 'main_plugin/siteSettings/lang.php';
|
||||
|
||||
/** @brief Текущий язык пользователя, по умолчанию 'en' */
|
||||
$lng = $_SESSION['lng'] ?? 'en';
|
||||
|
||||
if (in_array($_SESSION['username'], $configAdmins, true)) {
|
||||
|
||||
$Html = file_get_contents($path . 'main_plugin/siteSettings/siteSettings.php');
|
||||
|
||||
foreach ($lang[$lng] as $key => $value) {
|
||||
$Html = str_replace('{{' . $key . '}}', $value, $Html);
|
||||
}
|
||||
|
||||
echo $Html;
|
||||
|
||||
echo '<link rel="stylesheet" type="text/css" href="/main_plugin/siteSettings/siteSettings.css">';
|
||||
echo '<script type="text/javascript" src="/main_plugin/siteSettings/lang.js.php?lng=' . $lng . '"></script>';
|
||||
}
|
||||
?>
|
||||
33
main_plugin/siteSettings/siteSettings.css
Executable file
33
main_plugin/siteSettings/siteSettings.css
Executable file
@@ -0,0 +1,33 @@
|
||||
#siteSettingsButton {
|
||||
background: url(../../img/pict/mc_iconslyb.svg) -1840px 1664px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
float: right;
|
||||
margin: 0px 5px;
|
||||
}
|
||||
#siteSettingsButton:hover {
|
||||
background-image: url(../../img/pict/g_iconslyb.svg);
|
||||
}
|
||||
#siteSettings {
|
||||
margin: -2px -63px 0px 0px;
|
||||
position: absolute;
|
||||
top: 30px;
|
||||
right: 80px;
|
||||
background-color: #fff;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
||||
z-index: 1001;
|
||||
font-family: Arial, sans-serif;
|
||||
padding: 2px;
|
||||
}
|
||||
.siteSettingsOption {
|
||||
padding: 2px;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
.siteSettingsOption:hover {
|
||||
color: rgb(153, 153, 153);
|
||||
text-shadow: -1px -1px #666, 1px 1px #FFF;
|
||||
}
|
||||
88
main_plugin/siteSettings/siteSettings.js
Executable file
88
main_plugin/siteSettings/siteSettings.js
Executable file
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* @file siteSettings.js
|
||||
* @brief Основной файл siteSettings, открытие плагинов
|
||||
*/
|
||||
|
||||
addEventListener("load", function() {
|
||||
|
||||
let menu = document.getElementById('siteSettings');
|
||||
let button = document.getElementById('siteSettingsButton');
|
||||
|
||||
menu.onclick = function() {
|
||||
menu.style.display = 'none';
|
||||
};
|
||||
|
||||
function hbodyHref() {
|
||||
let hbody = document.getElementById('hbody');
|
||||
let links = hbody.querySelectorAll('a[href]');
|
||||
links.forEach(link => {
|
||||
let originalHref = link.getAttribute('href');
|
||||
link.removeAttribute('href');
|
||||
link.onclick = function(event) {
|
||||
event.preventDefault();
|
||||
hbodyHrefFunction(originalHref);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async function hbodyHrefFunction(href) {
|
||||
if (document.getElementById('basis3')?.style.visibility === "visible" && window.contentIsEdit == true) {
|
||||
messageQueue.push("{{save_data_question}}");
|
||||
try {
|
||||
const userConfirmed = await messageCreateQuestion();
|
||||
if (userConfirmed) {
|
||||
if (window.newPageFunValue == "newPage") {
|
||||
document.getElementById("saveHow").click();
|
||||
messageFunction("{{save_new_page}}");
|
||||
return;
|
||||
} else {
|
||||
await saveChanges();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Ошибка: ", error);
|
||||
}
|
||||
}
|
||||
window.location.href = href;
|
||||
}
|
||||
|
||||
hbodyHref();
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Подключает или отключает плагин по ID
|
||||
* @param id ID элемента DOM
|
||||
* @param plugin Название плагина
|
||||
* @param fnName Имя функции инициализации
|
||||
*/
|
||||
async function togglePlugin(id, plugin, fnName) {
|
||||
const exists = !!document.getElementById(id);
|
||||
if (exists) {
|
||||
if (plugin === 'editor') await removePluginDom('pickr');
|
||||
if (typeof window[fnName] === 'function') window[fnName]();
|
||||
await removePluginDom(plugin);
|
||||
} else {
|
||||
await includePlugin(plugin);
|
||||
await new Promise(res => {
|
||||
const i = setInterval(() => {
|
||||
if (typeof window[fnName] === 'function') {
|
||||
clearInterval(i);
|
||||
window[fnName]();
|
||||
res();
|
||||
}
|
||||
});
|
||||
});
|
||||
if (plugin === 'editor') await includePlugin('pickr');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** @brief Переключает редактор */
|
||||
function toggleEditor() { return togglePlugin("basis3", "editor", "basisVis"); }
|
||||
/** @brief Переключает дерево сайта */
|
||||
function toggleSiteTree() { return togglePlugin("treeDiv", "site_tree", "basisVisSiteTree"); }
|
||||
/** @brief Переключает менеджер */
|
||||
function toggleManager() { return togglePlugin("managerDiv", "manager", "basisVisManager"); }
|
||||
35
main_plugin/siteSettings/siteSettings.php
Executable file
35
main_plugin/siteSettings/siteSettings.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* @file siteSettings.php
|
||||
* @brief Контейнер настроек сайта: кнопка открытия, переключение между редактором страниц, деревом сайта и файловым менеджером
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php /** @brief Кнопка открытия панели настроек сайта */ $siteSettingsButton; ?>
|
||||
<span id="siteSettingsButton" onclick="toggleMenu()"></span>
|
||||
|
||||
<?php /** @brief Панель настроек сайта с опциями */ $siteSettings; ?>
|
||||
<div id="siteSettings" class="borderStyle" style="display: none;">
|
||||
<div id="editor" class="siteSettingsOption" onclick="toggleEditor()">{{editor_page}}</div>
|
||||
<div id="siteTree" class="siteSettingsOption" onclick="toggleSiteTree()">{{site_tree}}</div>
|
||||
<div id="manager" class="siteSettingsOption" onclick="toggleManager()">{{file_manager}}</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.addEventListener("load", function() {
|
||||
try {
|
||||
var siteSettingsButton = document.getElementById("siteSettingsButton").outerHTML;
|
||||
var siteSettings = document.getElementById("siteSettings").outerHTML;
|
||||
|
||||
document.getElementById("siteSettingsButton").remove();
|
||||
document.getElementById("siteSettings").remove();
|
||||
|
||||
var container = document.getElementById("hbody");
|
||||
if (!container) throw new Error("#hbody не найден для siteSettings");
|
||||
container.insertAdjacentHTML("beforeend", siteSettingsButton);
|
||||
container.insertAdjacentHTML("beforeend", siteSettings);
|
||||
} catch (e) {
|
||||
console.error("Ошибка в блоке siteSettings:", e);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user