function _juicebox_common_form_elements in Juicebox HTML5 Responsive Image Galleries 7
Helper to add common elements to Juicebox configuration forms.
Both the field formatter and view plugin share some common configuration options and structures. These are merged into the appropriate forms via a call to this function.
Parameters
array $form: The Drupal form array that common elements should be added to.
array $settings: An associative array containing all the settings for a Juicebox gallery (used to set default values).
Return value
array The merged form array.
2 calls to _juicebox_common_form_elements()
- juicebox_field_formatter_settings_form in ./
juicebox.module - Implements hook_field_formatter_settings_form().
- juicebox_style_plugin::options_form in plugins/
juicebox_style_plugin.inc - Define plugin options form.
File
- ./
juicebox.module, line 630 - Provides Drupal integration with the Juicebox library.
Code
function _juicebox_common_form_elements($form, $settings) {
// Get locally installed library details.
$library = _juicebox_library_detect();
$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(' (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.'),
'#default_value' => $settings['jlib_useThumbDots'],
);
$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['apply_markup_filter'] = array(
'#jb_fieldset' => 'advanced',
'#type' => 'checkbox',
'#title' => t('Filter title and caption output for compatibility with Juicebox javascript (recommended)'),
'#description' => t('This option helps ensure title/caption output is syntactically compatible with the Juicebox javascript library by removing block-level tags.'),
);
$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;
}
}
}
$form['#pre_render'] = array(
'_juicebox_form_pre_render_add_fieldset_markup',
);
return $form;
}