69 final private static function getClass( $action, array $overrides ) {
71 $action = strtolower( $action );
79 } elseif (
$wgActions[$action] ===
true && isset( $overrides[$action] ) ) {
80 return $overrides[$action];
82 return ucfirst( $action ) .
'Action';
98 $classOrCallable = self::getClass( $action, $page->getActionOverrides() );
100 if ( is_string( $classOrCallable ) ) {
101 if ( !class_exists( $classOrCallable ) ) {
104 return new $classOrCallable( $page,
$context );
107 if ( is_callable( $classOrCallable ) ) {
108 return $classOrCallable( $page,
$context );
111 return $classOrCallable;
127 $actionName = $request->getVal(
'action',
'view' );
131 $actionName =
'nosuchaction';
136 if ( $actionName ===
'historysubmit' ) {
137 if ( $request->getBool(
'revisiondelete' ) ) {
138 $actionName =
'revisiondelete';
139 } elseif ( $request->getBool(
'editchangetags' ) ) {
140 $actionName =
'editchangetags';
142 $actionName =
'view';
144 } elseif ( $actionName ===
'editredlink' ) {
145 $actionName =
'edit';
151 if ( !
$context->canUseWikiPage() ) {
156 if ( $action instanceof
Action ) {
157 return $action->getName();
160 return 'nosuchaction';
170 final public static function exists( $name ) {
171 return self::getClass( $name, [] ) !==
null;
182 } elseif ( $this->page instanceof
Article ) {
184 wfDebug( __METHOD__ .
": no context known, falling back to Article's context.\n" );
185 return $this->page->getContext();
188 wfWarn( __METHOD__ .
': no context known, falling back to RequestContext::getMain().' );
189 return RequestContext::getMain();
248 return $this->page->getTitle();
259 final public function msg( $key, ...$params ) {
260 return $this->
getContext()->msg( $key, ...$params );
271 wfWarn( __METHOD__ .
' called without providing a Context object.' );
310 if ( $right !==
null ) {
311 $errors = $this->
getTitle()->getUserPermissionsErrors( $right, $user );
312 if ( count( $errors ) ) {
362 $out->setRobotPolicy(
'noindex,nofollow' );
365 $out->setArticleRelated(
true );
374 return $this->
getTitle()->getPrefixedText();
384 return $this->
msg( strtolower( $this->
getName() ) )->escaped();
396 $msg =
wfMessage( MediaWikiServices::getInstance()->getContentLanguage()->lc(
400 if ( !$msg->isDisabled() ) {
401 $helpUrl = Skin::makeUrl( $msg->plain() );
402 $this->
getOutput()->addHelpLink( $helpUrl,
true );
404 $this->
getOutput()->addHelpLink( $to, $overrideBaseUrl );
416 abstract public function show();
$wgActions
Array of allowed values for the "title=foo&action=<action>" parameter.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfReadOnly()
Check whether the wiki is in read-only mode.
wfTransactionalTimeLimit()
Set PHP's time limit to the larger of php.ini or $wgTransactionalTimeLimit.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Actions are things which can be done to pages (edit, delete, rollback, etc).
static factory( $action, Page $page, IContextSource $context=null)
Get an appropriate Action subclass for the given action.
doesWrites()
Indicates whether this action may perform database writes.
checkCanExecute(User $user)
Checks if the given user (identified by an object) can perform this action.
getName()
Return the name of the action this object responds to.
$page
Page on which we're performing the action.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
requiresWrite()
Whether this action requires the wiki not to be locked.
getDescription()
Returns the description that goes below the <h1> tag.
static getClass( $action, array $overrides)
Get the Action subclass which should be used to handle this action, false if the action is disabled,...
getPageTitle()
Returns the name that goes in the <h1> page title.
getTitle()
Shortcut to get the Title object from the page.
getContext()
Get the IContextSource in use here.
requiresUnblock()
Whether this action can still be executed by a blocked user.
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User being used for this instance.
$context
IContextSource if specified; otherwise we'll use the Context from the Page.
setHeaders()
Set output headers for noindexing etc.
getRestriction()
Get the permission required to perform this action.
getSkin()
Shortcut to get the Skin being used for this instance.
show()
The main action entry point.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
static getActionName(IContextSource $context)
Get the action that will be executed, not necessarily the one passed passed through the "action" requ...
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
static exists( $name)
Check if a given action is recognised, even if it's disabled.
$fields
The fields used to create the HTMLForm.
getLanguage()
Shortcut to get the user Language being used for this instance.
__construct(Page $page, IContextSource $context=null)
Only public since 1.21.
getRequest()
Get the WebRequest being used for this instance.
Class for viewing MediaWiki article and history.
Show an error when a user tries to do something they do not have the necessary permissions for.
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
Show an error when the user tries to do something whilst blocked.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getBlock( $fromReplica=true)
Get the block affecting the user, or null if the user is not blocked.
isBlockedFrom( $title, $fromReplica=false)
Check if user is blocked from editing a particular article.
Interface for objects which can provide a MediaWiki context on request.
Interface for localizing messages in MediaWiki.
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)