function _adsense_search_settings_validate in Google AdSense integration 6
Same name and namespace in other branches
- 5.3 old/search/adsense_search.admin.inc \_adsense_search_settings_validate()
- 7 old/search/adsense_search.admin.inc \_adsense_search_settings_validate()
Validate adsense_search_settings form.
1 string reference to '_adsense_search_settings_validate'
- adsense_search_settings in old/
search/ adsense_search.admin.inc - Menu callback for the adsense_search module settings form.
File
- old/
search/ adsense_search.admin.inc, line 262 - Contains the administrative functions of the adsense_search module.
Code
function _adsense_search_settings_validate($form, &$form_state) {
$textbox_length = $form_state['values']['adsense_search_textbox_length'];
$min = 8;
$max = 64;
if ($textbox_length < $min || $textbox_length > $max) {
form_set_error('adsense_search_textbox_length', t("Text Box Length must be between !min and !max", array(
'!min' => $min,
'!max' => $max,
)));
}
$number_blocks = $form_state['values']['adsense_search_number_blocks'];
if ($number_blocks < 0) {
form_set_error('adsense_search_number_blocks', t("Number of blocks can't be a negative number"));
}
$colors = array(
'adsense_search_color_border',
'adsense_search_color_title',
'adsense_search_color_bg',
'adsense_search_color_text',
'adsense_search_color_url',
'adsense_search_color_visited_url',
'adsense_search_color_light_url',
'adsense_search_color_logo_bg',
);
foreach ($colors as $field_name) {
$field_value = $form_state['values'][$field_name];
$form_state['values'][$field_name] = drupal_strtoupper($field_value);
if (!preg_match('/#[0-9A-F]{6}/i', $field_value)) {
form_set_error($field_name, t("Color must be between #000000 and #FFFFFF"));
}
}
$box_background_color = $form_state['values']['adsense_search_color_box_background'];
if ($box_background_color == '#000000') {
$form_state['values']['adsense_search_color_box_text'] = '#FFFFFF';
}
elseif ($box_background_color == '#FFFFFF') {
$form_state['values']['adsense_search_color_box_text'] = '#000000';
}
}