Вход Регистрация
Файл: upload/pages/admin/theme/themes.php
Строк: 150
<?php
require_once ($_SERVER['DOCUMENT_ROOT'] . '/core/core.php');

if (
$users_perms['edit_templates'] != 1) {
    
RedirectToPage('/');
    exit();
}

echo 
'<div class="home_us tematic">';

$breadcrumbsArray = [
    [
'/''Главная'],
    [
'/admin''Админ панель'],
    [
'#''Стили']
];

$breadcrumbs generateBreadcrumbs($breadcrumbsArray);

echo 
$breadcrumbs['html'];
echo 
'<script type="application/ld+json">' $breadcrumbs['json_ld'] . '</script>';

echo 
'<div class="head_box section-header">
<div class="box_title">Стили</div>
</div>'
;

echo 
'<div class="side_in_count">';

include (
$_SERVER['DOCUMENT_ROOT'] . '/core/elements/sidebars/panel.php');

echo 
'<div class="info_box arb">
<div class="node-info_box adm">
<a class="btn button" data-bs-toggle="modal" data-bs-target="#upload-theme" style="display: flex;">Добавить тему</a>
</div>'
;

echo 
'<div class="modal fade" id="del-theme" tabindex="-1" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Удаление стиля</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal"><i class="fas fa-xmark"></i></button>
      </div>
      <div class="modal-body">
        <span>Вы уверены, что хотите удалить стиль <span id="del-theme-text"></span>?</span>
      </div>
      <div class="modal-footer">
        <a id="del-theme-btn" class="btn button" href="#" style="float: right; margin-left: 5px;">Удалить</a>
      </div>
    </div>
  </div>
</div>

<div class="modal fade" id="upload-theme" tabindex="-1" aria-hidden="true">
  <div class="modal-dialog">
    <form class="modal-content" action="' 
homeLink() . '/admin/themes/upload" method="post" enctype="multipart/form-data">
      <div class="modal-header">
        <h5 class="modal-title">Загрузка стиля</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal"><i class="fas fa-xmark"></i></button>
      </div>
      <div class="modal-body">
        <input type="file" name="theme" accept=".zip" required>
      </div>
      <div class="modal-footer">
        <input type="submit" value="Загрузить" style="float: right; margin-left: 5px;">
      </div>
    </form>
  </div>
</div>
'
;

global 
$THEMES;

$templates dbquery("SELECT * FROM `themes` ORDER BY `id` ASC");

while (
$tpl FetchAssoc($templates)) {

    
$id $tpl['id'];
    
$info $THEMES[$id] ?? null;

    
// Если theme.php отсутствует → битая тема
    
if (!$info) {
        echo 
'
        <div class="plug_error">
            <div class="err_plugin">Ошибка: theme.php стиля ' 
chars($tpl['name']) . ' не найден или повреждён</div>
            <a class="but_link-plug delete" data-bs-toggle="modal" data-bs-target="#del-theme"
               data-id="' 
$tpl['id'] . '" data-name="' chars($tpl['name']) . '">
                <i class="fas fa-trash"></i>
            </a>
        </div>'
;
        continue;
    }

    echo 
'<div class="user_info-work-box box-admin">
            <div class="user_in_ava box-adm">
                <div class="flex_adm-users">'
;

    
// Иконка темы
    
echo '<div class="plugin_icon">';
    if (!empty(
$info['icon'])) {
        echo 
'<img src="' homeLink() . '/core/templates/' $id '/' $info['icon'] . '" onerror="this.src='' . homeLink() . '/core/templates/' . $theme . '/images/admin/non-style.png'">';
    } else {
        echo 
'<img src="' homeLink() . '/core/templates/' $theme '/images/admin/non-style.png">';
    }
    echo 
'</div>';

    
// Название + статус
    
echo '<div class="user_name_work box">
            <div class="flex_st-name_plugin">'
;

    echo 
$tpl['is_active'] ? '<span class="pl_status on"></span>' '<span class="pl_status off"></span>';

    echo 
'<div class="name_plugin">' chars($info['name']) . '</div>
            </div>'
;

    
// Описание
    
echo '<div class="desc_plugin">' chars($info['description'] ?? 'Описание отсутствует') . '</div>';

    echo 
'<div class="plugin_flex_bot"></div>';

    echo 
'</div></div>';

    
// Кнопки управления
    
echo '<div class="flex-link-adm">';

    
// Включить / выключить тему
    
if ($tpl['is_active']) {
        echo 
'<a class="but_link-plug on" href="' homeLink() . '/admin/themes/disable?id=' $id '">
                <i class="fas fa-circle-check"></i>
              </a>'
;
    } else {
        echo 
'<a class="but_link-plug off" href="' homeLink() . '/admin/themes/enable?id=' $id '">
                <i class="far fa-circle"></i>
              </a>'
;
    }

    
// Удалить тему
    
echo '<a class="but_link-plug delete" data-bs-toggle="modal" data-bs-target="#del-theme"
             data-id="' 
$id '" data-name="' chars($info['name']) . '">
            <i class="fas fa-trash"></i>
          </a>'
;

    
// Экспорт темы
    
echo '<a class="but_link-plug edit" href="' homeLink() . '/admin/themes/export-theme/' $id '">
            <i class="fas fa-download"></i>
          </a>'
;

    echo 
'</div></div></div>';
}

echo 
'</div>';
echo 
'</div>';
echo 
'</div>';

$page_html ob_get_clean();
require_once (
$_SERVER['DOCUMENT_ROOT'] . '/layout.php');
?>

<script>
document.addEventListener('DOMContentLoaded', function() {
    const modal = document.getElementById('del-theme');

    modal.addEventListener('show.bs.modal', function (event) {
        const button = event.relatedTarget;

        const id = button.getAttribute('data-id');
        const name = button.getAttribute('data-name');

        document.getElementById('del-theme-text').innerHTML =
            "" + name + "";

        document.getElementById('del-theme-btn').href =
            "<?= homeLink() ?>/admin/themes/delete?id=" + id;
    });
});
</script>
Онлайн: 1
Реклама