Class

eZURI

class eZURI

Provides access to the HTTP uri The URI can be accessed one element at a time with element() and elements() and can be iterated with increase() and the current index returned with index().

Movin the beginning and end is done with toBeginning() and toEnd(). The base can be retrieved with base() and the elements with elements().

This class also supports the attribute system.

The index starts at 0

Properties

string $URI The original URI string
array $URIArray The URI array
int $Index The current index
array $UserArray User defined template variables

Methods

void __construct(string $uri)

Initializes with the URI string $uri.

static string decodeIRI(string $str)

Decodes a path string which is in IRI format and returns the new path in the internal encoding.

static string encodeIRI(string $str)

Encodes path string in internal encoding to a new string which conforms to the IRI specification.

static string codecURL(string $url, boolean $encode)

Parse URL and encode/decode its path string

static string encodeURL(type $url)

Encodes path string of URL in internal encoding to a new string which conforms to the IRI specification.

static string decodeURL(string $url)

Decodes URL which has path string is in IRI format and returns the new URL with path in the internal encoding.

void setURIString(string $uri, boolean $fullInitialize = true)

Sets uri string for instance

string uriString(boolean $withLeadingSlash = false)

Get the uri string

string originalURIString(boolean $withLeadingSlash = false)

Return the original URI

boolean isEmpty()

Check if there URI is set

string|null element(integer $index, boolean $relative = true)

Get element index from uri

array|string elements(boolean $as_text = true)

Return all URI elements

string convertFilterString()

Converts filter string to current locale.

array userParameters()

Get user variables

void toBeginning()

Reset the internal pointer

void toEnd()

Moves the index to the end.

void increase(int $num = 1)

Moves the index 1 step up or $num if specified.

void dropBase()

Removes all elements below the current index, recreates the URI string and sets index to 0.

int index()

Return the current position of pointer

string|array base(type $as_text = true)

Return the elements before pointer

boolean matchBase(eZURI $uri)

Tries to match the base of $uri against this base and returns the result.

array attributes()

Export all attributes of the object

boolean hasAttribute(string $attr)

Check if attribute exsits

boolean attribute(string $attr)

Get value for an attribute

static eZURI instance(bool|string $uri = false)

Returns a shared instance of the eZURI class IF $uri is false or the same as current request uri, if not then a new non shared instance is created.

static string transformURI(string $href, boolean $ignoreIndexDir = false, string $serverURL = null, boolean $htmlEscape = true)

Implementation of an 'ezurl' template operator Makes valid eZ Publish urls to use in links

static string getTransformURIMode()

Returns the current mode used for transformURI().

static  setTransformURIMode(string $mode)

Sets the current mode used for transformURI() to $mode.

Details

at line 74
public void __construct(string $uri)

Initializes with the URI string $uri.

The URI string is split on / into an array.

Parameters

string $uri the URI to use

Return Value

void

at line 87
static public string decodeIRI(string $str)

Decodes a path string which is in IRI format and returns the new path in the internal encoding.

More info on IRI here: {@link http://www.w3.org/International/O-URL-and-ident.html}

Parameters

string $str the string to decode

Return Value

string decoded version of $str

at line 102
static public string encodeIRI(string $str)

Encodes path string in internal encoding to a new string which conforms to the IRI specification.

More info on IRI here: {@link http://www.w3.org/International/O-URL-and-ident.html}

Parameters

string $str the IRI to encode

Return Value

string $str encoded as IRU

at line 132
static public string codecURL(string $url, boolean $encode)

Parse URL and encode/decode its path string

Parameters

string $url the URL to parse
boolean $encode tells to encode the URI

Return Value

string the parsed url

at line 192
static public string encodeURL(type $url)

Encodes path string of URL in internal encoding to a new string which conforms to the IRI specification.

Parameters

type $url

Return Value

string the encoded url

at line 203
static public string decodeURL(string $url)

Decodes URL which has path string is in IRI format and returns the new URL with path in the internal encoding.

Parameters

string $url url to decode

Return Value

string the decoded url

at line 218
public void setURIString(string $uri, boolean $fullInitialize = true)

Sets uri string for instance

Sets the current URI string to $uri, the URI is then split into array elements and index reset to 1.

Parameters

string $uri
boolean $fullInitialize

Return Value

void

at line 285
public string uriString(boolean $withLeadingSlash = false)

Get the uri string

The URI will not include the leading / if $withLeadingSlash is true.

Parameters

boolean $withLeadingSlash prefix the uri with /

Return Value

string the URI passed as to the object

at line 301
public string originalURIString(boolean $withLeadingSlash = false)

Return the original URI

the URI will not include the leading / if $withLeadingSlash is true.

Parameters

boolean $withLeadingSlash prefix the uri with /

Return Value

string the URI passed to the object with user parameters (if any).

at line 314
public boolean isEmpty()

Check if there URI is set

Return Value

boolean true if the URI is empty, ie it's equal to / or empty string.

at line 326
public string|null element(integer $index, boolean $relative = true)

Get element index from uri

Parameters

integer $index the index of URI to return
boolean $relative if index is relative to the internal pointer

Return Value

string|null the element at $index

at line 343
public array|string elements(boolean $as_text = true)

Return all URI elements

Parameters

boolean $as_text return the elements as string

Return Value

array|string all elements as string/array depending on $as_text

at line 362
public string convertFilterString()

Converts filter string to current locale.

When an user types in browser url like: "/content/view/full/2/(namefilter)/a" 'a' letter should be urldecoded and converted from utf-8 to current locale.

Return Value

string converted string

at line 383
public array userParameters()

Get user variables

Return Value

array all the user defined variables

at line 393
public void toBeginning()

Reset the internal pointer

Return Value

void

at line 403
public void toEnd()

Moves the index to the end.

Return Value

void

at line 414
public void increase(int $num = 1)

Moves the index 1 step up or $num if specified.

Parameters

int $num number of steps to move pointer

Return Value

void

at line 427
public void dropBase()

Removes all elements below the current index, recreates the URI string and sets index to 0.

Return Value

void

at line 446
public int index()

Return the current position of pointer

Return Value

int the current pointer position.

at line 457
public string|array base(type $as_text = true)

Return the elements before pointer

Parameters

type $as_text return as text or array

Return Value

string|array the base string or the base elements as an array if $as_text is true.

at line 478
public boolean matchBase(eZURI $uri)

Tries to match the base of $uri against this base and returns the result.

A match is made if all elements of this object match the base elements of the $uri object, this means that $uri's base may be longer than this base but not shorter.

Parameters

eZURI $uri the uri to match against

Return Value

boolean

at line 504
public array attributes()

Export all attributes of the object

Return Value

array the attributes for the object

at line 521
public boolean hasAttribute(string $attr)

Check if attribute exsits

Parameters

string $attr the attrbiute to check if exists

Return Value

boolean

at line 532
public boolean attribute(string $attr)

Get value for an attribute

Parameters

string $attr

Return Value

boolean the value for attribute $attr or null if it does not exist.

at line 572
static public eZURI instance(bool|string $uri = false)

Returns a shared instance of the eZURI class IF $uri is false or the same as current request uri, if not then a new non shared instance is created.

Parameters

bool|string $uri Shared uri instance if false

Return Value

eZURI

at line 597
static public string transformURI(string $href, boolean $ignoreIndexDir = false, string $serverURL = null, boolean $htmlEscape = true)

Implementation of an 'ezurl' template operator Makes valid eZ Publish urls to use in links

Parameters

string $href
boolean $ignoreIndexDir
string $serverURL full|relative
boolean $htmlEscape true to html escape the result for HTML

Return Value

string the link to use

at line 672
static public string getTransformURIMode()

Returns the current mode used for transformURI().

Return Value

string

See also

transformURI()
setTransformURIMode()

at line 685
static public setTransformURIMode(string $mode)

Sets the current mode used for transformURI() to $mode.

Parameters

string $mode

See also

transformURI()
getTransformURIMode()