JURI
Extends \JObjectJURI Class
This class serves two purposes. First it parses a URI and provides a common interface for the Joomla Platform to access and manipulate a URI. Second it obtains the URI of the current executing script from the server regardless of server.
package |
Joomla.Platform |
---|---|
subpackage |
Environment |
since |
11.1 |
Methods
__construct
Class constructor, overridden in descendant classes.
__construct(mixed $properties = null)
since |
11.1 |
---|
Arguments
- $properties
mixed
Either and associative array or another object to set the initial properties of the object.
__toString
Magic method to convert the object to a string gracefully.
__toString() : string
since |
11.1 |
---|---|
deprecated |
12.3 Classes should provide their own __toString() implementation. |
Response
string
The classname.
_cleanPath
Resolves //, .
_cleanPath(string $path) : string
./ and ./ from a path and returns the result. Eg:
/foo/bar/../boo.php => /foo/boo.php /foo/bar/../../boo.php => /boo.php /foo/bar/.././/boo.php => /foo/boo.php
since |
11.1 |
---|
Arguments
- $path
string
The URI path to clean.
Response
string
Cleaned and resolved URI path.
base
Returns the base URI for the request.
base(boolean $pathonly = false) : string
since |
11.1 |
---|
Arguments
- $pathonly
boolean
If false, prepend the scheme, host and port information. Default is false.
Response
string
The base URI string
buildQuery
Build a query from a array (reverse of the PHP parse_str()).
buildQuery(array $params) : string
see | \parse_str() |
---|---|
since |
11.1 |
Arguments
- $params
array
The array of key => value pairs to return as a query string.
Response
string
The resulting query string.
current
Returns the URL for the request, minus the query.
current() : string
since |
11.1 |
---|
Response
string
def
Sets a default value if not alreay assigned
def(string $property, mixed $default = null) : mixed
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $default
mixed
The default value.
Response
mixed
delVar
Removes an item from the query string variables if it exists.
delVar(string $name) : void
since |
11.1 |
---|
Arguments
- $name
string
Name of variable to remove.
get
Returns a property of the object or the default value if the property is not set.
get(string $property, mixed $default = null) : mixed
since |
11.1 |
---|---|
see | \JObject::getProperties() |
Arguments
- $property
string
The name of the property.- $default
mixed
The default value.
Response
mixed
The value of the property.
getError
Get the most recent error message.
getError(integer $i = null, boolean $toString = true) : string
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $i
integer
Option error index.- $toString
boolean
Indicates if JError objects should return their error message.
Response
string
Error message
getErrors
Return all errors, if any.
getErrors() : array
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Response
array
Array of error messages or JErrors.
getFragment
Get the URI archor string Everything after the "#".
getFragment() : string
since |
11.1 |
---|
Response
string
The URI anchor string.
getHost
Get URI host Returns the hostname/ip or null if no hostname/ip was specified.
getHost() : string
since |
11.1 |
---|
Response
string
The URI host.
getInstance
Returns the global JURI object, only creating it if it doesn't already exist.
getInstance(string $uri = 'SERVER') : \JURI
since |
11.1 |
---|
Arguments
- $uri
string
The URI to parse. [optional: if null uses script URI]
Response
\JURI
The URI object.
getPass
Get URI password Returns the password, or null if no password was specified.
getPass() : string
since |
11.1 |
---|
Response
string
The URI password.
getPath
Gets the URI path string.
getPath() : string
since |
11.1 |
---|
Response
string
The URI path string.
getPort
Get URI port Returns the port number, or null if no port was specified.
getPort() : integer
since |
11.1 |
---|
Response
integer
The URI port number.
getProperties
Returns an associative array of object properties.
getProperties(boolean $public = true) : array
since |
11.1 |
---|---|
see | \JObject::get() |
Arguments
- $public
boolean
If true, returns only the public properties.
Response
array
getQuery
Returns flat query string.
getQuery(boolean $toArray = false) : string
since |
11.1 |
---|
Arguments
- $toArray
boolean
True to return the query as a key => value pair array.
Response
string
Query string.
getScheme
Get URI scheme (protocol) ie. http, https, ftp, etc.
getScheme() : string
..
since |
11.1 |
---|
Response
string
The URI scheme.
getUser
Get URI username Returns the username, or null if no username was specified.
getUser() : string
since |
11.1 |
---|
Response
string
The URI username.
getVar
Returns a query variable by name.
getVar(string $name, string $default = null) : array
since |
11.1 |
---|
Arguments
- $name
string
Name of the query variable to get.- $default
string
Default value to return if the variable is not set.
Response
array
Query variables.
hasVar
Checks if variable exists.
hasVar(string $name) : boolean
since |
11.1 |
---|
Arguments
- $name
string
Name of the query variable to check.
Response
boolean
True if the variable exists.
isInternal
Checks if the supplied URL is internal
isInternal(string $url) : boolean
since |
11.1 |
---|
Arguments
- $url
string
The URL to check.
Response
boolean
True if Internal.
isSSL
Checks whether the current URI is using HTTPS.
isSSL() : boolean
since |
11.1 |
---|
Response
boolean
True if using SSL via HTTPS.
parse
Parse a given URI and populate the class fields.
parse(string $uri) : boolean
since |
11.1 |
---|
Arguments
- $uri
string
The URI string to parse.
Response
boolean
True on success.
reset
Method to reset class static members for testing and other various issues.
reset() : void
since |
11.1 |
---|
root
Returns the root URI for the request.
root(boolean $pathonly = false, string $path = null) : string
since |
11.1 |
---|
Arguments
- $pathonly
boolean
If false, prepend the scheme, host and port information. Default is false.- $path
string
The path
Response
string
The root URI string.
set
Modifies a property of the object, creating it if it does not already exist.
set(string $property, mixed $value = null) : mixed
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $value
mixed
The value of the property to set.
Response
mixed
Previous value of the property.
setError
Add an error message.
setError(string $error) : void
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $error
string
Error message.
setFragment
Set the URI anchor string everything after the "#".
setFragment(string $anchor) : void
since |
11.1 |
---|
Arguments
- $anchor
string
The URI anchor string.
setHost
Set URI host.
setHost(string $host) : void
since |
11.1 |
---|
Arguments
- $host
string
The URI host.
setPass
Set URI password.
setPass(string $pass) : void
since |
11.1 |
---|
Arguments
- $pass
string
The URI password.
setPath
Set the URI path string.
setPath(string $path) : void
since |
11.1 |
---|
Arguments
- $path
string
The URI path string.
setPort
Set URI port.
setPort(integer $port) : void
since |
11.1 |
---|
Arguments
- $port
integer
The URI port number.
setProperties
Set the object properties based on a named array/hash.
setProperties(mixed $properties) : boolean
since |
11.1 |
---|---|
see | \JObject::set() |
Arguments
- $properties
mixed
Either an associative array or another object.
Response
boolean
setQuery
Sets the query to a supplied string in format: foo=bar&x=y
setQuery(mixed $query) : void
since |
11.1 |
---|
Arguments
- $query
mixed
The query string or array.
setScheme
Set URI scheme (protocol) ie. http, https, ftp, etc.
setScheme(string $scheme) : void
..
since |
11.1 |
---|
Arguments
- $scheme
string
The URI scheme.
setUser
Set URI username.
setUser(string $user) : void
since |
11.1 |
---|
Arguments
- $user
string
The URI username.
setVar
Adds a query variable and value, replacing the value if it already exists and returning the old value.
setVar(string $name, string $value) : string
since |
11.1 |
---|
Arguments
- $name
string
Name of the query variable to set.- $value
string
Value of the query variable.
Response
string
Previous value for the query variable.
toString
Converts the object to a string (the class name).
toString() : string
Properties
_uri
Original URI
since |
11.1 |
---|
Type(s)
string
_scheme
Protocol
since |
11.1 |
---|
Type(s)
string
_host
Host
since |
11.1 |
---|
Type(s)
string
_port
Port
since |
11.1 |
---|
Type(s)
integer
_user
Username
since |
11.1 |
---|
Type(s)
string
_pass
Password
since |
11.1 |
---|
Type(s)
string
_path
Path
since |
11.1 |
---|
Type(s)
string
_query
Query
since |
11.1 |
---|
Type(s)
string
_fragment
Anchor
since |
11.1 |
---|
Type(s)
string
_vars
Query variable hash
since |
11.1 |
---|
Type(s)
array
instances
An array of JURI instances.
since |
11.1 |
---|
Type(s)
array
base
The current calculated base url segments.
since |
11.1 |
---|
Type(s)
array
root
The current calculated root url segments.
since |
11.1 |
---|
Type(s)
array
current
The current url.
since |
11.1 |
---|
Type(s)
string
_errors
An array of error messages or Exception objects.