function feeds_imagegrabber_form_validate in Feeds Image Grabber 6
Same name and namespace in other branches
- 7 feeds_imagegrabber.module \feeds_imagegrabber_form_validate()
2 string references to 'feeds_imagegrabber_form_validate'
- feeds_imagegrabber_admin in ./
feeds_imagegrabber.module - Implementation of the default settings admin form.
- feeds_imagegrabber_form_alter in ./
feeds_imagegrabber.module - Implementation of hook_form_alter().
File
- ./
feeds_imagegrabber.module, line 66 - Grabs image for each feed-item from their respective web pages and stores it in an image field. Requires Feeds module.
Code
function feeds_imagegrabber_form_validate($form, &$form_state) {
if ($form_state['values']['feeds_imagegrabber']['enabled'] == 1) {
$id_class = $form_state['values']['feeds_imagegrabber']['id_class'];
$id_class_desc = $form_state['values']['feeds_imagegrabber']['id_class_desc'];
if ($id_class) {
if (!isset($id_class_desc) || empty($id_class_desc) || $id_class_desc == '') {
form_set_error('feeds_imagegrabber][id_class_desc', "Specify the id/class of the desired tag.");
}
if ($id_class == 1 && !preg_match('/^[a-zA-Z]+[_a-zA-Z0-9-]*$/', $id_class_desc)) {
form_set_error('feeds_imagegrabber][id_class_desc', "Only alphabets, digits, hyphens and underscores are allowed in HTML id");
}
else {
if ($id_class == 2 && !preg_match('/^[a-zA-Z]+[_a-zA-Z0-9- ]*$/', $id_class_desc)) {
form_set_error('feeds_imagegrabber][id_class_desc', "Only alphabets, digits, hyphens, spaces and underscores are allowed in HTML class");
}
}
}
else {
form_set_value($form['feeds_imagegrabber']['id_class_desc'], '', $form_state);
}
$temp = $form_state['values']['feeds_imagegrabber']['exec_time'];
if (!is_numeric($temp) || $temp < 10 || $temp != round($temp) || $temp > 75) {
form_set_error('feeds_imagegrabber][exec_time', t('Select the correct option for FIG execution time.'));
}
}
}