163 lines
6.5 KiB
PHP
163 lines
6.5 KiB
PHP
<?php
|
|
namespace WizdomNetworks\WizeWeb\Controllers;
|
|
|
|
use WizdomNetworks\WizeWeb\Core\View;
|
|
use WizdomNetworks\WizeWeb\Utils\Logger;
|
|
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
|
|
{
|
|
public function index()
|
|
{
|
|
try {
|
|
Logger::info("Initializing HomeController::index()");
|
|
|
|
// Define page ID for page-specific styling
|
|
$pageId = 'home';
|
|
|
|
// Load configurations
|
|
$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);
|
|
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',
|
|
];
|
|
}
|
|
}
|