Документация по Joomla 1.7

Joomla.Platform\JController
libraries/joomla/application/component/controller.php at line 22

Class JController

JObject
└─JController
All Known Subclasses:
Joomla.Administrator\AdminController Joomla.Administrator\BannersController Joomla.Site\BannersController Joomla.Administrator\BannersControllerTracks Joomla.Administrator\CacheController Joomla.Administrator\CategoriesController Joomla.Administrator\CheckinController Joomla.Administrator\ConfigController Joomla.Administrator\ConfigControllerApplication Joomla.Administrator\ConfigControllerComponent Joomla.Administrator\ContactController Joomla.Site\ContactController Joomla.Administrator\ContentController Joomla.Site\ContentController Joomla.Administrator\CpanelController Joomla.Administrator\InstallerController Joomla.Administrator\InstallerControllerDiscover Joomla.Administrator\InstallerControllerInstall Joomla.Administrator\InstallerControllerManage Joomla.Administrator\InstallerControllerUpdate JControllerAdmin JControllerForm Joomla.Administrator\JHtmlMessages Joomla.Installation\JInstallationController Joomla.Installation\JInstallationControllerSetup Joomla.Administrator\LanguagesController Joomla.Administrator\LanguagesControllerInstalled Joomla.Administrator\LoginController Joomla.Site\MailtoController Joomla.Administrator\MediaController Joomla.Site\MediaController Joomla.Administrator\MediaControllerFile Joomla.Administrator\MediaControllerFolder Joomla.Administrator\MenusController Joomla.Administrator\MenusControllerMenus Joomla.Administrator\MessagesController Joomla.Administrator\MessagesControllerConfig Joomla.Administrator\MessagesHelper Joomla.Administrator\ModulesController Joomla.Administrator\NewsfeedsController Joomla.Site\NewsfeedsController Joomla.Administrator\PluginsController Joomla.Administrator\RedirectController Joomla.Administrator\SearchController Joomla.Site\SearchController Joomla.Administrator\SearchControllerSearches Joomla.Administrator\TemplatesController Joomla.Administrator\TemplatesControllerSource Joomla.Administrator\TemplatesControllerTemplate Joomla.Administrator\UsersController Joomla.Site\UsersController Joomla.Administrator\UsersControllerConfig Joomla.Administrator\UsersControllerMail Joomla.Administrator\WeblinksController Joomla.Site\WeblinksController Joomla.Site\WrapperController

public class JController
extends JObject

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

Subpackage:
Application
Since:
11.1

Field Summary
protected string

$_acoSection

ACO Section for the controller.

protected string

$_acoSectionValue

Default ACO Section value for the controller.

protected string

$basePath

The base path of the controller

protected string

$default_view

The default view for the display method.

protected string

$doTask

The mapped task that was performed.

protected string

$message

Redirect message.

protected string

$messageType

Redirect message type.

protected array

$methods

Array of class methods

protected string

$model_prefix

The prefix of the models

protected array

$name

The name of the controller

protected array

$paths

The set of search directories for resources (views).

protected string

$redirect

URL for redirection.

protected string

$task

Current or most recently performed task.

protected array

$taskMap

Array of class methods to call for a given task.

Fields inherited from Joomla.Platform\JObject
_errors
Constructor Summary
static JController

__construct(array config, mixed properties)

Constructor.

Method Summary
static void

addModelPath(mixed path, string prefix)

Adds to the stack of model paths in LIFO order.

protected static string

createFileName(string type, array parts)

Create the filename for a resource.

static mixed

getInstance(string prefix, array config)

Method to get a singleton controller instance.

protected JController

addPath(string type, mixed path)

Adds to the search path for templates and resources.

JController

addViewPath(mixed path)

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

boolean

authorize(string task)

Authorisation check

boolean

authorise(string task)

Authorisation check

protected boolean

checkEditId(string context, integer id)

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

protected mixed

createModel(string name, string prefix, array config)

Method to load and return a model object.

protected mixed

createView(string name, string prefix, string type, array config)

Method to load and return a view object.

JController

display(boolean cachable, array urlparams)

Typical view method for MVC based architectureThis function is provide as a default implementation, in most cases you will need to override it in your own controllers.

mixed

execute(string task)

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

object

getModel(string name, string prefix, array config)

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

string

getName()

Method to get the controller nameThe dispatcher name is set by default parsed using the classname, or it can be set by passing a $config['name'] in the class constructor

string

getTask()

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

array

getTasks()

Gets the available tasks in the controller.

object

getView(string name, string type, string prefix, array config)

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

protected static void

holdEditId(string context, integer id)

Method to add a record ID to the edit list.

boolean

redirect()

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

JController

registerDefaultTask(string method)

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

JController

registerTask(string task, string method)

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

JController

unregisterTask(string task)

Unregister (unmap) a task in the class.

protected void

releaseEditId(string context, integer id)

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

void

setAccessControl(string section, string value)

Sets the access control levels.

string

setMessage(string text, string type)

Sets the internal message that is passed with a redirect

protected void

setPath(string type, string path)

Sets an entire array of search paths for resources.

JController

setRedirect(string url, string msg, string type)

Set a URL for browser redirection.

Methods inherited from Joomla.Platform\JObject
__construct, __toString, def, get, getError, getErrors, getProperties, set, setError, setProperties, toString

Field Detail

libraries/joomla/application/component/controller.php at line 31

_acoSection

protected string $_acoSection = false

ACO Section for the controller.

Since:
11.1
Deprecated:
12.1

libraries/joomla/application/component/controller.php at line 40

_acoSectionValue

protected string $_acoSectionValue

Default ACO Section value for the controller.

Since:
11.1
Deprecated:
12.1

libraries/joomla/application/component/controller.php at line 49

basePath

protected string $basePath

The base path of the controller

Since:
11.1
Note:
Replaces _basePath.

libraries/joomla/application/component/controller.php at line 57

default_view

protected string $default_view

The default view for the display method.

Since:
11.1

libraries/joomla/application/component/controller.php at line 66

doTask

protected string $doTask

The mapped task that was performed.

Since:
11.1
Note:
Replaces _doTask.

libraries/joomla/application/component/controller.php at line 75

message

protected string $message

Redirect message.

Since:
11.1
Note:
Replaces _message.

libraries/joomla/application/component/controller.php at line 84

messageType

protected string $messageType

Redirect message type.

Since:
11.1
Note:
Replaces _messageType.

libraries/joomla/application/component/controller.php at line 93

methods

protected array $methods

Array of class methods

Since:
11.1
Note:
Replaces _methods.

libraries/joomla/application/component/controller.php at line 110

model_prefix

protected string $model_prefix

The prefix of the models

Since:
11.1

libraries/joomla/application/component/controller.php at line 102

name

protected array $name

The name of the controller

Since:
11.1
Note:
Replaces _name.

libraries/joomla/application/component/controller.php at line 119

paths

protected array $paths

The set of search directories for resources (views).

Since:
11.1
Note:
Replaces _path.

libraries/joomla/application/component/controller.php at line 128

redirect

protected string $redirect

URL for redirection.

Since:
11.1
Note:
Replaces _redirect.

libraries/joomla/application/component/controller.php at line 137

task

protected string $task

Current or most recently performed task.

Since:
11.1
Note:
Replaces _task.

libraries/joomla/application/component/controller.php at line 146

taskMap

protected array $taskMap

Array of class methods to call for a given task.

Since:
11.1
Note:
Replaces _taskMap.

Constructor Detail

libraries/joomla/application/component/controller.php at line 292

__construct

public static JController __construct(array config, mixed properties)

Constructor.

Parameters:
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).
Since:
11.1

Method Detail

libraries/joomla/application/component/controller.php at line 156

addModelPath

public static void addModelPath(mixed path, string prefix)

Adds to the stack of model paths in LIFO order.

Parameters:
path - The directory (string), or list of directories (array) to add.
prefix - A prefix for models

libraries/joomla/application/component/controller.php at line 172

createFileName

protected static string createFileName(string type, array parts)

Create the filename for a resource.

Parameters:
type - The resource type to create the filename for.
parts - An associative array of filename information. Optional.
Returns:
The filename.
Since:
11.1
Note:
Replaced _createFileName.

libraries/joomla/application/component/controller.php at line 212

getInstance

public static mixed getInstance(string prefix, array config)

Method to get a singleton controller instance.

Parameters:
prefix - The prefix for the controller.
config - An array of optional constructor options.
Returns:
JController derivative class or JException on error.
Since:
11.1

libraries/joomla/application/component/controller.php at line 398

addPath

protected JController addPath(string type, mixed path)

Adds to the search path for templates and resources.

Parameters:
type - The path type (e.g. 'model', 'view').
path - The directory string or stream array to search.
Returns:
A JController object to support chaining.
Since:
11.1
Note:
Replaces _addPath.

libraries/joomla/application/component/controller.php at line 427

addViewPath

public JController addViewPath(mixed path)

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

Parameters:
path - The directory (string) or list of directories (array) to add.
Returns:
This object to support chaining.

libraries/joomla/application/component/controller.php at line 445

authorize

public boolean authorize(string task)

Authorisation check

Parameters:
task - The ACO Section Value to check access on
Returns:
True if authorised
Since:
11.1
Deprecated:
12.1 Use JAuthorise

libraries/joomla/application/component/controller.php at line 461

authorise

public boolean authorise(string task)

Authorisation check

Parameters:
task - The ACO Section Value to check access on.
Returns:
True if authorised
Since:
11.1

libraries/joomla/application/component/controller.php at line 490

checkEditId

protected boolean checkEditId(string context, integer id)

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

Parameters:
context - The context for the session storage.
id - The ID of the record to add to the edit list.
Returns:
True if the ID is in the edit list.
Since:
11.1

libraries/joomla/application/component/controller.php at line 524

createModel

protected mixed createModel(string name, string prefix, array config)

Method to load and return a model object.

Parameters:
name - The name of the model.
prefix - Optional model prefix.
config - Configuration array for the model. Optional.
Returns:
Model object on success; otherwise null failure.
Since:
11.1
Note:
Replaces _createModel.

libraries/joomla/application/component/controller.php at line 552

createView

protected mixed createView(string name, string prefix, string type, array config)

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.

Parameters:
name - The name of the view.
prefix - Optional prefix for the view class name.
type - The type of view.
config - Configuration array for the view. Optional.
Returns:
View object on success; null or error result on failure.
Since:
11.1
Note:
Replaces _createView.

libraries/joomla/application/component/controller.php at line 601

display

public JController display(boolean cachable, array urlparams)

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.

Parameters:
cachable - If true, the view output will be cached
urlparams - An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
Returns:
A JController object to support chaining.
Since:
11.1

libraries/joomla/application/component/controller.php at line 664

execute

public mixed execute(string task)

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

Parameters:
task - The task to perform. If no matching task is found, the '__default' task is executed, if defined.
Returns:
The value returned by the called method, false in error case.
Since:
11.1

libraries/joomla/application/component/controller.php at line 702

getModel

public object getModel(string name, string prefix, array config)

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

Parameters:
name - The model name. Optional.
prefix - The class prefix. Optional.
config - Configuration array for model. Optional.
Returns:
The model.
Since:
11.1

libraries/joomla/application/component/controller.php at line 740

getName

public string getName()

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

Returns:
The name of the dispatcher
Since:
11.1

libraries/joomla/application/component/controller.php at line 761

getTask

public string getTask()

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

Returns:
The task that is being performed or was most recently performed.
Since:
11.1

libraries/joomla/application/component/controller.php at line 772

getTasks

public array getTasks()

Gets the available tasks in the controller.

Returns:
Array[i] of task names.
Since:
11.1

libraries/joomla/application/component/controller.php at line 788

getView

public object getView(string name, string type, string prefix, array config)

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

Parameters:
name - The view name. Optional, defaults to the controller name.
type - The view type. Optional.
prefix - The class prefix. Optional.
config - Configuration array for view. Optional.
Returns:
Reference to the view or an error.
Since:
11.1

libraries/joomla/application/component/controller.php at line 830

holdEditId

protected static void holdEditId(string context, integer id)

Method to add a record ID to the edit list.

Parameters:
context - The context for the session storage.
id - The ID of the record to add to the edit list.
Since:
11.1

libraries/joomla/application/component/controller.php at line 857

redirect

public boolean redirect()

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

Returns:
False if no redirect exists.
Since:
11.1

libraries/joomla/application/component/controller.php at line 875

registerDefaultTask

public JController registerDefaultTask(string method)

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

Parameters:
method - The name of the method in the derived class to perform if a named task is not found.
Returns:
A JController object to support chaining.
Since:
11.1

libraries/joomla/application/component/controller.php at line 891

registerTask

public JController registerTask(string task, string method)

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

Parameters:
task - The task.
method - The name of the method in the derived class to perform for this task.
Returns:
A JController object to support chaining.
Since:
11.1

libraries/joomla/application/component/controller.php at line 908

unregisterTask

public JController unregisterTask(string task)

Unregister (unmap) a task in the class.

Parameters:
task - The task.
Returns:
This object to support chaining.
Since:
11.1

libraries/joomla/application/component/controller.php at line 924

releaseEditId

protected void releaseEditId(string context, integer id)

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

Parameters:
context - The context for the session storage.
id - The ID of the record to add to the edit list.
Since:
11.1

libraries/joomla/application/component/controller.php at line 958

setAccessControl

public void setAccessControl(string section, string value)

Sets the access control levels.

Parameters:
section - The ACO section (eg, the component).
value - The ACO section value (if using a constant value).
Deprecated:
12.1 Use JAccess
See Also:
Jaccess
Since:
11.1

libraries/joomla/application/component/controller.php at line 973

setMessage

public string setMessage(string text, string type)

Sets the internal message that is passed with a redirect

Parameters:
text - Message to display on redirect.
type - Message type (since 11.1). Optional, defaults to 'message'.
Returns:
Previous message
Since:
11.1

libraries/joomla/application/component/controller.php at line 993

setPath

protected void setPath(string type, string path)

Sets an entire array of search paths for resources.

Parameters:
type - The type of path to set, typically 'view' or 'model'.
path - The new set of search paths. If null or false, resets to the current directory only.
Note:
Replaces _setPath.
Since:
11.1

libraries/joomla/application/component/controller.php at line 1013

setRedirect

public JController setRedirect(string url, string msg, string type)

Set a URL for browser redirection.

Parameters:
url - URL to redirect to.
msg - Message to display on redirect. Optional, defaults to value set internally by controller, if any.
type - Message type. Optional, defaults to 'message' or the type set by a previous call to setMessage.
Returns:
This object to support chaining.
Since:
11.1

Документация по Joomla 1.7