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

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

        if( empty ( $options['single_horizontal_tab'] ) ){
            return;
        }

        $style = $this->opt('vts_tab_style','tabs_style1');

        echo '<div class="tabbable '.$style.' '.$this->data['uid'].'">';

        if ( ! empty ( $options['single_horizontal_tab'] ) && is_array( $options['single_horizontal_tab'] ) )
        {
            echo '<ul class="nav fixclear">';

            $i       = 1;
            $content = '';

            foreach ( $options['single_horizontal_tab'] as $tab )
            {
                $cls = '';

                if ( $i == 1 ) {
                    $cls = 'active';
                }

                $uniq_name = $i . uniqid();

                // Tab Handle
                echo '<li class="' . $cls . '">';
                echo '<a href="#tabs_i2-pane' . $uniq_name . '" data-toggle="tab">';

                echo $tab['vts_tab_title'];
                echo '</a>';

                echo '</li>';

                // TAB CONTENT
                $content .= '<div class="tab-pane ' . $cls . '" id="tabs_i2-pane' . $uniq_name . '">';

                $content .= '<h4>' . $tab['vts_tab_c_title'] . '</h4>';

                $content .= wpautop(do_shortcode( $tab['vts_tab_c_content'] ));

                $content .= '</div>';

                $i ++;
            }

            echo '</ul>';

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

            echo do_shortcode( $content );

            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"           => __( "Tabs", 'zn_framework' ),
            "description"    => __( "Here you can add your desired tabs.", 'zn_framework' ),
            "id"             => "single_horizontal_tab",
            "std"            => "",
            "type"           => "group",
            "add_text"       => __( "Tab", 'zn_framework' ),
            "remove_text"    => __( "Tab", 'zn_framework' ),
            "group_sortable" => true,
            "subelements"    => array (
                array (
                    "name"        => __( "Tab Title", 'zn_framework' ),
                    "description" => __( "Please enter the desired title that will appear as tab.", 'zn_framework' ),
                    "id"          => "vts_tab_title",
                    "std"         => "",
                    "type"        => "text"
                ),
                array (
                    "name"        => __( "Tab Content Title", 'zn_framework' ),
                    "description" => __( "Please enter the desired title that will appear inside the tab.", 'zn_framework' ),
                    "id"          => "vts_tab_c_title",
                    "std"         => "",
                    "type"        => "text"
                ),
                array (
                    "name"        => __( "Content", 'zn_framework' ),
                    "description" => __( "Please enter the desired content for this tab.", 'zn_framework' ),
                    "id"          => "vts_tab_c_content",
                    "std"         => "",
                    "type"        => "visual_editor",
                    'class'       => 'zn_full'
                )
            )
        );
        return  array (
                    array (
                        "name"        => __( "Tabs Style", 'zn_framework' ),
                        "description" => __( "Using this option you can choose the desired tabs style.", 'zn_framework' ),
                        "id"          => "vts_tab_style",
                        "std"         => "tabs_style1",
                        'options'     => array(
                                'tabs_style1' => __( 'Style 1', 'zn_framework' ),
                                'tabs_style2' => __( 'Style 2', 'zn_framework' ),
                                'tabs_style3' => __( 'Style 3', 'zn_framework' ),
                                'tabs_style4' => __( 'Style 4', 'zn_framework' ),
                                'tabs_style5' => __( 'Style 5', 'zn_framework' ),
                            ),
                        "type"        => "select",
                        'live' => array(
                            'type'      => 'class',
                            'css_class' => '.'.$this->data['uid']
                        ),
                    ),
                $extra_options,
        );
    }
}
