[MVC] Полная миграция на MVC архитектуру
- Создано ядро MVC: App, Router, Controller, Model, View, Database - Созданы модели: User, Product, Category, Cart, Order - Созданы контроллеры: Home, Auth, Product, Cart, Order, Page, Admin - Созданы layouts и partials для представлений - Добавлены все views для страниц - Настроена маршрутизация с чистыми URL - Обновлена конфигурация Docker и Apache для mod_rewrite - Добавлена единая точка входа public/index.php
This commit is contained in:
75
app/Views/layouts/admin.php
Normal file
75
app/Views/layouts/admin.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AETERNA - Админ-панель</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body { font-family: Arial, sans-serif; background: #f5f5f5; }
|
||||
.admin-header { background: #453227; color: white; padding: 20px; display: flex; justify-content: space-between; align-items: center; }
|
||||
.admin-header h1 { font-size: 20px; }
|
||||
.admin-tabs { background: white; padding: 10px; border-bottom: 2px solid #453227; display: flex; gap: 10px; flex-wrap: wrap; }
|
||||
.admin-tab { padding: 10px 20px; border-radius: 5px; text-decoration: none; color: #333; transition: all 0.3s; }
|
||||
.admin-tab:hover, .admin-tab.active { background: #453227; color: white; }
|
||||
.admin-content { padding: 20px; }
|
||||
.form-container { background: white; padding: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); max-width: 800px; margin: 0 auto; }
|
||||
.form-group { margin-bottom: 15px; }
|
||||
.form-group label { display: block; margin-bottom: 5px; font-weight: bold; }
|
||||
.form-control { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; }
|
||||
.btn { padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; text-decoration: none; display: inline-block; transition: all 0.3s; }
|
||||
.btn-primary { background: #453227; color: white; }
|
||||
.btn-success { background: #28a745; color: white; }
|
||||
.btn-danger { background: #dc3545; color: white; }
|
||||
.btn-warning { background: #ffc107; color: #333; }
|
||||
.btn-sm { padding: 5px 10px; font-size: 12px; }
|
||||
.btn:hover { opacity: 0.9; }
|
||||
.alert { padding: 15px; border-radius: 4px; margin-bottom: 20px; }
|
||||
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
|
||||
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
|
||||
table { width: 100%; border-collapse: collapse; background: white; }
|
||||
th, td { padding: 10px; border: 1px solid #ddd; text-align: left; }
|
||||
th { background: #f8f9fa; }
|
||||
.action-buttons { display: flex; gap: 5px; }
|
||||
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin: 20px 0; }
|
||||
.stat-card { background: white; padding: 20px; border-radius: 5px; text-align: center; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
|
||||
.stat-card h3 { font-size: 32px; color: #453227; margin-bottom: 5px; }
|
||||
.stat-card p { color: #666; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="admin-header">
|
||||
<h1><i class="fas fa-user-shield"></i> Админ-панель AETERNA</h1>
|
||||
<div>
|
||||
<span><?= htmlspecialchars($user['email'] ?? 'Администратор') ?></span>
|
||||
<a href="/cite_practica/catalog" class="btn btn-primary" style="margin-left: 10px;">В каталог</a>
|
||||
<a href="/cite_practica/logout" class="btn btn-danger" style="margin-left: 10px;">Выйти</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-tabs">
|
||||
<a href="/cite_practica/admin" class="admin-tab <?= ($action ?? '') === 'dashboard' ? 'active' : '' ?>">
|
||||
<i class="fas fa-tachometer-alt"></i> Дашборд
|
||||
</a>
|
||||
<a href="/cite_practica/admin/products" class="admin-tab <?= str_contains($_SERVER['REQUEST_URI'] ?? '', '/products') ? 'active' : '' ?>">
|
||||
<i class="fas fa-box"></i> Товары
|
||||
</a>
|
||||
<a href="/cite_practica/admin/categories" class="admin-tab <?= str_contains($_SERVER['REQUEST_URI'] ?? '', '/categories') ? 'active' : '' ?>">
|
||||
<i class="fas fa-tags"></i> Категории
|
||||
</a>
|
||||
<a href="/cite_practica/admin/orders" class="admin-tab <?= str_contains($_SERVER['REQUEST_URI'] ?? '', '/orders') ? 'active' : '' ?>">
|
||||
<i class="fas fa-shopping-cart"></i> Заказы
|
||||
</a>
|
||||
<a href="/cite_practica/admin/users" class="admin-tab <?= str_contains($_SERVER['REQUEST_URI'] ?? '', '/users') ? 'active' : '' ?>">
|
||||
<i class="fas fa-users"></i> Пользователи
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="admin-content">
|
||||
<?= $content ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
68
app/Views/layouts/main.php
Normal file
68
app/Views/layouts/main.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AETERNA - <?= $title ?? 'Мебель и Интерьер' ?></title>
|
||||
<link rel="stylesheet/less" type="text/css" href="/cite_practica/style_for_cite.less">
|
||||
<script src="https://cdn.jsdelivr.net/npm/less"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||
<style>
|
||||
.user-profile-dropdown { position: relative; display: inline-block; }
|
||||
.user-profile-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 8px 12px; border-radius: 4px; transition: all 0.3s ease; }
|
||||
.user-profile-toggle:hover { background-color: rgba(0, 0, 0, 0.05); }
|
||||
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #617365 0%, #453227 100%); color: white; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 16px; }
|
||||
.user-info { display: flex; flex-direction: column; }
|
||||
.user-email { font-size: 12px; color: #666; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.user-status { font-size: 10px; padding: 2px 8px; border-radius: 12px; text-transform: uppercase; font-weight: bold; text-align: center; margin-top: 2px; }
|
||||
.user-status.admin { background-color: #617365; color: white; }
|
||||
.user-status.user { background-color: #28a745; color: white; }
|
||||
.user-profile-menu { display: none; position: absolute; top: 100%; right: 0; background: white; min-width: 280px; border-radius: 8px; box-shadow: 0 5px 20px rgba(0,0,0,0.15); z-index: 1000; padding-top: 10px; border: 1px solid #e0e0e0; }
|
||||
.user-profile-dropdown:hover .user-profile-menu { display: block; }
|
||||
.user-profile-header { padding: 15px; background: #f8f9fa; border-bottom: 1px solid #e0e0e0; }
|
||||
.user-profile-name { font-weight: bold; margin-bottom: 5px; color: #333; display: flex; align-items: center; gap: 8px; }
|
||||
.user-profile-details { font-size: 12px; color: #666; }
|
||||
.user-profile-links { list-style: none; padding: 10px 0; margin: 0; }
|
||||
.user-profile-links a { display: flex; align-items: center; gap: 10px; padding: 10px 15px; color: #333; text-decoration: none; transition: all 0.3s ease; border-left: 3px solid transparent; }
|
||||
.user-profile-links a:hover { background-color: #f5f5f5; border-left-color: #453227; color: #453227; }
|
||||
.logout-link { color: #dc3545 !important; }
|
||||
.logout-link:hover { background-color: #ffe6e6 !important; border-left-color: #dc3545 !important; }
|
||||
.cart-icon { position: relative; margin-right: 15px; }
|
||||
.cart-count { position: absolute; top: -8px; right: -8px; background: #dc3545; color: white; border-radius: 50%; width: 18px; height: 18px; font-size: 11px; display: flex; align-items: center; justify-content: center; }
|
||||
.notification { position: fixed; top: 20px; right: 20px; padding: 15px 20px; background: #28a745; color: white; border-radius: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 10000; transform: translateX(150%); transition: transform 0.3s ease; max-width: 300px; }
|
||||
.notification.show { transform: translateX(0); }
|
||||
.notification.error { background: #dc3545; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="notification" class="notification"></div>
|
||||
|
||||
<?= \App\Core\View::partial('header', ['user' => $user ?? null, 'isLoggedIn' => $isLoggedIn ?? false, 'isAdmin' => $isAdmin ?? false]) ?>
|
||||
|
||||
<main>
|
||||
<?= $content ?>
|
||||
</main>
|
||||
|
||||
<?= \App\Core\View::partial('footer') ?>
|
||||
|
||||
<script>
|
||||
function showNotification(message, type = 'success') {
|
||||
const notification = $('#notification');
|
||||
notification.text(message);
|
||||
notification.removeClass('success error').addClass(type + ' show');
|
||||
setTimeout(function() { notification.removeClass('show'); }, 3000);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
// Обновляем счетчик корзины
|
||||
$.get('/cite_practica/cart/count', function(response) {
|
||||
if (response.success) {
|
||||
$('.cart-count').text(response.cart_count);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user