Class FOFController

Description

FrameworkOnFramework controller class. FOF is based on the thin controller paradigm, where the controller is mainly used to set up the model state and spawn the view.

  • since: 1.0

Located in /libraries/fof/controller/controller.php (line 20)

JObject
   |
   --FOFController
Direct descendents
Class Description
 class PostinstallControllerMessage
Variable Summary
 string $basePath
 string $component
 array $config
 integer $csrfProtection
 string $default_view
 string $doTask
 boolean $hasForm
 string $layout
 string $message
 string $messageType
 array $methods
 string $modelName
 string $model_prefix
 array $name
 array $paths
 string $redirect
 string $task
 array $taskMap
 string $view
 string $viewName
 array $viewsCache
Method Summary
 static void addModelPath (mixed $path, [string $prefix = ''])
 static string createFileName (string $type, [array $parts = array()])
 static FOFController &getAnInstance ([string $option = null], [string $view = null], [array $config = array()])
 static \className &getTmpInstance ([string $option = null], [string $view = null], [array $config = array()])
 FOFController __construct ([array $config = array()])
 void accesspublic ()
 void accessspecial ()
 void add ()
 FOFController addPath (string $type, mixed $path)
 FOFController addViewPath (mixed $path)
 void apply ()
 boolean applySave ()
 void archive ()
 boolean authorise (string $task)
 void browse ()
 void cancel ()
 boolean checkACL (string $area)
 void copy ()
 FOFModel createModel (string $name, [string $prefix = ''], [array $config = array()])
 FOFView createView (string $name, [string $prefix = ''], [string $type = ''], [array $config = array()])
 void display ([bool $cachable = false], [bool $urlparams = false])
 void edit ()
 null|bool execute (string $task)
 object The getModel ([string $name = ''], [string $prefix = ''], [array $config = array()])
 string getName ()
 string getTask ()
 array getTasks ()
 FOFModel getThisModel ([array $config = array()])
 FOFView getThisView ([array $config = array()])
 FOFView getView ([string $name = ''], [string $type = ''], [string $prefix = ''], [array $config = array()])
 boolean hasRedirect ()
 boolean onAfterApplySave ()
 boolean onBeforeAdd ()
 boolean onBeforeApply ()
 boolean onBeforeApplySave (array &$data)
 boolean onBeforeBrowse ()
 boolean onBeforeCancel ()
 boolean onBeforeEdit ()
 boolean onBeforeGenericTask (string $task)
 boolean onBeforeOrderdown ()
 boolean onBeforeOrderup ()
 boolean onBeforePublish ()
 boolean onBeforeRemove ()
 boolean onBeforeSave ()
 boolean onBeforeSavenew ()
 boolean onBeforeSaveorder ()
 boolean onBeforeUnpublish ()
 void orderdown ()
 void orderup ()
 void publish ()
 void read ()
 boolean redirect ()
 FOFController registerTask (string $task, string $method)
 void remove ()
 void save ()
 void savenew ()
 void saveorder ()
 void setaccess ([integer $level = 0])
 string setMessage (string $text, [string $type = 'message'])
 void setPath (string $type, string $path)
 FOFController setRedirect (string $url, [string $msg = null], [string $type = null])
 void setstate ([integer $state = 0])
 void setThisModelName (string $modelName)
 void setThisViewName (string $viewName)
 void trash ()
 void unpublish ()
 FOFController unregisterTask (string $task)
 mixed &_createModel (string $name, [string $prefix = ''], [array $config = array()])
 FOFView &_createView (string $name, [string $prefix = ''], [string $type = ''], [array $config = array()])
 boolean _csrfProtection ()
Variables
int $autoRouting = 0 (line 29)
  • var: Bit mask to enable JRoute'ing on redirects.
    1. = never
    2. = frontend only
    3. = backend only
    4. = always
  • access: protected
string $bareComponent = 'foobar' (line 36)

The current component's name without the com_ prefix

  • access: protected
string $basePath (line 43)

The base path of the controller

  • access: protected
array $cacheableTasks = array('browse', 'read') (line 50)

The tasks for which caching should be enabled by default

  • access: protected
string $component = 'com_foobar' (line 57)

The current component's name; you can override it in the configuration

  • access: protected
array $config = array() (line 64)

A cached copy of the class configuration parameter passed during initialisation

  • access: protected
FOFConfigProvider $configProvider = null (line 71)

An instance of FOFConfigProvider to provision configuration overrides

  • access: protected
integer $csrfProtection = 2 (line 83)

Set to true to enable CSRF protection on selected tasks. The possible

values are: 0 Disabled; no token checks are performed 1 Enabled; token checks are always performed 2 Only on HTML requests and backend; token checks are always performed in the back-end and in the front-end only when format is 'html' 3 Only on back-end; token checks are performer only in the back-end

  • access: protected
string $default_view (line 90)

The default view for the display method.

  • access: protected
string $doTask (line 97)

The mapped task that was performed.

  • access: protected
boolean $hasForm = false (line 223)

Does this tried have a FOFForm which will be used to render it?

  • access: protected
FOFInput $input = array() (line 104)

The input object for this MVC triad; you can override it in the configuration

  • access: protected
string $layout = null (line 125)

The current layout; you can override it in the configuration

  • access: protected
string $message (line 111)

Redirect message.

  • access: protected
string $messageType (line 118)

Redirect message type.

  • access: protected
array $methods (line 132)

Array of class methods

  • access: protected
string $modelName = null (line 146)

Overrides the name of the view's default model

  • access: protected
string $model_prefix (line 139)

The prefix of the models

  • access: protected
array $name (line 181)

The name of the controller

  • access: protected
array $paths (line 153)

The set of search directories for resources (views).

  • access: protected
string $redirect (line 160)

URL for redirection.

  • access: protected
string $task (line 167)

Current or most recently performed task.

  • access: protected
array $taskMap (line 174)

Array of class methods to call for a given task.

  • access: protected
string $view = '' (line 188)

The current view name; you can override it in the configuration

  • access: protected
string $viewName = null (line 195)

Overrides the name of the view's default view

  • access: protected
array $viewsCache = array() (line 209)

A cache for the view item objects created in this controller

  • access: protected

Inherited Variables

Inherited from JObject

JObject::$_errors
Methods
static addModelPath (line 775)

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 createFileName (line 849)

Create the filename for a resource.

  • return: The filename.
  • 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 getAnInstance (line 236)

Gets a static (Singleton) instance of a controller class. It loads the relevant controller file from the component's directory or, if it doesn't exist, creates a new controller object out of thin air.

  • access: public
static FOFController &getAnInstance ([string $option = null], [string $view = null], [array $config = array()])
  • string $option: Component name, e.g. com_foobar
  • string $view: The view name, also used for the controller name
  • array $config: Configuration parameters
static getTmpInstance (line 270)

Gets a temporary instance of a controller object. A temporary instance is not a Singleton and can be disposed off after use.

  • return: A disposable class instance
  • access: public
static \className &getTmpInstance ([string $option = null], [string $view = null], [array $config = array()])
  • string $option: The component name, e.g. com_foobar
  • string $view: The view name, e.g. cpanel
  • array $config: Configuration parameters
Constructor __construct (line 413)

Public constructor of the Controller class

  • access: public
FOFController __construct ([array $config = array()])
  • array $config: Optional configuration parameters

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

Sets the access to public. Joomla! 1.5 compatibility.

  • deprecated: since 2.0
  • access: public
void accesspublic ()
accessregistered (line 1530)

Sets the access to registered. Joomla! 1.5 compatibility.

  • deprecated: since 2.0
  • access: public
void accessregistered ()
accessspecial (line 1549)

Sets the access to special. Joomla! 1.5 compatibility.

  • deprecated: since 2.0
  • access: public
void accessspecial ()
add (line 1217)

Single record add. The form layout is used to present a blank page.

  • access: public
void add ()
addPath (line 788)

Adds to the search path for templates and resources.

  • return: A FOFController object to support chaining.
  • access: protected
FOFController 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 818)

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

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

Save the incoming data and then return to the Edit task

  • access: public
void apply ()
applySave (line 2090)

Common method to handle apply and save tasks

  • return: Returns true on success
  • access: protected
boolean applySave ()
archive (line 1598)

Archive (set enabled = 2) an item.

  • access: public
void archive ()
authorise (line 834)

Authorisation check

  • return: True if authorised
  • deprecated: 2.0 Use JAccess instead.
  • access: public
boolean authorise (string $task)
  • string $task: The ACO Section Value to check access on.
browse (line 1125)

Implements a default browse task, i.e. read a bunch of records and send them to the browser.

  • access: public
void browse ()
cancel (line 1477)

Cancel the edit, check in the record and return to the Browse task

  • access: public
void cancel ()
checkACL (line 2753)

Checks if the current user has enough privileges for the requested ACL area.

  • return: True if the user has the ACL privilege specified
  • access: protected
boolean checkACL (string $area)
  • string $area: The ACL area, e.g. core.manage.
copy (line 1364)

Duplicates selected items

  • access: public
void copy ()
createModel (line 2451)

Creates a new model object

  • return: The model object
  • access: protected
FOFModel createModel (string $name, [string $prefix = ''], [array $config = array()])
  • string $name: The name of the model class, e.g. Items
  • string $prefix: The prefix of the model class, e.g. FoobarModel
  • array $config: The configuration parameters for the model class
createView (line 2501)

Creates a View object instance and returns it

  • access: protected
FOFView createView (string $name, [string $prefix = ''], [string $type = ''], [array $config = array()])
  • string $name: The name of the view, e.g. Items
  • string $prefix: The prefix of the view, e.g. FoobarView
  • string $type: The type of the view, usually one of Html, Raw, Json or Csv
  • array $config: The configuration variables to use for creating the view
display (line 1004)

Default task. Assigns a model to the view and asks the view to render itself.

YOU MUST NOT USETHIS TASK DIRECTLY IN A URL. It is supposed to be used ONLY inside your code. In the URL, use task=browse instead.

  • access: public
void display ([bool $cachable = false], [bool $urlparams = false])
  • bool $cachable: Is this view cacheable?
  • bool $urlparams: Add your safe URL parameters (see further down in the code)
edit (line 1258)

Single record edit. The ID set in the request is passed to the model, then the form layout is used to edit the result.

  • access: public
void edit ()
execute (line 900)

Executes a given controller task. The onBefore<task> and onAfter<task> methods are called automatically if they exist.

  • return: False on execution failure
  • access: public
null|bool execute (string $task)
  • string $task: The task to execute, e.g. "browse"
getModel (line 2225)

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

  • return: model.
  • 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.
getName (line 2349)

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
  • access: public
string getName ()
getTask (line 2378)

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.
  • access: public
string getTask ()
getTasks (line 2388)

Gets the available tasks in the controller.

  • return: Array[i] of task names.
  • access: public
array getTasks ()
getThisModel (line 2179)

Returns the default model associated with the current view

  • return: The global instance of the model (singleton)
  • access: public
FOFModel getThisModel ([array $config = array()])
  • array $config: Configuration variables for the model
getThisView (line 2282)

Returns current view object

  • return: The global instance of the view object (singleton)
  • access: public
FOFView getThisView ([array $config = array()])
  • array $config: Configuration variables for the model
getView (line 2403)

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

  • return: Reference to the view or an error.
  • access: public
FOFView 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.
hasRedirect (line 1843)

Returns true if there is a redirect set in the controller

  • access: public
boolean hasRedirect ()
onAfterApplySave (line 2874)

Execute something after applySave has run.

  • return: True to allow normal return, false to cause a 403 error
  • access: protected
boolean onAfterApplySave ()
onBeforeAccesspublic (line 2884)

ACL check before changing the access level; override to customise

  • return: True to allow accesspublic() to run
  • access: protected
boolean onBeforeAccesspublic ()
onBeforeAccessregistered (line 2898)

ACL check before changing the access level; override to customise

  • return: True to allow the method to run
  • access: protected
boolean onBeforeAccessregistered ()
onBeforeAccessspecial (line 2913)

ACL check before changing the access level; override to customise

  • return: True to allow the method to run
  • access: protected
boolean onBeforeAccessspecial ()
onBeforeAdd (line 2928)

ACL check before adding a new record; override to customise

  • return: True to allow the method to run
  • access: protected
boolean onBeforeAdd ()
onBeforeApply (line 2943)

ACL check before saving a new/modified record; override to customise

  • return: True to allow the method to run
  • access: protected
boolean onBeforeApply ()
onBeforeApplySave (line 2864)

Execute something before applySave is called. Return false to prevent applySave from executing.

  • return: True to allow applySave to run
  • access: protected
boolean onBeforeApplySave (array &$data)
  • array &$data: The data upon which applySave will act
onBeforeBrowse (line 2958)

ACL check before allowing someone to browse

  • return: True to allow the method to run
  • access: protected
boolean onBeforeBrowse ()
onBeforeCancel (line 2975)

ACL check before cancelling an edit

  • return: True to allow the method to run
  • access: protected
boolean onBeforeCancel ()
onBeforeEdit (line 2990)

ACL check before editing a record; override to customise

  • return: True to allow the method to run
  • access: protected
boolean onBeforeEdit ()
onBeforeGenericTask (line 2846)

A catch-all method for all tasks without a corresponding onBefore method. Applies the ACL preferences defined in fof.xml.

  • return: True to allow execution of the task
  • access: protected
boolean onBeforeGenericTask (string $task)
  • string $task: The task being executed
onBeforeOrderdown (line 3007)

ACL check before changing the ordering of a record; override to customise

  • return: True to allow the method to run
  • access: protected
boolean onBeforeOrderdown ()
onBeforeOrderup (line 3022)

ACL check before changing the ordering of a record; override to customise

  • return: True to allow the method to run
  • access: protected
boolean onBeforeOrderup ()
onBeforePublish (line 3037)

ACL check before changing the publish status of a record; override to customise

  • return: True to allow the method to run
  • access: protected
boolean onBeforePublish ()
onBeforeRemove (line 3052)

ACL check before removing a record; override to customise

  • return: True to allow the method to run
  • access: protected
boolean onBeforeRemove ()
onBeforeSave (line 3067)

ACL check before saving a new/modified record; override to customise

  • return: True to allow the method to run
  • access: protected
boolean onBeforeSave ()
onBeforeSavenew (line 3082)

ACL check before saving a new/modified record; override to customise

  • return: True to allow the method to run
  • access: protected
boolean onBeforeSavenew ()
onBeforeSaveorder (line 3097)

ACL check before changing the ordering of a record; override to customise

  • return: True to allow the method to run
  • access: protected
boolean onBeforeSaveorder ()
onBeforeUnpublish (line 3112)

ACL check before changing the publish status of a record; override to customise

  • return: True to allow the method to run
  • access: protected
boolean onBeforeUnpublish ()
orderdown (line 1693)

Moves selected items one position down the ordering list

  • access: public
void orderdown ()
orderup (line 1737)

Moves selected items one position up the ordering list

  • access: public
void orderup ()
publish (line 1566)

Publish (set enabled = 1) an item.

  • access: public
void publish ()
read (line 1164)

Single record read. The id set in the request is passed to the model and then the item layout is used to render the result.

  • access: public
void read ()
redirect (line 1825)

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

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

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

  • return: A FOFController object to support chaining.
  • access: public
FOFController 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 1870)

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

  • return: A FOFController object to support chaining.
  • access: public
FOFController 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.
remove (line 1781)

Delete selected item(s)

  • access: public
void remove ()
save (line 1411)

Save the incoming data and then return to the Browse task

  • access: public
void save ()
savenew (line 1444)

Save the incoming data and then return to the Add task

  • access: public
void savenew ()
saveorder (line 1630)

Saves the order of the items

  • access: public
void saveorder ()
setaccess (line 2033)

Sets the access level of the selected item(s).

  • access: protected
void setaccess ([integer $level = 0])
  • integer $level: The desired viewing access level ID
setMessage (line 1902)

Sets the internal message that is passed with a redirect

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

Sets an entire array of search paths for resources.

  • 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 1938)

Registers a redirection with an optional message. The redirection is carried out when you use the redirect method.

  • return: This object to support chaining
  • access: public
FOFController setRedirect (string $url, [string $msg = null], [string $type = null])
  • string $url: The URL to redirect to
  • string $msg: The message to be pushed to the application
  • string $type: The message type to be pushed to the application, e.g. 'error'
setstate (line 1994)

Sets the published state (the enabled field) of the selected item(s)

  • access: protected
void setstate ([integer $state = 0])
  • integer $state: The desired state. 0 is unpublished, 1 is published.
setThisModelName (line 2740)

Set the name of the model to be used by this Controller

  • access: public
void setThisModelName (string $modelName)
  • string $modelName: The name of the model
setThisViewName (line 2728)

Set the name of the view to be used by this Controller

  • access: public
void setThisViewName (string $viewName)
  • string $viewName: The name of the view
trash (line 1614)

Trash (set enabled = -2) an item.

  • access: public
void trash ()
unpublish (line 1582)

Unpublish (set enabled = 0) an item.

  • access: public
void unpublish ()
unregisterTask (line 1887)

Unregister (unmap) a task in the class.

  • return: This object to support chaining.
  • access: public
FOFController unregisterTask (string $task)
  • string $task: The task.
_createModel (line 2484)

Method to load and return a model object.

  • return: Model object on success; otherwise null
  • 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 2714)

Deprecated function to create a View object instance

  • see: FOFController::createView
  • deprecated: since version 2.0
  • access: protected
FOFView &_createView (string $name, [string $prefix = ''], [string $type = ''], [array $config = array()])
  • string $name: The name of the view, e.g. 'Items'
  • string $prefix: The prefix of the view, e.g. 'FoobarView'
  • string $type: The view type, e.g. 'html'
  • array $config: The configuration array for the view
_csrfProtection (line 3129)

Applies CSRF protection by means of a standard Joomla! token (nonce) check.

Raises a 403 Access Forbidden error through JError or an exception (depending the Joomla! version) if the check fails.

  • return: True if the CSRF check is successful
  • access: protected
boolean _csrfProtection ()

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

Documentation generated on Tue, 19 Nov 2013 14:57:21 +0100 by phpDocumentor 1.4.3