XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Net_URL2 Class Reference

Public Member Functions

 __construct ($url, array $options=array())
 
 __set ($var, $arg)
 
 __get ($var)
 
 getScheme ()
 
 setScheme ($scheme)
 
 getUser ()
 
 getPassword ()
 
 getUserinfo ()
 
 setUserinfo ($userinfo, $password=false)
 
 getHost ()
 
 setHost ($host)
 
 getPort ()
 
 setPort ($port)
 
 getAuthority ()
 
 setAuthority ($authority)
 
 getPath ()
 
 setPath ($path)
 
 getQuery ()
 
 setQuery ($query)
 
 getFragment ()
 
 setFragment ($fragment)
 
 getQueryVariables ()
 
 setQueryVariables (array $array)
 
 setQueryVariable ($name, $value)
 
 unsetQueryVariable ($name)
 
 getURL ()
 
 __toString ()
 
 getNormalizedURL ()
 
 normalize ()
 
 isAbsolute ()
 
 resolve ($reference)
 
 getOption ($optionName)
 

Static Public Member Functions

static removeDotSegments ($path)
 
static urlencode ($string)
 
static getCanonical ()
 
static getRequestedURL ()
 
static getRequested ()
 

Public Attributes

const OPTION_STRICT = 'strict'
 
const OPTION_USE_BRACKETS = 'use_brackets'
 
const OPTION_DROP_SEQUENCE = 'drop_sequence'
 
const OPTION_ENCODE_KEYS = 'encode_keys'
 
const OPTION_SEPARATOR_INPUT = 'input_separator'
 
const OPTION_SEPARATOR_OUTPUT = 'output_separator'
 

Protected Member Functions

 buildQuery (array $data, $separator, $key=null)
 
 parseUrl ($url)
 

Detailed Description

Definition at line 57 of file URL2.php.

Constructor & Destructor Documentation

Net_URL2::__construct (   $url,
array  $options = array() 
)

Constructor.

Parameters
string$urlan absolute or relative URL
array$optionsan array of OPTION_xxx constants

self::parseUrl()

Definition at line 148 of file URL2.php.

Member Function Documentation

Net_URL2::__get (   $var)

Magic Getter.

This is the magic get method to retrieve the private variable that was set by either __set() or it's setter...

Parameters
string$varThe property name to retrieve.
Returns
mixed $this->$var Either a boolean false if the property is not set or the value of the private property.

Definition at line 190 of file URL2.php.

Net_URL2::__set (   $var,
  $arg 
)

Magic Setter.

This method will magically set the value of a private variable ($var) with the value passed as the args

Parameters
string$varThe private variable to set.
mixed$argAn argument of any type.
Returns
void

Definition at line 170 of file URL2.php.

Net_URL2::__toString ( )

Returns a string representation of this URL.

Returns
string https://php.net/language.oop5.magic#object.tostring

Definition at line 752 of file URL2.php.

Net_URL2::buildQuery ( array  $data,
  $separator,
  $key = null 
)
protected

A simple version of http_build_query in userland. The encoded string is percentage encoded according to RFC 3986.

Parameters
array$dataAn array, which has to be converted into QUERY_STRING. Anything is possible.
string$separatorSeparator self::OPTION_SEPARATOR_OUTPUT
string$keyFor stacked values (arrays in an array).
Returns
string

Definition at line 1128 of file URL2.php.

Net_URL2::getAuthority ( )

Returns the authority part, i.e. [ userinfo "@" ] host [ ":" port ], or false if there is no authority.

Returns
string|bool

Definition at line 346 of file URL2.php.

static Net_URL2::getCanonical ( )
static

Returns a Net_URL2 instance representing the canonical URL of the currently executing PHP script.

Exceptions
Exception
Returns
string

Definition at line 1052 of file URL2.php.

Net_URL2::getFragment ( )

Returns the fragment name, or false if "#" is not present in the URL.

Returns
string|bool

Definition at line 459 of file URL2.php.

Net_URL2::getHost ( )

Returns the host part, or false if there is no authority part, e.g. relative URLs.

Returns
string|bool a hostname, an IP address, or false

Definition at line 296 of file URL2.php.

Net_URL2::getNormalizedURL ( )

Returns a normalized string representation of this URL. This is useful for comparison of URLs.

Returns
string

Definition at line 763 of file URL2.php.

Net_URL2::getOption (   $optionName)

Returns the value of the specified option.

Parameters
string$optionNameThe name of the option to retrieve
Returns
mixed

Definition at line 1111 of file URL2.php.

Net_URL2::getPassword ( )

Returns the password part of the userinfo part (the part after the first ":"), or false if there is no userinfo part (i.e. the URL does not contain "@" in front of the hostname) or the userinfo part does not contain ":".

Returns
string|bool

Definition at line 249 of file URL2.php.

Net_URL2::getPath ( )

Returns the path part (possibly an empty string).

Returns
string

Definition at line 409 of file URL2.php.

Net_URL2::getPort ( )

Returns the port number, or false if there is no port number specified, i.e. if the default port is to be used.

Returns
string|bool

Definition at line 321 of file URL2.php.

Net_URL2::getQuery ( )

Returns the query string (excluding the leading "?"), or false if "?" is not present in the URL.

Returns
string|bool
See Also
getQueryVariables

Definition at line 434 of file URL2.php.

Net_URL2::getQueryVariables ( )

Returns the query string like an array as the variables would appear in $_GET in a PHP script. If the URL does not contain a "?", an empty array is returned.

Returns
array

Definition at line 485 of file URL2.php.

static Net_URL2::getRequested ( )
static

Returns a Net_URL2 instance representing the URL used to retrieve the current request.

Exceptions
Exception
Returns
$this

Definition at line 1089 of file URL2.php.

static Net_URL2::getRequestedURL ( )
static

Returns the URL used to retrieve the current request.

Returns
string

Definition at line 1077 of file URL2.php.

Net_URL2::getScheme ( )

Returns the scheme, e.g. "http" or "urn", or false if there is no scheme specified, i.e. if this is a relative URL.

Returns
string|bool

Definition at line 206 of file URL2.php.

Net_URL2::getURL ( )

Returns a string representation of this URL.

Returns
string

Definition at line 699 of file URL2.php.

Net_URL2::getUser ( )

Returns the user part of the userinfo part (the part preceding the first ":"), or false if there is no userinfo part.

Returns
string|bool

Definition at line 234 of file URL2.php.

Net_URL2::getUserinfo ( )

Returns the userinfo part, or false if there is none, i.e. if the authority part does not contain "@".

Returns
string|bool

Definition at line 262 of file URL2.php.

Net_URL2::isAbsolute ( )

Returns whether this instance represents an absolute URL.

Returns
bool

Definition at line 868 of file URL2.php.

Net_URL2::normalize ( )

Normalizes the URL

See RFC 3986, Section 6. Normalization and Comparison

void

Definition at line 779 of file URL2.php.

Net_URL2::parseUrl (   $url)
protected

This method uses a regex to parse the url into the designated parts.

Parameters
string$urlURL
Returns
void self::$_scheme, self::setAuthority(), self::$_path, self::$_query, self::$_fragment
See Also
__construct

Definition at line 1166 of file URL2.php.

static Net_URL2::removeDotSegments (   $path)
static

Removes dots as described in RFC 3986, section 5.2.4, e.g. "/foo/../bar/baz" => "/bar/baz"

Parameters
string$patha path
Returns
string a path

Definition at line 976 of file URL2.php.

Net_URL2::resolve (   $reference)

Returns an Net_URL2 instance representing an absolute URL relative to this URL.

Parameters
Net_URL2 | string$referencerelative URL
Exceptions
Exception
Returns
$this

Definition at line 882 of file URL2.php.

Net_URL2::setAuthority (   $authority)

Sets the authority part, i.e. [ userinfo "@" ] host [ ":" port ]. Specify false if there is no authority.

Parameters
string | bool$authoritya hostname or an IP address, possibly with userinfo prefixed and port number appended, e.g. "foo:bar@example.org:81".
Returns
$this

Definition at line 377 of file URL2.php.

Net_URL2::setFragment (   $fragment)

Sets the fragment name. Specify false if "#" is not present in the URL.

Parameters
string | bool$fragmenta fragment excluding the leading "#", or false
Returns
$this

Definition at line 472 of file URL2.php.

Net_URL2::setHost (   $host)

Sets the host part. Specify false if there is no authority part, e.g. relative URLs.

Parameters
string | bool$hosta hostname, an IP address, or false
Returns
$this

Definition at line 309 of file URL2.php.

Net_URL2::setPath (   $path)

Sets the path part (possibly an empty string).

Parameters
string$patha path
Returns
$this

Definition at line 421 of file URL2.php.

Net_URL2::setPort (   $port)

Sets the port number. Specify false if there is no port number specified, i.e. if the default port is to be used.

Parameters
string | bool$porta port number, or false
Returns
$this

Definition at line 334 of file URL2.php.

Net_URL2::setQuery (   $query)

Sets the query string (excluding the leading "?"). Specify false if "?" is not present in the URL.

Parameters
string | bool$querya query string, e.g. "foo=1&bar=2"
Returns
$this
See Also
setQueryVariables

Definition at line 448 of file URL2.php.

Net_URL2::setQueryVariable (   $name,
  $value 
)

Sets the specified variable in the query string.

Parameters
string$namevariable name
mixed$valuevariable value
Returns
$this

Definition at line 672 of file URL2.php.

Net_URL2::setQueryVariables ( array  $array)

Sets the query string to the specified variable in the query string.

Parameters
array$array(name => value) array
Returns
$this

Definition at line 651 of file URL2.php.

Net_URL2::setScheme (   $scheme)

Sets the scheme, e.g. "http" or "urn". Specify false if there is no scheme specified, i.e. if this is a relative URL.

Parameters
string | bool$schemee.g. "http" or "urn", or false if there is no scheme specified, i.e. if this is a relative URL
Returns
$this
See Also
getScheme

Definition at line 222 of file URL2.php.

Net_URL2::setUserinfo (   $userinfo,
  $password = false 
)

Sets the userinfo part. If two arguments are passed, they are combined in the userinfo part as username ":" password.

Parameters
string | bool$userinfouserinfo or username
string | bool$passwordoptional password, or false
Returns
$this

Definition at line 276 of file URL2.php.

Net_URL2::unsetQueryVariable (   $name)

Removes the specified variable from the query string.

Parameters
string$namea query string variable, e.g. "foo" in "?foo=1"
Returns
void

Definition at line 687 of file URL2.php.

static Net_URL2::urlencode (   $string)
static

Percent-encodes all non-alphanumeric characters except these: _ . - ~ Similar to PHP's rawurlencode(), except that it also encodes ~ in PHP 5.2.x and earlier.

Parameters
string$stringstring to encode
Returns
string

Definition at line 1036 of file URL2.php.

Member Data Documentation

const Net_URL2::OPTION_DROP_SEQUENCE = 'drop_sequence'

Drop zero-based integer sequences in query using PHP's [] notation. Default is true.

Definition at line 74 of file URL2.php.

const Net_URL2::OPTION_ENCODE_KEYS = 'encode_keys'

URL-encode query variable keys. Default is true.

Definition at line 79 of file URL2.php.

const Net_URL2::OPTION_SEPARATOR_INPUT = 'input_separator'

Query variable separators when parsing the query string. Every character is considered a separator. Default is "&".

Definition at line 85 of file URL2.php.

const Net_URL2::OPTION_SEPARATOR_OUTPUT = 'output_separator'

Query variable separator used when generating the query string. Default is "&".

Definition at line 91 of file URL2.php.

const Net_URL2::OPTION_STRICT = 'strict'

Do strict parsing in resolve() (see RFC 3986, section 5.2.2). Default is true.

Definition at line 63 of file URL2.php.

const Net_URL2::OPTION_USE_BRACKETS = 'use_brackets'

Represent arrays in query using PHP's [] notation. Default is true.

Definition at line 68 of file URL2.php.


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