Commit 6614297d authored by frjo's avatar frjo
Browse files

Issue #1877060 by DoctorWho, frjo: Custom gallery value should allow hyphens.

parent 8ba01e89
......@@ -310,15 +310,12 @@ function colorbox_field_formatter_settings_form($field, $instance, $view_mode, $
);
$element['colorbox_gallery_custom'] = array(
'#title' => t('Custom gallery'),
'#type' => 'machine_name',
'#type' => 'textfield',
'#maxlength' => 32,
'#default_value' => $settings['colorbox_gallery_custom'],
'#description' => t('All images on a page with the same gallery value (rel attribute) will be grouped together. It must only contain lowercase letters, numbers, and underscores.'),
'#description' => t('All images on a page with the same gallery value (rel attribute) will be grouped together. It must only contain lowercase letters, numbers, hyphen and underscores.'),
'#element_validate' => array('colorbox_gallery_custom_validate'),
'#required' => FALSE,
'#machine_name' => array(
'exists' => 'colorbox_gallery_exists',
'error' => t('The custom gallery field must only contain lowercase letters, numbers, and underscores.'),
),
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][colorbox_gallery]"]' => array('value' => 'custom'),
......@@ -384,6 +381,15 @@ function colorbox_field_formatter_settings_form($field, $instance, $view_mode, $
return $element;
}
/**
* Validate function for colorbox_gallery_custom.
*/
function colorbox_gallery_custom_validate($element, &$form_state) {
if ($element['#value'] != drupal_html_class($element['#value'])) {
form_error($element, t('%name must only contain lowercase letters, numbers, hyphen and underscores.', array('%name' => $element['#title'])));
}
}
/**
* Implements hook_field_formatter_settings_summary().
*/
......
......@@ -162,14 +162,14 @@ If you would like to have the characters %5B and %5D please use the html entity
$tokens = $this->get_render_tokens($this->options['alter']);
$popup = filter_xss_admin($this->options['popup']);
$caption = filter_xss_admin($this->options['caption']);
$gallery = filter_xss_admin($this->options['custom_gid']);
$gallery = drupal_html_class($this->options['custom_gid']);
$popup = strtr($popup, $tokens);
$caption = strtr($caption, $tokens);
$gallery = strtr($gallery, $tokens);
$width = $this->options['width'] ? $this->options['width'] : '';
$height = $this->options['height'] ? $this->options['height'] : '';
$gallery_id = !empty($this->options['custom_gid']) ? $gallery : ($this->options['gid'] ? 'gallery-' . $this->view->name : '');
$gallery_id = !empty($gallery) ? $gallery : ($this->options['gid'] ? 'gallery-' . $this->view->name : '');
$link_text = $tokens["[{$this->options['trigger_field']}]"];
$link_options = array(
'html' => TRUE,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment