Elgg  Version master
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Elgg\Http\Urls Class Reference

Create, sanitize and compare urls. More...

Public Member Functions

 addQueryElementsToUrl (string $url, array $elements)
 Sets elements in a URL's query string. More...
 
 addActionTokensToUrl (string $url, bool $html_encode=false)
 Adds action tokens to URL. More...
 
 buildUrl (array $parts, bool $html_encode=true)
 Builds a URL from the a parts array like one returned by parse_url(). More...
 
 normalizeUrl (string $url)
 
 isUrlIdentical (string $url1, string $url2, array $ignore_params)
 Test if two URLs are functionally identical. More...
 

Static Public Member Functions

static isValidMultiByteUrl (string $url)
 Use a "fixed" filter_var() with FILTER_VALIDATE_URL that handles multi-byte chars. More...
 

Protected Member Functions

 arrayDiffAssocRecursive ()
 Computes the difference of arrays with additional index check. More...
 

Detailed Description

Create, sanitize and compare urls.

Since
4.3

Definition at line 11 of file Urls.php.

Member Function Documentation

Elgg\Http\Urls::addActionTokensToUrl ( string  $url,
bool  $html_encode = false 
)

Adds action tokens to URL.

Use this function to append action tokens to a URL's GET parameters. This will preserve any existing GET parameters.

Parameters
string$urlFull action URL
bool$html_encodeHTML encode the url? (default: false)
Returns
string URL with action tokens
Examples:
/root/Elgg/engine/classes/Elgg/Http/Urls.php.

Definition at line 69 of file Urls.php.

Elgg\Http\Urls::addQueryElementsToUrl ( string  $url,
array  $elements 
)

Sets elements in a URL's query string.

Parameters
string$urlThe URL
array$elementsKey/value pairs to set in the URL. If the value is null, the element is removed from the URL.
Returns
string The new URL with the query strings added
Examples:
/root/Elgg/engine/classes/Elgg/Http/Urls.php.

Definition at line 22 of file Urls.php.

Elgg\Http\Urls::arrayDiffAssocRecursive ( )
protected

Computes the difference of arrays with additional index check.

Returns
array
See also
array_diff_assoc()
https://github.com/Elgg/Elgg/issues/13016
Examples:
/root/Elgg/engine/classes/Elgg/Http/Urls.php.

Definition at line 308 of file Urls.php.

Elgg\Http\Urls::buildUrl ( array  $parts,
bool  $html_encode = true 
)

Builds a URL from the a parts array like one returned by parse_url().

Note
If only partial information is passed, a partial URL will be returned.
Parameters
array$partsAssociative array of URL components like parse_url() returns 'user' and 'pass' parts are ignored because of security reasons
bool$html_encodeHTML Encode the url?
See also
https://github.com/Elgg/Elgg/pull/8146#issuecomment-91544585
Returns
string Full URL
Examples:
/root/Elgg/engine/classes/Elgg/Http/Urls.php.

Definition at line 106 of file Urls.php.

Elgg\Http\Urls::isUrlIdentical ( string  $url1,
string  $url2,
array  $ignore_params 
)

Test if two URLs are functionally identical.

If $ignore_params is used, neither the name nor its value will be considered when comparing.

The order of GET params doesn't matter.

Parameters
string$url1First URL
string$url2Second URL
array$ignore_paramsGET params to ignore in the comparison
Returns
bool
Examples:
/root/Elgg/engine/classes/Elgg/Http/Urls.php.

Definition at line 190 of file Urls.php.

static Elgg\Http\Urls::isValidMultiByteUrl ( string  $url)
static

Use a "fixed" filter_var() with FILTER_VALIDATE_URL that handles multi-byte chars.

This function is static because it is used in . During installation this service can't be constructed because the database is not yet available.

Parameters
string$urlURL to validate
Returns
bool
Examples:
/root/Elgg/engine/classes/Elgg/Http/Urls.php.

Definition at line 277 of file Urls.php.

Elgg\Http\Urls::normalizeUrl ( string  $url)
Examples:
/root/Elgg/engine/classes/Elgg/Http/Urls.php.

Definition at line 134 of file Urls.php.


The documentation for this class was generated from the following file: