not working, unfinished css restructure changes

This commit is contained in:
overplayed 2025-02-05 15:32:10 -05:00
parent 0b1e792d15
commit df8929f65b
11 changed files with 7392 additions and 236 deletions

View File

@ -4,26 +4,159 @@ namespace WizdomNetworks\WizeWeb\Controllers;
use WizdomNetworks\WizeWeb\Core\View; use WizdomNetworks\WizeWeb\Core\View;
use WizdomNetworks\WizeWeb\Utils\Logger; use WizdomNetworks\WizeWeb\Utils\Logger;
use WizdomNetworks\WizeWeb\Utils\ErrorHandler; use WizdomNetworks\WizeWeb\Utils\ErrorHandler;
use Exception;
/**
* HomeController (v6)
*
* This controller handles the rendering of the home page.
*
* ## Features:
* - Initializes configurations for hero, single slider, and sidebar.
* - Ensures default values are applied to avoid undefined variable issues.
* - Implements logging for debugging key execution steps.
* - Uses exception handling to prevent application crashes.
*
* ## Methods:
* - `index()` - Loads and renders the home page.
* - `getHeroConfig()` - Returns configuration settings for the hero section.
* - `getSliderConfig()` - Returns configuration settings for the slider.
* - `getSidebarConfig()` - Returns configuration settings for the sidebar.
*/
class HomeController class HomeController
{ {
public function index() public function index()
{ {
Logger::debug("HomeController::index() - Executing home page rendering.");
try { try {
$data = [ Logger::info("Initializing HomeController::index()");
'title' => 'Home - Wizdom Networks',
'content' => "<h1>Welcome to Wizdom Networks</h1><p>Your trusted partner for IT Consulting and Services.</p>"
];
Logger::debug("HomeController::index() - Data prepared successfully."); // Define page ID for page-specific styling
View::render('pages/home', $data); $pageId = 'home';
Logger::info("HomeController::index() - Home page rendered successfully.");
} catch (\Throwable $e) { // Load configurations
Logger::error("HomeController::index() - Error rendering home page: " . $e->getMessage()); $heroConfig = $this->getHeroConfig();
$sliderConfig = $this->getSliderConfig();
$sidebarConfig = $this->getSidebarConfig();
Logger::info("HomeController loaded configs: hero=" . json_encode($heroConfig) . ", slider=" . json_encode($sliderConfig) . ", sidebar=" . json_encode($sidebarConfig));
// Ensure necessary keys exist
$heroConfig['enabled'] = $heroConfig['enabled'] ?? false;
$sliderConfig['enabled'] = $sliderConfig['enabled'] ?? false;
$sidebarConfig['enabled'] = $sidebarConfig['enabled'] ?? false;
// Log the view rendering attempt
Logger::info("Attempting to render home page");
View::render('pages/home', compact('pageId', 'heroConfig', 'sliderConfig', 'sidebarConfig'));
Logger::info("Successfully rendered Home Page");
} catch (Exception $e) {
ErrorHandler::exception($e); ErrorHandler::exception($e);
Logger::error("HomeController::index() encountered an error: " . $e->getMessage());
http_response_code(500);
echo "An internal error occurred. Please check the logs.";
} }
} }
private function getHeroConfig()
{
return [
'enabled' => false, // Default to false to prevent errors
'title' => 'Welcome to Wizdom Networks',
'description' => 'We provide innovative IT solutions.',
'cta_text' => 'Learn More',
'cta_link' => '/services',
'background_image' => '/assets/images/hero.jpg',
];
}
private function getSliderConfig()
{
return [
'enabled' => true,
'id' => 'main-slider',
'height' => '65vh',
'type' => 'standard',
'slides' => [
[
'src' => '/assets/images/information-light.jpg',
'alt' => 'Information Light Banner',
'title' => 'Innovative Solutions',
'description' => 'Bringing technology and expertise together.',
'cta_text' => 'Learn More',
'cta_link' => '/services/technology',
'cta_top' => '70%',
'cta_left' => '30%',
'text_color' => 'white'
],
[
'src' => '/assets/images/cardcatalouge-banner.jpg',
'alt' => 'Card Catalogue Banner',
'title' => 'Effortless Organization',
'description' => 'Streamline your workflow with our intuitive catalog system.',
'cta_text' => 'Learn More',
'cta_link' => '/services/catalogue-management',
'cta_top' => '45%',
'cta_left' => '75%',
'text_color' => 'white'
],
[
'src' => '/assets/images/rolodex-banner.jpg',
'alt' => 'Rolodex Banner',
'title' => 'Contact Management Made Easy',
'description' => 'Keep track of important contacts and information in one place.',
'cta_text' => 'Get Started',
'cta_link' => '/services/contact-management',
'cta_top' => '45%',
'cta_left' => '70%',
'text_color' => 'black'
],
[
'src' => '/assets/images/oldmic.jpg',
'alt' => 'Old Microphone',
'title' => 'Broadcast Your Message',
'description' => 'Reach your audience with high-quality audio and video solutions.',
'cta_text' => 'Explore Options',
'cta_link' => '/services/media-solutions',
'cta_top' => '56%',
'cta_left' => '65%',
'text_color' => 'white'
],
[
'src' => '/assets/images/ancient-library-shelf-crop1.jpg',
'alt' => 'Library Archives',
'title' => 'Knowledge Preservation',
'description' => 'Store and manage your records securely and efficiently.',
'cta_text' => 'Discover More',
'cta_link' => '/services/data-archiving',
'cta_top' => '50%',
'cta_left' => '50%',
'text_color' => 'white'
],
[
'src' => '/assets/images/combosafedoor.jpg',
'alt' => 'Combination Safe Door',
'title' => 'Secure Your Data',
'description' => 'Advanced encryption and security solutions for your digital assets.',
'cta_text' => 'Protect Now',
'cta_link' => '/services/cybersecurity',
'cta_top' => '56%',
'cta_left' => '35%',
'text_color' => 'white'
]
]
];
}
private function getSidebarConfig()
{
return [
'enabled' => false, // Default to false to prevent errors
'title' => 'Welcome to Wizdom Networks',
'description' => 'We provide innovative IT solutions.',
'cta_text' => 'Learn More',
'cta_link' => '/services',
'background_image' => '/assets/images/hero.jpg',
];
}
} }

View File

@ -38,6 +38,7 @@ class ProjectManagementController
View::render('pages/services/project_management', $data); View::render('pages/services/project_management', $data);
Logger::info("ProjectManagementController::index() - Project management page rendered successfully."); Logger::info("ProjectManagementController::index() - Project management page rendered successfully.");
} catch (\Throwable $e) { } catch (\Throwable $e) {
error_log("projectmanagement\t*******");
Logger::error("ProjectManagementController::index() - Error rendering project management page: " . $e->getMessage()); Logger::error("ProjectManagementController::index() - Error rendering project management page: " . $e->getMessage());
ErrorHandler::exception($e); ErrorHandler::exception($e);
} }

View File

@ -4,11 +4,20 @@ namespace WizdomNetworks\WizeWeb\Core;
use WizdomNetworks\WizeWeb\Utils\Logger; use WizdomNetworks\WizeWeb\Utils\Logger;
use WizdomNetworks\WizeWeb\Utils\ErrorHandler; use WizdomNetworks\WizeWeb\Utils\ErrorHandler;
use Exception;
/** /**
* View Renderer * View Renderer (v2)
* *
* Handles view rendering, ensuring proper data passing and error handling. * Handles view rendering, ensuring proper data passing, logging, and error handling.
*
* ## Features:
* - Dynamically resolves and includes view files.
* - Implements logging to track successful and failed rendering attempts.
* - Implements error handling to prevent fatal crashes.
*
* ## Methods:
* - `render(string $view, array $data = [])` - Renders the specified view file.
*/ */
class View class View
{ {
@ -17,30 +26,35 @@ class View
* *
* @param string $view The name of the view file (relative to /resources/views/). * @param string $view The name of the view file (relative to /resources/views/).
* @param array $data Associative array of variables to pass to the view. * @param array $data Associative array of variables to pass to the view.
* @throws \Exception If the view file is not found. * @throws Exception If the view file is not found.
*/ */
public static function render(string $view, array $data = []): void public static function render(string $view, array $data = []): void
{ {
Logger::debug("Rendering view: $view"); try {
Logger::info("View::render() - Attempting to render: " . $view);
// Extract data to make variables available in the view
extract($data); // Extract data to make variables available in the view
extract($data);
// Build the full path to the view file
Logger::debug("[DEBUG] Attempting to load view: " . $view . " | Expected path: " . __DIR__ . "/../../resources/views/" . str_replace('.', '/', $view) . ".php"); // Build the full path to the view file
$viewPath = realpath(__DIR__ . "/../../resources/views/" . str_replace('.', '/', $view) . ".php");
$viewPath = realpath(__DIR__ . "/../../resources/views/" . str_replace('.', '/', $view) . ".php");
// Debugging: Log resolved path
// Debugging: Log resolved path Logger::info("View::render() - Resolved view path: " . ($viewPath ?: 'null'));
Logger::debug("Resolved view path: $viewPath");
// Validate and include the view file
// Validate and include the view file if ($viewPath && file_exists($viewPath)) {
if ($viewPath && file_exists($viewPath)) { include $viewPath;
include $viewPath; Logger::info("View::render() - Successfully rendered: " . $view);
Logger::debug("Successfully rendered view: $view"); } else {
} else { Logger::error("View::render() - View file not found: " . $view . " | Resolved path: " . ($viewPath ?: 'null'));
Logger::error("View file not found: $view | Resolved path: $viewPath"); throw new Exception("View file not found: " . $view);
throw new \Exception("View file not found: $view"); }
} catch (Exception $e) {
ErrorHandler::exception($e);
Logger::error("View::render() - Error rendering view '$view': " . $e->getMessage());
http_response_code(500);
echo "An internal error occurred. Please check the logs.";
} }
} }
} }

View File

@ -30,8 +30,8 @@ class Logger
{ {
self::$logFile = $_ENV['LOG_DIRECTORY'] . "app.log" ?: __DIR__ . '/../../logs/app.log'; self::$logFile = $_ENV['LOG_DIRECTORY'] . "app.log" ?: __DIR__ . '/../../logs/app.log';
self::$debugEnabled = $_ENV['APP_DEBUG'] === 'true' || $_ENV['APP_DEBUG'] === true; //self::$debugEnabled = isset($_ENV['APP_DEBUG']) && filter_var($_ENV['APP_DEBUG'], FILTER_VALIDATE_BOOL);
//self::$debugEnabled = false; self::$debugEnabled = true;
} }
/** /**

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
/* Auto-generated styles for home sliders */
#slider-main-slider-slide-0 {
top: 70%;
left: 30%;
color: white;
}
#slider-main-slider-slide-1 {
top: 45%;
left: 75%;
color: white;
}
#slider-main-slider-slide-2 {
top: 45%;
left: 70%;
color: black;
}
#slider-main-slider-slide-3 {
top: 56%;
left: 65%;
color: white;
}
#slider-main-slider-slide-4 {
top: 50%;
left: 50%;
color: white;
}
#slider-main-slider-slide-5 {
top: 56%;
left: 35%;
color: white;
}

View File

@ -1,22 +1,24 @@
<?php <?php
use WizdomNetworks\WizeWeb\Core\View; use WizdomNetworks\WizeWeb\Core\View;
use WizdomNetworks\WizeWeb\Utils\Logger;
use WizdomNetworks\WizeWeb\Utils\ErrorHandler;
/** /**
* Main Layout (v7) * Main Layout (v8)
* *
* This file serves as the primary layout template for rendering pages. * This file serves as the primary layout template for rendering pages.
* It includes dynamic loading for sidebar, hero, and slider components. * It includes dynamic loading for sidebar, hero, and slider components.
* Implements improved error handling to prevent undefined variable issues. * Implements improved error handling and logging to prevent undefined variable issues.
* *
* ## Features: * ## Features:
* - Dynamically loads the `head.php` partial with key page configurations. * - Dynamically loads the `head.php` partial with key page configurations.
* - Includes global navigation, footer, and main content structure. * - Includes global navigation, footer, and main content structure.
* - Conditionally renders the hero, slider, and sidebar based on their configurations. * - Conditionally renders the hero, slider, and sidebar based on their configurations.
* - Uses Bootstrap's grid system to adjust layout dynamically. * - Uses Bootstrap's grid system to adjust layout dynamically.
* - Implements robust error handling to prevent undefined variable issues. * - Implements robust error handling to prevent undefined variable issues.
* * - Logs key rendering steps to facilitate debugging.
*
* ## Variables Passed: * ## Variables Passed:
* - `$title` (string) - The title of the page. * - `$title` (string) - The title of the page.
* - `$heroConfig` (array) - Configuration settings for the hero section. * - `$heroConfig` (array) - Configuration settings for the hero section.
@ -25,12 +27,18 @@ use WizdomNetworks\WizeWeb\Core\View;
* - `$pageId` (string) - Unique identifier for the page, used for loading page-specific styles. * - `$pageId` (string) - Unique identifier for the page, used for loading page-specific styles.
*/ */
// Ensure all optional configurations have default values to prevent errors try {
$title = $title ?? 'Wizdom Networks'; // Ensure all optional configurations have default values to prevent errors
$pageId = $pageId ?? null; $title = $title ?? 'Wizdom Networks';
$heroConfig = isset($heroConfig) && is_array($heroConfig) ? $heroConfig : ['enabled' => false]; $pageId = $pageId ?? null;
$sliderConfig = isset($sliderConfig) && is_array($sliderConfig) ? $sliderConfig : ['enabled' => false]; $heroConfig = isset($heroConfig) && is_array($heroConfig) ? $heroConfig : ['enabled' => false];
$sidebarConfig = isset($sidebarConfig) && is_array($sidebarConfig) ? $sidebarConfig : ['enabled' => false]; $sliderConfig = isset($sliderConfig) && is_array($sliderConfig) ? $sliderConfig : ['enabled' => false];
$sidebarConfig = isset($sidebarConfig) && is_array($sidebarConfig) ? $sidebarConfig : ['enabled' => false];
Logger::info("Rendering Main Layout for page: " . ($pageId ?? 'unknown'));
} catch (Exception $e) {
ErrorHandler::exception($e);
}
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
@ -47,12 +55,14 @@ $sidebarConfig = isset($sidebarConfig) && is_array($sidebarConfig) ? $sidebarCon
<!-- Hero Section (Optional) --> <!-- Hero Section (Optional) -->
<?php if (isset($heroConfig['enabled']) && $heroConfig['enabled']) : ?> <?php if (isset($heroConfig['enabled']) && $heroConfig['enabled']) : ?>
<?php Logger::info("Rendering Hero Section"); ?>
<?php View::render('partials/hero', compact('heroConfig')); ?> <?php View::render('partials/hero', compact('heroConfig')); ?>
<?php endif; ?> <?php endif; ?>
<!-- Slider Section (Optional) --> <!-- Slider Section (Optional) -->
<?php if (isset($sliderConfig['enabled']) && $sliderConfig['enabled']) : ?> <?php if (isset($sliderConfig['enabled']) && $sliderConfig['enabled']) : ?>
<?php View::render('partials/slider', compact('sliderConfig')); ?> <?php Logger::info("Rendering Slider Section"); ?>
<?php View::render('partials/slider', compact('sliderConfig', 'pageId')); ?>
<?php endif; ?> <?php endif; ?>
<div class="row"> <div class="row">
@ -63,6 +73,7 @@ $sidebarConfig = isset($sidebarConfig) && is_array($sidebarConfig) ? $sidebarCon
<!-- Sidebar (Optional) --> <!-- Sidebar (Optional) -->
<?php if (isset($sidebarConfig['enabled']) && $sidebarConfig['enabled']) : ?> <?php if (isset($sidebarConfig['enabled']) && $sidebarConfig['enabled']) : ?>
<?php Logger::info("Rendering Sidebar"); ?>
<div class="col-md-3"> <div class="col-md-3">
<?php View::render('partials/sidebar', compact('sidebarConfig')); ?> <?php View::render('partials/sidebar', compact('sidebarConfig')); ?>
</div> </div>
@ -71,7 +82,7 @@ $sidebarConfig = isset($sidebarConfig) && is_array($sidebarConfig) ? $sidebarCon
</main> </main>
<!-- Global Footer --> <!-- Global Footer -->
<?php Logger::info("Rendering Footer"); ?>
<?php View::render('layouts/footer'); ?> <?php View::render('layouts/footer'); ?>
</body> </body>

View File

@ -6,81 +6,42 @@ use WizdomNetworks\WizeWeb\Core\View;
* Home Page View (v2) * Home Page View (v2)
* *
* This view dynamically renders the homepage using data provided by the HomeController. * This view dynamically renders the homepage using data provided by the HomeController.
*
* ## Features:
* - Loads dynamic configurations for hero, slider, and sidebar.
* - Ensures configurations are correctly passed to avoid undefined variable issues.
* - Uses the main layout structure for rendering.
*
* ## Variables Passed:
* - `$pageId` (string) - Unique identifier for the page, used for loading page-specific styles.
* - `$heroConfig` (array) - Configuration settings for the hero section.
* - `$sliderConfig` (array) - Configuration settings for the slider.
* - `$sidebarConfig` (array) - Configuration settings for the sidebar.
*/ */
// Ensure data is available before rendering $title = 'Home - Wizdom Networks';
$title = $data['title'] ?? 'Home - Wizdom Networks'; $content = "
$content = $data['content'] ?? ''; <section class='home-intro'>
<h1>Welcome to Wizdom Networks</h1>
<p>Your trusted partner for IT Consulting and Services.</p>
</section>
<section class='home-services'>
<h2>Our Services</h2>
<ul>
<li><a href='/services/technology'>Technology Solutions</a></li>
<li><a href='/services/catalogue-management'>Catalogue Management</a></li>
<li><a href='/services/contact-management'>Contact Management</a></li>
<li><a href='/services/media-solutions'>Media Solutions</a></li>
<li><a href='/services/data-archiving'>Data Archiving</a></li>
<li><a href='/services/cybersecurity'>Cybersecurity</a></li>
</ul>
</section>
<section class='home-contact'>
<h2>Get in Touch</h2>
<p>Contact us today to learn how Wizdom Networks can help your business thrive.</p>
<a href='/contact' class='btn btn-primary'>Contact Us</a>
</section>
";
// Slider Configuration View::render('layouts/main', compact('title', 'pageId', 'heroConfig', 'sliderConfig', 'sidebarConfig', 'content'));
$sliderConfig = [ ?>
'id' => 'home', // Unique identifier for home page slider styles
'enabled' => true,
'type' => 'standard',
'height' => '65vh',
'slides' => [
[
'src' => '/assets/images/information-light.jpg',
'alt' => 'Information Light Banner',
'title' => 'Innovative Solutions',
'description' => 'Bringing technology and expertise together.',
'cta_text' => 'Learn More',
'cta_link' => '/services/technology',
'cta_top' => '70%',
'cta_left' => '30%'
],
[
'src' => '/assets/images/cardcatalouge-banner.jpg',
'alt' => 'Card Catalogue Banner',
'title' => 'Effortless Organization',
'description' => 'Streamline your workflow with our intuitive catalog system.',
'cta_text' => 'Learn More',
'cta_link' => '/services/catalogue-management',
'cta_top' => '45%',
'cta_left' => '75%'
],
[
'src' => '/assets/images/rolodex-banner.jpg',
'alt' => 'Rolodex Banner',
'title' => 'Contact Management Made Easy',
'description' => 'Keep track of important contacts and information in one place.',
'cta_text' => 'Get Started',
'cta_link' => '/services/contact-management',
'cta_top' => '45%',
'cta_left' => '70%',
'text_color' => 'black'
],
[
'src' => '/assets/images/oldmic.jpg',
'alt' => 'Old Microphone',
'title' => 'Broadcast Your Message',
'description' => 'Reach your audience with high-quality audio and video solutions.',
'cta_text' => 'Explore Options',
'cta_link' => '/services/media-solutions',
'cta_top' => '56%',
'cta_left' => '65%'
],
[
'src' => '/assets/images/ancient-library-shelf-crop1.jpg',
'alt' => 'Library Archives',
'title' => 'Knowledge Preservation',
'description' => 'Store and manage your records securely and efficiently.',
'cta_text' => 'Discover More',
'cta_link' => '/services/data-archiving',
'cta_top' => '50%',
'cta_left' => '50%'
],
[
'src' => '/assets/images/combosafedoor.jpg',
'alt' => 'Combination Safe Door',
'title' => 'Secure Your Data',
'description' => 'Advanced encryption and security solutions for your digital assets.',
'cta_text' => 'Protect Now',
'cta_link' => '/services/cybersecurity',
'cta_top' => '56%',
'cta_left' => '35%'
]
]
];
View::render('layouts/main', compact('title', 'content', 'sliderConfig'));

View File

@ -1,40 +1,57 @@
<?php <?php
/** /**
* Hero Partial (v2) * Hero Partial (v2) - Refactored to Remove Inline Styles
*
* This partial dynamically loads hero section configurations and writes styles to a page-specific CSS file (`<pageid>.css`).
* *
* This partial dynamically loads a hero section based on the provided configuration.
* It allows pages to enable or disable the hero and define custom styles.
*
* ## Configuration Options: * ## Configuration Options:
* - `enabled` (bool) - Determines whether the hero is displayed (default: false) * - `id` (string) - Unique identifier for the hero section.
* - `title` (string) - Hero title text * - `background_image` (string) - URL for the background image.
* - `description` (string) - Hero subtitle or description text * - `height` (string) - Height of the hero section (default: '65vh').
* - `image` (string) - Background image URL (default: 'wizdom-about-definitions.jpg') * - `overlay_opacity` (float) - Opacity of the background overlay (default: 0.5).
* - `height` (string) - Height of the hero section (default: '50vh') * - `content_width` (string) - Maximum width of the hero content (default: '60%').
* - `text_align` (string) - Text alignment ('left', 'center', 'right') (default: 'center') * - `text_align` (string) - Alignment of the hero text (default: 'center').
* - `overlay` (bool) - Apply a dark overlay to improve text readability (default: true)
*/ */
// Ensure hero visibility is explicitly enabled // Ensure hero visibility is explicitly enabled
if (!isset($heroConfig) || empty($heroConfig['enabled'])) { if (!isset($heroConfig) || empty($heroConfig['background_image'])) {
error_log("[ERROR] Missing or invalid hero configuration.");
return; return;
} }
$heroTitle = htmlspecialchars($heroConfig['title'] ?? '', ENT_QUOTES, 'UTF-8'); $heroId = htmlspecialchars($heroConfig['id'] ?? 'default', ENT_QUOTES, 'UTF-8');
$heroDescription = htmlspecialchars($heroConfig['description'] ?? '', ENT_QUOTES, 'UTF-8'); $pageCssFile = "/assets/css/" . htmlspecialchars($pageId, ENT_QUOTES, 'UTF-8') . ".css";
$heroImage = htmlspecialchars($heroConfig['image'] ?? '/assets/images/wizdom-about-definitions.jpg', ENT_QUOTES, 'UTF-8'); $cssFilePath = $_SERVER['DOCUMENT_ROOT'] . $pageCssFile;
$heroHeight = htmlspecialchars($heroConfig['height'] ?? '50vh', ENT_QUOTES, 'UTF-8'); $heroHeight = $heroConfig['height'] ?? '65vh';
$overlayOpacity = $heroConfig['overlay_opacity'] ?? 0.5;
$contentWidth = htmlspecialchars($heroConfig['content_width'] ?? '60%', ENT_QUOTES, 'UTF-8');
$textAlign = htmlspecialchars($heroConfig['text_align'] ?? 'center', ENT_QUOTES, 'UTF-8'); $textAlign = htmlspecialchars($heroConfig['text_align'] ?? 'center', ENT_QUOTES, 'UTF-8');
$overlay = $heroConfig['overlay'] ?? false;
$cssContent = "/* Auto-generated styles for {$pageId} hero section */\n";
$cssContent .= "#hero-{$heroId} {\n";
$cssContent .= " background-image: url('" . htmlspecialchars($heroConfig['background_image'], ENT_QUOTES, 'UTF-8') . "');\n";
$cssContent .= " height: {$heroHeight};\n";
$cssContent .= " background-size: cover;\n";
$cssContent .= " background-position: center;\n";
$cssContent .= "}\n";
$cssContent .= "#hero-{$heroId} .hero-overlay {\n background: rgba(0, 0, 0, {$overlayOpacity});\n}\n";
$cssContent .= "#hero-{$heroId} .hero-content {\n max-width: {$contentWidth};\n text-align: {$textAlign};\n}\n";
if (!file_exists($cssFilePath) || file_get_contents($cssFilePath) !== $cssContent) {
file_put_contents($cssFilePath, $cssContent);
}
?> ?>
<section class="hero-section" style="background-image: url('<?php echo $heroImage; ?>'); height: <?php echo $heroHeight; ?>;"> <section id="hero-<?php echo $heroId; ?>" class="hero-section">
<?php if ($overlay) : ?> <div class="hero-overlay"></div>
<div class="hero-overlay"></div> <div class="hero-content">
<?php endif; ?> <h1><?php echo htmlspecialchars($heroConfig['title'], ENT_QUOTES, 'UTF-8'); ?></h1>
<div class="hero-content" style="text-align: <?php echo $textAlign; ?>;"> <p><?php echo htmlspecialchars($heroConfig['description'], ENT_QUOTES, 'UTF-8'); ?></p>
<h1><?php echo $heroTitle; ?></h1> <?php if (!empty($heroConfig['cta_text']) && !empty($heroConfig['cta_link'])) : ?>
<p><?php echo $heroDescription; ?></p> <a href="<?php echo htmlspecialchars($heroConfig['cta_link'], ENT_QUOTES, 'UTF-8'); ?>" class="btn btn-primary">
<?php echo htmlspecialchars($heroConfig['cta_text'], ENT_QUOTES, 'UTF-8'); ?>
</a>
<?php endif; ?>
</div> </div>
</section> </section>

View File

@ -1,39 +1,64 @@
<?php <?php
use WizdomNetworks\WizeWeb\Utils\Logger;
use WizdomNetworks\WizeWeb\Utils\ErrorHandler;
/** /**
* Sidebar Partial (v1) * Sidebar Partial (v3) - Refactored for Consistency
*
* This partial dynamically loads sidebar configurations and writes styles to a page-specific CSS file (`<pageid>.css`).
* *
* This partial dynamically loads a sidebar based on the provided configuration.
* It allows pages to enable or disable the sidebar and define custom styles.
*
* ## Configuration Options: * ## Configuration Options:
* - `enabled` (bool) - Determines whether the sidebar is displayed (default: false) * - `id` (string) - Unique identifier for the sidebar.
* - `width` (string) - Sidebar width percentage (default: '25%') * - `width` (string) - Width of the sidebar (default: '300px').
* - `position` (string) - Sidebar alignment: 'left' or 'right' (default: 'right') * - `position` (string) - Allowed values: 'left', 'right' (default: 'right').
* - `widgets` (array) - List of widgets or components to include in the sidebar * - `background_color` (string) - Background color of the sidebar (default: '#f8f9fa').
*/ */
// Ensure sidebar visibility is explicitly enabled try {
if (!isset($sidebarConfig) || empty($sidebarConfig['enabled'])) { if (!isset($sidebarConfig) || empty($sidebarConfig['id'])) {
return; throw new Exception("Missing or invalid sidebar configuration.");
} }
$sidebarWidth = htmlspecialchars($sidebarConfig['width'] ?? '25%', ENT_QUOTES, 'UTF-8'); $sidebarId = htmlspecialchars($sidebarConfig['id'] ?? 'default', ENT_QUOTES, 'UTF-8');
$sidebarPosition = htmlspecialchars($sidebarConfig['position'] ?? 'right', ENT_QUOTES, 'UTF-8'); $pageCssFile = "/assets/css/" . htmlspecialchars($pageId, ENT_QUOTES, 'UTF-8') . ".css";
$sidebarId = htmlspecialchars($sidebarConfig['id'] ?? 'default', ENT_QUOTES, 'UTF-8'); $cssFilePath = $_SERVER['DOCUMENT_ROOT'] . $pageCssFile;
$widgets = $sidebarConfig['widgets'] ?? []; $sidebarWidth = htmlspecialchars($sidebarConfig['width'] ?? '300px', ENT_QUOTES, 'UTF-8');
$sidebarPosition = in_array($sidebarConfig['position'] ?? 'right', ['left', 'right']) ? $sidebarConfig['position'] : 'right';
$backgroundColor = htmlspecialchars($sidebarConfig['background_color'] ?? '#f8f9fa', ENT_QUOTES, 'UTF-8');
Logger::info("Generating sidebar styles for page: {$pageId}");
$cssContent = "/* Auto-generated styles for {$pageId} sidebar */\n";
$cssContent .= "#sidebar-{$sidebarId} {\n";
$cssContent .= " width: {$sidebarWidth};\n";
$cssContent .= " background-color: {$backgroundColor};\n";
$cssContent .= " float: {$sidebarPosition};\n";
$cssContent .= " padding: 1rem;\n";
$cssContent .= "}\n";
if (!file_exists($cssFilePath) || file_get_contents($cssFilePath) !== $cssContent) {
file_put_contents($cssFilePath, $cssContent);
Logger::info("Sidebar styles written to {$pageCssFile}.");
}
} catch (Exception $e) {
ErrorHandler::exception($e);
Logger::error("Sidebar generation error: " . $e->getMessage());
}
?> ?>
<aside class="sidebar sidebar-<?php echo $sidebarId; ?>" style="width: <?php echo $sidebarWidth; ?>; float: <?php echo $sidebarPosition; ?>;"> <aside id="sidebar-<?php echo $sidebarId; ?>" class="sidebar">
<div class="sidebar-content"> <div class="sidebar-content">
<?php if (!empty($widgets)) : ?> <?php if (!empty($sidebarConfig['title'])) : ?>
<?php foreach ($widgets as $widget): ?> <h2><?php echo htmlspecialchars($sidebarConfig['title'], ENT_QUOTES, 'UTF-8'); ?></h2>
<div class="sidebar-widget"> <?php endif; ?>
<?php echo $widget; ?> <div class="sidebar-items">
<?php foreach ($sidebarConfig['items'] ?? [] as $item): ?>
<div class="sidebar-item">
<a href="<?php echo htmlspecialchars($item['link'], ENT_QUOTES, 'UTF-8'); ?>">
<?php echo htmlspecialchars($item['text'], ENT_QUOTES, 'UTF-8'); ?>
</a>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
<?php else: ?> </div>
<p>No widgets configured.</p>
<?php endif; ?>
</div> </div>
</aside> </aside>

View File

@ -1,11 +1,15 @@
<?php <?php
use WizdomNetworks\WizeWeb\Utils\Logger;
use WizdomNetworks\WizeWeb\Utils\ErrorHandler;
/** /**
* Slider Partial (v12) * Slider Partial (v14) - Refactored to Remove Inline Styles
* *
* This partial dynamically loads different types of sliders based on the provided configuration. * This partial dynamically loads different types of sliders based on the provided configuration.
* It supports multiple slider types, including standard and testimonial sliders, and only loads when required. * All styles are written to a page-specific CSS file (`<pageid>.css`) instead of using inline styles.
* * Debug logging and error handling are implemented using the Logger and ErrorHandler utilities.
*
* ## Configuration Options: * ## Configuration Options:
* - `id` (string) - Unique identifier for the slider (used for styling and debugging) * - `id` (string) - Unique identifier for the slider (used for styling and debugging)
* - `type` (string) - Allowed values: 'standard', 'testimonial' * - `type` (string) - Allowed values: 'standard', 'testimonial'
@ -19,69 +23,57 @@
* - `cta_width` (string) - Defines CTA container width (default: 'auto') * - `cta_width` (string) - Defines CTA container width (default: 'auto')
* - `cta_text_align` (string) - Text alignment within CTA (default: 'center') * - `cta_text_align` (string) - Text alignment within CTA (default: 'center')
* - `lazy_load` (bool) - Enables lazy loading for images (default: true) * - `lazy_load` (bool) - Enables lazy loading for images (default: true)
* - `cta_top` (string) - Vertical positioning of CTA (default: varies per slide)
* - `cta_left` (string) - Horizontal positioning of CTA (default: varies per slide)
* - `text_color` (string) - Defines text color for each slide (default: 'white')
*/ */
// Ensure slider visibility is explicitly enabled try {
if (!isset($sliderConfig) || empty($sliderConfig['type'])) { if (!isset($sliderConfig) || empty($sliderConfig['type'])) {
error_log("[ERROR] Missing or invalid slider configuration."); throw new Exception("Missing or invalid slider configuration.");
return; }
}
$validTypes = ['standard', 'testimonial']; $validTypes = ['standard', 'testimonial'];
$sliderType = in_array($sliderConfig['type'], $validTypes) ? $sliderConfig['type'] : 'standard'; $sliderType = in_array($sliderConfig['type'], $validTypes) ? $sliderConfig['type'] : 'standard';
$sliderId = htmlspecialchars($sliderConfig['id'] ?? 'default', ENT_QUOTES, 'UTF-8'); $sliderId = htmlspecialchars($sliderConfig['id'] ?? 'default', ENT_QUOTES, 'UTF-8');
$sliderHeight = $sliderConfig['height'] ?? '65vh'; $pageCssFile = "/assets/css/" . htmlspecialchars($pageId, ENT_QUOTES, 'UTF-8') . ".css";
$objectFit = htmlspecialchars($sliderConfig['object_fit'] ?? 'cover', ENT_QUOTES, 'UTF-8'); $cssFilePath = $_SERVER['DOCUMENT_ROOT'] . $pageCssFile;
$interval = $sliderConfig['interval'] ?? 5000; // Default to 5 seconds $sliderHeight = $sliderConfig['height'] ?? '65vh';
$pauseOnHover = isset($sliderConfig['pause_on_hover']) && $sliderConfig['pause_on_hover'] ? 'hover' : 'false'; $objectFit = htmlspecialchars($sliderConfig['object_fit'] ?? 'cover', ENT_QUOTES, 'UTF-8');
$showControls = $sliderConfig['controls'] ?? true; $interval = $sliderConfig['interval'] ?? 5000;
$showIndicators = $sliderConfig['indicators'] ?? true; $pauseOnHover = isset($sliderConfig['pause_on_hover']) && $sliderConfig['pause_on_hover'] ? 'hover' : 'false';
$animationType = $sliderConfig['animation'] ?? 'slide'; $showControls = $sliderConfig['controls'] ?? true;
$ctaWidth = htmlspecialchars($sliderConfig['cta_width'] ?? 'auto', ENT_QUOTES, 'UTF-8'); $showIndicators = $sliderConfig['indicators'] ?? true;
$ctaTextAlign = htmlspecialchars($sliderConfig['cta_text_align'] ?? 'center', ENT_QUOTES, 'UTF-8'); $animationType = $sliderConfig['animation'] ?? 'slide';
$lazyLoad = isset($sliderConfig['lazy_load']) && $sliderConfig['lazy_load'] ? 'loading="lazy"' : ''; $ctaWidth = htmlspecialchars($sliderConfig['cta_width'] ?? 'auto', ENT_QUOTES, 'UTF-8');
$sliderImages = $sliderConfig['slides'] ?? []; $ctaTextAlign = htmlspecialchars($sliderConfig['cta_text_align'] ?? 'center', ENT_QUOTES, 'UTF-8');
$lazyLoad = isset($sliderConfig['lazy_load']) && $sliderConfig['lazy_load'] ? 'loading="lazy"' : '';
$sliderImages = $sliderConfig['slides'] ?? [];
// Debugging logs for missing or incorrect configurations if (empty($sliderImages)) {
if (empty($sliderImages)) { Logger::error("Slider '$sliderId' has no slides defined.");
error_log("[ERROR] Slider '$sliderId' has no slides defined."); throw new Exception("Slider '$sliderId' has no slides defined.");
} }
if (!in_array($sliderType, $validTypes)) {
error_log("[ERROR] Invalid slider type '$sliderType' for slider '$sliderId'."); $cssContent = "/* Auto-generated styles for {$pageId} sliders */\n";
foreach ($sliderImages as $index => $image) {
$cssContent .= "#slider-{$sliderId}-slide-{$index} {\n";
if (!empty($image['cta_top'])) {
$cssContent .= " top: {$image['cta_top']};\n";
}
if (!empty($image['cta_left'])) {
$cssContent .= " left: {$image['cta_left']};\n";
}
if (!empty($image['text_color'])) {
$cssContent .= " color: {$image['text_color']};\n";
}
$cssContent .= "}\n";
}
if (!file_exists($cssFilePath) || file_get_contents($cssFilePath) !== $cssContent) {
file_put_contents($cssFilePath, $cssContent);
}
Logger::info("Slider '$sliderId' styles successfully written to '$pageCssFile'.");
} catch (Exception $e) {
ErrorHandler::exception($e);
} }
?> ?>
<section class="slider slider-<?php echo $sliderId; ?> slider-<?php echo htmlspecialchars($sliderType, ENT_QUOTES, 'UTF-8'); ?>"
data-animation="<?php echo htmlspecialchars($animationType, ENT_QUOTES, 'UTF-8'); ?>"
style="height: <?php echo htmlspecialchars($sliderHeight, ENT_QUOTES, 'UTF-8'); ?>; overflow: hidden; position: relative;">
<div id="carousel" class="carousel <?php echo $animationType === 'fade' ? 'carousel-fade' : ''; ?> slide" data-bs-ride="carousel" data-bs-interval="<?php echo $interval; ?>" data-bs-pause="<?php echo $pauseOnHover; ?>">
<?php if ($showIndicators) : ?>
<div class="carousel-indicators">
<?php foreach ($sliderImages as $index => $image): ?>
<button type="button" data-bs-target="#carousel" data-bs-slide-to="<?php echo $index; ?>"
class="<?php echo $index === 0 ? 'active' : ''; ?> indicator-color-<?php echo $index + 1; ?>"
aria-label="Slide <?php echo $index + 1; ?>" <?php echo $index === 0 ? 'aria-current="true"' : ''; ?>></button>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div class="carousel-inner">
<?php foreach ($sliderImages as $index => $image): ?>
<div class="carousel-item <?php echo $index === 0 ? 'active' : ''; ?>">
<img src="<?php echo htmlspecialchars($image['src'], ENT_QUOTES, 'UTF-8'); ?>"
alt="<?php echo htmlspecialchars($image['alt'], ENT_QUOTES, 'UTF-8'); ?>"
class="d-block w-100 slider-image grayscale-effect"
style="height: <?php echo htmlspecialchars($sliderHeight, ENT_QUOTES, 'UTF-8'); ?>; object-fit: <?php echo $objectFit; ?>; filter: grayscale(100%); transition: filter 0.5s ease-in-out;"
<?php echo $lazyLoad; ?>>
<div class="carousel-caption"
style="color: <?php echo htmlspecialchars($image['text_color'] ?? 'white', ENT_QUOTES, 'UTF-8'); ?>; position: absolute; top: <?php echo htmlspecialchars($image['cta_top'], ENT_QUOTES, 'UTF-8'); ?>; left: <?php echo htmlspecialchars($image['cta_left'], ENT_QUOTES, 'UTF-8'); ?>; transform: translate(-50%, -50%); width: <?php echo $ctaWidth; ?>; text-align: <?php echo $ctaTextAlign; ?>;">
<h2><?php echo htmlspecialchars($image['title'], ENT_QUOTES, 'UTF-8'); ?></h2>
<p><?php echo htmlspecialchars($image['description'], ENT_QUOTES, 'UTF-8'); ?></p>
<a href="<?php echo htmlspecialchars($image['cta_link'], ENT_QUOTES, 'UTF-8'); ?>" class="btn btn-primary slider-cta"> <?php echo htmlspecialchars($image['cta_text'], ENT_QUOTES, 'UTF-8'); ?> </a>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</section>