<?php
/**
 * Elementor  Footer_gallery  Footer_gallery
 *
 * @since 1.0.0
 */
use Elementor\Controls_Manager;
use Elementor\Plugin;
use Elementor\Utils;
use Elementor\Widget_Base;

class  Footer_gallery extends Widget_Base {
	public function get_name() {
		return 'dexen_footer_gallery';
	}
	public function get_title() {
		return esc_html__( 'Footer gallery', 'plugin-name' );
	}
	public function get_icon() {
		return 'fa fa-object-ungroup';
	}
	public function get_categories() {
		return array( 'dexencore' );
	}
	protected function _register_controls() {
		$this->start_controls_section(
			'footer_info',
			array(
				'label' => esc_html__( 'Footer gallery', 'plugin-name' ),
				'tab'   => \Elementor\Controls_Manager::TAB_CONTENT,
			)
		);
		$this->add_control(
			'widget_title',
			array(
				'label'       => esc_html__( 'widget title', 'plugin-domain' ),
				'type'        => \Elementor\Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'title', 'plugin-domain' ),
			)
		);
		$this->end_controls_section();
		$this->start_controls_section(
			'gallery_list_area',
			array(
				'label' => esc_html__( 'gallery area', 'plugin-name' ),
				'tab'   => \Elementor\Controls_Manager::TAB_CONTENT,
			)
		);
		$repeater = new \Elementor\Repeater();

		$repeater->add_control(
			'gallery_list_img',
			array(
				'label'   => __( 'image', 'plugin-domain' ),
				'type'    => \Elementor\Controls_Manager::MEDIA,
				'default' => array(
					'url' => \Elementor\Utils::get_placeholder_image_src(),
				),
			)
		);
		$this->add_control(
			'gallery_list',
			array(
				'label'  => esc_html__( 'gallery list', 'plugin-domain' ),
				'type'   => \Elementor\Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
			)
		);
		$this->end_controls_section();
	}
	protected function render() {
		$settings     = $this->get_settings_for_display();
		$widget_title = $settings['widget_title'];
		$gallery_list = $settings['gallery_list'];
		?>
			<div class="footer-widget contact-widget">
				<div class="widget-title">
					<h3><?php echo esc_html( $widget_title ); ?></h3>
				</div><!-- /.widget-title -->
				<div class="insta-photo-list list-unstyled">
				<?php if ( $gallery_list ) : ?>
					<?php
					foreach ( $gallery_list as $item ) {

						$gallery_list_bg = ( $item['gallery_list_img']['id'] != '' ) ? wp_get_attachment_url( $item['gallery_list_img']['id'], 'full' ) : $item['gallery_list_img']['url'];
						?>
						<li>
							<a href="#_"><img src="<?php echo esc_attr( $gallery_list_bg ); ?>" alt="image"></a>
						</li>
					<?php } ?>
				<?php endif; ?>
				</div><!-- /.insta-photo-list -->
			</div>
		<?php
	}
}

Plugin::instance()->widgets_manager->register_widget_type( new Footer_gallery() );
?>
