<?php
/**
 * Handles frontend rendering of events
 */
if (!defined('ABSPATH')) exit;

class Event_Monster_Free_Frontend_Renderer {
    
    private $event_post;
    private $event_settings;
    private $event_id;
    
    public function __construct($event_post, $event_settings) {
        $this->event_post = $event_post;
        $this->event_settings = $event_settings;
        $this->event_id = $event_post->ID;
    }
    
    public function render_event_header() {
        // Make variables available to the template
        $event_post = $this->event_post;
        $event_settings = $this->event_settings;
        $event_id = $this->event_id;
        
        include EM_FREE_PLUGIN_DIR . 'templates/frontend/components/event-header.php';
    }
    
    public function render_event_content() {
        $event_post = $this->event_post;
        $event_settings = $this->event_settings;
        $event_id = $this->event_id;
        
        include EM_FREE_PLUGIN_DIR . 'templates/frontend/components/event-content.php';
    }
    
    public function render_event_details() {
        $event_post = $this->event_post;
        $event_settings = $this->event_settings;
        $event_id = $this->event_id;
        
        include EM_FREE_PLUGIN_DIR . 'templates/frontend/components/event-details.php';
    }
    
    public function render_booking_form() {
        if ($this->get_setting('em_accept_registration') === 'yes') {
            $event_post = $this->event_post;
            $event_settings = $this->event_settings;
            $event_id = $this->event_id;
            
            include EM_FREE_PLUGIN_DIR . 'templates/frontend/components/registration.php';
        }
    }
    
    public function render_event_gallery() {
        if ($this->get_setting('em_show_event_gallery') === 'yes') {
            $event_post = $this->event_post;
            $event_settings = $this->event_settings;
            $event_id = $this->event_id;
            
            include EM_FREE_PLUGIN_DIR . 'templates/frontend/components/event-gallery.php';
        }
    }
    

    public function render_scripts() {
        $event_post = $this->event_post;
        $event_settings = $this->event_settings;
        $event_id = $this->event_id;
        
        include EM_FREE_PLUGIN_DIR . 'templates/frontend/components/event-scripts.php';
    }
    
    private function get_setting($key, $default = '') {
        return $this->event_settings[$key] ?? $default;
    }
}

