You are here

function front_page_parse_url in Front Page 7.2

Same name and namespace in other branches
  1. 8 front_page.module \front_page_parse_url()
  2. 6.2 front_page.module \front_page_parse_url()
  3. 7 front_page.module \front_page_parse_url()
  4. 9.1.x front_page.module \front_page_parse_url()

Function to parse a full URL including GET variables and fragment to an array ready for drupal_goto(), url(), or l() functions.

1 call to front_page_parse_url()
front_page_init in ./front_page.module
Implements hook_init().

File

./front_page.module, line 186

Code

function front_page_parse_url($path) {
  $url['path'] = $path;
  $url['options'] = array();
  if (preg_match('@^(?P<path>[^?#]+)(\\?(?P<query>[^#]*))?(#(?P<fragment>.*))?$@', $path, $match)) {
    $url['path'] = $match['path'];
    if (!empty($match['query'])) {
      foreach (explode('&', $match['query']) as $query_part) {
        list($key, $value) = explode('=', $query_part);
        $url['options']['query'][$key] = $value;
      }
    }
    if (!empty($match['fragment'])) {
      $url['options']['fragment'] = $match['fragment'];
    }
  }

  // if the token module exists then replace any tokens in the path
  if (module_exists('token')) {
    $url['path'] = token_replace($url['path']);
  }
  return $url;
}