Commit 01cb0797 authored by Administrator's avatar Administrator

Update 3 files via Son of Anton

parent 220b3994
<?php <?php
/** /**
* Flash alert messages component. * Alerts component — reads flash alerts from session and displays them.
* Bulletproof: will never crash, never kill the page.
*/ */
$session = \App\Core\App::getInstance()->session(); $__alertList = [];
$alerts = $session->getAlerts(); try {
if (isset($_SESSION['_flash']['_alerts']) && is_array($_SESSION['_flash']['_alerts'])) {
if (empty($alerts)) { $__alertList = $_SESSION['_flash']['_alerts'];
return; unset($_SESSION['_flash']['_alerts']);
} elseif (isset($_SESSION['_alerts']) && is_array($_SESSION['_alerts'])) {
$__alertList = $_SESSION['_alerts'];
unset($_SESSION['_alerts']);
}
} catch (\Throwable $__e) {
$__alertList = [];
} }
foreach ($__alertList as $__a):
$__type = $__a['type'] ?? 'info';
$__msg = $__a['message'] ?? '';
if ($__msg === '') continue;
?> ?>
<?php foreach ($alerts as $alert): ?> <div class="alert alert-<?= e($__type) ?>"><?= e($__msg) ?></div>
<?php
$type = $alert['type'] ?? 'info';
$message = $alert['message'] ?? '';
$bgColor = match($type) {
'success' => '#F0FDF4',
'error' => '#FEF2F2',
'warning' => '#FFF7ED',
'info' => '#EFF6FF',
default => '#F9FAFB',
};
$textColor = match($type) {
'success' => '#059669',
'error' => '#DC2626',
'warning' => '#D97706',
'info' => '#0284C7',
default => '#6B7280',
};
$borderColor = match($type) {
'success' => '#BBF7D0',
'error' => '#FECACA',
'warning' => '#FED7AA',
'info' => '#BFDBFE',
default => '#E5E7EB',
};
$icon = match($type) {
'success' => '✓',
'error' => '✗',
'warning' => '⚠',
'info' => 'ℹ',
default => '',
};
?>
<div class="alert alert-<?= $type ?>" style="background:<?= $bgColor ?>;color:<?= $textColor ?>;border:1px solid <?= $borderColor ?>;padding:12px 20px;border-radius:8px;margin:0 25px 15px;font-size:14px;display:flex;justify-content:space-between;align-items:center;">
<span><?= $icon ?> <?= e($message) ?></span>
<button onclick="this.parentElement.remove()" style="background:none;border:none;cursor:pointer;font-size:18px;color:<?= $textColor ?>;opacity:0.6;padding:0 5px;">&times;</button>
</div>
<?php endforeach; ?> <?php endforeach; ?>
\ No newline at end of file
...@@ -25,7 +25,27 @@ ...@@ -25,7 +25,27 @@
<h1>🏛️ THE CLUB</h1> <h1>🏛️ THE CLUB</h1>
<p>نادي النادي شيراتون — Sports City</p> <p>نادي النادي شيراتون — Sports City</p>
</div> </div>
<?php try { $__template->include('Shared.Components.alerts'); } catch(\Throwable $e) {} ?>
<?php
// Inline alert reading — no includes, no method calls that can crash
$__alertList = [];
try {
if (isset($_SESSION['_flash']['_alerts']) && is_array($_SESSION['_flash']['_alerts'])) {
$__alertList = $_SESSION['_flash']['_alerts'];
unset($_SESSION['_flash']['_alerts']);
} elseif (isset($_SESSION['_alerts']) && is_array($_SESSION['_alerts'])) {
$__alertList = $_SESSION['_alerts'];
unset($_SESSION['_alerts']);
}
} catch (\Throwable $__e) {}
foreach ($__alertList as $__a):
$__type = $__a['type'] ?? 'info';
$__msg = $__a['message'] ?? '';
if ($__msg === '') continue;
?>
<div class="alert alert-<?= e($__type) ?>" style="margin-bottom:15px;"><?= e($__msg) ?></div>
<?php endforeach; ?>
<?php $__template->yield('content'); ?> <?php $__template->yield('content'); ?>
</div> </div>
</body> </body>
......
...@@ -35,9 +35,30 @@ ...@@ -35,9 +35,30 @@
</div> </div>
</header> </header>
<?php
// Inline alert reading — direct $_SESSION access, zero method calls
$__alertList = [];
try {
if (isset($_SESSION['_flash']['_alerts']) && is_array($_SESSION['_flash']['_alerts'])) {
$__alertList = $_SESSION['_flash']['_alerts'];
unset($_SESSION['_flash']['_alerts']);
} elseif (isset($_SESSION['_alerts']) && is_array($_SESSION['_alerts'])) {
$__alertList = $_SESSION['_alerts'];
unset($_SESSION['_alerts']);
}
} catch (\Throwable $__e) {}
if (!empty($__alertList)):
?>
<div style="padding:15px 25px 0;"> <div style="padding:15px 25px 0;">
<?php try { $__template->include('Shared.Components.alerts'); } catch(\Throwable $e) {} ?> <?php foreach ($__alertList as $__a):
$__type = $__a['type'] ?? 'info';
$__msg = $__a['message'] ?? '';
if ($__msg === '') continue;
?>
<div class="alert alert-<?= e($__type) ?>"><?= e($__msg) ?></div>
<?php endforeach; ?>
</div> </div>
<?php endif; ?>
<main class="main-content"> <main class="main-content">
<?php $__template->yield('content'); ?> <?php $__template->yield('content'); ?>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment