| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- require_once __DIR__ . "/config.php";
- require_once __DIR__ . "/includes/functions.php";
- $pageTitle = "Startseite";
- $products = getProducts();
- $categories = getCategories();
- $category = isset($_GET["category"])
- ? normalizeCategoryId($_GET["category"])
- : "";
- if ($category !== "" && getCategoryById($category) !== null) {
- $products = array_values(
- array_filter($products, function ($product) use ($category) {
- return productHasCategory($product, $category);
- }),
- );
- } else {
- $category = "";
- }
- include __DIR__ . "/includes/header.php";
- ?>
- <h2><?php echo escape(SITE_SERVICE_HEADER); ?></h2>
- <div class="disclaimer-box">
- <?php foreach (DISCLAIMER_LINES as $line): ?>
- <p><?php echo escape($line); ?></p>
- <?php endforeach; ?>
- </div>
- <div class="category-filter-bar" aria-label="Produktkategorien">
- <a href="?category=" class="btn btn-small <?php echo $category === ""
- ? ""
- : "btn-secondary"; ?>">Alle</a>
- <?php foreach ($categories as $categoryOption): ?>
- <a href="?category=<?php echo urlencode(
- $categoryOption["id"],
- ); ?>" class="btn btn-small <?php echo $category ===
- $categoryOption["id"]
- ? ""
- : "btn-secondary"; ?>">
- <?php echo escape($categoryOption["label"]); ?>
- </a>
- <?php endforeach; ?>
- </div>
- <?php if (empty($products)): ?>
- <div class="alert alert-info">
- <p>Keine Produkte gefunden.</p>
- </div>
- <?php else: ?>
- <div class="products-grid">
- <?php foreach ($products as $product): ?>
- <div class="product-card">
- <a href="product.php?id=<?php echo (int) $product["id"]; ?>">
- <?php $imagePath = getUploadPath(
- $product["image"] ?? "",
- ); ?>
- <?php $imageUrl = getUploadUrl($product["image"] ?? ""); ?>
- <?php if (
- $imagePath !== null &&
- $imageUrl !== null &&
- file_exists($imagePath)
- ): ?>
- <img src="<?php echo escape(
- $imageUrl,
- ); ?>" alt="<?php echo escape($product["name"]); ?>">
- <?php else: ?>
- <img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='200'%3E%3Crect fill='%233a4150' width='250' height='200'/%3E%3Ctext x='50%25' y='50%25' text-anchor='middle' dy='.3em' fill='%23c7ccd6'%3EKein Bild%3C/text%3E%3C/svg%3E" alt="Kein Bild">
- <?php endif; ?>
- </a>
- <div class="product-card-content">
- <h3><a href="product.php?id=<?php echo (int) $product[
- "id"
- ]; ?>" class="product-card-title-link"><?php echo escape(
- $product["name"],
- ); ?></a></h3>
- <a href="product.php?id=<?php echo (int) $product[
- "id"
- ]; ?>" class="btn btn-block mt-2">Details ansehen</a>
- </div>
- </div>
- <?php endforeach; ?>
- </div>
- <?php endif; ?>
- <?php include __DIR__ . "/includes/footer.php"; ?>
|