You are here

function follow_parse_url in Follow 6

Same name and namespace in other branches
  1. 5 follow.module \follow_parse_url()
  2. 7.2 follow.inc \follow_parse_url()
  3. 7 follow.module \follow_parse_url()

Split a Drupal path or external link into path and options like a menu link.

3 calls to follow_parse_url()
follow_link_save in ./follow.module
Inserts a new link, or updates an existing one.
follow_update_6001 in ./follow.install
Update existing data to the new schema.
follow_url_validate in ./follow.module
Validates the url field to verify it's actually a url.

File

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

Code

function follow_parse_url($url) {
  $parsed_url = parse_url($url);
  $defaults = array(
    'scheme' => '',
    'host' => '',
    'port' => '',
    'path' => '/',
    'query' => '',
    'fragment' => '',
  );
  $parsed_url += $defaults;
  $options = array(
    'query' => array(),
    'fragment' => $parsed_url['fragment'],
  );

  // Parse the query string into an array.
  parse_str($parsed_url['query'], $options['query']);
  if ($parsed_url['scheme']) {
    $parsed_url['scheme'] .= '://';
  }

  // Throw away port for now.
  $path = $parsed_url['scheme'] . $parsed_url['host'] . $parsed_url['path'];
  return array(
    'path' => $path,
    'options' => $options,
  );
}