Joomla! Platform 12.1

 Class JController

Description

Base class for a Joomla Controller

Controller (Controllers are where you put all the actual code.) Provides basic functionality, such as rendering views (aka displaying templates).

  • since: 11.1

Located in /libraries/joomla/application/component/controller.php (line 22)

Class JObject   (Subpackage Base)

Class JController   (Subpackage Application)
Direct descendents
Class Description
ClassJControllerForm Controller tailored to suit most form-based admin operations.
ClassJControllerAdmin Base class for a Joomla Administrator Controller
Variable Summary
Variable string $basePath
Variable string $default_view
Variable string $doTask
Variable string $message
Variable string $messageType
Variable array $methods
Variable string $model_prefix
Variable array $name
Variable array $paths
Variable string $redirect
Variable string $task
Variable array $taskMap
Variable string $_acoSection
Method Summary
Static method static void addModelPath (mixed $path, [string $prefix = ''])
Static method static string createFileName (string $type, [array $parts = array()])
Static method static JController getInstance (string $prefix, [array $config = array()])
Constructor JController __construct ([array $config = array()])
Method JController addPath (string $type, mixed $path)
Method JController addViewPath (mixed $path)
Method boolean authorise (string $task)
Method boolean authorize (string $task)
Method boolean checkEditId (string $context, integer $id)
Method mixed createModel (string $name, [string $prefix = ''], [array $config = array()])
Method mixed createView (string $name, [string $prefix = ''], [string $type = ''], [array $config = array()])
Method JController display ([boolean $cachable = false], [array $urlparams = false])
Method mixed execute (string $task)
Method object The getModel ([string $name = ''], [string $prefix = ''], [array $config = array()])
Method string getName ()
Method string getTask ()
Method array getTasks ()
Method object Reference getView ([string $name = ''], [string $type = ''], [string $prefix = ''], [array $config = array()])
Method void holdEditId (string $context, integer $id)
Method boolean redirect ()
Method JController registerDefaultTask (string $method)
Method JController registerTask (string $task, string $method)
Method void releaseEditId (string $context, integer $id)
Method void setAccessControl (string $section, [string $value = null])
Method string setMessage (string $text, [string $type = 'message'])
Method void setPath (string $type, string $path)
Method JController setRedirect (string $url, [string $msg = null], [string $type = null])
Method JController unregisterTask (string $task)
Variables
string $basePath (line 49)

The base path of the controller

  • since: 11.1
  • access: protected
string $default_view (line 57)

The default view for the display method.

  • since: 11.1
  • access: protected
string $doTask (line 66)

The mapped task that was performed.

  • since: 11.1
  • access: protected
JController $instance (line 152)
  • var: JController instance container.
  • since: 11.3
  • access: protected
string $message (line 75)

Redirect message.

  • since: 11.1
  • access: protected
string $messageType (line 84)

Redirect message type.

  • since: 11.1
  • access: protected
array $methods (line 93)

Array of class methods

  • since: 11.1
  • access: protected
string $model_prefix (line 110)

The prefix of the models

  • since: 11.1
  • access: protected
array $name (line 102)

The name of the controller

  • since: 11.1
  • access: protected
array $paths (line 119)

The set of search directories for resources (views).

  • since: 11.1
  • access: protected
string $redirect (line 128)

URL for redirection.

  • since: 11.1
  • access: protected
string $task (line 137)

Current or most recently performed task.

  • since: 11.1
  • access: protected
array $taskMap (line 146)

Array of class methods to call for a given task.

  • since: 11.1
  • access: protected
string $_acoSection (line 31)

ACO Section for the controller.

  • deprecated: 12.1
  • since: 11.1
  • access: protected
string $_acoSectionValue (line 40)

Default ACO Section value for the controller.

  • deprecated: 12.1
  • since: 11.1
  • access: protected

Inherited Variables

Inherited from JObject

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

Constructor.

  • since: 11.1
  • access: public
JController __construct ([array $config = array()])
  • array $config: An optional associative array of configuration settings. Recognized key values include 'name', 'default_task', 'model_path', and 'view_path' (this list is not meant to be comprehensive).

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

Redefined in descendants as:
addModelPath (line 162)

Adds to the stack of model paths in LIFO order.

  • access: public
void addModelPath (mixed $path, [string $prefix = ''])
  • mixed $path: The directory (string), or list of directories (array) to add.
  • string $prefix: A prefix for models
addPath (line 444)

Adds to the search path for templates and resources.

  • return: A JController object to support chaining.
  • since: 11.1
  • access: protected
JController addPath (string $type, mixed $path)
  • string $type: The path type (e.g. 'model', 'view').
  • mixed $path: The directory string or stream array to search.
addViewPath (line 474)

Add one or more view paths to the controller's stack, in LIFO order.

  • return: This object to support chaining.
  • access: public
JController addViewPath (mixed $path)
  • mixed $path: The directory (string) or list of directories (array) to add.
authorise (line 509)

Authorisation check

  • return: True if authorised
  • since: 11.1
  • access: public
boolean authorise (string $task)
  • string $task: The ACO Section Value to check access on.
authorize (line 492)

Authorisation check

  • return: True if authorised
  • deprecated: 12.1 Use JAuthorise
  • since: 11.1
  • access: public
boolean authorize (string $task)
  • string $task: The ACO Section Value to check access on
checkEditId (line 542)

Method to check whether an ID is in the edit list.

  • return: True if the ID is in the edit list.
  • since: 11.1
  • access: protected
boolean checkEditId (string $context, integer $id)
  • string $context: The context for the session storage.
  • integer $id: The ID of the record to add to the edit list.
createFileName (line 179)

Create the filename for a resource.

  • return: The filename.
  • since: 11.1
  • access: protected
string createFileName (string $type, [array $parts = array()])
  • string $type: The resource type to create the filename for.
  • array $parts: An associative array of filename information. Optional.
createModel (line 587)

Method to load and return a model object.

  • return: Model object on success; otherwise null failure.
  • since: 11.1
  • access: protected
mixed createModel (string $name, [string $prefix = ''], [array $config = array()])
  • string $name: The name of the model.
  • string $prefix: Optional model prefix.
  • array $config: Configuration array for the model. Optional.
createView (line 616)

Method to load and return a view object. This method first looks in the current template directory for a match and, failing that, uses a default set path to load the view class file.

Note the "name, prefix, type" order of parameters, which differs from the "name, type, prefix" order used in related public methods.

  • return: View object on success; null or error result on failure.
  • since: 11.1
  • access: protected
mixed createView (string $name, [string $prefix = ''], [string $type = ''], [array $config = array()])
  • string $name: The name of the view.
  • string $prefix: Optional prefix for the view class name.
  • string $type: The type of view.
  • array $config: Configuration array for the view. Optional.
display (line 664)

Typical view method for MVC based architecture

This function is provide as a default implementation, in most cases you will need to override it in your own controllers.

  • return: A JController object to support chaining.
  • since: 11.1
  • access: public
JController display ([boolean $cachable = false], [array $urlparams = false])
  • boolean $cachable: If true, the view output will be cached
  • array $urlparams: An array of safe url parameters and their variable types, for valid values see JFilterInput::clean().

Redefined in descendants as:
execute (line 730)

Execute a task by triggering a method in the derived class.

  • return: The value returned by the called method, false in error case.
  • since: 11.1
  • access: public
mixed execute (string $task)
  • string $task: The task to perform. If no matching task is found, the '__default' task is executed, if defined.
getInstance (line 229)

Method to get a singleton controller instance.

  • throws: Exception if the controller cannot be loaded.
  • since: 11.1
  • access: public
JController getInstance (string $prefix, [array $config = array()])
  • string $prefix: The prefix for the controller.
  • array $config: An array of optional constructor options.
getModel (line 774)

Method to get a model object, loading it if required.

  • return: model.
  • since: 11.1
  • access: public
object The getModel ([string $name = ''], [string $prefix = ''], [array $config = array()])
  • string $name: The model name. Optional.
  • string $prefix: The class prefix. Optional.
  • array $config: Configuration array for model. Optional.

Redefined in descendants as:
getName (line 818)

Method to get the controller name

The dispatcher name is set 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 ()
getTask (line 840)

Get the last task that is being performed or was most recently performed.

  • return: The task that is being performed or was most recently performed.
  • since: 11.1
  • access: public
string getTask ()
getTasks (line 852)

Gets the available tasks in the controller.

  • return: Array[i] of task names.
  • since: 11.1
  • access: public
array getTasks ()
getView (line 869)

Method to get a reference to the current view and load it if necessary.

  • return: to the view or an error.
  • since: 11.1
  • access: public
object Reference getView ([string $name = ''], [string $type = ''], [string $prefix = ''], [array $config = array()])
  • string $name: The view name. Optional, defaults to the controller name.
  • string $type: The view type. Optional.
  • string $prefix: The class prefix. Optional.
  • array $config: Configuration array for view. Optional.
holdEditId (line 915)

Method to add a record ID to the edit list.

  • since: 11.1
  • access: protected
void holdEditId (string $context, integer $id)
  • string $context: The context for the session storage.
  • integer $id: The ID of the record to add to the edit list.
redirect (line 946)

Redirects the browser or returns false if no redirect is set.

  • return: False if no redirect exists.
  • since: 11.1
  • access: public
boolean redirect ()
registerDefaultTask (line 966)

Register the default task to perform if a mapping is not found.

  • return: A JController object to support chaining.
  • since: 11.1
  • access: public
JController registerDefaultTask (string $method)
  • string $method: The name of the method in the derived class to perform if a named task is not found.
registerTask (line 983)

Register (map) a task to a method in the class.

  • return: A JController object to support chaining.
  • since: 11.1
  • access: public
JController registerTask (string $task, string $method)
  • string $task: The task.
  • string $method: The name of the method in the derived class to perform for this task.
releaseEditId (line 1019)

Method to check whether an ID is in the edit list.

  • since: 11.1
  • access: protected
void releaseEditId (string $context, integer $id)
  • string $context: The context for the session storage.
  • integer $id: The ID of the record to add to the edit list.
setAccessControl (line 1055)

Sets the access control levels.

  • see: Jaccess
  • deprecated: 12.1 Use JAccess
  • since: 11.1
  • access: public
void setAccessControl (string $section, [string $value = null])
  • string $section: The ACO section (eg, the component).
  • string $value: The ACO section value (if using a constant value).
setMessage (line 1073)

Sets the internal message that is passed with a redirect

  • return: Previous message
  • since: 11.1
  • access: public
string setMessage (string $text, [string $type = 'message'])
  • string $text: Message to display on redirect.
  • string $type: Message type (since 11.1). Optional, defaults to 'message'.
setPath (line 1093)

Sets an entire array of search paths for resources.

  • since: 11.1
  • access: protected
void setPath (string $type, string $path)
  • string $type: The type of path to set, typically 'view' or 'model'.
  • string $path: The new set of search paths. If null or false, resets to the current directory only.
setRedirect (line 1113)

Set a URL for browser redirection.

  • return: This object to support chaining.
  • since: 11.1
  • access: public
JController setRedirect (string $url, [string $msg = null], [string $type = null])
  • string $url: URL to redirect to.
  • string $msg: Message to display on redirect. Optional, defaults to value set internally by controller, if any.
  • string $type: Message type. Optional, defaults to 'message' or the type set by a previous call to setMessage.
unregisterTask (line 1002)

Unregister (unmap) a task in the class.

  • return: This object to support chaining.
  • since: 11.1
  • access: public
JController unregisterTask (string $task)
  • string $task: The task.

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>