<?php
/**
 * About Content API Endpoint
 */

header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');

require_once __DIR__ . '/../config/database.php';

try {
    $pdo = getDBConnection();
    
    $stmt = $pdo->query("
        SELECT section_key, title, content, image_url, display_order
        FROM about_content
        WHERE status = 'active'
        ORDER BY display_order ASC
    ");
    
    $sections = [];
    while ($row = $stmt->fetch()) {
        $sections[] = [
            'key' => $row['section_key'],
            'title' => $row['title'],
            'content' => $row['content'],
            'image_url' => $row['image_url'] ? '/backend/uploads/about/' . $row['image_url'] : null
        ];
    }
    
    echo json_encode([
        'success' => true,
        'sections' => $sections
    ]);
    
} catch (Exception $e) {
    error_log("About API error: " . $e->getMessage());
    http_response_code(500);
    echo json_encode([
        'success' => false,
        'sections' => []
    ]);
}

