Документация по Joomla 1.7

Joomla.Platform\JURI
libraries/joomla/environment/uri.php at line 25

Class JURI

JObject
└─JURI

public class JURI
extends JObject

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.

Subpackage:
Environment
Since:
11.1

Field Summary
protected string Anchor

$_fragment

protected string Host

$_host

protected string Password

$_pass

protected string Path

$_path

protected integer Port

$_port

protected string Query

$_query

protected string Protocol

$_scheme

protected string Original URI

$_uri

protected string Username

$_user

protected array Query variable hash

$_vars

protected static array The current calculated base url segments.

$base

protected static string The current url.

$current

protected static array An array of JURI instances.

$instances

protected static array The current calculated root url segments.

$root

Fields inherited from Joomla.Platform\JObject
_errors
Constructor Summary
JObject

__construct(string uri, mixed properties)

Constructor.

Method Summary
string

__toString()

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

static JURI

getInstance(string uri)

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

static string

base(boolean pathonly)

Returns the base URI for the request.

static string

root(boolean pathonly, mixed path)

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

toString(array parts)

Returns full uri string.

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)

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)

Returns flat query string.

static string

buildQuery(mixed params)

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

string

getScheme()

Get URI scheme (protocol) ie.

void

setScheme(string scheme)

Set URI scheme (protocol) ie.

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

protected string

_cleanPath(string path)

Resolves //, ../ and ./ from a path and returns the result.

Methods inherited from Joomla.Platform\JObject
__construct, __toString, def, get, getError, getErrors, getProperties, set, setError, setProperties, toString

Field Detail

libraries/joomla/environment/uri.php at line 79

_fragment

protected string Anchor $_fragment = null

Since:
11.1

libraries/joomla/environment/uri.php at line 43

_host

protected string Host $_host = null

Since:
11.1

libraries/joomla/environment/uri.php at line 61

_pass

protected string Password $_pass = null

Since:
11.1

libraries/joomla/environment/uri.php at line 67

_path

protected string Path $_path = null

Since:
11.1

libraries/joomla/environment/uri.php at line 49

_port

protected integer Port $_port = null

Since:
11.1

libraries/joomla/environment/uri.php at line 73

_query

protected string Query $_query = null

Since:
11.1

libraries/joomla/environment/uri.php at line 37

_scheme

protected string Protocol $_scheme = null

Since:
11.1

libraries/joomla/environment/uri.php at line 31

_uri

protected string Original URI $_uri = null

Since:
11.1

libraries/joomla/environment/uri.php at line 55

_user

protected string Username $_user = null

Since:
11.1

libraries/joomla/environment/uri.php at line 85

_vars

protected array Query variable hash $_vars = array ()

Since:
11.1

libraries/joomla/environment/uri.php at line 97

base

protected static array The current calculated base url segments. $base = array()

Since:
11.1

libraries/joomla/environment/uri.php at line 109

current

protected static string The current url. $current

Since:
11.1

libraries/joomla/environment/uri.php at line 91

instances

protected static array An array of JURI instances. $instances = array()

Since:
11.1

libraries/joomla/environment/uri.php at line 103

root

protected static array The current calculated root url segments. $root = array()

Since:
11.1

Constructor Detail

libraries/joomla/environment/uri.php at line 119

__construct

public JObject __construct(string uri, mixed properties)

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

Parameters:
uri - The optional URI string
Since:
11.1

Method Detail

libraries/joomla/environment/uri.php at line 132

__toString

public string __toString()

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

Since:
11.1

libraries/joomla/environment/uri.php at line 146

getInstance

public static JURI getInstance(string uri)

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

Parameters:
uri - The URI to parse. [optional: if null uses script URI]
Returns:
The URI object.
Since:
11.1

libraries/joomla/environment/uri.php at line 202

base

public static string base(boolean pathonly)

Returns the base URI for the request.

Parameters:
pathonly - If false, prepend the scheme, host and port information. Default is false.
Returns:
The base URI string
Since:
11.1

libraries/joomla/environment/uri.php at line 248

root

public static string root(boolean pathonly, mixed path)

Returns the root URI for the request.

Parameters:
pathonly - If false, prepend the scheme, host and port information. Default is false..
Returns:
The root URI string.
Since:
11.1

libraries/joomla/environment/uri.php at line 271

current

public static string current()

Returns the URL for the request, minus the query.

Since:
11.1

libraries/joomla/environment/uri.php at line 288

reset

public static void reset()

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

Since:
11.1

libraries/joomla/environment/uri.php at line 304

parse

public boolean parse(string uri)

Parse a given URI and populate the class fields.

Parameters:
uri - The URI string to parse.
Returns:
True on success.
Since:
11.1

libraries/joomla/environment/uri.php at line 349

toString

public string toString(array parts)

Returns full uri string.

Parameters:
parts - An array specifying the parts to render.
Returns:
The rendered URI string.
Since:
11.1
Deprecated:
12.1 Use magic method __toString()
See Also:
__toString()

libraries/joomla/environment/uri.php at line 378

setVar

public 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:
name - Name of the query variable to set.
value - Value of the query variable.
Returns:
Previous value for the query variable.
Since:
11.1

libraries/joomla/environment/uri.php at line 398

hasVar

public bool hasVar(string name)

Checks if variable exists.

Parameters:
name - Name of the query variable to check.
Returns:
exists.
Since:
11.1

libraries/joomla/environment/uri.php at line 413

getVar

public array getVar(string name, string default)

Returns a query variable by name.

Parameters:
name - Name of the query variable to get.
default - Default value to return if the variable is not set.
Returns:
Query variables.
Since:
11.1

libraries/joomla/environment/uri.php at line 430

delVar

public void delVar(string name)

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

Parameters:
name - Name of variable to remove.
Since:
11.1

libraries/joomla/environment/uri.php at line 450

setQuery

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

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

Parameters:
query - The query string.
Since:
11.1

libraries/joomla/environment/uri.php at line 474

getQuery

public string getQuery(boolean toArray)

Returns flat query string.

Returns:
Query string.
Since:
11.1

libraries/joomla/environment/uri.php at line 496

buildQuery

public static string buildQuery(mixed params)

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

Returns:
$params The resulting query string.
See Also:
parse_str()
Since:
11.1

libraries/joomla/environment/uri.php at line 512

getScheme

public string getScheme()

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

Returns:
The URI scheme.
Since:
11.1

libraries/joomla/environment/uri.php at line 527

setScheme

public void setScheme(string scheme)

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

Parameters:
scheme - The URI scheme.
Since:
11.1

libraries/joomla/environment/uri.php at line 539

getUser

public string getUser()

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

Returns:
The URI username.
Since:
11.1

libraries/joomla/environment/uri.php at line 553

setUser

public void setUser(string user)

Set URI username.

Parameters:
user - The URI username.
Since:
11.1

libraries/joomla/environment/uri.php at line 565

getPass

public string getPass()

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

Returns:
The URI password.
Since:
11.1

libraries/joomla/environment/uri.php at line 579

setPass

public void setPass(string pass)

Set URI password.

Parameters:
pass - The URI password.
Since:
11.1

libraries/joomla/environment/uri.php at line 591

getHost

public string getHost()

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

Returns:
The URI host.
Since:
11.1

libraries/joomla/environment/uri.php at line 605

setHost

public void setHost(string host)

Set URI host.

Parameters:
host - The URI host.
Since:
11.1

libraries/joomla/environment/uri.php at line 616

getPort

public integer getPort()

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

Returns:
The URI port number.

libraries/joomla/environment/uri.php at line 630

setPort

public void setPort(integer port)

Set URI port.

Parameters:
port - The URI port number.
Since:
11.1

libraries/joomla/environment/uri.php at line 641

getPath

public string getPath()

Gets the URI path string.

Returns:
The URI path string.
Since:
11.1

libraries/joomla/environment/uri.php at line 655

setPath

public void setPath(string path)

Set the URI path string.

Parameters:
path - The URI path string.
Since:
11.1

libraries/joomla/environment/uri.php at line 667

getFragment

public string getFragment()

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

Returns:
The URI anchor string.
Since:
11.1

libraries/joomla/environment/uri.php at line 682

setFragment

public void setFragment(string anchor)

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

Parameters:
anchor - The URI anchor string.
Since:
11.1

libraries/joomla/environment/uri.php at line 693

isSSL

public boolean isSSL()

Checks whether the current URI is using HTTPS.

Returns:
True if using SSL via HTTPS.
Since:
11.1

libraries/joomla/environment/uri.php at line 707

isInternal

public static boolean isInternal(string url)

Checks if the supplied URL is internal

Parameters:
url - The URL to check.
Returns:
True if Internal.
Since:
11.1

libraries/joomla/environment/uri.php at line 732

_cleanPath

protected string _cleanPath(string path)

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

Parameters:
path - The URI path to clean.
Returns:
Cleaned and resolved URI path.
Since:
11.1

Документация по Joomla 1.7