<?php

/**
 * @file
 * Describe the file
 *
 * @author Mathew Winstone (minorOffense) <mwinstone@coldfrontlabs.ca>
 */

/**
 * Implements hook_views_slideshow_slideshow_info().
 */
function flexslider_views_slideshow_views_slideshow_slideshow_info() {
  $options = array(
    'flexslider_views_slideshow' => array(
      'name' => t('FlexSlider'),
      'accepts' => array(
//        'goToSlide',
        'nextSlide',
        'pause',
        'play',
        'previousSlide',
      ),
      'calls' => array(
//        'transitionBegin',
//        'transitionEnd',
//        'goToSlide',
        'pause',
        'play',
        'nextSlide',
        'previousSlide',
      ),
    ),
  );

  // @todo figure out which options to add

  return $options;
}

/**
 * Implements hook_views_slideshow_option_definition().
 */
function flexslider_views_slideshow_views_slideshow_option_definition() {
  // Default options for FlexSlider
  $options['flexslider_views_slideshow'] = array(
    'contains' => array(
      'optionset' => array('default' => 'default'),
    ),
  );
  // @todo figure out which options to define
  // @todo integrate with "optionsets"

  return $options;
}

/**
 * Configuration form within the Views Slideshow settings pane
 */
function flexslider_views_slideshow_views_slideshow_slideshow_type_form(&$form, &$form_state, &$view) {
    // For a full list of options
    // @see http://flex.madebymufffin.com/

    // Load the list of option sets
    $optionsets = flexslider_optionset_load_all();
    // Parse out into key/value pairs
    foreach ($optionsets as $key => $optionset) {
      $options[$key] = $optionset->title;
    }

    // Add a select field
    $form['flexslider_views_slideshow']['optionset'] = array(
      '#type' => 'select',
      '#title' => t('Option Set'),
      '#multiple' => FALSE,
      '#description' => t('Select a configured option set to use with Flex Slider.'),
      '#options' => $options,
      '#default_value' => $view->options['flexslider_views_slideshow']['optionset'],
    );
}

function flexslider_views_slideshow_views_slideshow_slideshow_type_form_validate(&$form, &$form_state, &$view) {
  // @todo add validation for any fields in the settings form
}
