<?php if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } $editorStoreId = (int)($_GET['store'] ?? 1); $csrfToken = CSRF::token(); $stores = []; try { $stores = Database::fetchAll("SELECT id, domain, nickname, color_master FROM stores WHERE is_active = 1 ORDER BY id ASC"); } catch (\Throwable $e) {} $storeRows = []; try { $storeRows = Database::fetchAll( "SELECT id, row_type, display_order, config          FROM storefront_rows          WHERE store_id = ? AND is_active = 1 ORDER BY display_order ASC", [$editorStoreId] ); foreach ($storeRows as &$sr) { $raw = $sr['config'] ?? '{}'; try { $dec = Encryption::render($raw); $sr['config_decoded'] = json_decode($dec, true) ?: []; } catch (\Throwable $e) { $sr['config_decoded'] = json_decode($raw, true) ?: []; } } unset($sr); } catch (\Throwable $e) {} $products = []; try { $products = Database::fetchAll( "SELECT id, name AS title, image_path AS image_url, base_price AS price, status FROM products WHERE store_id = ? ORDER BY display_order ASC, id ASC", [$editorStoreId] ); foreach ($products as &$p) { try { $p['title'] = Encryption::render($p['title']); } catch (\Throwable $e) {} try { $p['price'] = Encryption::render($p['price']); } catch (\Throwable $e) {} } unset($p); } catch (\Throwable $e) {} $rowTypeLabels = [ 'banner' => ['label' => 'Hero Banner', 'icon' => '[img]', 'desc' => 'Full-width banner with store name, tagline, and CTA button'], 'triple_feature' => ['label' => '3-Product Feature', 'icon' => '[3x]', 'desc' => '3 quality products filling the full row with quality/unit pricing'], 'dual_showcase' => ['label' => 'Dual Showcase', 'icon' => '[2x+]', 'desc' => '2 products + store feature panel side by side'], 'product_grid' => ['label' => 'Product Grid', 'icon' => '[grid]', 'desc' => 'Individual product cards in a 3 or 4 column grid'], 'dual_cards' => ['label' => 'Dual Cards', 'icon' => '[2x]', 'desc' => '2 wide product cards side by side'], 'divider' => ['label' => 'Image Divider', 'icon' => '[div]', 'desc' => 'Full-width break image between content sections'], 'quad_feature' => ['label' => 'Quad Feature', 'icon' => '[1+4]', 'desc' => '1 product with 4 tabbed feature panels'], ]; 