Initial commit
This commit is contained in:
8
main_plugin/siteSettings/lang.js.php
Normal file
8
main_plugin/siteSettings/lang.js.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
$lang = include $path . 'lang.php';
|
||||
$lng = $_GET['lng'] ?? ($_SESSION['lng'] ?? 'en');
|
||||
$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
Normal file
77
main_plugin/siteSettings/lang.php
Normal 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;
|
||||
16
main_plugin/siteSettings/plug.php
Normal file
16
main_plugin/siteSettings/plug.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
global $path, $_SESSION, $configAdmins;
|
||||
$lang = include $path . 'main_plugin/siteSettings/lang.php';
|
||||
$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" 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
Normal file
33
main_plugin/siteSettings/siteSettings.css
Normal 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-left: 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;
|
||||
}
|
||||
46
main_plugin/siteSettings/siteSettings.js
Normal file
46
main_plugin/siteSettings/siteSettings.js
Normal file
@@ -0,0 +1,46 @@
|
||||
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 (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();
|
||||
|
||||
});
|
||||
25
main_plugin/siteSettings/siteSettings.php
Normal file
25
main_plugin/siteSettings/siteSettings.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<span id="siteSettingsButton" onclick="toggleMenu()"></span>
|
||||
<div id="siteSettings" class="borderStyle" style="display: none;">
|
||||
<div id="editor" class="siteSettingsOption" onclick="basisVis()">{{editor_page}}</div>
|
||||
<div id="manager" class="siteSettingsOption" onclick="basisVisManager()">{{file_manager}}</div>
|
||||
<div id="siteTree" class="siteSettingsOption" onclick="basisVisSiteTree()">{{site_tree}}</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