✨ New Features: - Reviews system with 1-5 star ratings - User can add, edit, and delete their own reviews - One review per product per user (DB constraint) - Automatic average rating calculation - Review count tracking - Interactive star selection UI - AJAX-powered review submission - Responsive design for all devices 🗄️ Database: - New 'reviews' table with full structure - Added 'rating' and 'review_count' fields to products - PostgreSQL triggers for automatic rating updates - Database functions for rating calculations - Indexes for performance optimization 📦 Backend (PHP): - Review model with 15+ methods - ReviewController with 5 actions - Updated Product model to include ratings - Updated ProductController to load reviews - 5 new API endpoints 🎨 Frontend: - Reviews list component (_reviews_list.php) - Review form component (_review_form.php) - Reviews sechow page - Star ratings in catalog view - Interactive JavaScript (200+ lines) - Adaptive styles (400+ lines) 🔒 Security: - Server-side authorization checks - XSS protection (htmlspecialchars) - SQL injection protection (PDO prepared) - Input validation (client + server) - Access control for review editing 📝 Modified Files: - app/Models/Product.php - added rating fields to queries - app/Controllers/ProductController.php - loads reviews - app/Views/products/show.php - reviews section - app/Views/products/catalog.php - star ratings - config/routes.php - review endpoints - public/style_for_cite.less - rating styles 🆕 New Files: - app/Models/Review.php - app/Controllers/ReviewController.php - app/Views/products/_reviews_list.php - app/Views/products/_review_form.php
85 lines
3.5 KiB
PHP
85 lines
3.5 KiB
PHP
<?php
|
||
$isLoggedIn = $isLoggedIn ?? \App\Core\View::isAuthenticated();
|
||
$isAdmin = $isAdmin ?? \App\Core\View::isAdmin();
|
||
$user = $user ?? \App\Core\View::currentUser();
|
||
?>
|
||
<style>
|
||
#catalogMenu {
|
||
display: none;
|
||
}
|
||
#catalogDropdown.active #catalogMenu {
|
||
display: block;
|
||
}
|
||
</style>
|
||
<header class="header">
|
||
<div class="header__top">
|
||
<div class="container header__top-content">
|
||
<a href="/" class="logo">AETERNA</a>
|
||
|
||
<div class="search-catalog">
|
||
<div class="catalog-dropdown" id="catalogDropdown">
|
||
Все категории <span>▼</span>
|
||
<div class="catalog-dropdown__menu" id="catalogMenu">
|
||
<ul>
|
||
<li><a href="/catalog">Все товары</a></li>
|
||
<?php if (!empty($categories)): ?>
|
||
<?php foreach ($categories as $category): ?>
|
||
<li><a href="/catalog?category=<?= $category['category_id'] ?>"><?= htmlspecialchars($category['name']) ?></a></li>
|
||
<?php endforeach; ?>
|
||
<?php endif; ?>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="search-box">
|
||
<form method="GET" action="/catalog" style="display: flex; width: 100%;">
|
||
<input type="text" name="search" placeholder="Поиск товаров" style="border: none; width: 100%; padding: 10px;">
|
||
<button type="submit" style="background: none; border: none; cursor: pointer;">
|
||
<span class="search-icon"><i class="fas fa-search"></i></span>
|
||
</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="header__icons--top">
|
||
<?php if ($isLoggedIn): ?>
|
||
<?php if (!$isAdmin): ?>
|
||
<a href="/cart" class="icon cart-icon">
|
||
<i class="fas fa-shopping-cart"></i>
|
||
<span class="cart-count">0</span>
|
||
</a>
|
||
<?php endif; ?>
|
||
|
||
<a href="/logout" style="font-size: 14px; color: #666; text-decoration: none; margin-left: 15px;">
|
||
<i class="fas fa-sign-out-alt"></i> Выйти
|
||
</a>
|
||
<?php else: ?>
|
||
<a href="/login" class="icon"><i class="far fa-user"></i></a>
|
||
<a href="/login" style="font-size: 12px; color: #666; margin-left: 5px;">Войти</a>
|
||
<?php endif; ?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="header__bottom">
|
||
<div class="container header__bottom-content">
|
||
<div class="catalog-menu">
|
||
<a href="/catalog" class="catalog-link">
|
||
<span class="catalog-lines">☰</span>
|
||
Каталог
|
||
</a>
|
||
</div>
|
||
|
||
<nav class="nav">
|
||
<ul class="nav-list">
|
||
<li><a href="/">Главная</a></li>
|
||
<li><a href="/services">Услуги</a></li>
|
||
<li><a href="/delivery">Доставка и оплата</a></li>
|
||
<li><a href="/warranty">Гарантия</a></li>
|
||
<li><a href="#footer">Контакты</a></li>
|
||
</ul>
|
||
</nav>
|
||
<div class="header-phone">+7(912)999-12-23</div>
|
||
</div>
|
||
</div>
|
||
</header>
|