<?php
    /*
        *****************************************************************************
        * MEGA Digital Space - by MEGA Digital Studio                               *
        * ------------------------------------------------------------------------- *
        * CMS Website:  https://megadigital.space                                   *
        * License:  https://megadigital.space/license                               *
        * Owner:  Giorgi Basharuli                                                  *
        * Contact:  online@megadigital.studio                                       *
        * MEGA Digital Studio – Official Development Studio for MEGA Digital Space  *
        * Website:  https://megadigital.studio                                      *
        * ------------------------------------------------------------------------- *
        * Description: This file is a part of the MEGA Digital Space CMS system.    *
        * Unauthorized distribution, modification, or commercial use is strictly -  *
        * prohibited without prior written permission.                              *
        * ------------------------------------------------------------------------- *
        * Copyright (c) 2023-2025 MEGA Digital Studio.                              *
        * All rights reserved.                                                      *
        *****************************************************************************
    */

    // Получение слайдера из базы данных
    $slider_id = $_GET['id'];
    $query = "SELECT * FROM social_sliders WHERE id = $slider_id";
    $result = mysqli_query($conn, $query);
    $slider = mysqli_fetch_assoc($result);

    // В зависимости от социальной сети подключаем соответствующее API
    if ($slider['social'] == 'instagram') {
        $posts = fetchInstagramPosts($slider['token'], $slider['resource']);
        $smarty->assign('posts', $posts);
        $smarty->assign('content', $smarty->fetch(TEMPLATES_DIR . '/' . $config['skin'] . '/widgets/slider_instagram.tpl'));
    } elseif ($slider['social'] == 'facebook') {
        $posts = fetchFacebookPosts($slider['token'], $slider['resource']);
        $smarty->assign('posts', $posts);
        $smarty->assign('content', $smarty->fetch(TEMPLATES_DIR . '/' . $config['skin'] . '/widgets/slider_facebook.tpl'));
    }