lib/ezutils/classes/ezuri.php
File containing the eZURI class.
- Copyright
- Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
- License
- eZ Business Use License Agreement Version 2.0
- Package
- lib
- Version
- 4.6.0
\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
Methods


__construct(
string $uri
)
:
void
Initializes with the URI string $uri. The URI string is split on / into an array.
Name | Type | Description |
---|---|---|
$uri | string | the URI to use |


attribute(
string $attr
)
:
boolean
Get value for an attribute
Name | Type | Description |
---|---|---|
$attr | string |
Type | Description |
---|---|
boolean | the value for attribute $attr or null if it does not exist. |


attributes(
)
:
array
Export all attributes of the object
Type | Description |
---|---|
array | the attributes for the object |


base(
\type $as_text
=
true
)
:
string | array
Return the elements before pointer
Name | Type | Description |
---|---|---|
$as_text | \type | return as text or array |
Type | Description |
---|---|
string | array | the base string or the base elements as an array if $as_text is true. |


codecURL(
string $url, boolean $encode
)
:
string
Parse URL and encode/decode its path string
Name | Type | Description |
---|---|---|
$url | string | the URL to parse |
$encode | boolean | tells to encode the URI |
Type | Description |
---|---|
string | the parsed url |


convertFilterString(
)
:
string
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.
Type | Description |
---|---|
string | converted string |


decodeIRI(
string $str
)
:
string
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}
Name | Type | Description |
---|---|---|
$str | string | the string to decode |
Type | Description |
---|---|
string | decoded version of $str |


decodeURL(
string $url
)
:
string
Decodes URL which has path string is in IRI format and returns the new URL with path in the internal encoding.
Name | Type | Description |
---|---|---|
$url | string | url to decode |
Type | Description |
---|---|
string | the decoded url |


dropBase(
)
:
void
Removes all elements below the current index, recreates the URI string and sets index to 0.


element(
integer $index
=
0, boolean $relative
=
true
)
:
string | null
Get element index from uri
Name | Type | Description |
---|---|---|
$index | integer | the index of URI to return |
$relative | boolean | if index is relative to the internal pointer |
Type | Description |
---|---|
string | null | the element at $index |


elements(
boolean $as_text
=
true
)
:
array | string
Return all URI elements
Name | Type | Description |
---|---|---|
$as_text | boolean | return the elements as string |
Type | Description |
---|---|
array | string | all elements as string/array depending on $as_text |


encodeIRI(
string $str
)
:
string
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}
Name | Type | Description |
---|---|---|
$str | string | the IRI to encode |
Type | Description |
---|---|
string | $str encoded as IRU |


encodeURL(
\type $url
)
:
string
Encodes path string of URL in internal encoding to a new string which conforms to the IRI specification.
Name | Type | Description |
---|---|---|
$url | \type |
Type | Description |
---|---|
string | the encoded url |


getTransformURIMode(
)
:
string
Returns the current mode used for transformURI().
Type | Description |
---|---|
string |
- See
- \transformURI()
- See
- \setTransformURIMode()


hasAttribute(
string $attr
)
:
boolean
Check if attribute exsits
Name | Type | Description |
---|---|---|
$attr | string | the attrbiute to check if exists |
Type | Description |
---|---|
boolean |


increase(
int $num
=
1
)
:
void
Moves the index 1 step up or $num if specified.
Name | Type | Description |
---|---|---|
$num | int | number of steps to move pointer |


index(
)
:
int
Return the current position of pointer
Type | Description |
---|---|
int | the current pointer position. |


instance(
false | string $uri
=
false
)
:
\eZURI
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.
Name | Type | Description |
---|---|---|
$uri | false | string | Shared uri instance if false |
Type | Description |
---|---|
\eZURI |


isEmpty(
)
:
boolean
Check if there URI is set
Type | Description |
---|---|
boolean | true if the URI is empty, ie it's equal to / or empty string. |


matchBase(
\eZURI $uri
)
:
boolean
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.
Name | Type | Description |
---|---|---|
$uri | \eZURI | the uri to match against |
Type | Description |
---|---|
boolean |


originalURIString(
boolean $withLeadingSlash
=
false
)
:
string
Return the original URI
the URI will not include the leading / if $withLeadingSlash is true.
Name | Type | Description |
---|---|---|
$withLeadingSlash | boolean | prefix the uri with / |
Type | Description |
---|---|
string | the URI passed to the object with user parameters (if any). |


setTransformURIMode(
string $mode
)
:
void
Sets the current mode used for transformURI() to $mode.
Name | Type | Description |
---|---|---|
$mode | string |
- See
- \transformURI()
- See
- \getTransformURIMode()


setURIString(
string $uri, boolean $fullInitialize
=
true
)
:
void
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.
Name | Type | Description |
---|---|---|
$uri | string | |
$fullInitialize | boolean |


transformURI(
string $href, boolean $ignoreIndexDir
=
false, string $serverURL
=
null
)
:
string
Implementation of an 'ezurl' template operator Makes valid eZ Publish urls to use in links
Name | Type | Description |
---|---|---|
$href | string | &$href |
$ignoreIndexDir | boolean | |
$serverURL | string | full|relative |
Type | Description |
---|---|
string | the link to use |


uriString(
boolean $withLeadingSlash
=
false
)
:
string
Get the uri string
The URI will not include the leading / if $withLeadingSlash is true.
Name | Type | Description |
---|---|---|
$withLeadingSlash | boolean | prefix the uri with / |
Type | Description |
---|---|
string | the URI passed as to the object |