You are here

function follow_url_validate in Follow 7

Same name and namespace in other branches
  1. 6 follow.module \follow_url_validate()
  2. 7.2 follow.inc \follow_url_validate()

Validates the url field to verify it's actually a url.

1 string reference to 'follow_url_validate'
_follow_links_form_link in ./follow.module
Helper function to create an individual link form element.

File

./follow.module, line 571
Allows users to add links to their social network profiles.

Code

function follow_url_validate($form) {
  $url = trim($form['#value']);
  $networks = follow_networks_load($form['#follow_uid']);
  $info = $networks[$form['#follow_network']];
  $regex = follow_build_url_regex($info);
  $parsed = follow_parse_url($url);
  if ($url && !preg_match($regex, $parsed['path'])) {
    if (!empty($info['domain'])) {
      $message = t('The specified url is invalid for the domain %domain.  Make sure you use http://.', array(
        '%domain' => $info['domain'],
      ));
    }
    else {
      $message = t('The specified path is invalid.  Please enter a path on this site (e.g. rss.xml or taxonomy/term/1/feed).');
    }
    form_error($form, $message);
  }
}