Joomla! Platform 11.4

 Class JApplication

Description

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.

  • since: 11.1

Located in /libraries/joomla/application/application.php (line 28)

Class JObject   (Subpackage Base)

Class JApplication   (Subpackage Application)
Variable Summary
Static variable static array $instances
Variable integer $clientId
Variable array $name
Variable string $scope
Variable integer $startTime
Variable integer $_clientId
Variable array $_name
Method Summary
Static method static string getHash (string $seed)
Static method static JApplication getInstance (mixed $client, [array $config = array()], [string $prefix = 'J'])
Static method static JRouter getRouter ([string $name = null], [ $options = array()])
Static method static boolean isWinOS ()
Static method static void registerEvent (string $event, mixed $handler)
Static method static string stringURLSafe (string $string)
Constructor JApplication __construct ([array $config = array()])
Method void checkSession ()
Method void close ([integer $code = 0])
Method void dispatch ([string $component = null])
Method void enqueueMessage (string $msg, [string $type = 'message'])
Method mixed getCfg (string $varname, [string $default = null])
Method integer getClientId ()
Method JMenu getMenu ([string $name = null], [array $options = array()])
Method array getMessageQueue ()
Method string getName ()
Method JPathway getPathway ([string $name = null], [array $options = array()])
Method string getTemplate ([array $params = false])
Method mixed getUserState (string $key, [mixed $default = null])
Method The getUserStateFromRequest (string $key, string $request, [string $default = null], [string $type = 'none'])
Method void initialise ([array $options = array()])
Method boolean isAdmin ()
Method boolean isSite ()
Method boolean login (array $credentials, [array $options = array()])
Method boolean logout ([integer $userid = null], [array $options = array()])
Method void redirect (string $url, [string $msg = ''], [string $msgType = 'message'], [boolean $moved = false])
Method void render ()
Method void route ()
Method mixed setUserState (string $key, string $value)
Method array triggerEvent (string $event, [array $args = null])
Method object A _createConfiguration (string $file)
Method JSession _createSession (string $name)
Method string __toString ()
Variables
integer $clientId = null (line 36)

The client identifier.

  • since: 11.1
  • access: protected
JInput $input = null (line 111)

The application input object.

  • since: 11.2
  • access: public
array $instances = array() (line 117)
  • var: JApplication instances container.
  • since: 11.3
  • access: protected
array $messageQueue = array() (line 53)

The application message queue.

  • since: 11.1
  • access: protected
array $name = null (line 70)

The name of the application.

  • since: 11.1
  • access: protected
date $requestTime = null (line 95)

The time the request was made.

  • since: 11.1
  • access: public
string $scope = null (line 87)

The scope of the application.

  • since: 11.1
  • access: public
integer $startTime = null (line 103)

The time the request was made as Unix timestamp.

  • since: 11.1
  • access: public
integer $_clientId = null (line 45)

The client identifier.

  • deprecated: use $clientId or declare as private
  • since: 11.1
  • access: protected
array $_messageQueue = array() (line 62)

The application message queue.

  • deprecated: use $messageQueue or declare as private
  • since: 11.1
  • access: protected
array $_name = null (line 79)

The name of the application.

  • deprecated: use $name or declare as private
  • since: 11.1
  • access: protected

Inherited Variables

Inherited from JObject

Variable JObject::$_errors
Methods
Constructor __construct (line 127)

Class constructor.

  • since: 11.1
  • access: public
JApplication __construct ([array $config = array()])
  • array $config: A configuration array including optional elements such as session session_name, clientId and others. This is not exhaustive.

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

Checks the user session.

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

  • since: 11.1
  • access: public
void checkSession ()
close (line 356)

Exit the application.

  • return: Exits the application.
  • since: 11.1
  • access: public
void close (integer $code)
  • integer $code: Exit code
dispatch (line 301)

Dispatch the application.

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.

  • since: 11.1
  • access: public
void dispatch ([string $component = null])
  • string $component: The component to dispatch.
enqueueMessage (line 475)

Enqueue a system message.

  • since: 11.1
  • access: public
void enqueueMessage (string $msg, [string $type = 'message'])
  • string $msg: The message to enqueue.
  • string $type: The message type. Default is message.
getCfg (line 531)

Gets a configuration value.

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

  • return: The user state.
  • since: 11.1
  • access: public
mixed getCfg (string $varname, [string $default = null])
  • string $varname: The name of the value to get.
  • string $default: Default value to return
getClientId (line 1140)

Gets the client id of the current running application.

  • return: A client identifier.
  • since: 11.1
  • access: public
integer getClientId ()
getHash (line 980)

Provides a secure hash based on a seed

  • return: A secure hash
  • since: 11.1
  • access: public
string getHash (string $seed)
  • string $seed: Seed string.
getInstance (line 194)

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

  • return: A JApplication object.
  • since: 11.1
  • access: public
JApplication getInstance (mixed $client, [array $config = array()], [string $prefix = 'J'])
  • mixed $client: A client identifier or name.
  • array $config: An optional associative array of configuration settings.
  • string $prefix: A prefix for class names
getMenu (line 953)

Returns the application JPathway object.

  • return: JMenu object.
  • since: 11.1
  • access: public
JMenu getMenu ([string $name = null], [array $options = array()])
  • string $name: The name of the application/client.
  • array $options: An optional associative array of configuration settings.
getMessageQueue (line 501)

Get the system message queue.

  • return: The system message queue.
  • since: 11.1
  • access: public
array getMessageQueue ()
getName (line 547)

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: The name of the dispatcher.
  • since: 11.1
  • access: public
string getName ()
getPathway (line 925)

Returns the application JPathway object.

  • return: A JPathway object
  • since: 11.1
  • access: public
JPathway getPathway ([string $name = null], [array $options = array()])
  • string $name: The name of the application.
  • array $options: An optional associative array of configuration settings.
getRouter (line 871)

Returns the application JRouter object.

  • return: A JRouter object
  • since: 11.1
  • access: public
JRouter getRouter ([string $name = null], [ $options = array()])
  • string $name: The name of the application.
  • array $options: An optional associative array of configuration settings.
getTemplate (line 856)

Gets the name of the current template.

  • return: System is the fallback.
  • since: 11.1
  • access: public
string getTemplate ([array $params = false])
  • array $params: An optional associative array of configuration settings
getUserState (line 574)

Gets a user state.

  • return: The user state or null.
  • since: 11.1
  • access: public
mixed getUserState (string $key, [mixed $default = null])
  • string $key: The path of the state.
  • mixed $default: Optional default value, returned if the internal value is null.
getUserStateFromRequest (line 622)

Gets the value of a user state variable.

  • return: request user state.
  • since: 11.1
  • access: public
The getUserStateFromRequest (string $key, string $request, [string $default = null], [string $type = 'none'])
  • 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 JFilterInput::clean(). Optional.
initialise (line 231)

Initialise the application.

  • since: 11.1
  • access: public
void initialise ([array $options = array()])
  • array $options: An optional associative array of configuration settings.
isAdmin (line 1152)

Is admin interface?

  • return: True if this application is administrator.
  • since: 11.1
  • access: public
boolean isAdmin ()
isSite (line 1164)

Is site interface?

  • return: True if this application is site.
  • since: 11.1
  • access: public
boolean isSite ()
isWinOS (line 1176)

Method to determine if the host OS is Windows

  • return: True if Windows OS
  • since: 11.1
  • access: public
boolean isWinOS ()
login (line 692)

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.

  • return: True on success.
  • since: 11.1
  • access: public
boolean login (array $credentials, [array $options = array()])
  • array $credentials: Array('username' => string, 'password' => string)
  • array $options: Array('remember' => boolean)
logout (line 808)

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.

  • return: True on success
  • since: 11.1
  • access: public
boolean logout ([integer $userid = null], [array $options = array()])
  • 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)
redirect (line 381)

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.

void redirect (string $url, [string $msg = ''], [string $msgType = 'message'], [boolean $moved = false])
  • 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.
registerEvent (line 650)

Registers a handler to a particular event group.

  • since: 11.1
  • access: public
void registerEvent (string $event, mixed $handler)
  • string $event: The event name.
  • mixed $handler: The handler, a function or an instance of a event object.
render (line 327)

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.

  • since: 11.1
  • access: public
void render ()
route (line 273)

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.

  • since: 11.1
  • access: public
void route ()
setUserState (line 597)

Sets the value of a user state variable.

  • return: The previous state, if one existed.
  • since: 11.1
  • access: public
mixed setUserState (string $key, string $value)
  • string $key: The path of the state.
  • string $value: The value of the variable.
stringURLSafe (line 901)

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

  • return: Processed string
  • since: 11.1
  • access: public
string stringURLSafe (string $string)
  • string $string: String to process
triggerEvent (line 666)

Calls all handlers associated with an event group.

  • return: An array of results from each function call.
  • since: 11.1
  • access: public
array triggerEvent (string $event, [array $args = null])
  • string $event: The event name.
  • array $args: An array of arguments.
_createConfiguration (line 994)

Create the configuration registry.

  • return: JConfig object
  • since: 11.1
  • access: protected
object A _createConfiguration (string $file)
  • string $file: The path to the configuration file
_createSession (line 1024)

Create the user session.

Old sessions are flushed based on the configuration value for the cookie lifetime. If an existing session, then the last access time is updated. If a new session, a session id is generated and a record is created in the #__sessions table.

  • return: JSession on success. May call exit() on database error.
  • since: 11.1
  • access: protected
JSession _createSession (string $name)
  • string $name: The sessions name.
__toString (line 1188)

Returns the response as a string.

  • return: The response
  • since: 11.1
  • access: public
string __toString ()

Redefinition of:
JObject::__toString()
Magic method to convert the object to a string gracefully.

Inherited Methods

Inherited From JObject

 JObject::__construct()
 JObject::def()
 JObject::get()
 JObject::getError()
 JObject::getErrors()
 JObject::getProperties()
 JObject::set()
 JObject::setError()
 JObject::setProperties()
 JObject::toString()
 JObject::__toString()
/html>