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

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

        echo '<div class="row ">';

        if ( ! empty ( $options['stp_title'] ) ) {
            echo '<div class="col-sm-12">';
            echo '<h3 class="m_title">' . $options['stp_title'] . '</h3>';
            echo '</div>';
        }

        if ( ! empty ( $options['steps_single2'] ) && is_array( $options['steps_single2'] ) ) {
            $i     = 1;
            $count = count( $options['steps_single2'] );
            echo '<div class="col-sm-12">';
            foreach ( $options['steps_single2'] as $step )
            {
                if ( $i % 3 == 1 ) {
                    echo '<div class="row gutter-md">';
                }

                $ok    = '';
                $image = '';

                if ( $step['stp_single_ok'] == 'yes' ) {
                    $ok    = 'ok';
                    // $image = '<img src="' . THEME_BASE_URI . '/images/ok.png" alt="">';
                    $image = '<span class="glyphicon glyphicon-ok-circle"></span>';
                }

                $goboxfirst = '';
                if($i == 1) $goboxfirst = 'gobox-first';

                $goboxlast = '';
                if($i == $count) $goboxlast = 'gobox-last';

                echo '<div class="col-sm-4">';

                echo '<div class="gobox ' . $ok . ' '.$goboxfirst.' '.$goboxlast.'">';

                echo $image;

                echo '<div class="gobox-content">';

                if ( ! empty ( $step['stp_single_title'] ) ) {
                    echo '<h4>' . $step['stp_single_title'] . '</h4>';
                }

                if ( ! empty ( $step['stp_single_link']['url'] ) ) {
                    echo '<a class="zn_step_link" href="' . $step['stp_single_link']['url'] . '" target="' . $step['stp_single_link']['target'] . '"></a>';
                }

                if ( ! empty ( $step['stp_single_desc'] ) ) {
                    echo '<p>' . $step['stp_single_desc'] . '</p>';
                }

                echo '</div>';

                echo '</div>';

                echo '</div>';

                if ( $i % 3 == 0 || $i == $count ) {
                    echo '</div>';
                }
                $i ++;
            }
            echo '</div>';
        }

        echo '</div>';
    }

    /**
     * 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"           => __( "Steps", 'zn_framework' ),
            "description"    => __( "Here you can create your desired steps.", 'zn_framework' ),
            "id"             => "steps_single2",
            "std"            => "",
            "type"           => "group",
            "add_text"       => __( "Step", 'zn_framework' ),
            "remove_text"    => __( "Step", 'zn_framework' ),
            "group_sortable" => true,
            "subelements"    => array (
                array (
                    "name"        => __( "Step Title", 'zn_framework' ),
                    "description" => __( "Please enter a title for this step.", 'zn_framework' ),
                    "id"          => "stp_single_title",
                    "std"         => "",
                    "type"        => "text"
                ),
                array (
                    "name"        => __( "Step content", 'zn_framework' ),
                    "description" => __( "Please enter a content for this step.", 'zn_framework' ),
                    "id"          => "stp_single_desc",
                    "std"         => "",
                    "type"        => "textarea"
                ),
                array (
                    "name"        => __( "Box Link", 'zn_framework' ),
                    "description" => __( "Please choose the link you want to use for this box.", 'zn_framework' ),
                    "id"          => "stp_single_link",
                    "std"         => "",
                    "type"        => "link",
                    "options"     => array (
                        '_blank' => __( "New window", 'zn_framework' ),
                        '_self'  => __( "Same window", 'zn_framework' )
                    )
                ),
                array (
                    "name"        => __( "Use alternative style?", 'zn_framework' ),
                    "description" => __( "Select yes if you want your box to use a different background color and display an OK
                                icon on the left", 'zn_framework' ),
                    "id"          => "stp_single_ok",
                    "type"        => "select",
                    "std"         => "no",
                    "options"     => array (
                        'yes' => __( 'Yes', 'zn_framework' ),
                        'no'  => __( 'No', 'zn_framework' )
                    ),
                )
            )
        );
        return array (
                array (
                    "name"        => __( "Title", 'zn_framework' ),
                    "description" => __( "Please enter a title that will appear on over the boxes", 'zn_framework' ),
                    "id"          => "stp_title",
                    "std"         => "",
                    "type"        => "text",
                ),
                $extra_options,
        );
    }
}
