Initial import

This commit is contained in:
Admin Nasledstvo
2026-05-01 20:52:04 +03:00
commit ac168868ee
10028 changed files with 2337954 additions and 0 deletions
@@ -0,0 +1,499 @@
<?php
use app\models\FileCms;
use app\widgets\services\Includes;
use app\services\Validate;
use app\widgets\services\UserRight;
?>
<?php if ($_SERVER['REQUEST_METHOD'] == 'GET'): ?>
<style>
.help_key_link {
cursor: pointer; position: absolute; font-size: 10px; color: grey; top: 15px; right:0
}
.help_key_link.has_link {
color: darkmagenta !important;
font-weight: bold;
font-size: 11px;
}
.help_info_button {
cursor: pointer;
position: absolute;
top: 5px;
right: -15px;
border-radius: 100%;
height: 17px;
width: 17px;
font-size: 17px;
text-align: center;
line-height: 17px;
background: #FFFFFF;
}
.help_info_button:hover {
background: #f1f1f1;
}
.help_info_button .la {
color: var(--base-background-dark);
}
.help_info_button .content-body {
position: absolute;
top: 20px;
right: 20px;
z-index: 1000;
background: #FFFFFF;
border: 1px solid var(--base-background-dark);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.4);
padding: 10px;
width: 150px;
border-radius: 5px;
cursor: default;
}
.help_info_button .content-body a { cursor: pointer }
.help_info_button .content-body .content-body-title {
font-size: 13px !important;
font-weight: bold;
text-align: left;
color: var(--base-background-dark);
}
.help_info_button .content-body .content-body-text {
font-size: 13px;
line-height: 13px;
text-align: left;
max-height: 300px;
overflow-y: scroll;
padding-right: 10px
}
.content-body-text::-webkit-scrollbar {
width: 3px;
}
.content-body-text::-webkit-scrollbar-track {
box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
}
.content-body-text::-webkit-scrollbar-thumb {
background-color: var(--base-background);
outline: 1px solid slategrey;
}
.help_info_button .content-body .content-body-text p {
font-size: 13px;
line-height: 13px;
text-align: left
}
</style>
<?php if (!UserRight::edit() && !empty($_GET['id']) || empty($_GET['id']) && !UserRight::add()): ?>
<!-- prevent edit view -->
<style>
.all-files {
display: none !important;
}
.top-page-panel .action-buttons {
display: none !important;
}
.files-container [data-del] {
display: none !important;
}
.file-img.dragging {
display: block !important;
opacity: 1 !important;
}
.readonly {
pointer-events: none !important;
appearance: none !important;
-webkit-appearance: none !important;
-moz-appearance: none !important;
padding: 0 !important;
border: 0 !important;
}
input[type="radio"] {
pointer-events: none !important;
}
.search-box {
pointer-events: none !important;
padding: 0 !important;
border: 0 !important;
}
.search-box::after {
display: none !important;
}
.selected-box .close {
display: none !important;
}
.selected-box {
padding-right: 5px !important;
}
.require::after {
display: none !important;
}
[data-exposition-id] {
display: none !important;
}
.cke_top {
display: none !important;
}
.upload-info {
display: none
}
.air-datepicker-cell {
pointer-events: none !important;
}
#partner_logo_image_0 {
pointer-events: none
}
</style>
<?php endif ?>
<?php if (!UserRight::edit() || !UserRight::add()): ?>
<style>
[onclick="addTs(this)"] {
display: none !important;
}
#tslist input {
pointer-events: none
}
</style>
<?php endif; ?>
<?php endif; ?>
<?php
/**
* @var $top array
* @var $tabs array
* @var $data array
* @var $writeView string
* @var $postService
* @var $validation
* @var \yii\db\ActiveRecord | string $model
*/
$dataModel = null;
if ($model) {
$dataModel = new $model();
if (isset($_GET['id'])) {
$updateModel = $model::findOne($_GET['id']);
if ($updateModel)
$dataModel = $updateModel;
if (!$dataModel->id)
header('Location: ' . explode('?', $_SERVER['REQUEST_URI'])[0]);
}
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
switch ($_GET['o']) {
case 'w':
if (empty($_GET['id']) && !UserRight::add()) die('You have no permission to operate');
if (!empty($_GET['id']) && !UserRight::edit()) die('You have no permission to operate');
if ($validation)
Validate::defaultValidation($validation((object)$_POST, (object)$_FILES));
if ($dataModel) {
$postService((object)$_POST, $dataModel);
} else {
$postService((object)$_POST);
}
break;
case 'u':
// UPDATE STATUS
foreach (['model', 'id', 'key'] as $p) {
if (empty($_POST[$p])) {
echo json_encode(['error' => 'Missing parameter: ' . $p]);
exit;
}
}
/**
* @var $modelStr \yii\db\ActiveRecord;
* @var $remoteUpdateModel \yii\db\ActiveRecord;
*/
$modelStr = $_POST['model'];
$remoteUpdateModel = $modelStr::findOne($_POST['id']);
$remoteUpdateModel->{$_POST['key']} = $_POST['value'] == 'null' ? NULL : 1;
if ($remoteUpdateModel->hasProperty('publish_date') && $_POST['key'] == 'is_active' && $_POST['value'] == 1) {
if ($remoteUpdateModel->{'publish_date'}) {
$dateRecorded = strtotime($remoteUpdateModel->{'publish_date'});
$dateNow = strtotime(date('Y-m-d'));
if ($dateNow > $dateRecorded) {
$remoteUpdateModel->{'publish_date'} = date('Y-m-d H:i:s');
}
} else {
$remoteUpdateModel->{'publish_date'} = date('Y-m-d H:i:s');
}
}
$remoteUpdateModel->save();
if ($remoteUpdateModel->hasProperty('article_key'))
\app\models\Articles::updateArticle($remoteUpdateModel);
echo json_encode(['successMsg' => Yii::t('cms', 'The status has been successfully updated')]);
exit;
break;
case 'd':
if (isset($_POST['ids']) && isset($_POST['model'])) {
$ids = json_decode($_POST['ids']);
/** @var \yii\db\ActiveRecord $model */
$model = $_POST['model'];
$table = $model::getTableSchema()->name;
$dataToDelete = $model::find()->where(['IN', 'id', $ids])->all();
foreach ($dataToDelete as $dtd) {
if ($dtd->hasProperty('media_key') && !empty($dtd->media_key)) {
FileCms::deleteAll(['media_key' => $dtd->media_key]);
$raw = $_SERVER['DOCUMENT_ROOT'] . '/_files/raw/' . $dtd->media_key;
$public = $_SERVER['DOCUMENT_ROOT'] . '/_files/ready/' . $dtd->media_key;
if (file_exists($raw))
system("rm -rf " . escapeshellarg($raw));
if (file_exists($public))
system("rm -rf " . escapeshellarg($public));
}
\app\models\History::deleteAll(['table_name' => $table, 'history_id' => $dtd->id]);
if ($dtd->hasProperty('article_key')) {
$articleForDelete = \app\models\Articles::find()->where(['key' => $dtd->{'article_key'}])->one();
if ($articleForDelete)
$articleForDelete->delete();
}
$dtd->delete();
}
$count = sizeof($ids);
$msg = $count == 1 ? '{count} record has been successfully deleted' :
'{count} records have been successfully deleted';
if (empty($_POST['noFlash']))
Yii::$app->flash('success', Yii::t('cms', $msg, ['count' => $count]));
echo json_encode(['success' => true, 'message' => Yii::t('cms', $msg, ['count' => $count])]);
exit;
}
}
exit;
}
$controller = Yii::$app->controller->id;
Includes::top($top['title'], $top['data'], $top['title_edit'] ?? null);
Includes::setTabs($tabs);
if ($model) {
$modelInfoKey = strtolower(substr(strrchr($model, "\\"), 1));
echo '<div data-info-key-value="' . $modelInfoKey . '"></div>';
}
echo $this->render('/' . $controller . '/' . $writeView, ['model' => $dataModel]);
?>
<?php if ($_SERVER['REQUEST_METHOD'] == 'GET'): ?>
<?php if (!UserRight::edit() && !empty($_GET['id']) || empty($_GET['id']) && !UserRight::add()): ?>
<!-- prevent edit view -->
<script>
function editSingleFileImage(e) {
event.preventDefault()
if (e.id !== 'partner_logo_image_0') {
let checkbox = e.parentNode.querySelector('input')
modal.modalPreview('<?= Yii::$app->params['cms'] ?>' + checkbox.dataset.srcRaw)
}
return 0;
}
setTimeout(function () {
document.querySelectorAll('.file-img').forEach(e => {
e.classList.remove('draggable')
e.removeAttribute('draggable')
e.removeAttribute('data-file-index')
e.removeAttribute('data-file-id')
e.addEventListener('dragstart', function () {
event.preventDefault()
})
e.addEventListener('dragging', function () {
event.preventDefault()
})
})
}, 300)
document.querySelectorAll('input:not([type="radio"]), textarea').forEach(e => {
e.setAttribute('readonly', true);
e.classList.add('readonly')
e.setAttribute('placeholder', 'Нама въведени данни')
})
document.querySelectorAll('select').forEach(e => {
e.classList.add('readonly')
})
</script>
<?php endif ?>
<script>
/* all('.ckEditor', t => {
t.id = t.name;
CKEDITOR.replace(t.id, {language: 'bg'});
}) */
document.addEventListener('DOMContentLoaded', function () {
if (typeof ClassicEditor === 'undefined') {
console.error('CKEditor 5 not loaded');
return;
}
document.querySelectorAll('.ckEditor').forEach(function (el) {
ClassicEditor.create(el);
});
});
let dataInfoKey = document.querySelector('[data-info-key-value]');
const infoKeys = [];
document.querySelectorAll('[name]').forEach(e => {
if (e.type !== 'hidden' || e.name === 'media_key') {
let input = e.name.replace('[]', '')
e.parentNode.style.position = 'relative'
let dataInfoKeyValue = dataInfoKey ? '_' + dataInfoKey.getAttribute('data-info-key-value') : '';
let keyText = input + dataInfoKeyValue
e.parentNode.setAttribute('data-hk', keyText)
infoKeys.push(keyText);
}
})
<?php if(!empty($_SESSION['help_keys'])): ?>
alert(window.location.path);
request({
url: '/admin-global/help-keys-remote/get-list/?keys=' + infoKeys.join(','), done: r => {
let has_link_list = [];
if(r.list) {
r.list.forEach(l => {
has_link_list.push(l.key)
})
}
document.querySelectorAll('[name]').forEach(e => {
if (e.type !== 'hidden' || e.name === 'media_key') {
let input = e.name.replace('[]', '')
console.log(input);
e.parentNode.style.position = 'relative'
let key = document.createElement('div')
key.classList.add('help_key_link')
let dataInfoKeyValue = dataInfoKey ? '_' + dataInfoKey.getAttribute('data-info-key-value') : '';
key.innerHTML = input + dataInfoKeyValue
if(has_link_list.indexOf(key.innerHTML) > -1) {
key.classList.add('has_link')
}
let label = e.parentNode.querySelector('label');
let title = label ? label.innerHTML : '';
key.addEventListener('click', function () {
request({
url: '/admin-global/help-keys-remote/set-help/', post: {
key: key.innerHTML,
title
}, done: r => {
if (r.url_to) {
window.open(r.url_to, '_blank').focus();
}
}
})
})
e.parentNode.appendChild(key)
}
})
}
});
<?php else: ?>
if(window.location.pathname !== '/admin-global/web-portal/tslist/') {
if (infoKeys.length > 0) {
request({
url: '/remote/help-keys-remote/get-list/?keys=' + infoKeys.join(','), done: r => {
if (r.list) {
r.list.forEach(le => {
let helpBtnContainer = document.querySelector(`[data-hk="${le.key}"]`);
let helpBtn = document.createElement('div')
helpBtn.classList.add('help_info_button')
let icon = document.createElement('i')
icon.className = 'help-info-ico la la-info-circle'
helpBtn.appendChild(icon);
helpBtnContainer.appendChild(helpBtn)
icon.addEventListener('click', () => {
if (helpBtn.classList.contains('open')) {
closeHelpInfoWindow(helpBtn)
icon.classList.add('la-info-circle')
icon.classList.remove('la-times-circle')
helpBtn.classList.remove('open')
} else {
openHelpInfoWindow(le.id, helpBtn)
icon.classList.remove('la-info-circle')
icon.classList.add('la-times-circle')
helpBtn.classList.add('open')
}
})
})
}
}
})
document.addEventListener('click', () => {
document.querySelectorAll('.help_info_button.open').forEach(b => {
if (!b.contains(event.target)) {
closeHelpInfoWindow(b)
let cIcon = b.querySelector('.la');
cIcon.classList.add('la-info-circle')
cIcon.classList.remove('la-times-circle')
b.classList.remove('open')
}
})
})
}
function openHelpInfoWindow(id, container) {
request({
dataType: 'html',
url: '/remote/help-keys-remote/get-content/?id=' + id,
done: html => {
console.log(html)
let contentBody = document.createElement('div');
contentBody.className = 'content-body'
contentBody.innerHTML = html;
container.appendChild(contentBody);
}
})
}
function closeHelpInfoWindow(container) {
container.querySelector('.content-body').remove();
}
}
<?php endif ?>
</script>
<?php endif ?>
<style>
/* Allow ckeditor vertical resize */
.ck-editor__editable {
resize: vertical;
min-height: 150px;
}
/* Prevent ckeditor horizontal resize */
.ck-editor__editable[contenteditable="true"] {
overflow: auto;
}
</style>