You are here

public function JuiceboxGalleryDrupal::confBaseForm in Juicebox HTML5 Responsive Image Galleries 7.2

Get common elements for Juicebox configuration forms.

Several Juicebox gallery types can share common options and structures. These can be merged into the appropriate forms via a call to this method.

Parameters

array $form: The Drupal form array that common elements should be added to.

array $settings: An associative array containing all the current settings for a Juicebox gallery (used to set default values).

Return value

array The common form elements merged within a form array.

Overrides JuiceboxGalleryDrupalInterface::confBaseForm

File

includes/JuiceboxGalleryDrupal.inc, line 401
Class to extend a JuiceboxGalleryDecorator object with Drupal-specific logic and structures.

Class

JuiceboxGalleryDrupal
Class to extend a JuiceboxGalleryDecorator object with Drupal-specific logic and structures.

Code

public function confBaseForm($form, $settings) {

  // Get locally installed library details.
  $library = $this->library;
  $disallowed_conf = array();
  if (!empty($library)) {

    // If we don't have a known version of the Juicebox library, just show a
    // generic warning.
    if (empty($library['version'])) {
      $notification_top = t('<strong>Notice:</strong> Your Juicebox Library version could not be detected. Some options below may not function correctly.');
    }
    elseif (!empty($library['disallowed_conf'])) {
      $disallowed_conf = $library['disallowed_conf'];
      $notification_top = t('<strong>Notice:</strong> You are currently using Juicebox library version <strong>@version</strong> which is not compatible with some of the options listed below. These options will appear disabled until you upgrade to the most recent Juicebox library version.', array(
        '@version' => $library['version'],
      ));
      $notification_label = t('&nbsp;(not available in @version)', array(
        '@version' => $library['version'],
      ));
    }
  }
  else {
    $notification_top = t('The Juicebox Javascript library does not appear to be installed. Please download and install the most recent version of the Juicebox library.');
    drupal_set_message($notification_top, 'error');
  }
  $form['juicebox_config'] = array(
    '#type' => 'fieldset',
    '#title' => t('Juicebox Library - Lite Config'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => !empty($notification_top) ? '<p>' . $notification_top . '</p>' : '',
    '#weight' => 10,
  );
  $form['jlib_galleryWidth'] = array(
    '#jb_fieldset' => 'juicebox_config',
    '#type' => 'textfield',
    '#title' => t('Gallery Width'),
    '#description' => t('Set the gallery width in a standard numeric format (such as 100% or 300px).'),
    '#element_validate' => array(
      'juicebox_element_validate_dimension',
    ),
  );
  $form['jlib_galleryHeight'] = array(
    '#jb_fieldset' => 'juicebox_config',
    '#type' => 'textfield',
    '#title' => t('Gallery Height'),
    '#description' => t('Set the gallery height in a standard numeric format (such as 100% or 300px).'),
    '#element_validate' => array(
      'juicebox_element_validate_dimension',
    ),
  );
  $form['jlib_backgroundColor'] = array(
    '#jb_fieldset' => 'juicebox_config',
    '#type' => 'textfield',
    '#title' => t('Background Color'),
    '#description' => t('Set the gallery background color as a CSS3 color value (such as rgba(10,50,100,0.7) or #FF00FF).'),
  );
  $form['jlib_textColor'] = array(
    '#jb_fieldset' => 'juicebox_config',
    '#type' => 'textfield',
    '#title' => t('Text Color'),
    '#description' => t('Set the color of all gallery text as a CSS3 color value (such as rgba(255,255,255,1) or #FF00FF).'),
  );
  $form['jlib_thumbFrameColor'] = array(
    '#jb_fieldset' => 'juicebox_config',
    '#type' => 'textfield',
    '#title' => t('Thumbnail Frame Color'),
    '#description' => t('Set the color of the thumbnail frame as a CSS3 color value (such as rgba(255,255,255,.5) or #FF00FF).'),
  );
  $form['jlib_showOpenButton'] = array(
    '#jb_fieldset' => 'juicebox_config',
    '#type' => 'checkbox',
    '#title' => t('Show Open Image Button'),
    '#description' => t('Whether to show the "Open Image" button. This will link to the full size version of the image within a new tab to facilitate downloading.'),
  );
  $form['jlib_showExpandButton'] = array(
    '#jb_fieldset' => 'juicebox_config',
    '#type' => 'checkbox',
    '#title' => t('Show Expand Button'),
    '#description' => t('Whether to show the "Expand" button. Clicking this button expands the gallery to fill the browser window.'),
  );
  $form['jlib_useFullscreenExpand'] = array(
    '#jb_fieldset' => 'juicebox_config',
    '#type' => 'checkbox',
    '#title' => t('Use Fullscreen Expand'),
    '#description' => t('Whether to trigger fullscreen mode when clicking the expand button (for supported browsers).'),
  );
  $form['jlib_showThumbsButton'] = array(
    '#jb_fieldset' => 'juicebox_config',
    '#type' => 'checkbox',
    '#title' => t('Show Thumbs Button'),
    '#description' => t('Whether to show the "Toggle Thumbnails" button.'),
  );
  $form['jlib_useThumbDots'] = array(
    '#jb_fieldset' => 'juicebox_config',
    '#type' => 'checkbox',
    '#title' => t('Show Thumbs Dots'),
    '#description' => t('Whether to replace the thumbnail images with small dots.'),
  );
  $form['juicebox_manual_config'] = array(
    '#type' => 'fieldset',
    '#title' => t('Juicebox Library - Pro / Manual Config'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => '<p>' . t('Specify any additional Juicebox library configuration options (such as "Pro" options) here.<br/>Options set here always take precedence over those set in the "Lite" options above if there is a conflict.') . '</p>',
    '#weight' => 20,
  );
  $form['manual_config'] = array(
    '#jb_fieldset' => 'juicebox_manual_config',
    '#type' => 'textarea',
    '#title' => t('Pro / Manual Configuraton Options'),
    '#description' => t('Add one option per line in the format <strong>optionName="optionValue"</strong><br/>See also: http://www.juicebox.net/support/config_options'),
    '#element_validate' => array(
      'juicebox_element_validate_config',
    ),
  );
  $form['advanced'] = array(
    '#type' => 'fieldset',
    '#title' => t('Juicebox - Advanced Options'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => 30,
  );
  $form['incompatible_file_action'] = array(
    '#jb_fieldset' => 'advanced',
    '#type' => 'select',
    '#title' => t('Incompatible File Type Handling'),
    '#options' => array(
      'skip' => 'Bypass incompatible files',
      'show_icon' => 'Show mimetype icon placehoder',
      'show_icon_and_link' => 'Show mimetype icon placholder and link to file',
    ),
    '#empty_option' => t('Do nothing'),
    '#description' => t('Specify any special handling that should be applied to files that Juicebox cannot display (non-images).'),
  );
  $form['linkurl_source'] = array(
    '#jb_fieldset' => 'advanced',
    '#type' => 'select',
    '#title' => t("LinkURL Source"),
    '#description' => t('The linkURL is an image-specific path for accessing each image outside the gallery. This is used by features such as the "Open Image Button".'),
    '#options' => array(
      'image_styled' => 'Main Image - Styled (use this gallery\'s main image style setting)',
    ),
    '#empty_option' => t('Main Image - Unstyled (original image)'),
  );
  $form['linkurl_target'] = array(
    '#jb_fieldset' => 'advanced',
    '#type' => 'select',
    '#title' => t('LinkURL Target'),
    '#options' => array(
      '_blank' => '_blank',
      '_self' => '_self',
      '_parent' => '_parent',
      '_top' => '_top',
    ),
    '#description' => t('Specify a target for any links that make user of the image linkURL.'),
  );
  $form['custom_parent_classes'] = array(
    '#jb_fieldset' => 'advanced',
    '#type' => 'textfield',
    '#title' => t('Custom Classes for Parent Container'),
    '#description' => t('Define any custom classes that should be added to the parent container within the Juicebox embed markup.<br/>This can be handy if you want to apply more advanced styling or dimensioning rules to this gallery via CSS. Enter as space-separated values.'),
  );

  // Set values that are directly related to each key.
  foreach ($form as $conf_key => &$conf_value) {
    if (!empty($conf_value['#type']) && $conf_value['#type'] != 'fieldset') {
      $conf_value['#default_value'] = $settings[$conf_key];
      if (in_array($conf_key, $disallowed_conf)) {
        $conf_value['#title'] .= $notification_label;
        $conf_value['#disabled'] = TRUE;
      }
    }
  }

  // Add a pre render callback that will ensure that the items are nested
  // correctly into fieldsets just before display.
  $form['#pre_render'] = array(
    'juicebox_form_pre_render_fieldsets',
  );
  return $form;
}