You are here

function total_gallery_formatter_field_formatter_settings_form in Total Gallery Formatter 7

Implements hook_field_formatter_settings_form().

File

./total_gallery_formatter.module, line 71
A gallery formatter that gives you the Total control.

Code

function total_gallery_formatter_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $element = array();
  if ($display['type'] == 'total_gallery_formatter') {
    $image_styles = array();
    foreach (image_styles() as $key => $style) {
      $image_styles[$key] = $key;
    }
    $element['slides_options'] = array(
      '#title' => t('Slides Options'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $element['slides_options']['slide_style'] = array(
      '#title' => t('Slide Image Style'),
      '#type' => 'select',
      '#default_value' => $settings['slides_options']['slide_style'],
      '#options' => $image_styles,
      '#description' => t('Select the image style for currently selected image'),
    );
    $element['slides_options']['scroll_fx'] = array(
      '#title' => t('Scroll Effect'),
      '#type' => 'select',
      '#default_value' => $settings['slides_options']['scroll_fx'],
      '#options' => array(
        'none' => t('None'),
        'scroll' => t('Scroll'),
        'directscroll' => t('Direct Scroll'),
        'fade' => t('Fade'),
        'crossfade' => t('CrossFade'),
        'cover' => t('Cover'),
        'cover-fade' => t('CoverFade'),
        'uncover' => t('Uncover'),
        'uncover-fade' => t('UncoverFade'),
      ),
      '#description' => t('Select effect to use when carousel slides'),
    );
    $element['slides_options']['direction'] = array(
      '#title' => t('Direction'),
      '#type' => 'select',
      '#default_value' => $settings['slides_options']['direction'],
      '#options' => array(
        'left' => t('Left'),
        'right' => t('Right'),
        'up' => t('Up'),
        'down' => t('Down'),
      ),
      '#description' => t('Select direction to use when carousel slides'),
    );
    $element['slides_options']['slide_duration'] = array(
      '#title' => t('Slide scroll duration'),
      '#type' => 'textfield',
      '#description' => t('Determines the duration of the slide transition in milliseconds.'),
      '#default_value' => $settings['slides_options']['slide_duration'],
      '#size' => 5,
      '#maxlength' => 5,
      '#required' => TRUE,
    );
    $element['slides_options']['responsive'] = array(
      '#title' => t('Responsive'),
      '#type' => 'checkbox',
      '#default_value' => $settings['slides_options']['responsive'],
      '#description' => t('Select if the gallery will be responsive.'),
    );
    $element['slides_options']['slide_controls'] = array(
      '#title' => t('Slide controls'),
      '#type' => 'checkbox',
      '#default_value' => $settings['slides_options']['slide_controls'],
      '#description' => t('Select if the slide will have prev and next buttons'),
    );
    $element['slides_options']['autoplay'] = array(
      '#title' => t('Autoplay'),
      '#type' => 'checkbox',
      '#default_value' => $settings['slides_options']['autoplay'],
      '#description' => t('Select if the carousel will have automatic scrolling'),
    );
    $element['slides_options']['style'] = array(
      '#title' => t('Style'),
      '#type' => 'select',
      '#default_value' => $settings['slides_options']['style'],
      '#options' => array(
        'nostyle' => t('No style'),
        'elegant' => t('Elegant'),
      ),
      '#description' => t('Select the style for the gallery.'),
    );
    $element['pagination_options'] = array(
      '#title' => t('Pagination Options'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $element['pagination_options']['thumb_style'] = array(
      '#title' => t('Thumbnail Image Style'),
      '#type' => 'select',
      '#default_value' => $settings['pagination_options']['thumb_style'],
      '#options' => $image_styles,
      '#description' => t('Select the image style for pagination thumbnail images'),
    );
    $element['pagination_options']['items_carousel'] = array(
      '#title' => t('Carousel Items'),
      '#type' => 'textfield',
      '#description' => t('Select the number of visible items in the pagination carousel'),
      '#default_value' => $settings['pagination_options']['items_carousel'],
      '#size' => 2,
      '#maxlength' => 3,
      '#required' => TRUE,
    );
    $element['pagination_options']['circular'] = array(
      '#title' => t('Circular'),
      '#type' => 'checkbox',
      '#default_value' => $settings['pagination_options']['circular'],
      '#description' => t('Select if the carousel should be circular.'),
    );
    $element['pagination_options']['infinite'] = array(
      '#title' => t('Infinite'),
      '#type' => 'checkbox',
      '#default_value' => $settings['pagination_options']['infinite'],
      '#description' => t('Select if the carousel will come back to start when finishes.'),
    );
    $element['pagination_options']['pag_duration'] = array(
      '#title' => t('Pagination scroll duration'),
      '#type' => 'textfield',
      '#description' => t('Determines the duration of the pagination transition in milliseconds.'),
      '#default_value' => $settings['pagination_options']['pag_duration'],
      '#size' => 5,
      '#maxlength' => 5,
      '#required' => TRUE,
    );
    $element['pagination_options']['easing'] = array(
      '#title' => t('Pagination easing'),
      '#type' => 'select',
      '#default_value' => $settings['pagination_options']['easing'],
      '#options' => array(
        'linear' => t('Linear'),
        'quadratic' => t('Quadratic'),
        'cubic' => t('Cubic'),
        'elastic' => t('Elastic'),
      ),
      '#description' => t('Select the pagination easing.'),
    );
    if (module_exists('colorbox')) {
      $element['colorbox_options'] = array(
        '#title' => t('Colorbox Options'),
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
      );
      $element['colorbox_options']['colorbox'] = array(
        '#title' => t('Open in Colorbox'),
        '#type' => 'checkbox',
        '#default_value' => $settings['colorbox_options']['colorbox'],
        '#description' => t('Select if the slides will be opened in Colorbox, when user click on it.'),
      );
      $image_styles[0] = t('None (original image)');
      $element['colorbox_options']['big_style'] = array(
        '#title' => t('Colorbox Image Style'),
        '#type' => 'select',
        '#default_value' => $settings['colorbox_options']['big_style'],
        '#options' => $image_styles,
        '#description' => t('Select the image style for colorbox image'),
      );
    }
  }

  // Only Carousel.
  if ($display['type'] == 'tgf_carousel') {
    $image_styles = array();
    foreach (image_styles() as $key => $style) {
      $image_styles[$key] = $key;
    }
    $element['general_options'] = array(
      '#title' => t('General Options'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $element['general_options']['items_style'] = array(
      '#title' => t('Items Image Style'),
      '#type' => 'select',
      '#default_value' => $settings['general_options']['items_style'],
      '#options' => $image_styles,
      '#description' => t('Select the image style for items'),
    );
    $element['general_options']['scroll_fx'] = array(
      '#title' => t('Scroll Effect'),
      '#type' => 'select',
      '#default_value' => $settings['general_options']['scroll_fx'],
      '#options' => array(
        'none' => t('None'),
        'scroll' => t('Scroll'),
        'directscroll' => t('Direct Scroll'),
        'fade' => t('Fade'),
        'crossfade' => t('CrossFade'),
        'cover' => t('Cover'),
        'cover-fade' => t('CoverFade'),
        'uncover' => t('Uncover'),
        'uncover-fade' => t('UncoverFade'),
      ),
      '#description' => t('Select effect to use when carousel items'),
    );
    $element['general_options']['direction'] = array(
      '#title' => t('Direction'),
      '#type' => 'select',
      '#default_value' => $settings['general_options']['direction'],
      '#options' => array(
        'left' => t('Left'),
        'right' => t('Right'),
        'up' => t('Up'),
        'down' => t('Down'),
      ),
      '#description' => t('Select direction to use when carousel items'),
    );
    $element['general_options']['slide_duration'] = array(
      '#title' => t('Slide scroll duration'),
      '#type' => 'textfield',
      '#description' => t('Determines the duration of the slide transition in milliseconds.'),
      '#default_value' => $settings['general_options']['slide_duration'],
      '#size' => 5,
      '#maxlength' => 5,
      '#required' => TRUE,
    );
    $element['general_options']['easing'] = array(
      '#title' => t('Pagination easing'),
      '#type' => 'select',
      '#default_value' => $settings['general_options']['easing'],
      '#options' => array(
        'linear' => t('Linear'),
        'quadratic' => t('Quadratic'),
        'cubic' => t('Cubic'),
        'elastic' => t('Elastic'),
      ),
      '#description' => t('Select the pagination easing.'),
    );
    $element['general_options']['style'] = array(
      '#title' => t('Style'),
      '#type' => 'select',
      '#default_value' => $settings['general_options']['style'],
      '#options' => array(
        'nostyle' => t('No style'),
        'elegant' => t('Elegant'),
      ),
      '#description' => t('Select the style for the gallery.'),
    );
    $element['general_options']['items_carousel'] = array(
      '#title' => t('Carousel Items'),
      '#type' => 'textfield',
      '#description' => t('Select the number of visible items in the pagination carousel'),
      '#default_value' => $settings['general_options']['items_carousel'],
      '#size' => 2,
      '#maxlength' => 3,
      '#required' => TRUE,
    );
    $element['general_options']['responsive'] = array(
      '#title' => t('Responsive'),
      '#type' => 'checkbox',
      '#default_value' => $settings['slides_options']['responsive'],
      '#description' => t('Select if the gallery will be responsive.'),
    );
    $element['general_options']['autoplay'] = array(
      '#title' => t('Autoplay'),
      '#type' => 'checkbox',
      '#default_value' => $settings['general_options']['autoplay'],
      '#description' => t('Select if the carousel will have automatic scrolling'),
    );
    $element['general_options']['circular'] = array(
      '#title' => t('Circular'),
      '#type' => 'checkbox',
      '#default_value' => $settings['general_options']['circular'],
      '#description' => t('Select if the carousel should be circular.'),
    );
    $element['general_options']['infinite'] = array(
      '#title' => t('Infinite'),
      '#type' => 'checkbox',
      '#default_value' => $settings['general_options']['infinite'],
      '#description' => t('Select if the carousel will come back to start when finishes.'),
    );
    if (module_exists('colorbox')) {
      $element['colorbox_options'] = array(
        '#title' => t('Colorbox Options'),
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
      );
      $element['colorbox_options']['colorbox'] = array(
        '#title' => t('Open in Colorbox'),
        '#type' => 'checkbox',
        '#default_value' => $settings['colorbox_options']['colorbox'],
        '#description' => t('Select if the slides will be opened in Colorbox, when user click on it.'),
      );
      $image_styles[0] = t('None (original image)');
      $element['colorbox_options']['big_style'] = array(
        '#title' => t('Colorbox Image Style'),
        '#type' => 'select',
        '#default_value' => $settings['colorbox_options']['big_style'],
        '#options' => $image_styles,
        '#description' => t('Select the image style for colorbox image'),
      );
    }
  }
  return $element;
}