MediaWiki REL1_37
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:

Public Member Functions

 __construct (Page $page, IContextSource $context=null)
 Only public since 1.21.
 
 addHelpLink ( $to, $overrideBaseUrl=false)
 Adds help link with an icon via page indicators.
 
 doesWrites ()
 Indicates whether this action may perform database writes.
 
 getArticle ()
 Get a Article object.
 
 getContext ()
 Get the IContextSource in use here.
 
 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.
 
 getWikiPage ()
 Get a WikiPage object.
 
 msg ( $key,... $params)
 Get a Message object with context set Parameters are the same as wfMessage()
 
 needsReadRights ()
 Indicates whether this action requires read rights.
 
 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 (string $name)
 Check if a given action is recognised, even if it's disabled.
 
static factory (string $action, Article $article, 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

 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.
 
 getHookContainer ()
 
 getHookRunner ()
 
 getPageTitle ()
 Returns the name that goes in the \<h1\> page title.
 
 setHeaders ()
 Set output headers for noindexing etc.
 
 useTransactionalTimeLimit ()
 Call wfTransactionalTimeLimit() if this request was POSTed.
 

Protected Attributes

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

Static Private Member Functions

static convertPageToArticle (Page $page, ?IContextSource $context, string $method)
 

Private Attributes

Article $article
 

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.

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 represent these two groups.

Stability: stable
to extend

Definition at line 43 of file Action.php.

Constructor & Destructor Documentation

◆ __construct()

Action::__construct ( Page  $page,
IContextSource  $context = null 
)

Only public since 1.21.

Stability: stable
to call
Parameters
Article | WikiPage | Page$pageCalling with anything other then Article is deprecated since 1.35
IContextSource | null$context

Reimplemented in DeleteAction.

Definition at line 260 of file Action.php.

References wfWarn().

Member Function Documentation

◆ addHelpLink()

Action::addHelpLink (   $to,
  $overrideBaseUrl = false 
)

Adds help link with an icon via page indicators.

Link target can be overridden by a local message containing a wikilink: the message key is: lowercase action name + '-helppage'.

Parameters
string$toTarget MediaWiki.org page title or encoded URL.
bool$overrideBaseUrlWhether $url is a full URL, to avoid MW.o.
Since
1.25

Definition at line 441 of file Action.php.

References $lang, and $title.

Referenced by HistoryAction\onView(), InfoAction\onView(), and DeleteAction\show().

◆ checkCanExecute()

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

Since
1.17
Stability: stable
to override
Parameters
User$user
Exceptions
UserBlockedError|ReadOnlyError|PermissionsError

Reimplemented in McrUndoAction, RevertAction, and WatchAction.

Definition at line 339 of file Action.php.

References User\getBlock(), getTitle(), User\isBlockedFrom(), and wfReadOnly().

Referenced by FormAction\show(), FormlessAction\show(), PurgeAction\show(), and RollbackAction\show().

◆ convertPageToArticle()

static Action::convertPageToArticle ( Page  $page,
?IContextSource  $context,
string  $method 
)
staticprivate

Definition at line 273 of file Action.php.

◆ doesWrites()

Action::doesWrites ( )

Indicates whether this action may perform database writes.

Returns
bool
Since
1.27
Stability: stable
to override

Reimplemented in DeleteAction, EditAction, FormAction, MarkpatrolledAction, ProtectAction, PurgeAction, RevertAction, RollbackAction, SpecialPageAction, UnprotectAction, UnwatchAction, and WatchAction.

Definition at line 482 of file Action.php.

◆ exists()

static Action::exists ( string  $name)
staticfinal

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

Since
1.17
Parameters
string$nameName of an action
Returns
bool

Definition at line 121 of file Action.php.

Referenced by HistoryAction\fetchRevisions(), HistoryAction\onView(), and InfoAction\pageInfo().

◆ factory()

static Action::factory ( string  $action,
Article  $article,
IContextSource  $context = null 
)
staticfinal

Get an appropriate Action subclass for the given action.

Since
1.17
Parameters
string$action
Article$article
IContextSource | null$contextFalls back to article's context
Returns
Action|bool|null False if the action is disabled, null if it is not recognised

Definition at line 85 of file Action.php.

References Article\getContext().

◆ getActionName()

static Action::getActionName ( IContextSource  $context)
staticfinal

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
IContextSource$context
Returns
string Action name

Definition at line 108 of file Action.php.

◆ getArticle()

Action::getArticle ( )

◆ getContext()

◆ getDescription()

Action::getDescription ( )
protected

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

Since
1.17
Stability: stable
to override
Returns
string HTML

Reimplemented in CreditsAction, HistoryAction, InfoAction, MarkpatrolledAction, McrRestoreAction, McrUndoAction, PurgeAction, RevertAction, RollbackAction, SpecialPageAction, and WatchAction.

Definition at line 429 of file Action.php.

◆ getHookContainer()

Action::getHookContainer ( )
protected
Since
1.35
Access: internal
since 1.37
Returns
HookContainer

Definition at line 237 of file Action.php.

◆ getHookRunner()

Action::getHookRunner ( )
protected
Since
1.35
Access: internal
This is for use by core only. Hook interfaces may be removed without notice.
Returns
HookRunner

Definition at line 247 of file Action.php.

Referenced by HistoryAction\getDescription(), FormAction\getForm(), HistoryAction\onView(), and EditAction\show().

◆ getLanguage()

Action::getLanguage ( )
final

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

Returns
Language

Definition at line 185 of file Action.php.

References getContext().

Referenced by CreditsAction\getAuthor(), CreditsAction\getContributors(), HistoryAction\getDescription(), RevertAction\getFormFields(), RevertAction\onSuccess(), and InfoAction\pageInfo().

◆ getName()

Action::getName ( )
abstract

◆ getOutput()

◆ getPageTitle()

Action::getPageTitle ( )
protected

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

Stability: stable
to override
Returns
string

Reimplemented in HistoryAction, InfoAction, and RevertAction.

Definition at line 418 of file Action.php.

References getTitle().

◆ getRequest()

◆ getRestriction()

Action::getRestriction ( )

Get the permission required to perform this action.

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

Since
1.17
Stability: stable
to override
Returns
string|null

Reimplemented in MarkpatrolledAction, McrUndoAction, RevertAction, and RollbackAction.

Definition at line 315 of file Action.php.

◆ getSkin()

Action::getSkin ( )
final

Shortcut to get the Skin being used for this instance.

Since
1.17
Returns
Skin

Definition at line 176 of file Action.php.

References getContext().

◆ getTitle()

◆ getUser()

◆ getWikiPage()

◆ msg()

◆ needsReadRights()

Action::needsReadRights ( )

Indicates whether this action requires read rights.

Since
1.37.1
Stability: stable
to override
Returns
bool

Reimplemented in ViewAction.

Definition at line 325 of file Action.php.

◆ requiresUnblock()

Action::requiresUnblock ( )

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

Since
1.17
Stability: stable
to override
Returns
bool

Reimplemented in HistoryAction, InfoAction, RawAction, SpecialPageAction, and WatchAction.

Definition at line 394 of file Action.php.

◆ requiresWrite()

Action::requiresWrite ( )

Whether this action requires the wiki not to be locked.

Since
1.17
Stability: stable
to override
Returns
bool

Reimplemented in HistoryAction, InfoAction, and RawAction.

Definition at line 383 of file Action.php.

◆ setHeaders()

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.

Stability: stable
to override
Since
1.17

Definition at line 404 of file Action.php.

Referenced by FormAction\show(), FormlessAction\show(), PurgeAction\show(), and RollbackAction\show().

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

Since
1.17
Exceptions
ErrorPageError

Reimplemented in DeleteAction, EditAction, FormAction, FormlessAction, McrUndoAction, ProtectAction, PurgeAction, RenderAction, RollbackAction, SpecialPageAction, SubmitAction, UnprotectAction, and ViewAction.

◆ useTransactionalTimeLimit()

Action::useTransactionalTimeLimit ( )
protected

Call wfTransactionalTimeLimit() if this request was POSTed.

Since
1.26

Definition at line 470 of file Action.php.

References wfTransactionalTimeLimit().

Referenced by RevertAction\onSubmit(), DeleteAction\show(), EditAction\show(), and McrUndoAction\show().

Member Data Documentation

◆ $article

Article Action::$article
private
Since
1.35

Definition at line 59 of file Action.php.

Referenced by EditAction\show(), and DeleteAction\tempDeleteArticle().

◆ $context

IContextSource Action::$context
protected

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

Since
1.17

Definition at line 66 of file Action.php.

Referenced by DeleteAction\__construct(), DeleteAction\tempDeleteArticle(), and DeleteAction\tempDeleteFile().

◆ $fields

array Action::$fields
protected

The fields used to create the HTMLForm.

Since
1.17

Definition at line 73 of file Action.php.

Referenced by HistoryAction\onView().

◆ $page

WikiPage Article ImagePage CategoryPage Page Action::$page
protected

Page on which we're performing the action.

Since
1.17
Deprecated:
since 1.35, use getArticle() ?? getWikiPage(). Must be removed.
Access: internal

Definition at line 53 of file Action.php.

Referenced by DeleteAction\__construct(), and CreditsAction\getAuthor().


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