Manual: $wgActions
| Actions: $wgActions | |
|---|---|
Array of allowed values for the action parameter for normal pages. |
|
| Introduzido na versão: | 1.18.0 (r86041) |
| Removido na versão: | Ainda em utilização |
| Valores permitidos: | (mapeamento de cadeias de carateres de matriz para booliano ou cadeia de carateres) |
| Valor predefinido: | veja em baixo |
| Outras definições: Alfabeticamente | Por função | |
Detalhes
Array of allowed values for the action parameter for normal pages.
A sintaxe é:
'foo' => 'ClassName'- Load the specified class which subclassesAction.'foo' => true- Load the classFooActionwhich subclassesAction.'foo' => false- The action is disabled; show an error message.
Valor predefinido
| Versão MediaWiki: | ≥ 1.37 |
/**
* Array of allowed values for the "title=foo&action=<action>" parameter.
* Consulte ActionFactory para a sintaxe.
* As predefinições principais estão em ActionFactory::CORE_ACTIONS, qualquer coisa aqui substitui isso.
*/
$wgActions = [];
| Versões do MediaWiki: | 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,
];
| Versão MediaWiki: | 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,
];
| Versões do MediaWiki: | 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,
];
| Versões do MediaWiki: | 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,
);
| Versão MediaWiki: | 1.18 |
$wgActions = array(
'credits' => true,
'deletetrackback' => true,
'info' => true,
'markpatrolled' => true,
'purge' => true,
'revert' => true,
'revisiondelete' => true,
'rollback' => true,
'unwatch' => true,
'watch' => true,
);
Exemplo
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 {
// Esta ação é chamada de 'example_action'. This class will only be invoked when the specified action is requested.
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.
// Instead, use the methods provided by the Action class (e.g. $this->getOutput()), instead.
public function show() {
// Create local instances of the context variables we need, to simplify later code.
$out = $this->getOutput();
$request = $this->getRequest();
// The view is the same for the main page and the talk page, so if we're on the talk page then we need to change $Title to point to the subject page instead.
$title = $this->page->getTitle();
if ( $title->isTalkPage() ) {
$title = $title->getSubjectPage();
}
// Define o título da página
$out->setPageTitle( 'Example Page Title' );
// Obtém alguns parâmetros do URL.
$param = $request->getIntOrNull( 'example_param' );
// Realiza alguma coisa internas para gerar o conteúdo (colocado em $output).
// Apresenta os resultados.
$out->addHTML( $output );
// ou
$out->addWikiText( $output );
}
}
Registe a nova ação em extension.json (consulte esquema extension.json):
"Actions": {
"example_action": "ExampleAction"
},
Desativar uma ação
Para desativar uma ação, basta adicionar o exemplo seguinte para a ação raw para o seu ficheiro “LocalSettings.php”:
$wgActions['raw'] = false;