Class JUri

Description

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.

  • since: 11.1

Located in /libraries/joomla/uri/uri.php (line 23)


	
			
Variable Summary
 static array $base
 static string $current
 static array $instances
 static array $root
 string $fragment
 string $host
 string $pass
 string $path
 integer $port
 string $query
 string $scheme
 string $uri
 string $user
 array $vars
Method Summary
 static string base ([boolean $pathonly = false])
 static string buildQuery (array $params)
 static string current ()
 static JUri getInstance ([string $uri = 'SERVER'])
 static boolean isInternal (string $url)
 static void reset ()
 static string root ([boolean $pathonly = false], [string $path = null])
 JUri __construct ([string $uri = null])
 void delVar (string $name)
 string getFragment ()
 string getHost ()
 string getPass ()
 string getPath ()
 integer getPort ()
 string getQuery ([boolean $toArray = false])
 string getScheme ()
 string getUser ()
 array getVar (string $name, [string $default = null])
 boolean hasVar (string $name)
 boolean isSSL ()
 boolean parse (string $uri)
 void setFragment (string $anchor)
 void setHost (string $host)
 void setPass (string $pass)
 void setPath (string $path)
 void setPort (integer $port)
 void setQuery (mixed $query)
 void setScheme (string $scheme)
 void setUser (string $user)
 string setVar (string $name, string $value)
 string toString ([array $parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment')])
 string _cleanPath (string $path)
 string __toString ()
Variables
static array $base = array() (line 95)
  • var: The current calculated base url segments.
  • since: 11.1
  • access: protected
static string $current (line 107)
  • var: The current url.
  • since: 11.1
  • access: protected
static array $instances = array() (line 89)
  • var: An array of JUri instances.
  • since: 11.1
  • access: protected
static array $root = array() (line 101)
  • var: The current calculated root url segments.
  • since: 11.1
  • access: protected
string $fragment = null (line 77)
  • var: Anchor
  • since: 12.1
  • access: protected
string $host = null (line 41)
  • var: Host
  • since: 12.1
  • access: protected
string $pass = null (line 59)
  • var: Password
  • since: 12.1
  • access: protected
string $path = null (line 65)
  • var: Path
  • since: 12.1
  • access: protected
integer $port = null (line 47)
  • var: Port
  • since: 12.1
  • access: protected
string $query = null (line 71)
  • var: Query
  • since: 12.1
  • access: protected
string $scheme = null (line 35)
  • var: Protocol
  • since: 12.1
  • access: protected
string $uri = null (line 29)
  • var: Original URI
  • since: 12.1
  • access: protected
string $user = null (line 53)
  • var: Username
  • since: 12.1
  • access: protected
array $vars = array() (line 83)
  • var: Query variable hash
  • since: 12.1
  • access: protected
Methods
static base (line 218)

Returns the base URI for the request.

  • return: The base URI string
  • since: 11.1
  • access: public
static string base ([boolean $pathonly = false])
  • boolean $pathonly: If false, prepend the scheme, host and port information. Default is false.
static buildQuery (line 544)

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

  • return: The resulting query string.
  • see: parse_str()
  • since: 11.1
  • access: public
static string buildQuery (array $params)
  • array $params: The array of key => value pairs to return as a query string.
static current (line 302)

Returns the URL for the request, minus the query.

  • since: 11.1
  • access: public
static string current ()
static getInstance (line 147)

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

  • return: The URI object.
  • since: 11.1
  • access: public
static JUri getInstance ([string $uri = 'SERVER'])
  • string $uri: The URI to parse. [optional: if null uses script URI]
static isInternal (line 765)

Checks if the supplied URL is internal

  • return: True if Internal.
  • since: 11.1
  • access: public
static boolean isInternal (string $url)
  • string $url: The URL to check.
static reset (line 321)

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

  • since: 11.1
  • access: public
static void reset ()
static root (line 276)

Returns the root URI for the request.

  • return: The root URI string.
  • since: 11.1
  • access: public
static string root ([boolean $pathonly = false], [string $path = null])
  • boolean $pathonly: If false, prepend the scheme, host and port information. Default is false.
  • string $path: The path
Constructor __construct (line 117)

Constructor.

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

  • since: 11.1
  • access: public
JUri __construct ([string $uri = null])
  • string $uri: The optional URI string
delVar (line 468)

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

  • since: 11.1
  • access: public
void delVar (string $name)
  • string $name: Name of variable to remove.
getFragment (line 724)

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

  • return: The URI anchor string.
  • since: 11.1
  • access: public
string getFragment ()
getHost (line 644)

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

  • return: The URI host.
  • since: 11.1
  • access: public
string getHost ()
getPass (line 617)

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

  • return: The URI password.
  • since: 11.1
  • access: public
string getPass ()
getPath (line 697)

Gets the URI path string.

  • return: The URI path string.
  • since: 11.1
  • access: public
string getPath ()
getPort (line 671)

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

  • return: The URI port number.
  • since: 11.1
  • access: public
integer getPort ()
getQuery (line 518)

Returns flat query string.

  • return: Query string.
  • since: 11.1
  • access: public
string getQuery ([boolean $toArray = false])
  • boolean $toArray: True to return the query as a key => value pair array.
getScheme (line 562)

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

  • return: The URI scheme.
  • since: 11.1
  • access: public
string getScheme ()
getUser (line 590)

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

  • return: The URI username.
  • since: 11.1
  • access: public
string getUser ()
getVar (line 449)

Returns a query variable by name.

  • return: Query variables.
  • since: 11.1
  • access: public
array getVar (string $name, [string $default = null])
  • string $name: Name of the query variable to get.
  • string $default: Default value to return if the variable is not set.
hasVar (line 434)

Checks if variable exists.

  • return: True if the variable exists.
  • since: 11.1
  • access: public
boolean hasVar (string $name)
  • string $name: Name of the query variable to check.
isSSL (line 751)

Checks whether the current URI is using HTTPS.

  • return: True if using SSL via HTTPS.
  • since: 11.1
  • access: public
boolean isSSL ()
parse (line 338)

Parse a given URI and populate the class fields.

  • return: True on success.
  • since: 11.1
  • access: public
boolean parse (string $uri)
  • string $uri: The URI string to parse.
setFragment (line 739)

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

  • since: 11.1
  • access: public
void setFragment (string $anchor)
  • string $anchor: The URI anchor string.
setHost (line 658)

Set URI host.

  • since: 11.1
  • access: public
void setHost (string $host)
  • string $host: The URI host.
setPass (line 631)

Set URI password.

  • since: 11.1
  • access: public
void setPass (string $pass)
  • string $pass: The URI password.
setPath (line 711)

Set the URI path string.

  • since: 11.1
  • access: public
void setPath (string $path)
  • string $path: The URI path string.
setPort (line 685)

Set URI port.

  • since: 11.1
  • access: public
void setPort (integer $port)
  • integer $port: The URI port number.
setQuery (line 489)

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

  • since: 11.1
  • access: public
void setQuery (mixed $query)
  • mixed $query: The query string or array.
setScheme (line 577)

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

  • since: 11.1
  • access: public
void setScheme (string $scheme)
  • string $scheme: The URI scheme.
setUser (line 604)

Set URI username.

  • since: 11.1
  • access: public
void setUser (string $user)
  • string $user: The URI username.
setVar (line 413)

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

  • return: Previous value for the query variable.
  • since: 11.1
  • access: public
string setVar (string $name, string $value)
  • string $name: Name of the query variable to set.
  • string $value: Value of the query variable.
toString (line 384)

Returns full uri string.

  • return: The rendered URI string.
  • since: 11.1
  • access: public
string toString ([array $parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment')])
  • array $parts: An array specifying the parts to render.
_cleanPath (line 793)

Resolves //, ../ 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

  • return: Cleaned and resolved URI path.
  • since: 11.1
  • access: protected
string _cleanPath (string $path)
  • string $path: The URI path to clean.
__toString (line 132)

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

  • since: 11.1
  • access: public
string __toString ()

Documentation generated on Tue, 19 Nov 2013 15:16:15 +0100 by phpDocumentor 1.4.3