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)

JObject
   |
   --JController
Direct descendents
Class Description
CpanelController Cpanel Controller
AdminController Admin Controller
CheckinController Checkin Controller
ModulesController Modules manager master display controller.
MessagesHelper
JHtmlMessages
MessagesController Messages master display controller.
MessagesControllerConfig Messages Component Message Model
UsersController Users master display controller.
UsersControllerMail Users mail controller.
NewsfeedsController Newsfeeds master display controller.
ConfigController Config Component Controller
ConfigControllerComponent Note: this view is intended only to be opened in a popup
ConfigControllerApplication
LanguagesController Languages Controller
LanguagesControllerInstalled Languages Controller
WeblinksController Weblinks Weblink Controller
PluginsController Plugins master display controller.
InstallerController Installer Controller
InstallerControllerDiscover
InstallerControllerInstall
InstallerControllerUpdate
InstallerControllerDatabase
InstallerControllerManage
CategoriesController Categories view class for the Category package.
RedirectController Redirect master display controller.
TemplatesController Templates manager master display controller.
TemplatesControllerTemplate Template style controller class.
TemplatesControllerSource Template style controller class.
FinderController Base controller class for Finder.
FinderControllerIndexer Indexer controller class for Finder.
MediaController Media Manager Component Controller
File Media Controller
MediaControllerFolder Folder Media Controller
ContactController Component Controller
JoomlaupdateController Joomla! Update Controller
JoomlaupdateControllerUpdate The Joomla! update controller for the Update view
ContentController Component Controller
SearchController Search master display controller.
SearchControllerSearches Methods supporting a list of search terms.
MenusController Base controller class for Menu Manager.
MenusControllerMenus The Menu List Controller
BannersController Banners master display controller.
Tracks list controller class.
LoginController Login Controller
CacheController Cache Controller
JControllerForm Controller tailored to suit most form-based admin operations.
JControllerAdmin Base class for a Joomla Administrator Controller
JControllerLegacy Alias to JController for forward compatability.
Variable Summary
string $basePath
string $default_view
string $doTask
string $message
string $messageType
array $methods
string $model_prefix
array $name
array $paths
string $redirect
string $task
array $taskMap
string $_acoSection
Method Summary
static void addModelPath (mixed $path, [string $prefix = ''])
static string createFileName (string $type, [array $parts = array()])
static JController getInstance (string $prefix, [array $config = array()])
JController __construct ([array $config = array()])
JController addPath (string $type, mixed $path)
JController addViewPath (mixed $path)
boolean authorise (string $task)
boolean authorize (string $task)
boolean checkEditId (string $context, integer $id)
mixed createModel (string $name, [string $prefix = ''], [array $config = array()])
mixed createView (string $name, [string $prefix = ''], [string $type = ''], [array $config = array()])
JController display ([boolean $cachable = false], [array $urlparams = false])
mixed execute (string $task)
object The getModel ([string $name = ''], [string $prefix = ''], [array $config = array()])
string getName ()
string getTask ()
array getTasks ()
object Reference getView ([string $name = ''], [string $type = ''], [string $prefix = ''], [array $config = array()])
void holdEditId (string $context, integer $id)
boolean redirect ()
JController registerDefaultTask (string $method)
JController registerTask (string $task, string $method)
void releaseEditId (string $context, integer $id)
void setAccessControl (string $section, [string $value = null])
string setMessage (string $text, [string $type = 'message'])
void setPath (string $type, string $path)
JController setRedirect (string $url, [string $msg = null], [string $type = null])
JController unregisterTask (string $task)
Variables
static JController $instance (line 152)
  • var: JController instance container.
  • since: 11.3
  • access: protected
string $basePath (line 49)

The base path of the controller

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

The mapped task that was performed.

  • since: 11.1
  • 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

JObject::$_errors
Methods
static method addModelPath (line 162)

Adds to the stack of model paths in LIFO order.

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

Create the filename for a resource.

  • return: The filename.
  • since: 11.1
  • access: protected
static 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.
static method getInstance (line 229)

Method to get a singleton controller instance.

  • throws: Exception if the controller cannot be loaded.
  • since: 11.1
  • access: public
static JController getInstance (string $prefix, [array $config = array()])
  • string $prefix: The prefix for the controller.
  • array $config: An array of optional constructor options.
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:
addPath (line 450)

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

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

Authorisation check

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

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

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.
createModel (line 593)

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

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

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

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.
getModel (line 780)

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

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

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

Gets the available tasks in the controller.

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

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

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

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

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

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

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

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

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

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

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

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

Documentation generated on Mon, 25 Jun 2012 13:53:32 -0500 by phpDocumentor 1.4.4