<?php

class Thememakers_Entity_Slider {

    public $slider_types = array();
    public $slider_types_options = array();
    public $current_slider_type;

    public function __construct() {
        $this->slider_types = array(
           'showcase' => 'Showcase'
        );

        if (!$this->current_slider_type) {
            $this->current_slider_type = 'showcase'; //default
        }

        $this->slider_types_options = array(
                      
            'showcase' => array(
              
                'auto' => array(
                    'title' => __('Auto', THEMEMAKERS_THEME_FOLDER_NAME),
                    'type' => 'checkbox',
                    'description' => __("", THEMEMAKERS_THEME_FOLDER_NAME),
                    'default' => 1,
                ),
                'interval' => array(
                    'title' => __('Interval', THEMEMAKERS_THEME_FOLDER_NAME),
                    'type' => 'text',
                    'description' => __("", THEMEMAKERS_THEME_FOLDER_NAME),
                    'default' => 5000,
                    'max' => 20000
                ),
                'continuous' => array(
                    'title' => __('Continuous', THEMEMAKERS_THEME_FOLDER_NAME),
                    'type' => 'checkbox',
                    'description' => __("", THEMEMAKERS_THEME_FOLDER_NAME),
                    'default' => 1,
                ),
                'loading' => array(
                    'title' => __('Loading', THEMEMAKERS_THEME_FOLDER_NAME),
                    'type' => 'checkbox',
                    'description' => __("", THEMEMAKERS_THEME_FOLDER_NAME),
                    'default' => 1,
                ),
                'keybord_keys' => array(
                    'title' => __('Keybord keys', THEMEMAKERS_THEME_FOLDER_NAME),
                    'type' => 'checkbox',
                    'description' => __("", THEMEMAKERS_THEME_FOLDER_NAME),
                    'default' => 1,
                ),
                'pauseonover' => array(
                    'title' => __('Pause on over', THEMEMAKERS_THEME_FOLDER_NAME),
                    'type' => 'checkbox',
                    'description' => __("", THEMEMAKERS_THEME_FOLDER_NAME),
                    'default' => 1,
                ),
                'transition' => array(
                    'title' => __('Transition effects', THEMEMAKERS_THEME_FOLDER_NAME),
                    'type' => 'select',
                    'values_list' => array(
                        'fade' => 'fade',
                        'hslide' => 'hslide',
                        'vslide' => 'vslide'
                    ),
                    'description' => "",
                    'default' => 'fade',
                ),
                'transition_delay' => array(
                    'title' => __('Transition delay', THEMEMAKERS_THEME_FOLDER_NAME),
                    'type' => 'text',
                    'description' => __("", THEMEMAKERS_THEME_FOLDER_NAME),
                    'default' => 300,
                    'max' => 2000
                ),
                'transition_speed' => array(
                    'title' => __('Transition speed', THEMEMAKERS_THEME_FOLDER_NAME),
                    'type' => 'text',
                    'description' => __("", THEMEMAKERS_THEME_FOLDER_NAME),
                    'default' => 500,
                    'max' => 2000
                ),
              
                'thumbnails_position' => array(
                    'title' => __('Thumbnails position', THEMEMAKERS_THEME_FOLDER_NAME),
                    'type' => 'select',
                    'values_list' => array(
                        'outside-last' => 'right',
                        'outside-first' => 'left'
                        
                    ),
                    'description' => "",
                    'default' => 'outside-last',
                ),
                'thumbnails_direction' => array(
                    'title' => __('Thumbnails direction', THEMEMAKERS_THEME_FOLDER_NAME),
                    'type' => 'select',
                    'values_list' => array(
                        'vertical' => 'vertical'
                        
                    ),
                    'description' => "",
                    'default' => 'vertical',
                ),
                'thumbnails_slidex' => array(
                    'title' => __('Thumbnails slidex', THEMEMAKERS_THEME_FOLDER_NAME),
                    'type' => 'text',
                    'description' => __("0 = auto, 1 = slide one thumbnail, 2 = slide two thumbnails etc.", THEMEMAKERS_THEME_FOLDER_NAME),
                    'default' => 1,
                    'max' => 10
                )
            ),
        );
    }

    public function draw_sliders_options() {
        $data = array();
        $data['slider_object'] = $this;
        return ThemeMakersThemeView::draw_html('slider/sliders_options', $data);
    }

    public function get_slider_options($slider_type) {
        $options_list = $this->slider_types_options[$slider_type];

        $options = array();
        if (!empty($options_list)) {
            foreach ($options_list as $option_key => $values) {
                $option = ThemeMakersThemeModel::get_option("slider_" . $slider_type . "_" . $option_key);
                if (empty($option) AND !is_numeric($option)) {
                    $option = $values['default'];
                }

                $options[$option_key] = $option;
            }
        }

        return $options;
    }

    public static function get_slides() {
        $slides = ThemeMakersThemeModel::get_option('sliders');
		return $slides;
    }

    public static function get_slide_group($slide_name) {
        $slides = self::get_slides();
        $slide = array();
        if (!empty($slides)) {
            foreach ($slides as $key => $value) {
                if (@$value['name'] == $slide_name) {
                    $slide = $value['options'];
                    break;
                }
            }
        }


        return $slide;
    }

    public static function get_sliders_types() {
        $obj = new Thememakers_Entity_Slider();
        return $obj->slider_types;
    }

}

