MediaWiki  REL1_20
Action Class Reference

Actions are things which can be done to pages (edit, delete, rollback, etc). More...

Inheritance diagram for Action:
Collaboration diagram for Action:

List of all members.

Public Member Functions

 execute ()
 Execute the action in a silent fashion: do not display anything or release any errors.
 getContext ()
 Get the IContextSource in use here.
 getLang ()
 Shortcut to get the user Language being used for this instance.
 getLanguage ()
 Shortcut to get the user Language being used for this instance.
 getName ()
 Return the name of the action this object responds to.
 getOutput ()
 Get the OutputPage being used for this instance.
 getRequest ()
 Get the WebRequest being used for this instance.
 getRestriction ()
 Get the permission required to perform this action.
 getSkin ()
 Shortcut to get the Skin being used for this instance.
 getTitle ()
 Shortcut to get the Title object from the page.
 getUser ()
 Shortcut to get the User being used for this instance.
 msg ()
 Get a Message object with context set Parameters are the same as wfMessage()
 requiresUnblock ()
 Whether this action can still be executed by a blocked user.
 requiresWrite ()
 Whether this action requires the wiki not to be locked.
 show ()
 The main action entry point.

Static Public Member Functions

static exists ($name)
 Check if a given action is recognised, even if it's disabled.
static factory ($action, Page $page, IContextSource $context=null)
 Get an appropriate Action subclass for the given action.
static getActionName (IContextSource $context)
 Get the action that will be executed, not necessarily the one passed passed through the "action" request parameter.

Protected Member Functions

 __construct (Page $page, IContextSource $context=null)
 Protected constructor: use Action::factory( $action, $page ) to actually build these things in the real world.
 checkCanExecute (User $user)
 Checks if the given user (identified by an object) can perform this action.
 getDescription ()
 Returns the description that goes below the <h1> tag.
 getPageTitle ()
 Returns the name that goes in the <h1> page title.
 setHeaders ()
 Set output headers for noindexing etc.

Protected Attributes

IContextSource $context
 IContextSource if specified; otherwise we'll use the Context from the Page $context.
Array $fields
 The fields used to create the HTMLForm $fields.
Page $page
 Page on which we're performing the action $page.

Static Private Member Functions

static getClass ($action, array $overrides)
 Get the Action subclass which should be used to handle this action, false if the action is disabled, or null if it's not recognised.

Detailed Description

Actions are things which can be done to pages (edit, delete, rollback, etc).

They are distinct from Special Pages because an action must apply to exactly one page.

To add an action in an extension, create a subclass of Action, and add the key to $wgActions. There is also the deprecated UnknownAction hook

Actions generally fall into two groups: the show-a-form-then-do-something-with-the-input format (protect, delete, move, etc), and the just-do-something format (watch, rollback, patrol, etc). The FormAction and FormlessAction classes respresent these two groups.

Definition at line 37 of file Action.php.


Constructor & Destructor Documentation

Action::__construct ( Page page,
IContextSource context = null 
) [protected]

Protected constructor: use Action::factory( $action, $page ) to actually build these things in the real world.

Parameters:
$pagePage
$contextIContextSource

Definition at line 246 of file Action.php.


Member Function Documentation

Action::checkCanExecute ( User user) [protected]

Checks if the given user (identified by an object) can perform this action.

Can be overridden by sub-classes with more complicated permissions schemes. Failures here must throw subclasses of ErrorPageError

Parameters:
$userUser: the user to check, or null to use the context user
Exceptions:
ErrorPageError
Returns:
bool True on success

Reimplemented in WatchAction, and RevertFileAction.

Definition at line 275 of file Action.php.

Referenced by PurgeAction\show().

Action::execute ( ) [abstract]

Execute the action in a silent fashion: do not display anything or release any errors.

Returns:
Bool whether execution was successful

Reimplemented in RevertAction.

static Action::exists ( name) [static, final]

Check if a given action is recognised, even if it's disabled.

Parameters:
$nameString: name of an action
Returns:
Bool

Definition at line 150 of file Action.php.

Referenced by HistoryAction\fetchRevisions().

static Action::factory ( action,
Page page,
IContextSource context = null 
) [static, final]

Get an appropriate Action subclass for the given action.

Parameters:
$actionString
$pagePage
$contextIContextSource
Returns:
Action|bool|null false if the action is disabled, null if it is not recognised

Definition at line 88 of file Action.php.

Referenced by WatchAction\doUnwatch(), WatchAction\doWatch(), and SkinTemplate\outputPage().

static Action::getActionName ( IContextSource context) [static, final]

Get the action that will be executed, not necessarily the one passed passed through the "action" request parameter.

Actions disabled in $wgActions will be replaced by "nosuchaction".

Since:
1.19
Parameters:
$contextIContextSource
Returns:
string: action name

Definition at line 106 of file Action.php.

static Action::getClass ( action,
array $  overrides 
) [static, final, private]

Get the Action subclass which should be used to handle this action, false if the action is disabled, or null if it's not recognised.

Parameters:
$actionString
$overridesArray
Returns:
bool|null|string

Definition at line 61 of file Action.php.

Action::getDescription ( ) [protected]

Returns the description that goes below the <h1> tag.

Returns:
String

Reimplemented in InfoAction, UnwatchAction, RevertFileAction, RollbackAction, HistoryAction, PurgeAction, RevisiondeleteAction, WatchAction, CreditsAction, and MarkpatrolledAction.

Definition at line 340 of file Action.php.

Action::getLang ( ) [final]

Shortcut to get the user Language being used for this instance.

Deprecated:
1.19 Use getLanguage instead
Returns:
Language

Definition at line 216 of file Action.php.

Action::getPageTitle ( ) [protected]

Returns the name that goes in the <h1> page title.

Returns:
String

Reimplemented in InfoAction, RevertFileAction, and HistoryAction.

Definition at line 331 of file Action.php.

Get the permission required to perform this action.

Often, but not always, the same as the action name

Returns:
String|null

Reimplemented in RevertFileAction, and RollbackAction.

Definition at line 262 of file Action.php.

Action::getSkin ( ) [final]

Shortcut to get the Skin being used for this instance.

Returns:
Skin

Definition at line 197 of file Action.php.

Whether this action can still be executed by a blocked user.

Returns:
Bool

Reimplemented in HistoryAction, RawAction, InfoAction, PurgeAction, RevisiondeleteAction, and WatchAction.

Definition at line 310 of file Action.php.

Whether this action requires the wiki not to be locked.

Returns:
Bool

Reimplemented in InfoAction, HistoryAction, and RawAction.

Definition at line 302 of file Action.php.

Action::setHeaders ( ) [protected]

Set output headers for noindexing etc.

This function will not be called through the execute() entry point, so only put UI-related stuff in here.

Definition at line 318 of file Action.php.

Referenced by WatchAction\show(), and PurgeAction\show().

Action::show ( ) [abstract]

The main action entry point.

Do all output for display and send it to the context output. Do not use globals $wgOut, $wgRequest, etc, in implementations; use $this->getOutput(), etc.

Exceptions:
ErrorPageError

Reimplemented in FormlessAction, FormAction, SubmitAction, PurgeAction, WatchAction, UnprotectAction, RevisiondeleteAction, RevertAction, DeleteAction, EditAction, ProtectAction, RenderAction, and ViewAction.


Member Data Documentation

IContextSource Action::$context [protected]

IContextSource if specified; otherwise we'll use the Context from the Page $context.

Definition at line 47 of file Action.php.

Referenced by RawPage\__construct(), and EditAction\show().

Array Action::$fields [protected]

The fields used to create the HTMLForm $fields.

Definition at line 52 of file Action.php.

Page Action::$page [protected]

Page on which we're performing the action $page.

Definition at line 42 of file Action.php.

Referenced by WatchAction\doUnwatch(), WatchAction\doWatch(), InfoAction\getContributors(), CreditsAction\link(), and EditAction\show().


The documentation for this class was generated from the following file: