MediaWiki master
|
Actions are things which can be done to pages (edit, delete, rollback, etc). More...
Inherits MessageLocalizer.
Inherited by MediaWiki\Actions\FormAction, and MediaWiki\Actions\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 66 of file Action.php.
MediaWiki\Actions\Action::__construct | ( | Article | $article, |
IContextSource | $context ) |
Only public since 1.21.
Article | $article | |
IContextSource | $context |
Reimplemented in MediaWiki\Actions\DeleteAction, and MediaWiki\Actions\FileDeleteAction.
Definition at line 287 of file Action.php.
MediaWiki\Actions\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 465 of file Action.php.
Referenced by MediaWiki\Actions\HistoryAction\onView(), MediaWiki\Actions\InfoAction\onView(), and MediaWiki\Actions\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, MediaWiki\Actions\McrUndoAction, MediaWiki\Actions\RevertAction, and MediaWiki\Actions\WatchAction.
Definition at line 340 of file Action.php.
References MediaWiki\User\User\getBlock(), and getTitle().
Referenced by MediaWiki\Actions\DeleteAction\show(), MediaWiki\Actions\FormAction\show(), MediaWiki\Actions\FormlessAction\show(), MediaWiki\Actions\PurgeAction\show(), and MediaWiki\Actions\RollbackAction\show().
MediaWiki\Actions\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 MediaWiki\Actions\EditAction, MediaWiki\Actions\FormAction, MediaWiki\Actions\MarkpatrolledAction, MediaWiki\Actions\ProtectAction, MediaWiki\Actions\PurgeAction, MediaWiki\Actions\RevertAction, MediaWiki\Actions\RollbackAction, MediaWiki\Actions\UnprotectAction, MediaWiki\Actions\UnwatchAction, and MediaWiki\Actions\WatchAction.
Definition at line 519 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 103 of file Action.php.
References MediaWiki\Actions\Action\$context, MediaWiki\Page\Article\getContext(), and MediaWiki\MediaWikiServices\getInstance().
|
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 122 of file Action.php.
References MediaWiki\Actions\Action\$context, and MediaWiki\Context\IContextSource\getActionName().
MediaWiki\Actions\Action::getArticle | ( | ) |
Get a Article object.
Definition at line 216 of file Action.php.
Referenced by MediaWiki\Actions\FileDeleteAction\__construct(), MediaWiki\Actions\Action\getContext(), MediaWiki\Actions\FormAction\getForm(), MediaWiki\Actions\HistoryAction\onView(), MediaWiki\Actions\InfoAction\onView(), MediaWiki\Actions\EditAction\show(), MediaWiki\Actions\ProtectAction\show(), MediaWiki\Actions\RenderAction\show(), MediaWiki\Actions\UnprotectAction\show(), MediaWiki\Actions\ViewAction\show(), and MediaWiki\Actions\DeleteAction\tempDelete().
|
final |
Shortcut to get the Authority executing this instance.
Definition at line 176 of file Action.php.
Referenced by MediaWiki\Actions\RollbackAction\handleRollbackRequest(), MediaWiki\Actions\MarkpatrolledAction\onSubmit(), MediaWiki\Actions\PurgeAction\onSubmit(), MediaWiki\Actions\RevertAction\onSubmit(), MediaWiki\Actions\UnwatchAction\onSubmit(), MediaWiki\Actions\WatchAction\onSubmit(), MediaWiki\Actions\HistoryAction\onView(), and MediaWiki\Actions\RawAction\onView().
|
final |
Get the IContextSource in use here.
Definition at line 132 of file Action.php.
References MediaWiki\Actions\Action\$context, MediaWiki\Actions\Action\getArticle(), and wfDebug().
Referenced by MediaWiki\Actions\WatchAction\__construct(), MediaWiki\Pager\HistoryPager\__construct(), MediaWiki\Actions\HistoryAction\getDescription(), MediaWiki\Actions\FormAction\getForm(), MediaWiki\Actions\WatchAction\getFormFields(), MediaWiki\Actions\Action\getOutput(), MediaWiki\Actions\RawAction\getRawText(), MediaWiki\Actions\Action\getRequest(), MediaWiki\Actions\Action\getUser(), MediaWiki\Actions\RollbackAction\handleRollbackRequest(), MediaWiki\Actions\HistoryAction\onView(), MediaWiki\Actions\InfoAction\onView(), and MediaWiki\Actions\DeleteAction\tempDelete().
|
protected |
Returns the description that goes below the <h1>
element.
Reimplemented in MediaWiki\Actions\CreditsAction, MediaWiki\Actions\HistoryAction, MediaWiki\Actions\InfoAction, MediaWiki\Actions\MarkpatrolledAction, MediaWiki\Actions\McrRestoreAction, MediaWiki\Actions\McrUndoAction, MediaWiki\Actions\PurgeAction, MediaWiki\Actions\RevertAction, MediaWiki\Actions\RollbackAction, and MediaWiki\Actions\WatchAction.
Definition at line 453 of file Action.php.
|
protected |
Definition at line 259 of file Action.php.
|
protected |
Definition at line 272 of file Action.php.
Referenced by MediaWiki\Actions\HistoryAction\getDescription(), MediaWiki\Actions\FormAction\getForm(), MediaWiki\Actions\HistoryAction\onView(), MediaWiki\Actions\InfoAction\onView(), MediaWiki\Actions\RawAction\onView(), and MediaWiki\Actions\EditAction\show().
|
final |
Shortcut to get the user Language being used for this instance.
Definition at line 195 of file Action.php.
Referenced by MediaWiki\Actions\CreditsAction\getContributors(), MediaWiki\Actions\HistoryAction\getDescription(), MediaWiki\Actions\RevertAction\getFormFields(), and MediaWiki\Actions\RevertAction\onSuccess().
|
abstract |
Return the name of the action this object responds to.
Reimplemented in MediaWiki\Actions\CreditsAction, MediaWiki\Actions\DeleteAction, MediaWiki\Actions\EditAction, MediaWiki\Actions\HistoryAction, MediaWiki\Actions\InfoAction, MediaWiki\Actions\MarkpatrolledAction, MediaWiki\Actions\McrRestoreAction, MediaWiki\Actions\McrUndoAction, MediaWiki\Actions\ProtectAction, MediaWiki\Actions\PurgeAction, MediaWiki\Actions\RawAction, MediaWiki\Actions\RenderAction, MediaWiki\Actions\RevertAction, MediaWiki\Actions\RollbackAction, MediaWiki\Actions\SubmitAction, MediaWiki\Actions\UnprotectAction, MediaWiki\Actions\UnwatchAction, MediaWiki\Actions\ViewAction, and MediaWiki\Actions\WatchAction.
Referenced by MediaWiki\Actions\FormAction\getForm().
|
final |
Get the OutputPage being used for this instance.
Definition at line 156 of file Action.php.
References MediaWiki\Actions\Action\getContext().
Referenced by MediaWiki\Actions\RollbackAction\handleRollbackRequest(), MediaWiki\Actions\MarkpatrolledAction\onSubmit(), MediaWiki\Actions\PurgeAction\onSuccess(), MediaWiki\Actions\RevertAction\onSuccess(), MediaWiki\Actions\UnwatchAction\onSuccess(), MediaWiki\Actions\CreditsAction\onView(), MediaWiki\Actions\HistoryAction\onView(), MediaWiki\Actions\InfoAction\onView(), MediaWiki\Actions\RawAction\onView(), MediaWiki\Actions\EditAction\show(), MediaWiki\Actions\FormlessAction\show(), MediaWiki\Actions\McrUndoAction\show(), MediaWiki\Actions\PurgeAction\show(), and MediaWiki\Actions\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 MediaWiki\Actions\DeleteAction, MediaWiki\Actions\FileDeleteAction, MediaWiki\Actions\HistoryAction, MediaWiki\Actions\InfoAction, and MediaWiki\Actions\RevertAction.
Definition at line 442 of file Action.php.
References getTitle().
|
final |
Get the WebRequest being used for this instance.
Definition at line 146 of file Action.php.
References MediaWiki\Actions\Action\getContext().
Referenced by MediaWiki\Actions\FileDeleteAction\__construct(), MediaWiki\Actions\MarkpatrolledAction\alterForm(), MediaWiki\Actions\RevertAction\alterForm(), MediaWiki\Actions\RollbackAction\alterForm(), MediaWiki\Actions\RevertAction\checkCanExecute(), MediaWiki\Actions\RawAction\getContentType(), MediaWiki\Actions\FormAction\getForm(), MediaWiki\Actions\RevertAction\getFormFields(), MediaWiki\Actions\RawAction\getOldId(), MediaWiki\Actions\RawAction\getRawText(), MediaWiki\Actions\MarkpatrolledAction\getRecentChange(), MediaWiki\Actions\RollbackAction\handleRollbackRequest(), MediaWiki\Actions\McrRestoreAction\initFromParameters(), MediaWiki\Actions\McrUndoAction\initFromParameters(), MediaWiki\Actions\RevertAction\onSubmit(), MediaWiki\Actions\WatchAction\onSubmit(), MediaWiki\Actions\RevertAction\onSuccess(), MediaWiki\Actions\HistoryAction\onView(), MediaWiki\Actions\RawAction\onView(), MediaWiki\Actions\McrUndoAction\show(), and MediaWiki\Actions\PurgeAction\show().
MediaWiki\Actions\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 MediaWiki\Actions\DeleteAction, MediaWiki\Actions\MarkpatrolledAction, MediaWiki\Actions\McrUndoAction, MediaWiki\Actions\RevertAction, MediaWiki\Actions\RollbackAction, and MediaWiki\Actions\WatchAction.
Definition at line 312 of file Action.php.
|
final |
Shortcut to get the Skin being used for this instance.
Definition at line 186 of file Action.php.
|
final |
Shortcut to get the Title object from the page.
Definition at line 226 of file Action.php.
Referenced by MediaWiki\Actions\FileDeleteAction\__construct(), MediaWiki\Actions\WatchAction\__construct(), MediaWiki\Actions\DeleteAction\alterForm(), MediaWiki\Actions\RevertAction\alterForm(), MediaWiki\Actions\McrUndoAction\checkCanExecute(), MediaWiki\Actions\RevertAction\checkCanExecute(), MediaWiki\Actions\HistoryAction\getDescription(), MediaWiki\Actions\RevertAction\getDescription(), MediaWiki\Actions\FormAction\getForm(), MediaWiki\Actions\RevertAction\getFormFields(), MediaWiki\Actions\DeleteAction\getPageTitle(), MediaWiki\Actions\FileDeleteAction\getPageTitle(), MediaWiki\Actions\HistoryAction\getPageTitle(), MediaWiki\Actions\RevertAction\getPageTitle(), MediaWiki\Actions\RawAction\getRawText(), MediaWiki\Actions\RollbackAction\handleRollbackRequest(), MediaWiki\Actions\RevertAction\onSubmit(), MediaWiki\Actions\UnwatchAction\onSubmit(), MediaWiki\Actions\WatchAction\onSubmit(), MediaWiki\Actions\PurgeAction\onSuccess(), MediaWiki\Actions\RevertAction\onSuccess(), MediaWiki\Actions\UnwatchAction\onSuccess(), MediaWiki\Actions\HistoryAction\onView(), MediaWiki\Actions\RawAction\onView(), MediaWiki\Actions\CreditsAction\othersLink(), MediaWiki\Actions\EditAction\show(), and MediaWiki\Actions\DeleteAction\tempDelete().
|
final |
Shortcut to get the User being used for this instance.
Definition at line 166 of file Action.php.
References MediaWiki\Actions\Action\getContext().
Referenced by MediaWiki\Actions\WatchAction\__construct(), MediaWiki\Actions\RevertAction\getFormFields(), MediaWiki\Actions\RollbackAction\handleRollbackRequest(), MediaWiki\Actions\RevertAction\onSuccess(), MediaWiki\Actions\HistoryAction\onView(), MediaWiki\Actions\RawAction\onView(), MediaWiki\Actions\DeleteAction\show(), MediaWiki\Actions\EditAction\show(), MediaWiki\Actions\FormAction\show(), MediaWiki\Actions\FormlessAction\show(), MediaWiki\Actions\PurgeAction\show(), and MediaWiki\Actions\RollbackAction\show().
|
final |
Get a WikiPage object.
Definition at line 205 of file Action.php.
Referenced by MediaWiki\Actions\CreditsAction\getContributors(), MediaWiki\Actions\RawAction\getOldId(), MediaWiki\Actions\RollbackAction\handleRollbackRequest(), MediaWiki\Actions\McrRestoreAction\initFromParameters(), MediaWiki\Actions\McrUndoAction\initFromParameters(), MediaWiki\Actions\PurgeAction\onSubmit(), MediaWiki\Actions\CreditsAction\onView(), MediaWiki\Actions\HistoryAction\onView(), MediaWiki\Actions\RawAction\onView(), MediaWiki\Actions\ViewAction\show(), and MediaWiki\Actions\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 240 of file Action.php.
Referenced by MediaWiki\Actions\RevertAction\checkCanExecute(), MediaWiki\Actions\CreditsAction\getContributors(), MediaWiki\Actions\CreditsAction\getDescription(), MediaWiki\Actions\HistoryAction\getDescription(), MediaWiki\Actions\PurgeAction\getFormFields(), MediaWiki\Actions\RevertAction\getFormFields(), MediaWiki\Actions\RollbackAction\getFormFields(), MediaWiki\Actions\UnwatchAction\getFormFields(), MediaWiki\Actions\WatchAction\getFormFields(), MediaWiki\Actions\DeleteAction\getPageTitle(), MediaWiki\Actions\FileDeleteAction\getPageTitle(), MediaWiki\Actions\HistoryAction\getPageTitle(), MediaWiki\Actions\RevertAction\getPageTitle(), MediaWiki\Actions\RollbackAction\handleRollbackRequest(), MediaWiki\Actions\MarkpatrolledAction\onSubmit(), MediaWiki\Actions\CreditsAction\onView(), MediaWiki\Actions\HistoryAction\onView(), MediaWiki\Actions\InfoAction\onView(), MediaWiki\Actions\CreditsAction\othersLink(), MediaWiki\Actions\PurgeAction\postText(), MediaWiki\Actions\MarkpatrolledAction\preText(), MediaWiki\Actions\DeleteAction\tempDelete(), and MediaWiki\Actions\CreditsAction\userLink().
MediaWiki\Actions\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 MediaWiki\Actions\ViewAction.
Definition at line 326 of file Action.php.
MediaWiki\Actions\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 MediaWiki\Actions\HistoryAction, MediaWiki\Actions\InfoAction, MediaWiki\Actions\RawAction, and MediaWiki\Actions\WatchAction.
Definition at line 410 of file Action.php.
MediaWiki\Actions\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 MediaWiki\Actions\HistoryAction, MediaWiki\Actions\InfoAction, and MediaWiki\Actions\RawAction.
Definition at line 395 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 420 of file Action.php.
References wfDeprecated().
Referenced by MediaWiki\Actions\DeleteAction\show(), MediaWiki\Actions\FormAction\show(), MediaWiki\Actions\FormlessAction\show(), MediaWiki\Actions\PurgeAction\show(), and MediaWiki\Actions\RollbackAction\show().
MediaWiki\Actions\Action::setHookContainer | ( | HookContainer | $hookContainer | ) |
HookContainer | $hookContainer |
Definition at line 249 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 MediaWiki\Actions\DeleteAction, MediaWiki\Actions\EditAction, MediaWiki\Actions\FormAction, MediaWiki\Actions\FormlessAction, MediaWiki\Actions\McrUndoAction, MediaWiki\Actions\ProtectAction, MediaWiki\Actions\PurgeAction, MediaWiki\Actions\RenderAction, MediaWiki\Actions\RollbackAction, MediaWiki\Actions\SubmitAction, MediaWiki\Actions\UnprotectAction, and MediaWiki\Actions\ViewAction.
|
protected |
Call wfTransactionalTimeLimit() if this request was POSTed.
Definition at line 494 of file Action.php.
References wfTransactionalTimeLimit().
Referenced by MediaWiki\Actions\RevertAction\onSubmit(), MediaWiki\Actions\DeleteAction\show(), MediaWiki\Actions\EditAction\show(), and MediaWiki\Actions\McrUndoAction\show().
|
protected |
IContextSource if specified; otherwise we'll use the Context from the Page.
Definition at line 79 of file Action.php.
Referenced by MediaWiki\Actions\DeleteAction\__construct(), MediaWiki\Actions\FileDeleteAction\__construct(), MediaWiki\Actions\RollbackAction\__construct(), MediaWiki\Actions\InfoAction\__construct(), MediaWiki\Actions\RevertAction\__construct(), MediaWiki\Actions\MarkpatrolledAction\__construct(), MediaWiki\Actions\CreditsAction\__construct(), MediaWiki\Actions\RawAction\__construct(), MediaWiki\Actions\McrUndoAction\__construct(), MediaWiki\Actions\UnwatchAction\__construct(), MediaWiki\Actions\WatchAction\__construct(), MediaWiki\Actions\Action\factory(), MediaWiki\Actions\Action\getActionName(), MediaWiki\Actions\Action\getContext(), and MediaWiki\Actions\DeleteAction\tempDelete().
|
protected |
The fields used to create the HTMLForm.
Definition at line 86 of file Action.php.
Referenced by MediaWiki\Actions\HistoryAction\onView().