<?php
/*
Plugin Name: Chart Lists
Description: Renders the homepage chart list sections.
Version: 1.0
*/

register_block('charts', function (): void {
    $db = $GLOBALS['db'] ?? null;
    if (!$db instanceof PDO) {
        return;
    }

    $gamesQuery = $db->query("SELECT alias, title FROM games WHERE is_active = TRUE ORDER BY time_open");
    $games = $gamesQuery ? $gamesQuery->fetchAll(PDO::FETCH_ASSOC) : [];
    require CMS_THEME_MOD_DIR . '/chart_lists.php';
});
