Révision e33d3026
Ajouté par Julien Enselme il y a presque 10 ans
drupal7/includes/common.inc | ||
---|---|---|
544 | 544 |
} |
545 | 545 |
|
546 | 546 |
/** |
547 |
* Parses a system URL string into an associative array suitable for url().
|
|
547 |
* Parses a URL string into its path, query, and fragment components.
|
|
548 | 548 |
* |
549 |
* This function should only be used for URLs that have been generated by the |
|
550 |
* system, such as via url(). It should not be used for URLs that come from |
|
551 |
* external sources, or URLs that link to external resources. |
|
549 |
* This function splits both internal paths like @code node?b=c#d @endcode and |
|
550 |
* external URLs like @code https://example.com/a?b=c#d @endcode into their |
|
551 |
* component parts. See |
|
552 |
* @link http://tools.ietf.org/html/rfc3986#section-3 RFC 3986 @endlink for an |
|
553 |
* explanation of what the component parts are. |
|
552 | 554 |
* |
553 |
* The returned array contains a 'path' that may be passed separately to url(). |
|
554 |
* For example: |
|
555 |
* @code |
|
556 |
* $options = drupal_parse_url($_GET['destination']); |
|
557 |
* $my_url = url($options['path'], $options); |
|
558 |
* $my_link = l('Example link', $options['path'], $options); |
|
559 |
* @endcode |
|
555 |
* Note that, unlike the RFC, when passed an external URL, this function |
|
556 |
* groups the scheme, authority, and path together into the path component. |
|
560 | 557 |
* |
561 |
* This is required, because url() does not support relative URLs containing a |
|
562 |
* query string or fragment in its $path argument. Instead, any query string |
|
563 |
* needs to be parsed into an associative query parameter array in |
|
564 |
* $options['query'] and the fragment into $options['fragment']. |
|
565 |
* |
|
566 |
* @param $url |
|
567 |
* The URL string to parse, f.e. $_GET['destination']. |
|
558 |
* @param string $url |
|
559 |
* The internal path or external URL string to parse. |
|
568 | 560 |
* |
569 |
* @return |
|
570 |
* An associative array containing the keys:
|
|
571 |
* - 'path': The path of the URL. If the given $url is external, this includes
|
|
572 |
* the scheme and host.
|
|
573 |
* - 'query': An array of query parameters of $url, if existent.
|
|
574 |
* - 'fragment': The fragment of $url, if existent.
|
|
561 |
* @return array
|
|
562 |
* An associative array containing: |
|
563 |
* - path: The path component of $url. If $url is an external URL, this
|
|
564 |
* includes the scheme, authority, and path.
|
|
565 |
* - query: An array of query parameters from $url, if they exist.
|
|
566 |
* - fragment: The fragment component from $url, if it exists.
|
|
575 | 567 |
* |
576 |
* @see url() |
|
577 | 568 |
* @see drupal_goto() |
569 |
* @see l() |
|
570 |
* @see url() |
|
571 |
* @see http://tools.ietf.org/html/rfc3986 |
|
572 |
* |
|
578 | 573 |
* @ingroup php_wrappers |
579 | 574 |
*/ |
580 | 575 |
function drupal_parse_url($url) { |
Formats disponibles : Unified diff
Update drupal to 7.30