class JApplication extends JObject


Located at : UKNOWVA_ROOT/libraries/joomla/application/application.php

Base class for a Joomla! application.

Acts as a Factory class for application specific objects and provides many supporting API functions. Derived clases should supply the route(), dispatch() and render() functions.

Properties

string $scope The scope of the application.
date $requestTime The time the request was made.
integer $startTime The time the request was made as Unix timestamp.
JInput $input The application input object.

Methods

__construct(array $config = array())

Class constructor.

string
__toString()

Returns the response as a string.

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() deprecated

No description

from JObject
static JApplication
getInstance($client, $config = array(), $prefix = 'J')

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

initialise(array $options = array())

Initialise the application.

void;
route()

Route the application.

void
dispatch(string $component = null)

Dispatch the applicaiton.

void
render()

Render the application.

void
close(integer $code)

Exit the application.

void
redirect(string $url, string $msg = '', string $msgType = 'message', boolean $moved = false)

Redirect to another URL.

void
enqueueMessage(string $msg, string $type = 'message')

Enqueue a system message.

array
getMessageQueue()

Get the system message queue.

mixed
getCfg(string $varname, string $default = null)

Gets a configuration value.

string
getName()

Method to get the application name.

mixed
getUserState(string $key, mixed $default = null)

Gets a user state.

mixed
setUserState(string $key, string $value)

Sets the value of a user state variable.

The
getUserStateFromRequest(string $key, string $request, string $default = null, string $type = 'none')

Gets the value of a user state variable.

static void
registerEvent(string $event, mixed $handler)

Registers a handler to a particular event group.

array
triggerEvent(string $event, array $args = null)

Calls all handlers associated with an event group.

boolean
login(array $credentials, array $options = array())

Login authentication function.

boolean
logout(integer $userid = null, array $options = array())

Logout authentication function.

string
getTemplate(array $params = false)

Gets the name of the current template.

static JRouter
getRouter(string $name = null, array $options = array())

Returns the application JRouter object.

static string
stringURLSafe(string $string)

This method transliterates a string into an URL safe string or returns a URL safe UTF-8 string based on the global configuration

getPathway(string $name = null, array $options = array())

Returns the application JPathway object.

getMenu(string $name = null, array $options = array())

Returns the application JPathway object.

static string
getHash(string $seed)

Provides a secure hash based on a seed

void
checkSession()

Checks the user session.

integer
getClientId()

Gets the client id of the current running application.

boolean
isAdmin()

Is admin interface?

boolean
isSite()

Is site interface?

goBack($msg = null, $msg_type = 'warning')

No description

static boolean
isWinOS()

Method to determine if the host OS is Windows

Details

at line 95
JObject __construct(array $config = array())

Class constructor.

Parameters

array $config A configuration array including optional elements such as session session_name, clientId and others. This is not exhaustive.

Return Value

JObject

at line 1137
string __toString()

Returns the response as a string.

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

in JObject at line 235
string toString() deprecated

deprecated 12.1 Use magic method __toString()

Return Value

string

See also

__toString()

at line 156
static JApplication getInstance($client, $config = array(), $prefix = 'J')

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

Parameters

$client
$config
$prefix

Return Value

JApplication A JApplication object.

at line 195
initialise(array $options = array())

Initialise the application.

Parameters

array $options An optional associative array of configuration settings.

at line 236
void; route()

Route the application.

Routing is the process of examining the request environment to determine which component should receive the request. The component optional parameters are then set in the request object to be processed when the application is being dispatched.

Return Value

void;

at line 264
void dispatch(string $component = null)

Dispatch the applicaiton.

Dispatching is the process of pulling the option from the request object and mapping them to a component. If the component does not exist, it handles determining a default component to dispatch.

Parameters

string $component The component to dispatch.

Return Value

void

at line 290
void render()

Render the application.

Rendering is the process of pushing the document buffers into the template placeholders, retrieving data from the document and pushing it into the JResponse buffer.

Return Value

void

at line 324
void close(integer $code)

Exit the application.

Parameters

integer $code Exit code

Return Value

void Exits the application.

at line 349
void redirect(string $url, string $msg = '', string $msgType = 'message', boolean $moved = false)

Redirect to another URL.

Optionally enqueues a message in the system message queue (which will be displayed the next time a page is loaded) using the enqueueMessage method. If the headers have not been sent the redirect will be accomplished using a "301 Moved Permanently" code in the header pointing to the new location. If the headers have already been sent this will be accomplished using a JavaScript statement.

Parameters

string $url The URL to redirect to. Can only be http/https URL
string $msg An optional message to display on redirect.
string $msgType An optional message type. Defaults to message.
boolean $moved True if the page is 301 Permanently Moved, otherwise 303 See Other is assumed.

Return Value

void Calls exit().

See also

JApplication::enqueueMessage()

at line 428
void enqueueMessage(string $msg, string $type = 'message')

Enqueue a system message.

Parameters

string $msg The message to enqueue.
string $type The message type. Default is message.

Return Value

void

at line 452
array getMessageQueue()

Get the system message queue.

Return Value

array The system message queue.

at line 480
mixed getCfg(string $varname, string $default = null)

Gets a configuration value.

An example is in application/japplication-getcfg.php Getting a configuration

Parameters

string $varname The name of the value to get.
string $default Default value to return

Return Value

mixed The user state.

at line 496
string getName()

Method to get the application name.

The dispatcher name is by default parsed using the classname, or it can be set by passing a $config['name'] in the class constructor.

Return Value

string The name of the dispatcher.

at line 521
mixed getUserState(string $key, mixed $default = null)

Gets a user state.

Parameters

string $key The path of the state.
mixed $default Optional default value, returned if the internal value is null.

Return Value

mixed The user state or null.

at line 543
mixed setUserState(string $key, string $value)

Sets the value of a user state variable.

Parameters

string $key The path of the state.
string $value The value of the variable.

Return Value

mixed The previous state, if one existed.

at line 567
The getUserStateFromRequest(string $key, string $request, string $default = null, string $type = 'none')

Gets the value of a user state variable.

Parameters

string $key The key of the user state variable.
string $request The name of the variable passed in a request.
string $default The default value for the variable if not found. Optional.
string $type Filter for the variable, for valid values see {@link JFilterInput::clean()}. Optional.

Return Value

The request user state.

at line 593
static void registerEvent(string $event, mixed $handler)

Registers a handler to a particular event group.

Parameters

string $event The event name.
mixed $handler The handler, a function or an instance of a event object.

Return Value

void

at line 609
array triggerEvent(string $event, array $args = null)

Calls all handlers associated with an event group.

Parameters

string $event The event name.
array $args An array of arguments.

Return Value

array An array of results from each function call.

at line 635
boolean login(array $credentials, array $options = array())

Login authentication function.

Username and encoded password are passed the onUserLogin event which is responsible for the user validation. A successful validation updates the current session record with the user's details.

Username and encoded password are sent as credentials (along with other possibilities) to each observer (authentication plugin) for user validation. Successful validation will update the current session with the user details.

Parameters

array $credentials Array('username' => string, 'password' => string)
array $options Array('remember' => boolean)

Return Value

boolean True on success.

at line 755
boolean logout(integer $userid = null, array $options = array())

Logout authentication function.

Passed the current user information to the onUserLogout event and reverts the current session record back to 'anonymous' parameters. If any of the authentication plugins did not successfully complete the logout routine then the whole method fails. Any errors raised should be done in the plugin as this provides the ability to give much more information about why the routine may have failed.

Parameters

integer $userid The user to load - Can be an integer or string - If string, it is converted to ID automatically
array $options Array('clientid' => array of client id's)

Return Value

boolean True on success

at line 804
string getTemplate(array $params = false)

Gets the name of the current template.

Parameters

array $params An optional associative array of configuration settings

Return Value

string System is the fallback.

at line 819
static JRouter getRouter(string $name = null, array $options = array())

Returns the application JRouter object.

Parameters

string $name The name of the application.
array $options An optional associative array of configuration settings.

Return Value

JRouter A JRouter object

at line 847
static string stringURLSafe(string $string)

This method transliterates a string into an URL safe string or returns a URL safe UTF-8 string based on the global configuration

Parameters

string $string String to process

Return Value

string Processed string

at line 869
JPathway getPathway(string $name = null, array $options = array())

Returns the application JPathway object.

Parameters

string $name The name of the application.
array $options An optional associative array of configuration settings.

Return Value

JPathway A JPathway object

at line 895
JMenu getMenu(string $name = null, array $options = array())

Returns the application JPathway object.

Parameters

string $name The name of the application/client.
array $options An optional associative array of configuration settings.

Return Value

JMenu JMenu object.

at line 920
static string getHash(string $seed)

Provides a secure hash based on a seed

Parameters

string $seed Seed string.

Return Value

string A secure hash

at line 1029
void checkSession()

Checks the user session.

If the session record doesn't exist, initialise it. If session is new, create session variables

Return Value

void

at line 1084
integer getClientId()

Gets the client id of the current running application.

Return Value

integer A client identifier.

at line 1096
boolean isAdmin()

Is admin interface?

Return Value

boolean True if this application is administrator.

at line 1108
boolean isSite()

Is site interface?

Return Value

boolean True if this application is site.

at line 1115
goBack($msg = null, $msg_type = 'warning')

Parameters

$msg
$msg_type

at line 1125
static boolean isWinOS()

Method to determine if the host OS is Windows

Return Value

boolean True if Windows OS