<?php
// pages/calendar.php
require_once BEEZUI_ROOT . '/components/index.php';
require_once BEEZUI_ROOT . '/pages/layout.php';

use Components\Data\DataRegistry;
use Components\Ui\Calendar;

$pageId = 'calendar';
$state = Calendar::resolveStateFromRequest();
$events = DataRegistry::calendarEvents()->events($state);
$options = Calendar::resolveActionOptions($state);

ob_start();
echo \Components\Ui\PageHeader::render('<span id="calendar-title-target">' . (string)mh_lng('UI_CALENDAR_TITLE', 'Marketing Calendar') . '</span>', [
    'subtitle' => mh_lng('UI_CALENDAR_SUBTITLE', 'campaigns'),
    'center' => '<div id="calendar-view-mode-target"></div>',
    'right' => '<div id="calendar-right-target"></div>',
]);

ob_start();
require BEEZUI_ROOT . '/pages/components/calendar_subscribe_popover.php';
$footerRight = ob_get_clean();

echo Calendar::render($state, $events, array_merge($options, ['footer_right' => $footerRight]));

$content = ob_get_clean();

echo layout($pageId, $content);
