MediaWiki
master
|
Actions are things which can be done to pages (edit, delete, rollback, etc). More...
Public Member Functions | |
__construct (Page $page, IContextSource $context=null) | |
Only public since 1.21. More... | |
addHelpLink ( $to, $overrideBaseUrl=false) | |
Adds help link with an icon via page indicators. More... | |
doesWrites () | |
Indicates whether this action may perform database writes. More... | |
getArticle () | |
Get a Article object. More... | |
getContext () | |
Get the IContextSource in use here. More... | |
getLanguage () | |
Shortcut to get the user Language being used for this instance. More... | |
getName () | |
Return the name of the action this object responds to. More... | |
getOutput () | |
Get the OutputPage being used for this instance. More... | |
getRequest () | |
Get the WebRequest being used for this instance. More... | |
getRestriction () | |
Get the permission required to perform this action. More... | |
getSkin () | |
Shortcut to get the Skin being used for this instance. More... | |
getTitle () | |
Shortcut to get the Title object from the page. More... | |
getUser () | |
Shortcut to get the User being used for this instance. More... | |
getWikiPage () | |
Get a WikiPage object. More... | |
msg ( $key,... $params) | |
Get a Message object with context set Parameters are the same as wfMessage() More... | |
requiresUnblock () | |
Whether this action can still be executed by a blocked user. More... | |
requiresWrite () | |
Whether this action requires the wiki not to be locked. More... | |
show () | |
The main action entry point. More... | |
Static Public Member Functions | |
static | exists (string $name) |
Check if a given action is recognised, even if it's disabled. More... | |
static | factory (?string $action, Page $article, IContextSource $context=null) |
Get an appropriate Action subclass for the given action. More... | |
static | getActionName (IContextSource $context) |
Get the action that will be executed, not necessarily the one passed passed through the "action" request parameter. More... | |
Protected Member Functions | |
checkCanExecute (User $user) | |
Checks if the given user (identified by an object) can perform this action. More... | |
getDescription () | |
Returns the description that goes below the \<h1\> tag. More... | |
getHookContainer () | |
getHookRunner () | |
getPageTitle () | |
Returns the name that goes in the \<h1\> page title. More... | |
setHeaders () | |
Set output headers for noindexing etc. More... | |
useTransactionalTimeLimit () | |
Call wfTransactionalTimeLimit() if this request was POSTed. More... | |
Protected Attributes | |
IContextSource | $context |
IContextSource if specified; otherwise we'll use the Context from the Page. More... | |
array | $fields |
The fields used to create the HTMLForm. More... | |
WikiPage Article ImagePage CategoryPage Page | $page |
Page on which we're performing the action. More... | |
Static Private Member Functions | |
static | convertPageToArticle (Page $page, ?IContextSource $context, string $method) |
static | getClass (string $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. More... | |
Private Attributes | |
Article | $article |
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 43 of file Action.php.
Action::__construct | ( | Page | $page, |
IContextSource | $context = null |
||
) |
Only public since 1.21.
Article | WikiPage | Page | $page | Calling with anything other then Article is deprecated since 1.35 |
IContextSource | null | $context |
Reimplemented in WatchAction, and CachedAction.
Definition at line 342 of file Action.php.
References $context, $page, convertPageToArticle(), and wfWarn().
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 509 of file Action.php.
References $lang, $title, getContext(), getOutput(), msg(), and Title\newFromText().
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 WatchAction, RevertAction, and McrUndoAction.
Definition at line 411 of file Action.php.
References User\getBlock(), getLanguage(), getName(), getRequest(), getRestriction(), getTitle(), User\isBlockedFrom(), requiresUnblock(), requiresWrite(), and wfReadOnly().
Referenced by FormAction\show(), FormlessAction\show(), and PurgeAction\show().
|
staticprivate |
Definition at line 355 of file Action.php.
References $context, $page, RequestContext\getMain(), Article\newFromWikiPage(), and wfDeprecated().
Referenced by __construct().
Action::doesWrites | ( | ) |
Indicates whether this action may perform database writes.
Reimplemented in WatchAction, UnwatchAction, UnprotectAction, SpecialPageAction, RollbackAction, RevertAction, PurgeAction, ProtectAction, MarkpatrolledAction, FormAction, EditAction, and DeleteAction.
Definition at line 550 of file Action.php.
|
staticfinal |
Check if a given action is recognised, even if it's disabled.
string | $name | Name of an action |
Definition at line 206 of file Action.php.
References getClass().
Referenced by MediaWiki\Permissions\PermissionManager\checkUserBlock(), HistoryAction\fetchRevisions(), HistoryAction\onView(), and InfoAction\pageInfo().
|
staticfinal |
Get an appropriate Action subclass for the given action.
string | null | $action | Null is hard-deprecated since 1.35 |
Article | WikiPage | Page | $article | Calling with anything other than Article is hard-deprecated since 1.35 |
IContextSource | null | $context |
Definition at line 115 of file Action.php.
References $article, $context, Article\getActionOverrides(), getClass(), and wfDeprecated().
Referenced by MediaWiki\Permissions\PermissionManager\checkUserBlock(), RebuildFileCache\execute(), getActionName(), Skin\getFooterLinks(), and MediaWiki\performAction().
|
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 154 of file Action.php.
References $context, $wgActions, IContextSource\canUseWikiPage(), factory(), IContextSource\getRequest(), IContextSource\getWikiPage(), and Article\newFromWikiPage().
Referenced by SkinTemplate\buildContentNavigationUrls(), MediaWiki\getAction(), OutputPage\getHeadLinksArray(), OutputPage\getJSVars(), OutputPage\headElement(), and SkinTemplate\wrapHTML().
Action::getArticle | ( | ) |
Get a Article object.
Definition at line 289 of file Action.php.
References $article.
Referenced by CachedAction\getCacheKey(), getContext(), FormAction\getForm(), getWikiPage(), HistoryAction\onView(), InfoAction\onView(), InfoAction\pageInfo(), DeleteAction\show(), EditAction\show(), ProtectAction\show(), RenderAction\show(), UnprotectAction\show(), and ViewAction\show().
|
staticprivate |
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.
string | $action | |
array | $overrides |
Definition at line 82 of file Action.php.
References $wgActions.
|
final |
Get the IContextSource in use here.
Definition at line 215 of file Action.php.
References $context, getArticle(), and wfDebug().
Referenced by WatchAction\__construct(), addHelpLink(), HistoryAction\getDescription(), FormAction\getForm(), WatchAction\getFormFields(), getLanguage(), getOutput(), RawAction\getRawText(), getRequest(), getSkin(), getUser(), RollbackAction\handleRollbackRequest(), msg(), McrUndoAction\onSubmit(), WatchAction\onSubmit(), WatchAction\onSuccess(), HistoryAction\onView(), InfoAction\onView(), RawAction\onView(), InfoAction\pageInfo(), EditAction\show(), McrUndoAction\show(), ProtectAction\show(), and SpecialPageAction\show().
|
protected |
Returns the description that goes below the \<h1\> tag.
Reimplemented in WatchAction, SpecialPageAction, RollbackAction, RevertAction, PurgeAction, McrUndoAction, McrRestoreAction, MarkpatrolledAction, InfoAction, HistoryAction, and CreditsAction.
Definition at line 497 of file Action.php.
References getName(), and msg().
Referenced by setHeaders().
|
protected |
Definition at line 319 of file Action.php.
Referenced by getHookRunner().
|
protected |
Definition at line 329 of file Action.php.
References getHookContainer().
Referenced by HistoryAction\getDescription(), FormAction\getForm(), HistoryAction\onView(), InfoAction\onView(), RawAction\onView(), and EditAction\show().
|
final |
Shortcut to get the user Language being used for this instance.
Definition at line 268 of file Action.php.
References getContext().
Referenced by checkCanExecute(), CreditsAction\getAuthor(), CachedAction\getCacheKey(), CreditsAction\getContributors(), HistoryAction\getDescription(), RevertAction\getFormFields(), RevertAction\onSuccess(), and InfoAction\pageInfo().
|
abstract |
Return the name of the action this object responds to.
Reimplemented in WatchAction, ViewAction, UnwatchAction, UnprotectAction, SubmitAction, SpecialPageAction, RollbackAction, RevertAction, RenderAction, RawAction, PurgeAction, ProtectAction, McrUndoAction, McrRestoreAction, MarkpatrolledAction, InfoAction, HistoryAction, EditAction, DeleteAction, and CreditsAction.
Referenced by checkCanExecute(), CachedAction\getCacheKey(), getDescription(), and FormAction\getForm().
|
final |
Get the OutputPage being used for this instance.
Definition at line 239 of file Action.php.
References getContext().
Referenced by CachedAction\addCachedHTML(), addHelpLink(), HistoryAction\feed(), RollbackAction\handleRollbackRequest(), CachedAction\onCacheInitialized(), MarkpatrolledAction\onSubmit(), McrUndoAction\onSuccess(), PurgeAction\onSuccess(), RevertAction\onSuccess(), UnwatchAction\onSuccess(), WatchAction\onSuccess(), HistoryAction\onView(), RawAction\onView(), setHeaders(), EditAction\show(), FormlessAction\show(), McrUndoAction\show(), ProtectAction\show(), ViewAction\show(), and McrUndoAction\showPreview().
|
protected |
Returns the name that goes in the \<h1\> page title.
Reimplemented in RevertAction, InfoAction, and HistoryAction.
Definition at line 486 of file Action.php.
References getTitle().
Referenced by setHeaders().
|
final |
Get the WebRequest being used for this instance.
Definition at line 229 of file Action.php.
References getContext().
Referenced by MarkpatrolledAction\alterForm(), RevertAction\alterForm(), RollbackAction\alterForm(), checkCanExecute(), RevertAction\checkCanExecute(), RollbackAction\enableTransactionalTimelimit(), HistoryAction\feed(), McrUndoAction\generateDiffOrPreview(), RawAction\getContentType(), FormAction\getForm(), McrUndoAction\getFormFields(), RevertAction\getFormFields(), SpecialPageAction\getName(), 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(), PurgeAction\show(), RollbackAction\show(), CachedAction\startCache(), and useTransactionalTimeLimit().
Action::getRestriction | ( | ) |
Get the permission required to perform this action.
Often, but not always, the same as the action name
Reimplemented in RollbackAction, RevertAction, and MarkpatrolledAction.
Definition at line 397 of file Action.php.
Referenced by checkCanExecute().
|
final |
Shortcut to get the Skin being used for this instance.
Definition at line 259 of file Action.php.
References getContext().
|
final |
Shortcut to get the Title object from the page.
Definition at line 299 of file Action.php.
References getWikiPage().
Referenced by WatchAction\__construct(), McrUndoAction\alterForm(), RevertAction\alterForm(), checkCanExecute(), RevertAction\checkCanExecute(), HistoryAction\feed(), HistoryAction\feedEmpty(), HistoryAction\feedItem(), HistoryAction\fetchRevisions(), HistoryAction\getDescription(), RevertAction\getDescription(), FormAction\getForm(), RevertAction\getFormFields(), getPageTitle(), HistoryAction\getPageTitle(), InfoAction\getPageTitle(), RevertAction\getPageTitle(), RawAction\getRawText(), RollbackAction\handleRollbackRequest(), McrUndoAction\onSubmit(), RevertAction\onSubmit(), UnwatchAction\onSubmit(), WatchAction\onSubmit(), McrUndoAction\onSuccess(), PurgeAction\onSuccess(), RevertAction\onSuccess(), UnwatchAction\onSuccess(), WatchAction\onSuccess(), HistoryAction\onView(), RawAction\onView(), CreditsAction\othersLink(), InfoAction\pageInfo(), EditAction\show(), McrUndoAction\show(), and McrUndoAction\showPreview().
|
final |
Shortcut to get the User being used for this instance.
Definition at line 249 of file Action.php.
References getContext().
Referenced by WatchAction\__construct(), RevertAction\getFormFields(), RollbackAction\handleRollbackRequest(), MarkpatrolledAction\onSubmit(), RevertAction\onSubmit(), UnwatchAction\onSubmit(), RevertAction\onSuccess(), HistoryAction\onView(), RawAction\onView(), InfoAction\pageInfo(), EditAction\show(), FormAction\show(), FormlessAction\show(), PurgeAction\show(), and RollbackAction\show().
|
final |
Get a WikiPage object.
Definition at line 278 of file Action.php.
References getArticle().
Referenced by HistoryAction\fetchRevisions(), CreditsAction\getAuthor(), CreditsAction\getContributors(), RevertAction\getFile(), RawAction\getOldId(), getTitle(), RollbackAction\handleRollbackRequest(), McrRestoreAction\initFromParameters(), McrUndoAction\initFromParameters(), McrUndoAction\onSubmit(), PurgeAction\onSubmit(), CreditsAction\onView(), HistoryAction\onView(), RawAction\onView(), InfoAction\pageCounts(), InfoAction\pageInfo(), ViewAction\show(), and McrUndoAction\showPreview().
|
final |
Get a Message object with context set Parameters are the same as wfMessage()
string | string[] | MessageSpecifier | $key | |
mixed | ...$params |
Implements MessageLocalizer.
Definition at line 311 of file Action.php.
References getContext().
Referenced by addHelpLink(), RevertAction\checkCanExecute(), HistoryAction\feed(), HistoryAction\feedEmpty(), HistoryAction\feedItem(), CreditsAction\getAuthor(), CreditsAction\getContributors(), getDescription(), CreditsAction\getDescription(), HistoryAction\getDescription(), PurgeAction\getFormFields(), RevertAction\getFormFields(), RollbackAction\getFormFields(), UnwatchAction\getFormFields(), WatchAction\getFormFields(), HistoryAction\getPageTitle(), InfoAction\getPageTitle(), RevertAction\getPageTitle(), RollbackAction\handleRollbackRequest(), MarkpatrolledAction\onSubmit(), CreditsAction\onView(), HistoryAction\onView(), InfoAction\onView(), CreditsAction\othersLink(), InfoAction\pageInfo(), PurgeAction\postText(), HistoryAction\preCacheMessages(), MarkpatrolledAction\preText(), SpecialPageAction\show(), and CreditsAction\userLink().
Action::requiresUnblock | ( | ) |
Whether this action can still be executed by a blocked user.
Reimplemented in WatchAction, SpecialPageAction, RawAction, PurgeAction, InfoAction, and HistoryAction.
Definition at line 462 of file Action.php.
Referenced by checkCanExecute().
Action::requiresWrite | ( | ) |
Whether this action requires the wiki not to be locked.
Reimplemented in RawAction, InfoAction, and HistoryAction.
Definition at line 451 of file Action.php.
Referenced by checkCanExecute().
|
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 472 of file Action.php.
References getDescription(), getOutput(), and getPageTitle().
Referenced by FormAction\show(), FormlessAction\show(), and PurgeAction\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.
ErrorPageError |
Reimplemented in ViewAction, UnprotectAction, SubmitAction, SpecialPageAction, RollbackAction, RenderAction, PurgeAction, ProtectAction, McrUndoAction, FormlessAction, FormAction, EditAction, and DeleteAction.
|
protected |
Call wfTransactionalTimeLimit() if this request was POSTed.
Definition at line 538 of file Action.php.
References getRequest(), and wfTransactionalTimeLimit().
Referenced by RevertAction\onSubmit(), DeleteAction\show(), EditAction\show(), and McrUndoAction\show().
|
private |
Definition at line 59 of file Action.php.
Referenced by factory(), getArticle(), and EditAction\show().
|
protected |
IContextSource if specified; otherwise we'll use the Context from the Page.
Definition at line 66 of file Action.php.
Referenced by __construct(), CachedAction\__construct(), WatchAction\__construct(), convertPageToArticle(), factory(), getActionName(), and getContext().
|
protected |
The fields used to create the HTMLForm.
Definition at line 73 of file Action.php.
Referenced by HistoryAction\onView().
|
protected |
Page on which we're performing the action.
Definition at line 53 of file Action.php.
Referenced by __construct(), CachedAction\__construct(), WatchAction\__construct(), convertPageToArticle(), WatchAction\doUnwatch(), WatchAction\doWatch(), CreditsAction\getAuthor(), CreditsAction\link(), and InfoAction\pageCounts().