<?php
namespace Elementor;

/**
 * Elementor Widget
 * @package Pubzi
 * @since 1.0.0
 */ 
 
class Gallery_Box extends Widget_Base {

	/**
	 * Get widget name.
	 * Retrieve button widget name.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'pubzi-gallery-box-widget';
	}

	/**
	 * Get widget title.
	 * Retrieve button widget title.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Gallery box', 'pubzi-core' );
	}

	/**
	 * Get widget icon.
	 * Retrieve button widget icon.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget icon.
	 */
	public function get_icon() {
		return 'eicon-flash';
	}

	/**
	 * Get widget categories.
	 * Retrieve the list of categories the button widget belongs to.
	 * Used to determine where to display the widget in the editor.
	 *
	 * @since  2.0.0
	 * @access public
	 * @return array Widget categories.
	 */
	public function get_categories()
    {
        return ['pubzi_widgets'];
    }
	
	/**
	 * Register button widget controls.
	 * Adds different input fields to allow the user to change and customize the widget settings.
	 *
	 * @since  1.0.0
	 * @access protected
	 */
	protected function register_controls() {

		// Tab Start - 1

		$this->start_controls_section(
			'gallery_box_content',
			[
				'label' => esc_html__( 'Gallery box', 'pubzi-core' ),
			]
		);		

		$this->add_control(
			'image',
			[
				'label' => __( 'Image', 'pubzi-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);	

		$this->add_control(
			'image2',
			[
				'label' => __( 'Image', 'pubzi-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);	

		$this->add_control(
			'image3',
			[
				'label' => __( 'Image', 'pubzi-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);	

		$this->add_control(
			'image4',
			[
				'label' => __( 'Image', 'pubzi-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);	

		$this->add_control(
			'image5',
			[
				'label' => __( 'Image', 'pubzi-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);	

		$this->add_control(
			'image6',
			[
				'label' => __( 'Image', 'pubzi-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);	

		$this->add_control(
			'image7',
			[
				'label' => __( 'Image', 'pubzi-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);	

		$this->add_control(
			'image8',
			[
				'label' => __( 'Image', 'pubzi-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);	

		$this->end_controls_section();

	
		}

	/**
	 * Render button widget output on the frontend.
	 * Written in PHP and used to generate the final HTML.
	 *
	 * @since  1.0.0
	 * @access protected
	 */
	protected function render() {
		$settings = $this->get_settings_for_display();
		$allowed_tags = wp_kses_allowed_html('post');
		?>

	<div class="gt-gallery-section fix">
            <div class="container">
               <div class="row g-4">
                    <div class="col-xl-4 col-lg-6 col-md-6">
                        <div class="gt-epic-gallery-item">
                            <div class="gt-gallery-iamge">
                               <img src="<?php echo wp_get_attachment_url($settings['image']['id']);?>" alt="img">
                               <a href="<?php echo wp_get_attachment_url($settings['image']['id']);?>" class="icon img-popup2">
                                <i class="fa-regular fa-arrows-up-down-left-right"></i>
                               </a>
                            </div>
                        </div>
                        <div class="gt-epic-gallery-item mb-0">
                            <div class="gt-gallery-iamge">
                               <img src="<?php echo wp_get_attachment_url($settings['image2']['id']);?>" alt="img">
                               <a href="<?php echo wp_get_attachment_url($settings['image2']['id']);?>" class="icon img-popup2">
                                <i class="fa-regular fa-arrows-up-down-left-right"></i>
                            </a>
                            </div>
                        </div>
                    </div>
                    <div class="col-xl-4 col-lg-6 col-md-6">
                        <div class="gt-epic-gallery-item">
                            <div class="gt-gallery-iamge">
                               <img src="<?php echo wp_get_attachment_url($settings['image3']['id']);?>" alt="img">
                               <a href="<?php echo wp_get_attachment_url($settings['image3']['id']);?>" class="icon img-popup2">
                                <i class="fa-regular fa-arrows-up-down-left-right"></i>
                               </a>
                            </div>
                        </div>
                        <div class="gt-epic-gallery-item mb-0">
                            <div class="gt-gallery-iamge">
                               <img src="<?php echo wp_get_attachment_url($settings['image4']['id']);?>" alt="img">
                               <a href="<?php echo wp_get_attachment_url($settings['image4']['id']);?>" class="icon img-popup2">
                                <i class="fa-regular fa-arrows-up-down-left-right"></i>
                              </a>
                            </div>
                        </div>
                    </div>
                    <div class="col-xl-4 col-lg-6 col-md-6">
                        <div class="gt-epic-gallery-item">
                            <div class="gt-gallery-iamge">
                               <img src="<?php echo wp_get_attachment_url($settings['image5']['id']);?>" alt="img">
                               <a href="<?php echo wp_get_attachment_url($settings['image5']['id']);?>" class="icon img-popup2">
                                <i class="fa-regular fa-arrows-up-down-left-right"></i>
                              </a>
                            </div>
                        </div>
                        <div class="gt-epic-gallery-item mb-0">
                            <div class="gt-gallery-iamge">
                               <img src="<?php echo wp_get_attachment_url($settings['image6']['id']);?>" alt="img">
                               <a href="<?php echo wp_get_attachment_url($settings['image6']['id']);?>" class="icon img-popup2">
                                <i class="fa-regular fa-arrows-up-down-left-right"></i>
                              </a>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6">
                        <div class="gt-epic-gallery-item mb-0">
                            <div class="gt-gallery-iamge">
                               <img src="<?php echo wp_get_attachment_url($settings['image7']['id']);?>" alt="img">
                               <a href="<?php echo wp_get_attachment_url($settings['image7']['id']);?>" class="icon img-popup2">
                                <i class="fa-regular fa-arrows-up-down-left-right"></i>
                              </a>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6">
                        <div class="gt-epic-gallery-item mb-0">
                            <div class="gt-gallery-iamge">
                               <img src="<?php echo wp_get_attachment_url($settings['image8']['id']);?>" alt="img">
                               <a href="<?php echo wp_get_attachment_url($settings['image8']['id']);?>" class="icon img-popup2">
                                <i class="fa-regular fa-arrows-up-down-left-right"></i>
                              </a>
                            </div>
                        </div>
                    </div>
               </div>
            </div>
        </div>
             
		<?php 
	}


}

Plugin::instance()->widgets_manager->register_widget_type(new Gallery_Box());