You are here

function galleria_admin_settings_validate in Galleria 6

Validation for the administration form.

File

./galleria.admin.inc, line 199
Administration callbacks for the galleria module.

Code

function galleria_admin_settings_validate($form, &$form_state) {
  if (module_exists('jcarousel')) {
    $input_names = array(
      'visible' => t('Limit of visible thumbnails'),
      'scroll' => t('Scroll size'),
    );
    foreach ($input_names as $name => $title) {
      $value =& $form_state['values']['galleria_jcarousel_' . $name];
      if (!is_numeric($value)) {
        form_set_error('galleria_jcarousel_' . $name, t('"' . $title . '" must be an integer.'));
      }
      else {
        $value = intval($value);
      }
    }

    // The "visible" setting cannot be 0, otherwise the carousel explodes in IE.
    if ($form_state['values']['galleria_jcarousel_visible'] == 0) {
      form_set_error('galleria_jcarousel_visible', t('"Limit of visible thumbnails" must be greater than zero.'));
    }
    $animation =& $form_state['values']['galleria_jcarousel_animation'];
    switch ($animation) {
      case 'slow':
      case 'normal':
      case 'fast':
        break;
      default:
        if (!is_numeric($animation)) {
          form_set_error('galleria_jcarousel_animation', t('"Animation speed" must be "slow", "normal", "fast", or an integer value.'));
        }
        else {
          $animation = intval($animation);
        }
        break;
    }
  }
}