Manual:$wgActions/dtp
Actions: $wgActions | |
---|---|
Array of allowed values for the action parameter for normal pages. |
|
Introduced in version: | 1.18.0 (r86041) |
Removed in version: | Still in use |
Allowed values: | (array mapping strings to boolean or string) |
Default value: | see below |
Other settings: Alphabetical | By function |
Details
Array of allowed values for the action
parameter for normal pages.
Syntax is:
'foo' => 'ClassName'
- Load the specified class which subclassesAction
.'foo' => true
- Load the classFooAction
which subclassesAction
.'foo' => false
- The action is disabled; show an error message.
Default value
MediaWiki version: | ≥ 1.37 |
/**
* Array of allowed values for the "title=foo&action=<action>" parameter.
* See ActionFactory for the syntax.
* Core defaults are in ActionFactory::CORE_ACTIONS, anything here overrides that.
*/
$wgActions = [];
MediaWiki versions: | 1.32 – 1.36 |
$wgActions = [
'credits' => true,
'delete' => true,
'edit' => true,
'editchangetags' => SpecialPageAction::class,
'history' => true,
'info' => true,
'markpatrolled' => true,
'mcrundo' => McrUndoAction::class,
'mcrrestore' => McrRestoreAction::class,
'protect' => true,
'purge' => true,
'raw' => true,
'render' => true,
'revert' => true,
'revisiondelete' => SpecialPageAction::class,
'rollback' => true,
'submit' => true,
'unprotect' => true,
'unwatch' => true,
'view' => true,
'watch' => true,
];
MediaWiki version: | 1.31 |
$wgActions = [
'credits' => true,
'delete' => true,
'edit' => true,
'editchangetags' => SpecialPageAction::class,
'history' => true,
'info' => true,
'markpatrolled' => true,
'protect' => true,
'purge' => true,
'raw' => true,
'render' => true,
'revert' => true,
'revisiondelete' => SpecialPageAction::class,
'rollback' => true,
'submit' => true,
'unprotect' => true,
'unwatch' => true,
'view' => true,
'watch' => true,
];
MediaWiki versions: | 1.25 – 1.30 |
$wgActions = [
'credits' => true,
'delete' => true,
'edit' => true,
'editchangetags' => 'SpecialPageAction',
'history' => true,
'info' => true,
'markpatrolled' => true,
'protect' => true,
'purge' => true,
'raw' => true,
'render' => true,
'revert' => true,
'revisiondelete' => 'SpecialPageAction',
'rollback' => true,
'submit' => true,
'unprotect' => true,
'unwatch' => true,
'view' => true,
'watch' => true,
];
MediaWiki versions: | 1.19 – 1.24 |
$wgActions = array(
'credits' => true,
'delete' => true,
'edit' => true,
'history' => true,
'info' => true,
'markpatrolled' => true,
'protect' => true,
'purge' => true,
'raw' => true,
'render' => true,
'revert' => true,
'revisiondelete' => true,
'rollback' => true,
'submit' => true,
'unprotect' => true,
'unwatch' => true,
'view' => true,
'watch' => true,
);
MediaWiki version: | 1.18 |
$wgActions = array(
'credits' => true,
'deletetrackback' => true,
'info' => true,
'markpatrolled' => true,
'purge' => true,
'revert' => true,
'revisiondelete' => true,
'rollback' => true,
'unwatch' => true,
'watch' => true,
);
Example
There is a lot you can do with a custom action, and the best method of discovery is to browse the Action
, FormAction
and FormlessAction
classes in the core MediaWiki code (as these are the classes you will be extending) and to look at examples of pages that provide similar function to what you require, either in the core or in stable and well-supported extensions.
The following example covers the most common use-case, namely generating a custom page for the action, possibly with some extra URL arguments.
class ExampleAction extends Action {
// This action is called 'example_action'. <span lang="en" dir="ltr" class="mw-content-ltr">This class will only be invoked when the specified action is requested.</span>
public function getName() {
// This should be the same name as used when registering the action in $wgActions.
return 'example_action';
}
// This is the function that is called whenever a page is being requested using this action.
// You should not use globals $wgOut, $wgRequest, etc.
// Mantad do laang kalas (e.g. $this->getOutput()), nogi.
public function show() {
// Create local instances of the context variables we need, to simplify later code.
$out = $this->getOutput();
$request = $this->getRequest();
// Kopokitanan nopo nga miagal montok do bolikan tagayo om bolikan mimboros, mantad di yahai id
$title = $this->page->getTitle();
if ( $title->isTalkPage() ) {
$title = $title->getSubjectPage();
}
// Tatapo uhu bolikan.
$out->setPageTitle( 'Example Page Title' );
// Manganu piipiro parameter mantad URL dii.
$param = $request->getIntOrNull( 'example_param' );
// Do some internal stuff to generate the content (placed in $output).
// Posoliwano kootusan.
$out->addHTML( $output );
// toi ko'
$out->addWikiText( $output );
}
}
Register the new action in extension.json (see extension.json schema):
"Actions": {
"example_action": "ExampleAction"
},
Disable an action
To disable an action just add the following e.g. for the raw
action to your "LocalSettings.php" file:
$wgActions['raw'] = false;