From d78176c3b7b454e6bc903c2949138f69e70d5586 Mon Sep 17 00:00:00 2001 From: overplayed Date: Sat, 1 Feb 2025 01:11:05 -0500 Subject: [PATCH] Modularization of Hero --- app/Utils/Logger.php | 52 ++++++++++++++++--- public/assets/css/hero.css | 26 +++++++++- resources/views/layouts/head.php | 7 +-- resources/views/layouts/main.php | 6 +-- resources/views/pages/home.php | 2 - .../pages/services/emergency_support.php | 10 ++++ 6 files changed, 88 insertions(+), 15 deletions(-) diff --git a/app/Utils/Logger.php b/app/Utils/Logger.php index be79ee2..31825b0 100644 --- a/app/Utils/Logger.php +++ b/app/Utils/Logger.php @@ -7,25 +7,43 @@ use WizdomNetworks\WizeWeb\Utils\ErrorHandler; /** * Logger Utility * - * A utility class for logging messages to a file. + * A utility class for logging messages to a file with environment-based debug control. * - * Supports logging messages at different levels (INFO, WARNING, ERROR) with timestamps. + * Supports different log levels and dynamic debugging based on an environment variable. */ class Logger { /** * @var string The path to the log file. */ - protected static string $logFile = __DIR__ . '/../../logs/app.log'; + protected static string $logFile; + + /** + * @var bool Flag to enable or disable debug logging. + */ + protected static bool $debugEnabled; + + /** + * Initialize Logger settings from environment variables. + */ + public static function init(): void + { + self::$logFile = getenv('LOG_FILE_PATH') ?: __DIR__ . '/../../logs/app.log'; + self::$debugEnabled = getenv('APP_DEBUG') === 'true'; + } /** * Logs a message to the log file. * - * @param string $level The log level (e.g., INFO, WARNING, ERROR). + * @param string $level The log level (DEBUG, INFO, WARNING, ERROR, CRITICAL). * @param string $message The log message. */ public static function log(string $level, string $message): void { + if ($level === 'DEBUG' && !self::$debugEnabled) { + return; // Skip debug logs if debugging is disabled + } + $timestamp = date('Y-m-d H:i:s'); $formattedMessage = "[$timestamp] [$level]: $message" . PHP_EOL; @@ -33,11 +51,20 @@ class Logger file_put_contents(self::$logFile, $formattedMessage, FILE_APPEND | LOCK_EX); } catch (\Throwable $e) { ErrorHandler::exception($e); - // Fallback to PHP's error_log if writing to the file fails error_log("[ERROR] Logging to file failed: " . $e->getMessage()); } } + /** + * Logs a debug message (only if DEBUG is enabled). + * + * @param string $message The log message. + */ + public static function debug(string $message): void + { + self::log('DEBUG', $message); + } + /** * Logs an informational message. * @@ -69,7 +96,17 @@ class Logger } /** - * Sets the log file path. + * Logs a critical error message. + * + * @param string $message The log message. + */ + public static function critical(string $message): void + { + self::log('CRITICAL', $message); + } + + /** + * Sets the log file path dynamically. * * @param string $filePath The path to the log file. */ @@ -78,3 +115,6 @@ class Logger self::$logFile = $filePath; } } + +// Initialize Logger on class load +Logger::init(); diff --git a/public/assets/css/hero.css b/public/assets/css/hero.css index bf41dae..a1ea9e9 100644 --- a/public/assets/css/hero.css +++ b/public/assets/css/hero.css @@ -1,4 +1,4 @@ -/* Hero Section Styling */ +/* Hero Section Styling - Modular Support for Different Layouts */ .hero-section { position: relative; width: 100%; @@ -42,3 +42,27 @@ padding: 0.75rem 1.5rem; border-radius: 5px; } + +/* Compact Hero Style */ +.hero-compact { + height: 40vh; + align-items: flex-start; + padding-top: 3rem; +} + +/* Overlay Hero Style */ +.hero-overlay .hero-content { + background: rgba(0, 0, 0, 0.6); + padding: 1.5rem; + border-radius: 8px; +} + +/* Inline Hero Positioning */ +.hero-inline { + height: auto; + padding: 2rem 0; +} + +.hero-inline .hero-content { + max-width: 80%; +} diff --git a/resources/views/layouts/head.php b/resources/views/layouts/head.php index 7dd18df..6db9ee0 100644 --- a/resources/views/layouts/head.php +++ b/resources/views/layouts/head.php @@ -17,15 +17,16 @@ onerror="this.onerror=null;this.href='/assets/bootstrap/css/bootstrap.min.css';"> - + - + + - + diff --git a/resources/views/layouts/main.php b/resources/views/layouts/main.php index 4a6414f..b9e5bc5 100644 --- a/resources/views/layouts/main.php +++ b/resources/views/layouts/main.php @@ -14,17 +14,17 @@ render('layouts/head', $data); ?> - + render('layouts/header', $data); ?> render('partials/navbar', $data); ?> - + render('partials/hero', compact('heroConfig')); ?> - + render('partials/slider', ['sliderConfig' => $showSlider]); ?> diff --git a/resources/views/pages/home.php b/resources/views/pages/home.php index 152800e..4b70fa8 100644 --- a/resources/views/pages/home.php +++ b/resources/views/pages/home.php @@ -7,8 +7,6 @@ */ $title = 'Home - Wizdom Networks'; -$showHeader = false; -$showHero = false; $showSlider = ['type' => 'hero']; // Enable hero slider $content = << 'Innovative IT Solutions', + 'description' => 'Empowering businesses with cutting-edge technology solutions.', + 'image' => '/assets/images/rescue-training.jpg', + 'cta' => ['text' => 'Learn More', 'link' => '/services'], + 'style' => 'default', + 'position' => 'top' +]; + + $content = <<Emergency Support

We offer 24/7 emergency IT support to ensure your business operations run smoothly.

HTML;