“Mediawiki特殊页面”的版本间的差异
(创建页面,内容为“https://blog.csdn.net/chengliang69/article/details/84709690”) |
|||
| (未显示同一用户的1个中间版本) | |||
| 第1行: | 第1行: | ||
| + | |||
| + | Mediawiki特殊页面开发步骤 | ||
| + | |||
| + | 1 页面显示名字设置 | ||
| + | |||
| + | 1.1 languages\i18n\目录中各语言文件中的中添加特殊页面名称。以网上支付为列: | ||
| + | 添加简体中文语言(languages\i18n\zh-hans.json文件中): | ||
| + | |||
| + | "OnlinePay":"进行网银支付" | ||
| + | |||
| + | |||
| + | 2 别名设置 | ||
| + | 2.1 languages\messages目录中各语言文件中的$specialPageAliases = array()中添加特殊页面别名。 | ||
| + | 以网上支付为列: | ||
| + | |||
| + | 添加简体中文语言(MessagesZh_hans.php文件中): | ||
| + | |||
| + | 'OnlinePay' => array( '网上支付' ) | ||
| + | |||
| + | |||
| + | 3 注册Specialpage\SpecialPageFactory.php: | ||
| + | //在private static $list = array()中添加网上支付处理类: | ||
| + | |||
| + | 'OnlinePay' => 'SpecialOnlinePay', | ||
| + | |||
| + | |||
| + | 4 开发功能 | ||
| + | 4.1 includes/specials下增加SpecialOnlinePay.php文件 | ||
| + | 4.2 添加页面链接功能 | ||
| + | //通过构造函数设置页面显示的信息和链接信息,当前设置为'OnlinePay'后,在页面上显示信息为读取第一步中设置的值,URL链接为第二步设置的值。可以看到这两个值都是通过'OnlinePay'进行设置的,所以在第一步和第二步中的健值必须一样,否则显示不出相关信息。 | ||
| + | |||
| + | public function __construct($name = 'OnlinePay') { | ||
| + | parent::__construct($name); | ||
| + | } | ||
| + | |||
| + | |||
| + | // 文件中最后的方法getGroupName返回值代表特殊页面列表中的分组,本例的分组为'other',在特殊页面的【其他特殊页面】下。 | ||
| + | |||
| + | protected function getGroupName() { | ||
| + | return 'other'; | ||
| + | } | ||
| + | |||
| + | |||
| + | //进入特殊页面 | ||
| + | |||
| + | public function execute($subPage) { | ||
| + | //判断权限,在未登录状态不可通过url 直接访问 | ||
| + | $this->checkPermissions(); | ||
| + | //设置头部信息 | ||
| + | $request = $this->getRequest(); | ||
| + | $out = $this->getOutput(); | ||
| + | $this->setHeaders(); | ||
| + | |||
| + | |||
| + | //设置网页 | ||
| + | |||
| + | 方法一: | ||
| + | |||
| + | $this -> getOutput() -> addHTML("<html><body>......<body></html>"); | ||
| + | |||
| + | |||
| + | 方法二: | ||
| + | |||
| + | $template = new StrokesTemplate(); | ||
| + | $this->getOutput()->addTemplate($template); | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | StrokesTemplate 为模板类: | ||
| + | |||
| + | Exp: | ||
| + | |||
| + | <?php | ||
| + | class StrokesTemplate extends BaseTemplate { | ||
| + | function execute() { | ||
| + | ?> | ||
| + | <html>...</html> | ||
| + | <?php | ||
| + | } | ||
| + | } | ||
| + | ?> | ||
| + | |||
| + | |||
| + | StrokesTemplate.php 使用前需要在AutoLoader.php中注册。 | ||
| + | |||
| + | |||
| + | |||
| + | 'StrokesTemplate' => 'includes/templates/StrokesTemplate.php', | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | 5 配置页面指向 | ||
| + | 5.1ncludes /AutoLoader.php中文件路径 | ||
| + | 'SpecialOnlinePay' => 'includes/specials/SpecialOnlinePay.php', | ||
| + | |||
| + | |||
| + | 6 页面测试 | ||
| + | 6.1进入特殊页面,找到“链接” | ||
| + | 进入特殊页面中,在【其他特殊页面】类别下点击【进入网银支付】链接,即可跳转到创建的页面中。 | ||
| + | |||
| + | 见附件:图片1.png | ||
| + | |||
| + | |||
| + | |||
| + | 6.2进入刚刚创建的特殊页面 | ||
| + | 见附件:图片2.png | ||
| + | |||
| + | |||
| + | |||
| + | |||
https://blog.csdn.net/chengliang69/article/details/84709690 | https://blog.csdn.net/chengliang69/article/details/84709690 | ||
2019年12月7日 (六) 10:49的最新版本
Mediawiki特殊页面开发步骤
1 页面显示名字设置
1.1 languages\i18n\目录中各语言文件中的中添加特殊页面名称。以网上支付为列: 添加简体中文语言(languages\i18n\zh-hans.json文件中):
"OnlinePay":"进行网银支付"
2 别名设置
2.1 languages\messages目录中各语言文件中的$specialPageAliases = array()中添加特殊页面别名。
以网上支付为列:
添加简体中文语言(MessagesZh_hans.php文件中):
'OnlinePay' => array( '网上支付' )
3 注册Specialpage\SpecialPageFactory.php:
//在private static $list = array()中添加网上支付处理类:
'OnlinePay' => 'SpecialOnlinePay',
4 开发功能
4.1 includes/specials下增加SpecialOnlinePay.php文件
4.2 添加页面链接功能
//通过构造函数设置页面显示的信息和链接信息,当前设置为'OnlinePay'后,在页面上显示信息为读取第一步中设置的值,URL链接为第二步设置的值。可以看到这两个值都是通过'OnlinePay'进行设置的,所以在第一步和第二步中的健值必须一样,否则显示不出相关信息。
public function __construct($name = 'OnlinePay') { parent::__construct($name); }
// 文件中最后的方法getGroupName返回值代表特殊页面列表中的分组,本例的分组为'other',在特殊页面的【其他特殊页面】下。
protected function getGroupName() { return 'other'; }
//进入特殊页面
public function execute($subPage) { //判断权限,在未登录状态不可通过url 直接访问 $this->checkPermissions(); //设置头部信息 $request = $this->getRequest(); $out = $this->getOutput(); $this->setHeaders();
//设置网页
方法一:
$this -> getOutput() -> addHTML("<html><body>......<body></html>");
方法二:
$template = new StrokesTemplate(); $this->getOutput()->addTemplate($template);
StrokesTemplate 为模板类:
Exp:
<?php class StrokesTemplate extends BaseTemplate { function execute() { ?> <html>...</html> <?php } } ?>
StrokesTemplate.php 使用前需要在AutoLoader.php中注册。
'StrokesTemplate' => 'includes/templates/StrokesTemplate.php',
5 配置页面指向
5.1ncludes /AutoLoader.php中文件路径
'SpecialOnlinePay' => 'includes/specials/SpecialOnlinePay.php',
6 页面测试
6.1进入特殊页面,找到“链接”
进入特殊页面中,在【其他特殊页面】类别下点击【进入网银支付】链接,即可跳转到创建的页面中。
见附件:图片1.png
6.2进入刚刚创建的特殊页面
见附件:图片2.png