MediaWiki master
|
Actions are things which can be done to pages (edit, delete, rollback, etc). More...
Inherits MessageLocalizer.
Inherited by FormAction, and FormlessAction.
Public Member Functions | |
__construct (Article $article, IContextSource $context) | |
Only public since 1.21. | |
addHelpLink ( $to, $overrideBaseUrl=false) | |
Adds help link with an icon via page indicators. | |
doesWrites () | |
Indicates whether POST requests handled by this action require write access to the wiki. | |
getArticle () | |
Get a Article object. | |
getAuthority () | |
Shortcut to get the Authority executing this instance. | |
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 () | |
Indicates whether this action page write access to the wiki. | |
setHookContainer (HookContainer $hookContainer) | |
show () | |
The main action entry point. | |
Static Public Member Functions | |
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> element. | |
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 null | $context |
IContextSource if specified; otherwise we'll use the Context from the Page. | |
array | $fields |
The fields used to create the HTMLForm. | |
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.
Definition at line 54 of file Action.php.
Action::__construct | ( | Article | $article, |
IContextSource | $context ) |
Only public since 1.21.
Article | $article | |
IContextSource | $context |
Reimplemented in DeleteAction, and MediaWiki\Actions\FileDeleteAction.
Definition at line 275 of file Action.php.
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'.
string | $to | Target MediaWiki.org page title or encoded URL. |
bool | $overrideBaseUrl | Whether $url is a full URL, to avoid MW.o. |
Definition at line 453 of file Action.php.
Referenced by HistoryAction\onView(), InfoAction\onView(), and DeleteAction\show().
|
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
User | $user |
UserBlockedError|ReadOnlyError|PermissionsError |
Reimplemented in MediaWiki\Actions\FileDeleteAction, McrUndoAction, RevertAction, and WatchAction.
Definition at line 328 of file Action.php.
References MediaWiki\User\User\getBlock(), and getTitle().
Referenced by DeleteAction\show(), FormAction\show(), FormlessAction\show(), PurgeAction\show(), and RollbackAction\show().
Action::doesWrites | ( | ) |
Indicates whether POST requests handled by this action require write access to the wiki.
Subclasses must override this method to return true if any of the operations that they perform on POST requests are not "safe" per RFC 7231 section 4.2.1. A subclass's operation is "safe" if it is essentially read-only, i.e. the client does not request nor expect any state change that would be observable in the responses to future requests.
Implementations of this method must always return the same value, regardless of the parameters passed to the constructor or system state.
When handling GET/HEAD requests, subclasses should only perform "safe" operations. Note that some subclasses might only perform "safe" operations even for POST requests, particularly in the case where large input parameters are required.
Reimplemented in EditAction, FormAction, MarkpatrolledAction, ProtectAction, PurgeAction, RevertAction, RollbackAction, UnprotectAction, UnwatchAction, and WatchAction.
Definition at line 507 of file Action.php.
|
staticfinal |
Get an appropriate Action subclass for the given action.
string | $action | |
Article | $article | |
IContextSource | null | $context | Falls back to article's context |
Definition at line 91 of file Action.php.
References $context, and Article\getContext().
|
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".
IContextSource | $context |
Definition at line 110 of file Action.php.
References MediaWiki\Context\IContextSource\getActionName().
Action::getArticle | ( | ) |
Get a Article object.
Definition at line 204 of file Action.php.
Referenced by MediaWiki\Actions\FileDeleteAction\__construct(), getContext(), FormAction\getForm(), HistoryAction\onView(), InfoAction\onView(), EditAction\show(), ProtectAction\show(), RenderAction\show(), UnprotectAction\show(), ViewAction\show(), and DeleteAction\tempDelete().
|
final |
Shortcut to get the Authority executing this instance.
Definition at line 164 of file Action.php.
References getAuthority(), and getContext().
Referenced by getAuthority(), RollbackAction\handleRollbackRequest(), MarkpatrolledAction\onSubmit(), McrUndoAction\onSubmit(), PurgeAction\onSubmit(), RevertAction\onSubmit(), UnwatchAction\onSubmit(), WatchAction\onSubmit(), HistoryAction\onView(), and RawAction\onView().
|
final |
Get the IContextSource in use here.
Definition at line 120 of file Action.php.
References getArticle(), and wfDebug().
Referenced by WatchAction\__construct(), MediaWiki\Pager\HistoryPager\__construct(), getAuthority(), HistoryAction\getDescription(), FormAction\getForm(), WatchAction\getFormFields(), getOutput(), RawAction\getRawText(), getRequest(), getUser(), RollbackAction\handleRollbackRequest(), McrUndoAction\onSubmit(), HistoryAction\onView(), InfoAction\onView(), and DeleteAction\tempDelete().
|
protected |
Returns the description that goes below the <h1>
element.
Reimplemented in CreditsAction, HistoryAction, InfoAction, MarkpatrolledAction, McrRestoreAction, McrUndoAction, PurgeAction, RevertAction, RollbackAction, and WatchAction.
Definition at line 441 of file Action.php.
|
protected |
Definition at line 247 of file Action.php.
|
protected |
Definition at line 260 of file Action.php.
Referenced by HistoryAction\getDescription(), FormAction\getForm(), McrUndoAction\onSubmit(), HistoryAction\onView(), InfoAction\onView(), RawAction\onView(), and EditAction\show().
|
final |
Shortcut to get the user Language being used for this instance.
Definition at line 183 of file Action.php.
Referenced by CreditsAction\getContributors(), HistoryAction\getDescription(), RevertAction\getFormFields(), and RevertAction\onSuccess().
|
abstract |
Return the name of the action this object responds to.
Reimplemented in CreditsAction, DeleteAction, EditAction, HistoryAction, InfoAction, MarkpatrolledAction, McrRestoreAction, McrUndoAction, ProtectAction, PurgeAction, RawAction, RenderAction, RevertAction, RollbackAction, SubmitAction, UnprotectAction, UnwatchAction, ViewAction, and WatchAction.
Referenced by FormAction\getForm().
|
final |
Get the OutputPage being used for this instance.
Definition at line 144 of file Action.php.
References getContext().
Referenced by RollbackAction\handleRollbackRequest(), MarkpatrolledAction\onSubmit(), McrUndoAction\onSuccess(), PurgeAction\onSuccess(), RevertAction\onSuccess(), UnwatchAction\onSuccess(), CreditsAction\onView(), HistoryAction\onView(), InfoAction\onView(), RawAction\onView(), EditAction\show(), FormlessAction\show(), McrUndoAction\show(), PurgeAction\show(), and ViewAction\show().
|
protected |
Returns the name that goes in the <h1>
page title.
Since 1.41, returning a string from this method has been deprecated.
Reimplemented in DeleteAction, MediaWiki\Actions\FileDeleteAction, HistoryAction, InfoAction, and RevertAction.
Definition at line 430 of file Action.php.
References getTitle().
|
final |
Get the WebRequest being used for this instance.
Definition at line 134 of file Action.php.
References getContext().
Referenced by MediaWiki\Actions\FileDeleteAction\__construct(), MarkpatrolledAction\alterForm(), RevertAction\alterForm(), RollbackAction\alterForm(), RevertAction\checkCanExecute(), RawAction\getContentType(), FormAction\getForm(), McrUndoAction\getFormFields(), RevertAction\getFormFields(), RawAction\getOldId(), RawAction\getRawText(), MarkpatrolledAction\getRecentChange(), RollbackAction\handleRollbackRequest(), McrRestoreAction\initFromParameters(), McrUndoAction\initFromParameters(), McrUndoAction\onSubmit(), RevertAction\onSubmit(), WatchAction\onSubmit(), RevertAction\onSuccess(), HistoryAction\onView(), RawAction\onView(), McrUndoAction\show(), and PurgeAction\show().
Action::getRestriction | ( | ) |
Get the permission required to perform this action.
Often, but not always, the same as the action name
Implementations of this methods must always return the same value, regardless of parameters passed to the constructor or system state.
Reimplemented in DeleteAction, MarkpatrolledAction, McrUndoAction, RevertAction, RollbackAction, and WatchAction.
Definition at line 300 of file Action.php.
|
final |
Shortcut to get the Skin being used for this instance.
Definition at line 174 of file Action.php.
|
final |
Shortcut to get the Title object from the page.
Definition at line 214 of file Action.php.
Referenced by MediaWiki\Actions\FileDeleteAction\__construct(), FormAction\getForm(), MediaWiki\Actions\FileDeleteAction\getPageTitle(), PurgeAction\onSuccess(), and EditAction\show().
|
final |
Shortcut to get the User being used for this instance.
Definition at line 154 of file Action.php.
References getContext().
Referenced by WatchAction\__construct(), RevertAction\getFormFields(), RollbackAction\handleRollbackRequest(), McrUndoAction\onSubmit(), RevertAction\onSuccess(), HistoryAction\onView(), RawAction\onView(), DeleteAction\show(), EditAction\show(), FormAction\show(), FormlessAction\show(), PurgeAction\show(), and RollbackAction\show().
|
final |
Get a WikiPage object.
Definition at line 193 of file Action.php.
Referenced by CreditsAction\getContributors(), RawAction\getOldId(), RollbackAction\handleRollbackRequest(), McrRestoreAction\initFromParameters(), McrUndoAction\initFromParameters(), McrUndoAction\onSubmit(), PurgeAction\onSubmit(), CreditsAction\onView(), HistoryAction\onView(), RawAction\onView(), ViewAction\show(), and DeleteAction\tempDelete().
|
final |
Get a Message object with context set Parameters are the same as wfMessage()
string | string[] | MessageSpecifier | $key | @phpcs:ignore Generic.Files.LineLength |
MessageParam|MessageSpecifier|string|int|float|list<MessageParam|MessageSpecifier|string|int|float> | ...$params See Message::params() |
Implements MessageLocalizer.
Definition at line 228 of file Action.php.
References $params.
Referenced by RevertAction\checkCanExecute(), CreditsAction\getContributors(), CreditsAction\getDescription(), HistoryAction\getDescription(), PurgeAction\getFormFields(), RevertAction\getFormFields(), RollbackAction\getFormFields(), UnwatchAction\getFormFields(), WatchAction\getFormFields(), DeleteAction\getPageTitle(), MediaWiki\Actions\FileDeleteAction\getPageTitle(), HistoryAction\getPageTitle(), RevertAction\getPageTitle(), RollbackAction\handleRollbackRequest(), MarkpatrolledAction\onSubmit(), CreditsAction\onView(), HistoryAction\onView(), InfoAction\onView(), CreditsAction\othersLink(), PurgeAction\postText(), MarkpatrolledAction\preText(), DeleteAction\tempDelete(), and CreditsAction\userLink().
Action::needsReadRights | ( | ) |
Indicates whether this action requires read rights.
Implementations of this methods must always return the same value, regardless of parameters passed to the constructor or system state.
Reimplemented in ViewAction.
Definition at line 314 of file Action.php.
Action::requiresUnblock | ( | ) |
Whether this action can still be executed by a blocked user.
Implementations of this methods must always return the same value, regardless of parameters passed to the constructor or system state.
Reimplemented in HistoryAction, InfoAction, RawAction, and WatchAction.
Definition at line 398 of file Action.php.
Action::requiresWrite | ( | ) |
Indicates whether this action page write access to the wiki.
Subclasses must override this method to return true if the operation they will perform is not "safe" per RFC 7231 section 4.2.1. A subclass's operation is "safe" if it is essentially read-only, i.e. the client does not request nor expect any state change that would be observable in the responses to future requests.
Implementations of this method must always return the same value, regardless of the parameters passed to the constructor or system state.
When handling GET/HEAD requests, subclasses should only perform "safe" operations. Note that subclasses handling POST requests might still implement "safe" operations, particularly in the case where large input parameters are required.
Reimplemented in HistoryAction, InfoAction, and RawAction.
Definition at line 383 of file Action.php.
|
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 408 of file Action.php.
References wfDeprecated().
Referenced by DeleteAction\show(), FormAction\show(), FormlessAction\show(), PurgeAction\show(), and RollbackAction\show().
Action::setHookContainer | ( | HookContainer | $hookContainer | ) |
HookContainer | $hookContainer |
Definition at line 237 of file Action.php.
|
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.
ErrorPageError |
Reimplemented in DeleteAction, EditAction, FormAction, FormlessAction, McrUndoAction, ProtectAction, PurgeAction, RenderAction, RollbackAction, SubmitAction, UnprotectAction, and ViewAction.
|
protected |
Call wfTransactionalTimeLimit() if this request was POSTed.
Definition at line 482 of file Action.php.
References wfTransactionalTimeLimit().
Referenced by RevertAction\onSubmit(), DeleteAction\show(), EditAction\show(), and McrUndoAction\show().
|
protected |
IContextSource if specified; otherwise we'll use the Context from the Page.
Definition at line 67 of file Action.php.
Referenced by MediaWiki\Actions\FileDeleteAction\__construct(), factory(), and DeleteAction\tempDelete().
|
protected |
The fields used to create the HTMLForm.
Definition at line 74 of file Action.php.
Referenced by HistoryAction\onView().