JURI

Extends \JObject

JURI 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) 
inherited
since

11.1

Arguments

$properties

mixedEither 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
inherited deprecated
since

11.1

deprecated

12.3 Classes should provide their own __toString() implementation.

Response

stringThe 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

stringThe URI path to clean.

Response

stringCleaned and resolved URI path.

base

Returns the base URI for the request.

base(boolean $pathonly = false) : string
static
since

11.1

Arguments

$pathonly

booleanIf false, prepend the scheme, host and port information. Default is false.

Response

stringThe base URI string

buildQuery

Build a query from a array (reverse of the PHP parse_str()).

buildQuery(array $params) : string
static
see \parse_str()
since

11.1

Arguments

$params

arrayThe array of key => value pairs to return as a query string.

Response

stringThe resulting query string.

current

Returns the URL for the request, minus the query.

current() : string
static
since

11.1

Response

string

def

Sets a default value if not alreay assigned

def(string $property, mixed $default = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$default

mixedThe 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

stringName 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
inherited
since

11.1

see \JObject::getProperties()

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixedThe value of the property.

getError

Get the most recent error message.

getError(integer $i = null, boolean $toString = true) : string
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$i

integerOption error index.

$toString

booleanIndicates if JError objects should return their error message.

Response

stringError message

getErrors

Return all errors, if any.

getErrors() : array
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Response

arrayArray of error messages or JErrors.

getFragment

Get the URI archor string Everything after the "#".

getFragment() : string
since

11.1

Response

stringThe 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

stringThe URI host.

getInstance

Returns the global JURI object, only creating it if it doesn't already exist.

getInstance(string $uri = 'SERVER') : \JURI
static
since

11.1

Arguments

$uri

stringThe URI to parse. [optional: if null uses script URI]

Response

\JURIThe URI object.

getPass

Get URI password Returns the password, or null if no password was specified.

getPass() : string
since

11.1

Response

stringThe URI password.

getPath

Gets the URI path string.

getPath() : string
since

11.1

Response

stringThe URI path string.

getPort

Get URI port Returns the port number, or null if no port was specified.

getPort() : integer
since

11.1

Response

integerThe URI port number.

getProperties

Returns an associative array of object properties.

getProperties(boolean $public = true) : array
inherited
since

11.1

see \JObject::get()

Arguments

$public

booleanIf true, returns only the public properties.

Response

array

getQuery

Returns flat query string.

getQuery(boolean $toArray = false) : string
since

11.1

Arguments

$toArray

booleanTrue to return the query as a key => value pair array.

Response

stringQuery string.

getScheme

Get URI scheme (protocol) ie. http, https, ftp, etc.

getScheme() : string

..

since

11.1

Response

stringThe URI scheme.

getUser

Get URI username Returns the username, or null if no username was specified.

getUser() : string
since

11.1

Response

stringThe URI username.

getVar

Returns a query variable by name.

getVar(string $name, string $default = null) : array
since

11.1

Arguments

$name

stringName of the query variable to get.

$default

stringDefault value to return if the variable is not set.

Response

arrayQuery variables.

hasVar

Checks if variable exists.

hasVar(string $name) : boolean
since

11.1

Arguments

$name

stringName of the query variable to check.

Response

booleanTrue if the variable exists.

isInternal

Checks if the supplied URL is internal

isInternal(string $url) : boolean
static
since

11.1

Arguments

$url

stringThe URL to check.

Response

booleanTrue if Internal.

isSSL

Checks whether the current URI is using HTTPS.

isSSL() : boolean
since

11.1

Response

booleanTrue if using SSL via HTTPS.

parse

Parse a given URI and populate the class fields.

parse(string $uri) : boolean
since

11.1

Arguments

$uri

stringThe URI string to parse.

Response

booleanTrue on success.

reset

Method to reset class static members for testing and other various issues.

reset() : void
static
since

11.1

root

Returns the root URI for the request.

root(boolean $pathonly = false, string $path = null) : string
static
since

11.1

Arguments

$pathonly

booleanIf false, prepend the scheme, host and port information. Default is false.

$path

stringThe path

Response

stringThe 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
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$value

mixedThe value of the property to set.

Response

mixedPrevious value of the property.

setError

Add an error message.

setError(string $error) : void
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$error

stringError message.

setFragment

Set the URI anchor string everything after the "#".

setFragment(string $anchor) : void
since

11.1

Arguments

$anchor

stringThe URI anchor string.

setHost

Set URI host.

setHost(string $host) : void
since

11.1

Arguments

$host

stringThe URI host.

setPass

Set URI password.

setPass(string $pass) : void
since

11.1

Arguments

$pass

stringThe URI password.

setPath

Set the URI path string.

setPath(string $path) : void
since

11.1

Arguments

$path

stringThe URI path string.

setPort

Set URI port.

setPort(integer $port) : void
since

11.1

Arguments

$port

integerThe URI port number.

setProperties

Set the object properties based on a named array/hash.

setProperties(mixed $properties) : boolean
inherited
since

11.1

see \JObject::set()

Arguments

$properties

mixedEither 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

mixedThe query string or array.

setScheme

Set URI scheme (protocol) ie. http, https, ftp, etc.

setScheme(string $scheme) : void

..

since

11.1

Arguments

$scheme

stringThe URI scheme.

setUser

Set URI username.

setUser(string $user) : void
since

11.1

Arguments

$user

stringThe 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

stringName of the query variable to set.

$value

stringValue of the query variable.

Response

stringPrevious value for the query variable.

toString

Converts the object to a string (the class name).

toString() : string
inherited deprecated
since

11.1

deprecated

12.1 Use magic method __toString()

see \JObject::__toString()

Response

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.

static
since

11.1

Type(s)

array

base

The current calculated base url segments.

static
since

11.1

Type(s)

array

root

The current calculated root url segments.

static
since

11.1

Type(s)

array

current

The current url.

static
since

11.1

Type(s)

string

_errors

An array of error messages or Exception objects.

inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Type(s)

array