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 27)

JObject
   |
   --JApplication
Direct descendents
Class Description
JAdministrator Joomla! Application class
JSite Joomla! Application class
JInstallation Joomla Application class
Variable Summary
static array $instances
string $scope
integer $startTime
integer $_clientId
array $_name
Method Summary
static string getHash (string $seed)
static JApplication getInstance (mixed $client, [array $config = array()], [string $prefix = 'J'])
static JRouter getRouter ([string $name = null], [array $options = array()])
static boolean isWinOS ()
static void registerEvent (string $event, mixed $handler)
static string stringURLSafe (string $string)
JApplication __construct ([array $config = array()])
void checkSession ()
void close ([integer $code = 0])
void dispatch ([string $component = null])
void enqueueMessage (string $msg, [string $type = 'message'])
mixed getCfg (string $varname, [string $default = null])
integer getClientId ()
JMenu getMenu ([string $name = null], [array $options = array()])
array getMessageQueue ()
string getName ()
JPathway getPathway ([string $name = null], [array $options = array()])
string getTemplate ([array $params = false])
mixed getUserState (string $key, [mixed $default = null])
The getUserStateFromRequest (string $key, string $request, [string $default = null], [string $type = 'none'])
void initialise ([array $options = array()])
boolean isAdmin ()
boolean isSite ()
boolean login (array $credentials, [array $options = array()])
boolean logout ([integer $userid = null], [array $options = array()])
void redirect (string $url, [string $msg = ''], [string $msgType = 'message'], [boolean $moved = false])
void render ()
void route ()
mixed setUserState (string $key, string $value)
array triggerEvent (string $event, [array $args = null])
object A _createConfiguration (string $file)
JSession _createSession (string $name)
string __toString ()
Variables
static array $instances = array() (line 89)
  • var: JApplication instances container.
  • since: 11.3
  • access: protected
JInput $input = null (line 83)

The application input object.

  • since: 11.2
  • access: public
date $requestTime = null (line 67)

The time the request was made.

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

The scope of the application.

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

The time the request was made as Unix timestamp.

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

The client identifier.

  • since: 11.1
  • access: protected
array $_messageQueue = array() (line 43)

The application message queue.

  • since: 11.1
  • access: protected
array $_name = null (line 51)

The name of the application.

  • since: 11.1
  • access: protected

Inherited Variables

Inherited from JObject

JObject::$_errors
Methods
static method getHash (line 951)

Provides a secure hash based on a seed

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

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

  • return: A JApplication object.
  • since: 11.1
  • access: public
static 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
static method getRouter (line 842)

Returns the application JRouter object.

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

Redefined in descendants as:
static method isWinOS (line 1155)

Method to determine if the host OS is Windows

  • return: True if Windows OS
  • since: 11.1
  • access: public
static boolean isWinOS ()
static method registerEvent (line 622)

Registers a handler to a particular event group.

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

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
static string stringURLSafe (string $string)
  • string $string: String to process
Constructor __construct (line 99)

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.

Redefined in descendants as:
checkSession (line 1057)

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 328)

Exit the application.

  • return: Exits the application.
  • since: 11.1
  • access: public
void close ([integer $code = 0])
  • integer $code: Exit code
dispatch (line 273)

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.

Redefined in descendants as:
enqueueMessage (line 447)

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 503)

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 1119)

Gets the client id of the current running application.

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

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.

Redefined in descendants as:
getMessageQueue (line 473)

Get the system message queue.

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

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 896)

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.

Redefined in descendants as:
getTemplate (line 827)

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

Redefined in descendants as:
getUserState (line 546)

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 594)

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 203)

Initialise the application.

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

Redefined in descendants as:
isAdmin (line 1131)

Is admin interface?

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

Is site interface?

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

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)

Redefined in descendants as:
logout (line 779)

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 353)

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.

Redefined in descendants as:
render (line 299)

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

Redefined in descendants as:
route (line 245)

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

Redefined in descendants as:
setUserState (line 569)

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.
triggerEvent (line 638)

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 965)

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

Redefined in descendants as:
_createSession (line 995)

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.

Redefined in descendants as:
__toString (line 1167)

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

Documentation generated on Mon, 25 Jun 2012 13:52:07 -0500 by phpDocumentor 1.4.4