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

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

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

        echo '<div class="step-boxes-3">';
        if ( ! empty ( $options['steps_single3'] ) && is_array( $options['steps_single3'] ) ) {
            $i   = 1;
            $all = count( $options['steps_single3'] );
            $cls = '';
            foreach ( $options['steps_single3'] as $step )
            {
                if ( $i % 2 != 0 ) {
                    $align = 'left';
                }
                else {
                    $align = 'right';
                }

                if ( $i == $all ) {
                    $cls = 'last';
                }

                echo '<div class="process_box ' . $cls . '" data-align="' . $align . '">';

                echo '<div class="number"><span>';

                if ( $i < 10 ) {
                    echo '0' . $i;
                }
                else {
                    echo $i;
                }

                echo '</span></div>';

                echo '<div class="content">';
                if ( ! empty ( $step['stp_single_title'] ) ) {
                    echo '<h4 class="stp_title">' . $step['stp_single_title'] . '</h4>';
                }
                // STEP CONTENT
                if ( ! empty ( $step['stp_single_desc'] ) ) {
                    if ( preg_match( '%(<p[^>]*>.*?</p>)%i', $step['stp_single_desc'], $regs ) ) {
                        echo $step['stp_single_desc'];
                    }
                    else {
                        echo '<p>' . $step['stp_single_desc'] . '</p>';
                    }
                }
                echo '</div>';
                echo '<div class="clear"></div>';
                echo '</div>';

                $i ++;
            }
        }
        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_single3",
            "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"
                )
            )
        );
        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,
        );
    }
}
