<?php
// +-------------------------------------------------+
// © 2002-2012 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: cms_module_storyplay_datasource_storyplay.class.php,v 1.1.4.2 2025/10/30 08:13:37 gneveu Exp $

if (stristr($_SERVER['REQUEST_URI'], ".class.php")) {
    die("no access");
}

class cms_module_storyplay_datasource_storyplay extends cms_module_common_datasource_list
{
    public function __construct($id = 0)
    {
        parent::__construct($id);
        $this->sortable = false;
        $this->limitable = false;
    }

    /**
     * Retourne les selecteurs utilisable pour cette source de donnee
     *
     * @return cms_module_common_selector[]
     */
    public function get_available_selectors()
    {
        return [
            'cms_module_storyplay_selector_storyplay'
        ];
    }

    /**
     * Retourne les criteres de tri utilisable pour cette source de donnee
     *
     * @return array
     */
    protected function get_sort_criterias()
    {
        return [];
    }

    /**
     * Recuperation des donnees de la source...
     *
     * @return false|array{connector: int}
     */
    public function get_datas()
    {
        $selector = $this->get_selected_selector();
        if ($selector) {
            $source_id = $selector->get_value();
            $source_id = intval($source_id);

            $result = pmb_mysql_query('SELECT 1 FROM connectors_sources WHERE id_connector = "storyplay" AND source_id = ' . $source_id);
            if (pmb_mysql_num_rows($result)) {
                return [
                    'connector' => $source_id
                ];
            }
        }
        return false;
    }
}
