You are here

function _adsense_cse_settings_validate in Google AdSense integration 7

Same name and namespace in other branches
  1. 5.3 cse/adsense_cse.admin.inc \_adsense_cse_settings_validate()
  2. 6 cse/adsense_cse.admin.inc \_adsense_cse_settings_validate()

Validate adsense_cse_settings form.

1 string reference to '_adsense_cse_settings_validate'
adsense_cse_settings in cse/adsense_cse.admin.inc
Menu callback for the adsense_cse module settings form.

File

cse/adsense_cse.admin.inc, line 145
Contains the administrative functions of the adsense_cse module.

Code

function _adsense_cse_settings_validate($form, &$form_state) {
  $textbox_length = $form_state['values']['adsense_cse_textbox_length'];
  $min = 8;
  $max = 64;
  if ($textbox_length < $min || $textbox_length > $max) {
    form_set_error('adsense_cse_textbox_length', t("Text Box Length must be between !min and !max", array(
      '!min' => $min,
      '!max' => $max,
    )));
  }
  $min = $form_state['values']['adsense_cse_ad_location'] == 'adsense_cse_loc_top_bottom' ? 500 : 795;
  $max = 10000;
  $frame_width = $form_state['values']['adsense_cse_frame_width'];
  if ($frame_width < $min || $frame_width > $max) {
    form_set_error('adsense_cse_frame_width', t("Results area width must be between !min and !max", array(
      '!min' => $min,
      '!max' => $max,
    )));
  }
  $number_blocks = $form_state['values']['adsense_cse_number_blocks'];
  if ($number_blocks < 0) {
    form_set_error('adsense_cse_number_blocks', t("Number of blocks can't be a negative number"));
  }
}