class JURI extends JObject


Located at : UKNOWVA_ROOT/libraries/joomla/environment/uri.php

JURI Class

This class serves two purposes. First it parses a URI and provides a common interface for the Joomla Framework to access and manipulate a URI. Second it obtains the URI of the current executing script from the server regardless of server.

Methods

__construct(string $uri = null)

Constructor.

string
__toString()

Magic method to get the string representation of the URI object.

mixed
def(string $property, mixed $default = null)

Sets a default value if not alreay assigned

from JObject
mixed
get(string $property, mixed $default = null)

Returns a property of the object or the default value if the property is not set.

from JObject
array
getProperties(boolean $public = true)

Returns an associative array of object properties.

from JObject
string
getError(integer $i = null, boolean $toString = true)

Get the most recent error message.

from JObject
array
getErrors()

Return all errors, if any.

from JObject
mixed
set(string $property, mixed $value = null)

Modifies a property of the object, creating it if it does not already exist.

from JObject
boolean
setProperties(mixed $properties)

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

from JObject
void
setError(string $error)

Add an error message.

from JObject
string
toString(array $parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment'))

Returns full uri string.

static JURI
getInstance(string $uri = 'SERVER')

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

static string
base(boolean $pathonly = false)

Returns the base URI for the request.

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

Returns the root URI for the request.

static string
current()

Returns the URL for the request, minus the query.

static void
reset()

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

boolean
parse(string $uri)

Parse a given URI and populate the class fields.

string
setVar(string $name, string $value)

Adds a query variable and value, replacing the value if it already exists and returning the old value.

bool
hasVar(string $name)

Checks if variable exists.

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

Returns a query variable by name.

void
delVar(string $name)

Removes an item from the query string variables if it exists.

void
setQuery(mixed(array|string) $query)

Sets the query to a supplied string in format: foo=bar&x=y

string
getQuery(boolean $toArray = false)

Returns flat query string.

static string
buildQuery($params)

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

string
getScheme()

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

void
setScheme(string $scheme)

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

string
getUser()

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

void
setUser(string $user)

Set URI username.

string
getPass()

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

void
setPass(string $pass)

Set URI password.

string
getHost()

Get URI host Returns the hostname/ip or null if no hostname/ip was specified.

void
setHost(string $host)

Set URI host.

integer
getPort()

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

void
setPort(integer $port)

Set URI port.

string
getPath()

Gets the URI path string.

void
setPath(string $path)

Set the URI path string.

string
getFragment()

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

void
setFragment(string $anchor)

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

boolean
isSSL()

Checks whether the current URI is using HTTPS.

static boolean
isInternal(string $url)

Checks if the supplied URL is internal

mixed
getContentInfo()

Given a URL, this function gets the brief information on its content .i.e. title, description, images, baseurl, author, etc.

Details

at line 119
JObject __construct(string $uri = null)

Constructor.

You can pass a URI string to the constructor to initialise a specific URI.

Parameters

string $uri The optional URI string

Return Value

JObject

at line 132
string __toString()

Magic method to get the string representation of the URI object.

Return Value

string The classname.

in JObject at line 70
mixed def(string $property, mixed $default = null)

Sets a default value if not alreay assigned

Parameters

string $property The name of the property.
mixed $default The default value.

Return Value

mixed

in JObject at line 88
mixed get(string $property, mixed $default = null)

Returns a property of the object or the default value if the property is not set.

Parameters

string $property The name of the property.
mixed $default The default value.

Return Value

mixed The value of the property.

See also

getProperties()

in JObject at line 107
array getProperties(boolean $public = true)

Returns an associative array of object properties.

Parameters

boolean $public If true, returns only the public properties.

Return Value

array

See also

get()

in JObject at line 133
string getError(integer $i = null, boolean $toString = true)

Get the most recent error message.

Parameters

integer $i Option error index.
boolean $toString Indicates if JError objects should return their error message.

Return Value

string Error message

in JObject at line 165
array getErrors()

Return all errors, if any.

Return Value

array Array of error messages or JErrors.

in JObject at line 180
mixed set(string $property, mixed $value = null)

Modifies a property of the object, creating it if it does not already exist.

Parameters

string $property The name of the property.
mixed $value The value of the property to set.

Return Value

mixed Previous value of the property.

in JObject at line 198
boolean setProperties(mixed $properties)

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

Parameters

mixed $properties Either an associative array or another object.

Return Value

boolean

See also

set()

in JObject at line 222
void setError(string $error)

Add an error message.

Parameters

string $error Error message.

Return Value

void

at line 349
string toString(array $parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment'))

Returns full uri string.

Parameters

array $parts An array specifying the parts to render.

Return Value

string

at line 146
static JURI getInstance(string $uri = 'SERVER')

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

Parameters

string $uri The URI to parse. [optional: if null uses script URI]

Return Value

JURI The URI object.

at line 202
static string base(boolean $pathonly = false)

Returns the base URI for the request.

Parameters

boolean $pathonly If false, prepend the scheme, host and port information. Default is false.

Return Value

string The base URI string

at line 248
static string root($pathonly = false, $path = null)

Returns the root URI for the request.

Parameters

$pathonly
$path

Return Value

string The root URI string.

at line 271
static string current()

Returns the URL for the request, minus the query.

Return Value

string

at line 288
static void reset()

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

Return Value

void

at line 304
boolean parse(string $uri)

Parse a given URI and populate the class fields.

Parameters

string $uri The URI string to parse.

Return Value

boolean True on success.

at line 378
string setVar(string $name, string $value)

Adds a query variable and value, replacing the value if it already exists and returning the old value.

Parameters

string $name Name of the query variable to set.
string $value Value of the query variable.

Return Value

string Previous value for the query variable.

at line 398
bool hasVar(string $name)

Checks if variable exists.

Parameters

string $name Name of the query variable to check.

Return Value

bool exists.

at line 413
array getVar(string $name, string $default = null)

Returns a query variable by name.

Parameters

string $name Name of the query variable to get.
string $default Default value to return if the variable is not set.

Return Value

array Query variables.

at line 430
void delVar(string $name)

Removes an item from the query string variables if it exists.

Parameters

string $name Name of variable to remove.

Return Value

void

at line 450
void setQuery(mixed(array|string) $query)

Sets the query to a supplied string in format: foo=bar&x=y

Parameters

mixed(array|string) $query The query string.

Return Value

void

at line 474
string getQuery(boolean $toArray = false)

Returns flat query string.

Parameters

boolean $toArray

Return Value

string Query string.

at line 496
static string buildQuery($params)

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

Parameters

$params

Return Value

string $params The resulting query string.

See also

parse_str()

at line 512
string getScheme()

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

..

Return Value

string The URI scheme.

at line 527
void setScheme(string $scheme)

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

..

Parameters

string $scheme The URI scheme.

Return Value

void

at line 539
string getUser()

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

Return Value

string The URI username.

at line 553
void setUser(string $user)

Set URI username.

Parameters

string $user The URI username.

Return Value

void

at line 565
string getPass()

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

Return Value

string The URI password.

at line 579
void setPass(string $pass)

Set URI password.

Parameters

string $pass The URI password.

Return Value

void

at line 591
string getHost()

Get URI host Returns the hostname/ip or null if no hostname/ip was specified.

Return Value

string The URI host.

at line 605
void setHost(string $host)

Set URI host.

Parameters

string $host The URI host.

Return Value

void

at line 616
integer getPort()

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

Return Value

integer The URI port number.

at line 630
void setPort(integer $port)

Set URI port.

Parameters

integer $port The URI port number.

Return Value

void

at line 641
string getPath()

Gets the URI path string.

Return Value

string The URI path string.

at line 655
void setPath(string $path)

Set the URI path string.

Parameters

string $path The URI path string.

Return Value

void

at line 667
string getFragment()

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

Return Value

string The URI anchor string.

at line 682
void setFragment(string $anchor)

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

Parameters

string $anchor The URI anchor string.

Return Value

void

at line 693
boolean isSSL()

Checks whether the current URI is using HTTPS.

Return Value

boolean True if using SSL via HTTPS.

at line 707
static boolean isInternal(string $url)

Checks if the supplied URL is internal

Parameters

string $url The URL to check.

Return Value

boolean True if Internal.

at line 773
mixed getContentInfo()

Given a URL, this function gets the brief information on its content .i.e. title, description, images, baseurl, author, etc.

It parses the meta tags and page contents/images to get this informction This function is used by the URL share feature of uKnowva

Return Value

mixed An associative array with following keys url: The given URL title: The page Title images: An array of images with their absolute paths description: The description of the page host: The hostname like www.uknowva.com, etc. baseurl: The base url author: The author of the page if any OR Null in case of failure