<?php
require_once __DIR__ . '/../models/Page.php';
require_once __DIR__ . '/../models/SiteSettings.php';
require_once __DIR__ . '/../models/Menu.php';

class PageController {
    private $page;
    private $siteSettings;
    private $menu;
    
    public function __construct() {
        $this->page = new Page();
        $this->siteSettings = new SiteSettings();
        $this->menu = new Menu();
    }
    
    public function show($slug) {
        $settings = $this->siteSettings->getAllSettings();
        $page = $this->page->getPageBySlug($slug);
        
        if (!$page) {
            header('HTTP/1.0 404 Not Found');
            include __DIR__ . '/../views/404.php';
            return;
        }
        
        $pageTitle = $page['title'];
        $pageDescription = $page['meta_description'] ?? substr(strip_tags($page['content']), 0, 160);
        
        include __DIR__ . '/../views/page.php';
    }
} 