function shadowbox_global_settings_validate in Shadowbox 7.3
Same name and namespace in other branches
- 5.2 shadowbox.module \shadowbox_global_settings_validate()
- 6.4 shadowbox.admin.inc \shadowbox_global_settings_validate()
- 6.2 shadowbox.module \shadowbox_global_settings_validate()
- 6.3 shadowbox.admin.inc \shadowbox_global_settings_validate()
- 7.4 shadowbox.admin.inc \shadowbox_global_settings_validate()
Validate admin settings form inputs.
File
- ./
shadowbox.admin.inc, line 346 - Administrative interface for the Shadowbox module.
Code
function shadowbox_global_settings_validate($form, &$form_state) {
$color = $form_state['values']['shadowbox_overlay_color'];
$opacity = $form_state['values']['shadowbox_overlay_opacity'];
$slideshow_delay = $form_state['values']['shadowbox_slideshow_delay'];
$resize_duration = $form_state['values']['shadowbox_resize_duration'];
$fade_duration = $form_state['values']['shadowbox_fade_duration'];
$viewport_padding = $form_state['values']['shadowbox_viewport_padding'];
$initial_height = $form_state['values']['shadowbox_initial_height'];
$initial_width = $form_state['values']['shadowbox_initial_width'];
$counter_limit = $form_state['values']['shadowbox_counter_limit'];
if (!is_numeric($resize_duration) || $resize_duration < 0 || $resize_duration > 10) {
form_set_error('shadowbox_resize_duration', t('You must enter a number between 0 and 10.'));
}
if (!is_numeric($fade_duration) || $fade_duration < 0 || $fade_duration > 10) {
form_set_error('shadowbox_fade_duration', t('You must enter a number between 0 and 10.'));
}
if (!is_numeric($initial_height)) {
form_set_error('shadowbox_initial_height', t('You must enter a number.'));
}
else {
$form_state['values']['shadowbox_initial_height'] = floor($initial_height);
}
if (!is_numeric($initial_width)) {
form_set_error('shadowbox_initial_width', t('You must enter a number.'));
}
else {
$form_state['values']['shadowbox_initial_width'] = floor($initial_width);
}
if (!_validate_hex_color($color)) {
form_set_error('shadowbox_overlay_color', t('You must enter a properly formed hex value (e.g. 000 or 000000 for black.)'));
}
if ($opacity == '' || floor($opacity) != 0 && $opacity != 1) {
form_set_error('shadowbox_overlay_opacity', t('You must enter a decimal number between 0 and 1.'));
}
if (!is_numeric($viewport_padding) || $viewport_padding < 0 || $viewport_padding > 200) {
form_set_error('shadowbox_viewport_padding', t('You must enter a number between 0 and 200.'));
}
else {
$form_state['values']['shadowbox_viewport_padding'] = (int) $viewport_padding;
}
}