Manual:$wgActions/zh
操作: $wgActions | |
---|---|
普通页面action 参数允许值的数组。 |
|
引进版本: | 1.18.0 (r86041) |
移除版本: | 仍在使用 |
允许的值: | (将字符串映射到布尔值或字符串的数组) |
参见下方 | |
其他设置: 按首字母排序 | 按功能排序 |
详情
普通页面action
参数允许值的数组。
語法:
'foo' => 'ClassName'
- 加载将Action
子类化的指定类'foo' => true
- 加载将Action
子类化的类FooAction
'foo' => false
- 如果该操作已禁用则显示错误消息
Since MediaWiki 1.37, core defaults are defined in ActionFactory.php.
MediaWiki版本: | ≥ 1.37 |
/**
* Array of allowed values for the "title=foo&action=<action>" parameter.
* 语法请参见ActionFactory。
* Core defaults are in ActionFactory::CORE_ACTIONS, anything here overrides that.
*/
$wgActions = [];
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,
];
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,
];
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,
];
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,
);
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,
);
使用自定义操作可以做很多事情,最好的发现方法是浏览核心MediaWiki代码中的Action
、FormAction
、FormlessAction
类(因为这些是您将扩展的类),并查看提供与您所需相似功能的页面示例,无论是在核心中还是在稳定且支持良好的扩展中。
下面的示例涵盖了最常见的用例,即为操作生成一个定制页面,可能带有一些额外的URL参数。
class ExampleAction extends Action {
// 此操作称为'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.
// 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();
}
// 设定页面标题。
$out->setPageTitle( 'Example Page Title' );
// 从URL获取一些参数。
$param = $request->getIntOrNull( 'example_param' );
// Do some internal stuff to generate the content (placed in $output).
// 输出结果。
$out->addHTML( $output );
// 或
$out->addWikiText( $output );
}
}
在extension.json中注册新操作(请参阅extension.json 架构):
"Actions": {
"example_action": "ExampleAction"
},
禁用一个操作
要禁用某个操作,只需将以下代码,如raw
操作,添加到“LocalSettings.php”文件中:
$wgActions['raw'] = false;
扰乱核心行动可能会导致事情大声抱怨。