<?php if(! defined('ABSPATH')){ return; }
/*
 Name: Historic Element
 Description: Create and display a Historic element
 Class: TH_HistoricElement
 Category: content
 Level: 3
*/
/**
 * Class TH_HistoricElement
 *
 * Create and display a Historic element
 *
 * @package  Kallyas
 * @category Page Builder
 * @author   Team Hogash
 * @since    3.8.0
 */
class TH_HistoricElement extends ZnElements
{
    public static function getName(){
        return __( "Historic Element", 'zn_framework' );
    }

    /**
     * This method is used to display the output of the element.
     * @return void
     */
    function element()
    {
        $options = $this->data['options'];

        $start_text = $this->opt( 'he_start', '' );


        echo '<div class="timeline_bar">';
        echo '<div class="row">';
        echo '<div class="col-sm-12 end_timeline"><span>' . $start_text . '</span></div>';

        if ( ! empty ( $options['historic_single'] ) && is_array( $options['historic_single'] ) ) {
            $i = 1;
            foreach ( $options['historic_single'] as $event ) {
                $pos = '<div class="col-sm-6">';
                if ( $i % 2 != 0 ) {
                    $pos = '<div class="col-sm-6 col-sm-offset-6" data-align="right">';
                }
                echo $pos;
                echo '<div class="timeline_box">';

                echo '<div class="date">' . $event['she_event_date'] . '</div>';
                echo '<h4 class="htitle">' . $event['she_event_name'] . '</h4>';


                echo wpautop(do_shortcode( $event['she_event_desc'] ));
                

                echo '</div><!-- end timeline box -->';
                echo '</div>';

                $i ++;
            }
        }
        echo '<div class="col-sm-12 end_timeline">';
        echo '<span>' . __( "PRESENT", 'zn_framework' ) . '</span>';
        echo '</div>';
        echo '</div>';
        echo '</div><!-- end timeline bar -->';

    }

    /**
     * This method is used to retrieve the configurable options of the element.
     * @return array The list of options that compose the element and then passed as the argument for the render() function
     */
    function options()
    {
        $extra_options = array (
            "name"           => __( "Events", 'zn_framework' ),
            "description"    => __( "Here you can add your desired events.", 'zn_framework' ),
            "id"             => "historic_single",
            "std"            => "",
            "type"           => "group",
            "add_text"       => __( "Event", 'zn_framework' ),
            "remove_text"    => __( "Event", 'zn_framework' ),
            "group_title"    => "",
            "group_sortable" => true,
            "subelements"    => array (
                array (
                    "name"        => __( "Event title", 'zn_framework' ),
                    "description" => __( "Please enter a title for this event", 'zn_framework' ),
                    "id"          => "she_event_name",
                    "std"         => "",
                    "type"        => "text"
                ),
                array (
                    "name"        => __( "Event date", 'zn_framework' ),
                    "description" => __( "Please enter the date for this event", 'zn_framework' ),
                    "id"          => "she_event_date",
                    "std"         => "",
                    "type"        => "text",
                ),
                array (
                    "name"        => __( "Event description", 'zn_framework' ),
                    "description" => __( "Please enter a description for this event", 'zn_framework' ),
                    "id"          => "she_event_desc",
                    "std"         => "",
                    "type"        => "visual_editor",
                    'class'       => 'zn_full'
                ),
            )
        );
        return array (
                array (
                    "name"        => __( "Start text", 'zn_framework' ),
                    "description" => __( "Please enter a text that will appear as a start", 'zn_framework' ),
                    "id"          => "he_start",
                    "std"         => "",
                    "type"        => "text",
                ),
                $extra_options,
        );
    }
}
