<?php

namespace Layerdrops\Ostech\Widgets;


class SidebarCaseInfo extends \Elementor\Widget_Base
{
    public function get_name()
    {
        return 'sidebar-case-info';
    }

    public function get_title()
    {
        return __('Portfolio Info', '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'),
                ]
            ]
        );

        $this->end_controls_section();


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


        $case_info = new \Elementor\Repeater();

        $case_info->add_control(
            'title',
            [
                'label' => __('Title', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => __('Date:', 'ostech-addon'),
                'label_block' => true,
            ]
        );

        $case_info->add_control(
            'content',
            [
                'label' => __('Content', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => __('23 July 2023', 'ostech-addon'),
                'label_block' => true,
            ]
        );

        $this->add_control(
            'case_info',
            [
                'label' => __('Portfolio Info', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::REPEATER,
                'prevent_empty' => false,
                'fields' => $case_info->get_controls(),
            ]
        );

        $social_icons = new \Elementor\Repeater();

        $social_icons->add_control(
            'social_icon',
            [
                'label' => __('Select Icon', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::ICONS,
                'default' => [
                    'value' => 'fab fa-facebook-f',
                    'library' => 'brand',
                ],
                'label_block' => true,
            ]
        );

        $social_icons->add_control(
            'social_url',
            [
                'label' => __('Add Url', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::URL,
                'placeholder' => __('#', 'ostech-addon'),
                'show_external' => false,
                'default' => [
                    'url' => '#',
                    'is_external' => false,
                    'nofollow' => false,
                ],
                'show_label' => false,
            ]
        );

        $this->add_control(
            'social_icons',
            [
                'label' => __('Social Icons', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::REPEATER,
                'fields' => $social_icons->get_controls(),
                'prevent_empty' => false,
                'default' => [
                    [
                        'social_url' => [
                            'url' => '#',
                            'is_external' => false,
                            'nofollow' => false,
                        ],
                    ],
                ],
            ]
        );

        $this->end_controls_section();

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

        ostech_elementor_general_style_options($this, 'Portfolio Info Title', '{{WRAPPER}} .portfolio-details__info-list li span', ['layout_one']);
        ostech_elementor_general_style_options($this, 'Portfolio Info Content', '{{WRAPPER}} .portfolio-details__info-list li', ['layout_one']);

        $this->end_controls_section();

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

        ostech_elementor_button_style_options($this, 'Social Icon', '{{WRAPPER}} .portfolio-details__socials a', '{{WRAPPER}} .portfolio-details__socials a', ['layout_one']);

        $this->end_controls_section();
    }

    protected function render()
    {
        $settings = $this->get_settings_for_display();
        include ostech_get_template('sidebar-case-info-one.php');
    }
}
