Class JURI

Description

JURI Class

This class serves two purposes. First to parse a URI and provide a common interface for the Joomla Framework to access and manipulate a URI. Second to attain the URI of the current executing script from the server regardless of server.

The concept and implementation of this class is drawn heavily from the binary cloud environment package. <http://www.binarycloud.com/>

Located in /application/environment/uri.php (line 31)

JObject
   |
   --JURI
Variable Summary
 string $_anchor
 string $_host
 string $_pass
 string $_path
 integer $_port
 string $_scheme
 string $_uri
 string $_user
 array $_vars
Method Summary
 JURI __construct ([string $uri = null])
 void delVar (string $name)
 string getAnchor ()
 string getHost ()
 JURI getInstance ([string $uri = 'SERVER'])
 string getPassword ()
 string getPath ()
 int getPort ()
 string getQueryString ()
 string getScheme ()
 string getUsername ()
 array getVars ()
 boolean isSSL ()
 boolean parse (string $uri)
 void setAnchor (string $anchor)
 void setHost (string $host)
 void setPassword (string $pass)
 void setPath (string $path)
 void setPort (int $port)
 void setQueryString (string $query)
 void setScheme (string $scheme)
 void setUsername (string $user)
 string setVar (string $name, string $value)
 string toString ([array $parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment')])
 string _cleanPath (mixed $path, string $uri)
 array _parseQueryString (string $query)
Variables
string $_anchor = null (line 94)

Anchor

string $_host = null (line 66)

Host

string $_pass = null (line 59)

Password

string $_path = null (line 80)

Path

integer $_port = null (line 73)

Port

string $_scheme = null (line 45)

Protocol

string $_uri = null (line 38)

Original URI

string $_user = null (line 52)

Username

array $_vars = array () (line 87)

Query variable hash

Methods
Constructor __construct (line 102)

Constructor.

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

JURI __construct ([string $uri = null])
  • string $uri: The optional URI string

Redefinition of:
JObject::__construct()
Class constructor, overridden in descendant classes.
delVar (line 285)

Removes an item from the query string variables if it exists

  • since: 1.1
  • access: public
void delVar (string $name)
  • string $name: Name of variable to remove
getAnchor (line 480)

Get the URI archor string everything after the "#"

  • return: The URI anchor string
  • since: 1.1
  • access: public
string getAnchor ()
getHost (line 413)

Get URI host returns the hostname/ip, or null if no hostname/ip was specified

  • return: The URI host
  • since: 1.1
  • access: public
string getHost ()
getInstance (line 121)

Returns a reference to a global JURI object, only creating it if it doesn't already exist.

This method must be invoked as:

  $uri =& JURI::getInstance([$uri]);

  • return: The URI object.
  • since: 1.1
  • static:
JURI getInstance ([string $uri = 'SERVER'])
  • string $uri: The URI to parse. [optional: if null uses script URI]
getPassword (line 390)

Get URI password returns the password, or null if no password was specified

  • return: The URI password
  • since: 1.1
  • access: public
string getPassword ()
getPath (line 457)

Gets the URI path string

  • return: The URI path string
  • since: 1.1
  • access: public
string getPath ()
getPort (line 435)

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

  • return: The URI port number
  • access: public
int getPort ()
getQueryString (line 311)

Returns flat query string from (array) $_vars hash

  • return: Query string
  • since: 1.1
  • access: public
string getQueryString ()
getScheme (line 343)

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

  • return: The URI scheme
  • since: 1.1
  • access: public
string getScheme ()
getUsername (line 367)

Get URI username returns the username, or null if no username was specified

  • return: The URI username
  • since: 1.1
  • access: public
string getUsername ()
getVars (line 274)

Returns an array with all of the query variables

  • return: Query variables
  • since: 1.1
  • access: public
array getVars ()
isSSL (line 503)

Checks whether the current URI is using HTTPS

  • return: True if using SSL via HTTPS
  • since: 1.1
  • access: public
boolean isSSL ()
parse (line 195)

Parse a given URI and populate the class fields

  • return: True on success
  • since: 1.1
  • access: public
boolean parse (string $uri)
  • string $uri: The URI string to parse
setAnchor (line 492)

Set the URI anchor string everything after the "#"

  • since: 1.1
  • access: public
void setAnchor (string $anchor)
  • string $anchor: The URI anchor string
setHost (line 424)

Set URI host

  • since: 1.1
  • access: public
void setHost (string $host)
  • string $host: The URI host
setPassword (line 401)

Set URI password

  • since: 1.1
  • access: public
void setPassword (string $pass)
  • string $pass: The URI password
setPath (line 468)

Set the URI path string

  • since: 1.1
  • access: public
void setPath (string $path)
  • string $path: The URI path string
setPort (line 446)

Set URI port

  • since: 1.1
  • access: public
void setPort (int $port)
  • int $port: The URI port number
setQueryString (line 300)

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

  • since: 1.1
  • access: public
void setQueryString (string $query)
  • string $query: The query string
setScheme (line 355)

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

  • since: 1.1
  • access: public
void setScheme (string $scheme)
  • string $scheme: The URI scheme
setUsername (line 378)

Set URI username

  • since: 1.1
  • access: public
void setUsername (string $user)
  • string $user: The URI username
setVar (line 260)

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: 1.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 233)

Returns full uri string

  • return: The rendered URI string
  • since: 1.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

Redefinition of:
JObject::toString()
Object-to-string conversion.
_cleanPath (line 565)

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: 1.1
  • access: private
string _cleanPath (mixed $path, string $uri)
  • string $uri: The URI path to clean
_parseQueryString (line 516)

Parses raw query and returns an array of key/value pairs representing the query string variables.

  • return: An array of the query data
  • since: 1.1
  • access: private
array _parseQueryString (string $query)
  • string $query: The query string to parse

Inherited Methods

Inherited From JObject

 JObject::__construct()
 JObject::JObject()
 JObject::get()
 JObject::set()
 JObject::toString()
 JObject::__destruct()

Documentation generated on Sat, 4 Feb 2006 14:27:09 +0100 by phpDocumentor 1.3.0RC4