You are here

function lightgallery_style_plugin::options_form in Lightgallery 7

Adds Lightgallery configuration form options.

Overrides views_plugin_style::options_form

File

views/lightgallery_style_plugin.inc, line 29
Contains the lightgallery style plugin.

Class

lightgallery_style_plugin
Style plugin to render views as lightgallery instance.

Code

function options_form(&$form, &$form_state) {

  // Check if fields have been added.  Table style plugin will set
  // error_markup if fields are not added.
  // @see views_plugin_style::options_form()
  if (isset($form['error_markup'])) {
    return;
  }
  $fields = $this
    ->conf_get_field_sources();
  $missing_field_warning = '';
  if (empty($fields['field_options_images'])) {
    $missing_field_warning = t('<strong>You must add a field of type image, file or file ID to your view display before this value can be set.</strong><br/>');
  }

  // CORE OPTIONS.
  $form['lightgallery_core'] = array(
    '#type' => 'fieldset',
    '#title' => t('Lightgallery core settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['lightgallery_core']['thumb_field'] = array(
    '#title' => t('Thumbnail field'),
    '#type' => 'select',
    '#options' => $fields['field_options_images'],
    '#default_value' => isset($this->options['lightgallery']['thumb_field']) ? $this->options['lightgallery']['thumb_field'] : NULL,
    '#description' => t('Select the field you want to use to display the thumbnails on page load.'),
    '#suffix' => $missing_field_warning,
    '#required' => TRUE,
  );
  $form['lightgallery_core']['image_field'] = array(
    '#title' => t('Image field'),
    '#type' => 'select',
    '#options' => $fields['field_options_images'],
    '#default_value' => isset($this->options['lightgallery']['image_field']) ? $this->options['lightgallery']['image_field'] : NULL,
    '#description' => t('Select the field you want to use to display the images in the Lightgallery.'),
    '#suffix' => $missing_field_warning,
    '#required' => TRUE,
  );
  $form['lightgallery_core']['title'] = array(
    '#title' => t('Title field'),
    '#type' => 'select',
    '#options' => array(
      '' => t('None'),
    ) + $fields['field_options'],
    '#default_value' => isset($this->options['lightgallery']['title']) ? $this->options['lightgallery']['title'] : NULL,
    '#description' => t('Select the field you want to use as title in the Lightgallery. Leave empty to omit titles.'),
    '#required' => FALSE,
  );
  $form['lightgallery_core']['mode'] = array(
    '#type' => 'select',
    '#title' => t('Transition'),
    '#options' => _lightgallery_get_modes(),
    '#default_value' => isset($this->options['lightgallery']['mode']) ? $this->options['lightgallery']['mode'] : NULL,
    '#description' => t('Type of transition between images.'),
  );
  $form['lightgallery_core']['preload'] = array(
    '#type' => 'select',
    '#title' => t('Preload'),
    '#options' => drupal_map_assoc(array(
      1,
      2,
      3,
      4,
    )),
    '#default_value' => isset($this->options['lightgallery']['preload']) ? $this->options['lightgallery']['preload'] : 1,
    '#description' => t('number of preload slides. will exicute only after the current slide is fully loaded. ' . 'ex:// you clicked on 4th image and if preload = 1 then 3rd slide and 5th slide will be loaded in the background after the 4th slide is fully loaded. ' . 'If preload is 2 then 2nd 3rd 5th 6th slides will be preloaded'),
  );
  $form['lightgallery_core']['closable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Closable'),
    '#default_value' => isset($this->options['lightgallery']['closable']) ? $this->options['lightgallery']['closable'] : TRUE,
    '#description' => t('Allows clicks on dimmer to close gallery.'),
  );
  $form['lightgallery_core']['loop'] = array(
    '#type' => 'checkbox',
    '#title' => t('Loop'),
    '#default_value' => isset($this->options['lightgallery']['loop']) ? $this->options['lightgallery']['loop'] : TRUE,
    '#description' => t('If not selected, the ability to loop back to the beginning of the gallery when on the last element, will be disabled.'),
  );
  $form['lightgallery_core']['esc_key'] = array(
    '#type' => 'checkbox',
    '#title' => t('Escape key'),
    '#default_value' => isset($this->options['lightgallery']['esc_key']) ? $this->options['lightgallery']['esc_key'] : TRUE,
    '#description' => t('Whether the LightGallery could be closed by pressing the "Esc" key.'),
  );
  $form['lightgallery_core']['key_press'] = array(
    '#type' => 'checkbox',
    '#title' => t('Keyboard'),
    '#default_value' => isset($this->options['lightgallery']['key_press']) ? $this->options['lightgallery']['key_press'] : TRUE,
    '#description' => t('Enable keyboard navigation.'),
  );
  $form['lightgallery_core']['controls'] = array(
    '#type' => 'checkbox',
    '#title' => t('Controls'),
    '#default_value' => isset($this->options['lightgallery']['controls']) ? $this->options['lightgallery']['controls'] : TRUE,
    '#description' => t('If not checked, prev/next buttons will not be displayed.'),
  );
  $form['lightgallery_core']['mouse_wheel'] = array(
    '#type' => 'checkbox',
    '#title' => t('Mouse wheel'),
    '#default_value' => isset($this->options['lightgallery']['mouse_wheel']) ? $this->options['lightgallery']['mouse_wheel'] : TRUE,
    '#description' => t('Chane slide on mousewheel'),
  );
  $form['lightgallery_core']['download'] = array(
    '#type' => 'checkbox',
    '#title' => t('Download'),
    '#default_value' => isset($this->options['lightgallery']['download']) ? $this->options['lightgallery']['download'] : TRUE,
    '#description' => t('Enable download button. ' . 'By default download url will be taken from data-src/href attribute but it supports only for modern browsers.'),
  );
  $form['lightgallery_core']['counter'] = array(
    '#type' => 'checkbox',
    '#title' => t('Counter'),
    '#default_value' => isset($this->options['lightgallery']['counter']) ? $this->options['lightgallery']['counter'] : TRUE,
    '#description' => t('Whether to show total number of images and index number of currently displayed image.'),
  );
  $form['lightgallery_core']['drag'] = array(
    '#type' => 'checkbox',
    '#title' => t('Drag'),
    '#default_value' => isset($this->options['lightgallery']['drag']) ? $this->options['lightgallery']['drag'] : TRUE,
    '#description' => t('Enables desktop mouse drag support.'),
  );
  $form['lightgallery_core']['touch'] = array(
    '#type' => 'checkbox',
    '#title' => t('Touch'),
    '#default_value' => isset($this->options['lightgallery']['touch']) ? $this->options['lightgallery']['touch'] : TRUE,
    '#description' => t('Enables touch support.'),
  );

  // THUMB OPTIONS.
  $form['lightgallery_thumbs'] = array(
    '#type' => 'fieldset',
    '#title' => t('Lightgallery thumbnail settings'),
    '#collapsible' => TRUE,
    '#collapsed' => isset($this->options['lightgallery']['thumbnails']) ? !$this->options['lightgallery']['thumbnails'] : FALSE,
  );
  $form['lightgallery_thumbs']['thumbnails'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use thumbnails'),
    '#default_value' => isset($this->options['lightgallery']['thumbnails']) ? $this->options['lightgallery']['thumbnails'] : TRUE,
    '#description' => t('Indicate if you want to use thumbnails in the LightGallery.'),
  );
  $form['lightgallery_thumbs']['animate_thumb'] = array(
    '#type' => 'checkbox',
    '#title' => t('Animate thumbnails'),
    '#default_value' => isset($this->options['lightgallery']['animate_thumb']) ? $this->options['lightgallery']['animate_thumb'] : TRUE,
    '#description' => t('Enable thumbnail animation.'),
  );
  $form['lightgallery_thumbs']['current_pager_position'] = array(
    '#type' => 'select',
    '#title' => t('Position'),
    '#options' => array(
      'left' => t('Left'),
      'middle' => t('Middle'),
      'right' => t('Right'),
    ),
    '#default_value' => isset($this->options['lightgallery']['current_pager_position']) ? $this->options['lightgallery']['current_pager_position'] : 'middle',
    '#description' => t('Position of selected thumbnail.'),
  );
  $form['lightgallery_thumbs']['thumb_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width'),
    '#default_value' => isset($this->options['lightgallery']['thumb_width']) ? $this->options['lightgallery']['thumb_width'] : 100,
    '#description' => t('Width of each thumbnails.'),
  );
  $form['lightgallery_thumbs']['thumb_cont_height'] = array(
    '#type' => 'textfield',
    '#title' => t('Height'),
    '#default_value' => isset($this->options['lightgallery']['thumb_cont_height']) ? $this->options['lightgallery']['thumb_cont_height'] : 100,
    '#description' => t('Height of the thumbnail container including padding and border.'),
  );

  // AUTOPLAY OPTIONS.
  $form['lightgallery_autoplay'] = array(
    '#type' => 'fieldset',
    '#title' => t('Lightgallery autoplay settings'),
    '#collapsible' => TRUE,
    '#collapsed' => isset($this->options['lightgallery']['autoplay']) ? !$this->options['lightgallery']['autoplay'] : FALSE,
  );
  $form['lightgallery_autoplay']['autoplay'] = array(
    '#type' => 'checkbox',
    '#title' => t('Autoplay'),
    '#default_value' => isset($this->options['lightgallery']['autoplay']) ? $this->options['lightgallery']['autoplay'] : TRUE,
    '#description' => t('Enable/Disable gallery autoplay.'),
  );
  $form['lightgallery_autoplay']['pause'] = array(
    '#type' => 'textfield',
    '#title' => t('Pause'),
    '#default_value' => isset($this->options['lightgallery']['pause']) ? $this->options['lightgallery']['pause'] : 5000,
    '#description' => t('The time (in ms) between each auto transition.'),
  );
  $form['lightgallery_autoplay']['progress_bar'] = array(
    '#type' => 'checkbox',
    '#title' => t('Progress bar'),
    '#default_value' => isset($this->options['lightgallery']['progress_bar']) ? $this->options['lightgallery']['progress_bar'] : TRUE,
    '#description' => t('Enable/Disable autoplay progress bar.'),
  );
  $form['lightgallery_autoplay']['autoplay_controls'] = array(
    '#type' => 'checkbox',
    '#title' => t('Autoplay controls'),
    '#default_value' => isset($this->options['lightgallery']['autoplay_controls']) ? $this->options['lightgallery']['autoplay_controls'] : TRUE,
    '#description' => t('Show/hide autoplay controls.'),
  );

  // FULL SCREEN OPTIONS.
  $form['lightgallery_full_screen'] = array(
    '#type' => 'fieldset',
    '#title' => t('Lightgallery fullscreen settings'),
    '#collapsible' => TRUE,
    '#collapsed' => isset($this->options['lightgallery']['full_screen']) ? !$this->options['lightgallery']['full_screen'] : FALSE,
  );
  $form['lightgallery_full_screen']['full_screen'] = array(
    '#type' => 'checkbox',
    '#title' => t('Full screen'),
    '#default_value' => isset($this->options['lightgallery']['full_screen']) ? $this->options['lightgallery']['full_screen'] : TRUE,
    '#description' => t('Enable/Disable fullscreen mode.'),
  );

  // PAGER OPTIONS.
  $form['lightgallery_pager'] = array(
    '#type' => 'fieldset',
    '#title' => t('Lightgallery pager settings'),
    '#collapsible' => TRUE,
    '#collapsed' => isset($this->options['lightgallery']['pager']) ? !$this->options['lightgallery']['pager'] : FALSE,
  );
  $form['lightgallery_pager']['pager'] = array(
    '#type' => 'checkbox',
    '#title' => t('Pager'),
    '#default_value' => isset($this->options['lightgallery']['pager']) ? $this->options['lightgallery']['pager'] : TRUE,
    '#description' => t('Enable/Disable pager.'),
  );

  // ZOOM OPTIONS.
  $form['lightgallery_zoom'] = array(
    '#type' => 'fieldset',
    '#title' => t('Lightgallery zoom settings'),
    '#collapsible' => TRUE,
    '#collapsed' => isset($this->options['lightgallery']['zoom']) ? !$this->options['lightgallery']['zoom'] : FALSE,
  );
  $form['lightgallery_zoom']['zoom'] = array(
    '#type' => 'checkbox',
    '#title' => t('Zoom'),
    '#default_value' => isset($this->options['lightgallery']['zoom']) ? $this->options['lightgallery']['zoom'] : TRUE,
    '#description' => t('Enable/Disable zoom option.'),
  );
  $form['lightgallery_zoom']['scale'] = array(
    '#type' => 'select',
    '#title' => t('Scale'),
    '#options' => drupal_map_assoc(array(
      1,
      2,
      3,
      4,
    )),
    '#default_value' => isset($this->options['lightgallery']['scale']) ? $this->options['lightgallery']['scale'] : 1,
    '#description' => t('Value of zoom that should be incremented/decremented.'),
  );

  // HASH OPTIONS.
  $form['lightgallery_hash'] = array(
    '#type' => 'fieldset',
    '#title' => t('Lightgallery hash settings'),
    '#collapsible' => TRUE,
    '#collapsed' => isset($this->options['lightgallery']['hash']) ? !$this->options['lightgallery']['hash'] : FALSE,
  );
  $form['lightgallery_hash']['hash'] = array(
    '#type' => 'checkbox',
    '#title' => t('Update hash in url'),
    '#default_value' => isset($this->options['lightgallery']['hash']) ? $this->options['lightgallery']['hash'] : TRUE,
    '#description' => t('Enable/Disable hash option.'),
  );
  $form['lightgallery_hash']['gallery_id'] = array(
    '#type' => 'textfield',
    '#title' => t('Gallery ID'),
    '#default_value' => isset($this->options['lightgallery']['gallery_id']) ? $this->options['lightgallery']['gallery_id'] : 1,
    '#description' => t('Unique id for each gallery. It is mandatory when you use hash plugin for multiple galleries on the same page.'),
  );
}