MediaWiki
1.28.0
|
Actions are things which can be done to pages (edit, delete, rollback, etc). More...
Public Member Functions | |
__construct (Page $page, IContextSource $context=null) | |
Constructor. 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... | |
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... | |
msg () | |
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 ($name) |
Check if a given action is recognised, even if it's disabled. More... | |
static | factory ($action, Page $page, 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... | |
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 | |
$context | |
IContextSource if specified; otherwise we'll use the Context from the Page. More... | |
$fields | |
The fields used to create the HTMLForm. More... | |
$page | |
Page on which we're performing the action. More... | |
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. More... | |
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 represent these two groups.
Definition at line 37 of file Action.php.
Action::__construct | ( | Page | $page, |
IContextSource | $context = null |
||
) |
Constructor.
Only public since 1.21
Page | $page | |
IContextSource | null | $context |
Definition at line 269 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 390 of file Action.php.
References $wgContLang, getActionName(), getOutput(), global, Skin\makeUrl(), and wfMessage().
Referenced by HistoryAction\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 | The user to check, or null to use the context user |
UserBlockedError|ReadOnlyError|PermissionsError |
Definition at line 308 of file Action.php.
References User\getBlock(), getRestriction(), getTitle(), User\isBlocked(), requiresUnblock(), requiresWrite(), and wfReadOnly().
Referenced by FormlessAction\show(), PurgeAction\show(), and FormAction\show().
Action::doesWrites | ( | ) |
Indicates whether this action may perform database writes.
Definition at line 429 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 169 of file Action.php.
References $name.
Referenced by HistoryAction\fetchRevisions(), ActionTest\testActionExists(), ActionTest\testActionExists_doesNotRequireInstantiation(), ActionTest\testDisabledAction_exists(), and ActionTest\testNull_doesNotExist().
|
staticfinal |
Get an appropriate Action subclass for the given action.
string | $action | |
Page | $page | |
IContextSource | null | $context |
Definition at line 95 of file Action.php.
References $context.
Referenced by RebuildFileCache\execute(), getActionName(), MediaWiki\performAction(), SkinTemplate\prepareQuickTemplate(), ActionTest\testActionFactory(), ActionTest\testDisabledAction_factoryReturnsFalse(), and ActionTest\testNull_canNotBeInstantiated().
|
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 $context, $request, IContextSource\canUseWikiPage(), factory(), IContextSource\getRequest(), IContextSource\getWikiPage(), and global.
Referenced by addHelpLink(), SkinTemplate\buildContentNavigationUrls(), MediaWiki\getAction(), OutputPage\getHeadLinksArray(), OutputPage\getJSVars(), OutputPage\headElement(), ActionTest\testDisabledAction_isNotResolved(), ActionTest\testGetActionName(), ActionTest\testGetActionName_editredlinkWorkaround(), ActionTest\testGetActionName_historysubmitWorkaround(), ActionTest\testGetActionName_revisiondeleteWorkaround(), ActionTest\testGetActionName_whenCanNotUseWikiPage_defaultsToView(), ActionTest\testNull_defaultsToView(), and SkinTemplate\wrapHTML().
|
staticfinalprivate |
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 67 of file Action.php.
References global.
|
final |
Get the IContextSource in use here.
Definition at line 178 of file Action.php.
References $context, RequestContext\getMain(), page, wfDebug(), and wfWarn().
Referenced by FormAction\getForm(), getLanguage(), getOutput(), RawAction\getRawText(), getRequest(), getSkin(), getUser(), msg(), RollbackAction\onView(), InfoAction\onView(), HistoryAction\onView(), InfoAction\pageInfo(), EditAction\show(), ProtectAction\show(), DeleteAction\show(), RevisiondeleteAction\show(), and SpecialPageAction\show().
|
protected |
Returns the description that goes below the \<h1\> tag.
Definition at line 378 of file Action.php.
References getName(), and msg().
Referenced by setHeaders().
|
final |
Shortcut to get the user Language being used for this instance.
Definition at line 236 of file Action.php.
References getContext().
Referenced by CreditsAction\getAuthor(), CachedAction\getCacheKey(), CreditsAction\getContributors(), InfoAction\getContributors(), RevertAction\getFormFields(), RevertAction\onSuccess(), and InfoAction\pageInfo().
|
abstract |
Return the name of the action this object responds to.
Referenced by CachedAction\getCacheKey(), getDescription(), and FormAction\getForm().
|
final |
Get the OutputPage being used for this instance.
Definition at line 207 of file Action.php.
References getContext().
Referenced by CachedAction\addCachedHTML(), addHelpLink(), CachedAction\onCacheInitialized(), UnwatchAction\onSuccess(), WatchAction\onSuccess(), PurgeAction\onSuccess(), RevertAction\onSuccess(), MarkpatrolledAction\onView(), RawAction\onView(), RollbackAction\onView(), HistoryAction\onView(), setHeaders(), FormlessAction\show(), ProtectAction\show(), ViewAction\show(), DeleteAction\show(), and EditAction\show().
|
protected |
Returns the name that goes in the \<h1\> page title.
Definition at line 368 of file Action.php.
References getTitle().
Referenced by setHeaders().
|
final |
Get the WebRequest being used for this instance.
Definition at line 197 of file Action.php.
References getContext().
Referenced by RevertAction\alterForm(), RevertAction\checkCanExecute(), HistoryAction\feed(), RawAction\getContentType(), FormAction\getForm(), RevertAction\getFormFields(), SpecialPageAction\getName(), RawAction\getOldId(), RawAction\getRawText(), RevertAction\onSubmit(), RevertAction\onSuccess(), MarkpatrolledAction\onView(), RawAction\onView(), RollbackAction\onView(), HistoryAction\onView(), PurgeAction\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
Definition at line 295 of file Action.php.
Referenced by checkCanExecute().
|
final |
Shortcut to get the Skin being used for this instance.
Definition at line 227 of file Action.php.
References getContext().
|
final |
Shortcut to get the Title object from the page.
Definition at line 246 of file Action.php.
References page.
Referenced by RevertAction\alterForm(), RevertAction\checkCanExecute(), checkCanExecute(), HistoryAction\feed(), HistoryAction\feedEmpty(), HistoryAction\feedItem(), HistoryAction\fetchRevisions(), HistoryAction\getDescription(), RevertAction\getDescription(), FormAction\getForm(), RevertAction\getFormFields(), RawAction\getOldId(), HistoryAction\getPageTitle(), RevertAction\getPageTitle(), getPageTitle(), InfoAction\getPageTitle(), RawAction\getRawText(), UnwatchAction\onSubmit(), WatchAction\onSubmit(), RevertAction\onSubmit(), UnwatchAction\onSuccess(), WatchAction\onSuccess(), PurgeAction\onSuccess(), RevertAction\onSuccess(), RollbackAction\onView(), HistoryAction\onView(), CreditsAction\othersLink(), and InfoAction\pageInfo().
|
final |
Shortcut to get the User being used for this instance.
Definition at line 217 of file Action.php.
References getContext().
Referenced by RevertAction\getFormFields(), UnwatchAction\onSubmit(), WatchAction\onSubmit(), RevertAction\onSubmit(), RevertAction\onSuccess(), MarkpatrolledAction\onView(), RawAction\onView(), RollbackAction\onView(), HistoryAction\onView(), InfoAction\pageInfo(), FormlessAction\show(), EditAction\show(), PurgeAction\show(), and FormAction\show().
|
final |
Get a Message object with context set Parameters are the same as wfMessage()
Definition at line 256 of file Action.php.
References $params, and getContext().
Referenced by RevertAction\checkCanExecute(), HistoryAction\feed(), HistoryAction\feedEmpty(), HistoryAction\feedItem(), CreditsAction\getAuthor(), CreditsAction\getContributors(), InfoAction\getContributors(), UnwatchAction\getDescription(), CreditsAction\getDescription(), WatchAction\getDescription(), HistoryAction\getDescription(), getDescription(), RevertAction\getFormFields(), HistoryAction\getPageTitle(), RevertAction\getPageTitle(), InfoAction\getPageTitle(), MarkpatrolledAction\onView(), CreditsAction\onView(), RollbackAction\onView(), InfoAction\onView(), HistoryAction\onView(), CreditsAction\othersLink(), InfoAction\pageInfo(), PurgeAction\postText(), HistoryAction\preCacheMessages(), UnwatchAction\preText(), WatchAction\preText(), PurgeAction\preText(), SpecialPageAction\show(), and CreditsAction\userLink().
Action::requiresUnblock | ( | ) |
Whether this action can still be executed by a blocked user.
Definition at line 346 of file Action.php.
Referenced by checkCanExecute().
Action::requiresWrite | ( | ) |
Whether this action requires the wiki not to be locked.
Definition at line 336 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 355 of file Action.php.
References $out, getDescription(), getOutput(), and getPageTitle().
Referenced by FormlessAction\show(), PurgeAction\show(), and FormAction\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 |
|
protected |
Call wfTransactionalTimeLimit() if this request was POSTed.
Definition at line 418 of file Action.php.
References getRequest(), and wfTransactionalTimeLimit().
Referenced by RevertAction\onSubmit(), DeleteAction\show(), and EditAction\show().
|
protected |
IContextSource if specified; otherwise we'll use the Context from the Page.
Definition at line 51 of file Action.php.
Referenced by RevisiondeleteAction\__construct(), __construct(), factory(), getActionName(), and getContext().
|
protected |
|
protected |
Page on which we're performing the action.
Definition at line 44 of file Action.php.
Referenced by __construct(), WatchAction\doUnwatch(), WatchAction\doWatch(), HistoryAction\getArticle(), InfoAction\getContributors(), CreditsAction\link(), and EditAction\show().