<?php

namespace Layerdrops\Ostech\Widgets;


class Sponsors extends \Elementor\Widget_Base
{
    public function get_name()
    {
        return 'ostech-sponsors';
    }

    public function get_title()
    {
        return __('Sponsors', 'ostech-addon');
    }

    public function get_icon()
    {
        return 'eicon-cogs';
    }

    public function get_categories()
    {
        return ['ostech-category'];
    }

    protected function register_controls()
    {

        $this->start_controls_section(
            'layout_section',
            [
                'label' => __('Layout', 'ostech-addon'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'layout_type',
            [
                'label' => __('Select Layout', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::SELECT2,
                'default' => 'layout_one',
                'options' => [
                    'layout_one' => __('Layout One', 'ostech-addon'),
                    'layout_two' => __('Layout Two', 'ostech-addon'),
                    'layout_three' => __('Layout Three', 'ostech-addon'),
                    'layout_four' => __('Layout Four', 'ostech-addon'),
                ]
            ]
        );

        $this->end_controls_section();

        $this->start_controls_section(
            'content_section',
            [
                'label' => __('Content', 'ostech-addon'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'sec_title',
            [
                'label' => __('Section Title', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::TEXTAREA,
                'placeholder' => __('Add title', 'ostech-addon'),
                'default' => __('Default Title', 'ostech-addon'),
                'condition' => [
                    'layout_type' => 'layout_ff'
                ]
            ]
        );


        $sponsor_images = new \Elementor\Repeater();

        $sponsor_images->add_control(
            'image',
            [
                'label' => __('Add Image', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::MEDIA,
                'default' => [
                    'url' => \Elementor\Utils::get_placeholder_image_src(),
                ]
            ]
        );

        $this->add_control(
            'sponsor_images',
            [
                'label' => __('Sponsor Items', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::REPEATER,
                'fields' => $sponsor_images->get_controls(),
            ]
        );

        $this->end_controls_section();

        //General style
        $this->start_controls_section(
            'general_style',
            [
                'label' => esc_html__('Content Style', 'ostech-addon'),
                'tab' => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );

        ostech_elementor_general_style_options($this, 'Section Title', '{{WRAPPER}} .client-carousel__tilte span', ['layout_one', 'layout_two', 'layout_three']);
        ostech_elementor_general_style_options($this, 'Background Color', '{{WRAPPER}} .client-carousel', ['layout_one', 'layout_two', 'layout_three'], 'background-color', false);

        $this->end_controls_section();

        ostech_get_elementor_carousel_options($this, ['layout_one', 'layout_two', 'layout_three', 'layout_four']);
    }

    protected function render()
    {
        $settings = $this->get_settings_for_display();
        include ostech_get_template('sponsors-one.php');
        include ostech_get_template('sponsors-two.php');
        include ostech_get_template('sponsors-three.php');
        include ostech_get_template('sponsors-four.php');
    }
}
