<?php
/**
 * @package     productive-forms
 * @author      productiveminds.com
 * @copyright   productiveminds.com
 */

if ( !defined( 'ABSPATH' ) ) {
    die();
}

/**
 * Productive Contact_Us_Page Widget for Elementor.
 *
 */
class Productive_Elementor_Widget_Contact_Us_Page extends \Elementor\Widget_Base {

    /**
     *
     * Widget Name (System).
     */
    public function get_name() {
        return 'productive_elementor_widget_cpt_contact_us_page';
    }

    /**
     *
     * Widget Name (Visible).
     */
    public function get_title() {
        return esc_html__( 'Contact Us Page', 'productive-forms' );
    }

    /**
     *
     * Widget Icon
     */
    public function get_icon() {
        return 'eicon-circle-o';
    }

    /**
     *
     * Widget Support Url
     */
    public function get_custom_help_url() {
        return PRODUCTIVE_GLOBAL_PRODUCT_SUPPORT_BASE_URL;
    }

    /**
     *
     * Category in Element Admin Area
     */
    public function get_categories() {
        return [ 'productiveminds' ];
    }

    /**
     *
     * Widget Keywords
     */
    public function get_keywords() {
        return [ 'productive_elementor_widget_cpt_contact_us_page', 'Contact Us', 'Contact Us Page', 'productiveminds', 'productiveminds.com' ];
    }

    /**
     *
     * Widget Controls
     */
    protected function register_controls() {
        require( plugin_dir_path( __FILE__ ) . 'partials/partial-productive-elementor-widget-layout.php' );
        require( plugin_dir_path( __FILE__ ) . 'partials/partial-productive-elementor-widget-header.php' );
        require( plugin_dir_path( __FILE__ ) . 'partials/partial-productive-elementor-widget-content.php' );
        require( plugin_dir_path( __FILE__ ) . 'partials/partial-productive-elementor-widget-settings.php' );
        require( plugin_dir_path( __FILE__ ) . 'partials/partial-productive-elementor-widget-update-data.php' );
    }
    
    /**
     *
     * Widget Rendered Content
     */
    protected function render() {
        $settings = $this->get_settings_for_display();
        
        if ( !isset($settings['section_content_header_is_show_section_header']) || empty($settings['section_content_header_is_show_section_header'])) {
            $settings['section_content_header_is_show_section_header'] = 0;
        } else {
            $settings['section_content_header_is_show_section_header'] = 1;
        }
        
        if ( !isset($settings['section_style_content_button_hover_animation']) || empty($settings['section_style_content_button_hover_animation']) ) {
            $settings['section_style_content_button_hover_animation'] = '';
        } else {
            $this->add_render_attribute( 'wrapper', 'class', $settings['section_style_content_button_hover_animation'] );
            $settings['section_style_content_button_hover_animation'] = 'elementor-animation-' . $settings['section_style_content_button_hover_animation'];
        }
        
        $settings['slider_swiper_css_class_from_elementor'] = 'via_elementor_slider';
        $settings['section_content_settings_unique_id'] = 'section_unique_id_' . rand() . '_' . rand();
        
        $cpt_section_args = array(
            'section_initiator'                                     => 'elementor',
            'section_content_settings_unique_id'                    => $settings['section_content_settings_unique_id'],
            'section_content_header_is_show_section_header'         => $settings['section_content_header_is_show_section_header'],
            'is_formonly'                                           => $settings['is_formonly'],
            'productive_forms_contact_side'                         => $settings['productive_forms_contact_side'],
            'section_title'                                         => $settings['section_title'],
            'section_title_suffix'                                  => $settings['section_title_suffix'],
            'section_title_html_tag'                                => $settings['section_title_html_tag'],
            'section_intro'                                         => $settings['section_intro'],
            'section_heading_auxiliary'                             => $settings['section_heading_auxiliary'],
            'section_heading_auxiliary_position'                    => $settings['section_heading_auxiliary_position'],
            'display_contact_form_label'                            => $settings['display_contact_form_label'],
            'section_style_content_button_hover_animation'          => $settings['section_style_content_button_hover_animation'],
            'contact_how_to_display_contact_name_field'             => $settings['contact_how_to_display_contact_name_field'],
            'contact_ask_for_visitor_phone'                         => $settings['contact_ask_for_visitor_phone'],
            'request_data_privacy_consent'                          => $settings['request_data_privacy_consent'],
            'submission_verify_type'                                => $settings['submission_verify_type'],
            'display_contact_email_address'                         => $settings['display_contact_email_address'],
            'display_contact_phone_number'                          => $settings['display_contact_phone_number'],
            'display_contact_whatsapp_number'                       => $settings['display_contact_whatsapp_number'],
            'display_contact_location'                              => $settings['display_contact_location'],
            'display_contact_opening_hours'                         => $settings['display_contact_opening_hours'],
            'section_show_social_media_follow'                    => $settings['section_show_social_media_follow'],
            'section_show_social_media_follow_on_copy'              => $settings['section_show_social_media_follow_on_copy'],
            'slider_swiper_css_class_from_elementor'                => $settings['slider_swiper_css_class_from_elementor'],
        );
        
        $section_bg_color_scheme        = 'productive-paddable-section page_main_section_container ' . $settings['section_gtbg_align'] 
                . ' ' . $settings['section_bg_color_scheme'] . ' ' . $settings['section_block_max_width'] . ' ' . $settings['section_block_spacing'];
    
        $display_contact_social_media_icons_style = '';
        if( isset($settings['display_contact_social_media_icons_style']) ) {
            $display_contact_social_media_icons_style = $settings['display_contact_social_media_icons_style'];
        }
        $section_content_items_css_classes = ' ' . $display_contact_social_media_icons_style;
        
        do_action( 'productive_global_render_content_wrapper_full_full_top', $section_bg_color_scheme );
            do_action( 'productive_global_render_content_wrapper_full_top', $section_content_items_css_classes );
                productive_forms_render_contact_us_page( $cpt_section_args );
            do_action('productive_global_render_content_wrapper_full_bottom');
        do_action('productive_global_render_content_wrapper_full_full_bottom');
    }
    
}
