<?php
/**
 * Navigation Helper Class
 * Manages featured pages and navigation menu structure
 * 
 * Featured Pages: Home, Shop, About, Contact (displayed in main nav)
 * More Pages: Products, Blogs, Awards, Kits & Services, Legal Pages (displayed in MORE dropdown)
 */

class NavigationHelper {
    
    /**
     * Get all featured pages to be displayed in main navigation
     * These are: Home, Shop, About, Contact
     * 
     * @return array Array of featured page data
     */
    public static function getFeaturedPages() {
        return [
            [
                'id' => 1,
                'title' => 'Home',
                'url' => 'index.php',
                'featured' => true
            ],
            [
                'id' => 2,
                'title' => 'Shop',
                'url' => 'shop.php',
                'featured' => true
            ],
            [
                'id' => 3,
                'title' => 'About',
                'url' => 'about.php',
                'featured' => true
            ],
            [
                'id' => 4,
                'title' => 'Contact',
                'url' => 'contact.php',
                'featured' => true
            ]
        ];
    }
    
    /**
     * Get all pages including featured and non-featured
     * Non-featured pages appear in the MORE dropdown
     * 
     * @return array Array of all page data
     */
    public static function getAllPages() {
        $featured = self::getFeaturedPages();
        $allPages = $featured;
        
        // Add non-featured pages that appear in MORE dropdown
        $morePages = [
            [
                'id' => 5,
                'title' => 'Products',
                'url' => 'product.php',
                'featured' => false
            ],
            [
                'id' => 6,
                'title' => 'Blog',
                'url' => 'blog.php',
                'featured' => false
            ],
            [
                'id' => 7,
                'title' => 'Awards',
                'url' => 'awards.php',
                'featured' => false
            ],
            [
                'id' => 8,
                'title' => 'Kits & Services',
                'url' => 'kits_services.php',
                'featured' => false
            ],
            [
                'id' => 9,
                'title' => 'Legal Policies',
                'url' => 'legal_policies.php',
                'featured' => false
            ]
        ];
        
        return array_merge($allPages, $morePages);
    }
    
    /**
     * Get only non-featured pages (for MORE dropdown)
     * 
     * @return array Array of non-featured pages
     */
    public static function getNonFeaturedPages() {
        $featured = self::getFeaturedPages();
        $all = self::getAllPages();
        
        $nonFeatured = [];
        foreach ($all as $page) {
            $isFeatured = false;
            foreach ($featured as $fp) {
                if ($fp['id'] === $page['id']) {
                    $isFeatured = true;
                    break;
                }
            }
            if (!$isFeatured) {
                $nonFeatured[] = $page;
            }
        }
        
        return $nonFeatured;
    }
    
    /**
     * Get a single page by ID
     * 
     * @param int $id Page ID
     * @return array|null Page data or null if not found
     */
    public static function getPageById($id) {
        $pages = self::getAllPages();
        foreach ($pages as $page) {
            if ($page['id'] === $id) {
                return $page;
            }
        }
        return null;
    }
    
    /**
     * Get a single page by URL
     * 
     * @param string $url Page URL/slug
     * @return array|null Page data or null if not found
     */
    public static function getPageByUrl($url) {
        $pages = self::getAllPages();
        foreach ($pages as $page) {
            if ($page['url'] === $url) {
                return $page;
            }
        }
        return null;
    }
}
?>
