You are here

function shrinktheweb_admin_settings_validate in ShrinkTheWeb 6

Same name and namespace in other branches
  1. 7 shrinktheweb.admin.inc \shrinktheweb_admin_settings_validate()

File

./shrinktheweb.admin.inc, line 321

Code

function shrinktheweb_admin_settings_validate($form, &$form_state) {
  $cache_days = $form_state['values']['shrinktheweb_cache_days'];
  if (!empty($cache_days)) {
    if (!is_numeric($cache_days)) {
      form_set_error('shrinktheweb_cache_days', t('You must enter an integer for days in cache.'));
    }
    else {
      if ($cache_days < -1) {
        form_set_error('shrinktheweb_cache_days', t('Number of days in cache must be greater then -1.'));
      }
    }
  }
  $thumb_size_custom = $form_state['values']['shrinktheweb_thumb_size_custom'];
  if (!empty($thumb_size_custom)) {
    if (!is_numeric($thumb_size_custom)) {
      form_set_error('shrinktheweb_', t('You must enter an integer for custom thumb size.'));
    }
    else {
      if ($thumb_size_custom < 0) {
        form_set_error('shrinktheweb_', t('Custom thumb size must be positive.'));
      }
    }
  }
  $max_height = $form_state['values']['shrinktheweb_max_height'];
  if (!empty($max_height)) {
    if (!is_numeric($max_height)) {
      form_set_error('shrinktheweb_', t('You must enter an integer for maximum height.'));
    }
    else {
      if ($max_height < 0) {
        form_set_error('shrinktheweb_', t('Maximum height must be positive.'));
      }
    }
  }
  $native_res = $form_state['values']['shrinktheweb_native_res'];
  if (!empty($native_res)) {
    if (!is_numeric($native_res)) {
      form_set_error('shrinktheweb_', t('You must enter an integer for native resolution.'));
    }
    else {
      if ($native_res < 0) {
        form_set_error('shrinktheweb_', t('Native resolution must be positive.'));
      }
    }
  }
  $widescreen_y = $form_state['values']['shrinktheweb_widescreen_y'];
  if (!empty($widescreen_y)) {
    if (!is_numeric($widescreen_y)) {
      form_set_error('shrinktheweb_', t('You must enter an integer for widescreen Y.'));
    }
    else {
      if ($widescreen_y < 0) {
        form_set_error('shrinktheweb_', t('Widescreen Y must be positive.'));
      }
    }
  }
  $delay = $form_state['values']['shrinktheweb_delay'];
  if (!empty($delay)) {
    if (!is_numeric($delay)) {
      form_set_error('shrinktheweb_', t('You must enter an integer for delay.'));
    }
    else {
      if ($delay < 0 || $delay > 45) {
        form_set_error('shrinktheweb_', t('Delay must be between 0 and 45.'));
      }
    }
  }
  $quality = $form_state['values']['shrinktheweb_quality'];
  if (!empty($quality)) {
    if (!is_numeric($quality)) {
      form_set_error('shrinktheweb_', t('You must enter an integer for quality.'));
    }
    else {
      if ($quality < 0 || $quality > 100) {
        form_set_error('shrinktheweb_', t('Quality must be between 0 and 100.'));
      }
    }
  }
}