You are here

function twitter_profile_widget_admin_validate in Twitter Profile Widget 6

Same name and namespace in other branches
  1. 7 twitter_profile_widget.admin.inc \twitter_profile_widget_admin_validate()

Validate widget admin form

1 string reference to 'twitter_profile_widget_admin_validate'
twitter_profile_widget_admin in ./twitter_profile_widget.admin.inc
Admin form for twitter widget

File

./twitter_profile_widget.admin.inc, line 317
Administative functions for the twitter profile widget module.

Code

function twitter_profile_widget_admin_validate($form, &$form_state) {
  $values = $form_state['values'];
  if (drupal_strlen($values['twitter_profile_widget_username']) < 2) {
    form_set_error('twitter_profile_widget_username', t('Please, enter correct username'));
  }
  if (!ctype_digit($values['twitter_profile_widget_post_amount']) || $values['twitter_profile_widget_post_amount'] < 1 || $values['twitter_profile_widget_post_amount'] > 30) {
    form_set_error('twitter_profile_widget_post_amount', t('Please, enter only digits from 1 to 30 in Post amount field'));
  }
  if (!ctype_digit($values['twitter_profile_widget_tweet_intervals']) || $values['twitter_profile_widget_tweet_intervals'] < 1 || $values['twitter_profile_widget_tweet_intervals'] > 20) {
    form_set_error('twitter_profile_widget_tweet_intervals', t('Please, enter only digits from 1 to 20 in Twitter interval field'));
  }
  if (!ctype_xdigit($values['twitter_profile_widget_shell_bg_color'])) {
    form_set_error('twitter_profile_widget_shell_bg_color', t('Shell background color field allows only "01234567890" digits and "abcdefABCDEF" chars'));
  }
  if (drupal_strlen($values['twitter_profile_widget_shell_bg_color']) != 6) {
    form_set_error('twitter_profile_widget_shell_bg_color', t('Shell background color field must contain 6 characters'));
  }
  if (!ctype_xdigit($values['twitter_profile_widget_shell_text_color'])) {
    form_set_error('twitter_profile_widget_shell_text_color', t('Shell text color field allows only "01234567890" digits and "abcdefABCDEF" chars'));
  }
  if (drupal_strlen($values['twitter_profile_widget_shell_text_color']) != 6) {
    form_set_error('twitter_profile_widget_shell_text_color', t('Shell text color field must contain 6 characters'));
  }
  if (!ctype_xdigit($values['twitter_profile_widget_tweet_bg_color'])) {
    form_set_error('twitter_profile_widget_tweet_bg_color', t('Tweet background color field allows only "01234567890" digits and "abcdefABCDEF" chars'));
  }
  if (drupal_strlen($values['twitter_profile_widget_tweet_bg_color']) != 6) {
    form_set_error('twitter_profile_widget_tweet_bg_color', t('Tweet background color field must contain 6 characters'));
  }
  if (!ctype_xdigit($values['twitter_profile_widget_tweet_text_color'])) {
    form_set_error('twitter_profile_widget_tweet_text_color', t('Tweet text color field allows only "01234567890" digits and "abcdefABCDEF" chars'));
  }
  if (drupal_strlen($values['twitter_profile_widget_tweet_text_color']) != 6) {
    form_set_error('twitter_profile_widget_tweet_text_color', t('Tweet text color field must contain 6 characters'));
  }
  if (!ctype_xdigit($values['twitter_profile_widget_tweet_links_color'])) {
    form_set_error('twitter_profile_widget_tweet_links_color', t('Tweet links color field allows only "01234567890" digits and "abcdefABCDEF" chars'));
  }
  if (drupal_strlen($values['twitter_profile_widget_tweet_links_color']) != 6) {
    form_set_error('twitter_profile_widget_tweet_links_color', t('Tweet links color field must contain 6 characters'));
  }
  if (drupal_substr(trim($values['twitter_profile_widget_follow_us_link']), 0, 7) != 'http://') {
    form_set_error('twitter_profile_widget_follow_us_link', t('Follow us link should start with "http://"'));
  }
  if (!ctype_digit($values['twitter_profile_widget_width']) || $values['twitter_profile_widget_width'] < 1) {
    form_set_error('twitter_profile_widget_width', t('Please, enter only digital values in Twitter widget width field'));
  }
  if (!ctype_digit($values['twitter_profile_widget_height']) || $values['twitter_profile_widget_height'] < 1) {
    form_set_error('twitter_profile_widget_height', t('Please, enter only digital values in Twitter widget height field'));
  }
}