MediaWiki修改:预置初始编辑文本
天下维客,你可以修改的网络知识库
目录 |
[编辑]
安装破解
本破解易于安装.
[编辑]
第一步: 创建 MediaWiki:New
首先,在您的wiki中创建一个“MediaWiki:New”。您必须以管理员身份登录系统才能创建该页面。当前页当中的任何文本和格式将作为默认内容出现在每篇文章当中。 First, create MediaWiki:New in your wiki. You will have to login as an administrator to create this page. The page should include whatever text and formatting should appear by default in each article.
[编辑]
第二步: 编辑“EditPage.php”页面
编辑
includes/EditPage.php。注意:编辑此文件可能会导致您的wiki出现问题,所以需要格外小心。 找到
function editForm。在函数顶部得变量中,添加以下内容:
$startText = '';。
找到类似下面代码的语句:
if(!$this->mTitle->getArticleID()) { # new article
$wgOut->addWikiText(wfmsg('newarticletext'));
}
在上述代码的if条件语句中,添加如下内容:
if(!$this->preview) {
$startText = htmlspecialchars(wfMsgForContent("new"));
}
添加完成后的内容如下所示:
if(!$this->mTitle->getArticleID()) { # new article
$wgOut->addWikiText(wfmsg('newarticletext'));
if(!$this->preview) {
$startText = htmlspecialchars(wfMsgForContent("new"));
}
}
最后,找到第一个代码块textarea:
<textarea tabindex='1' accesskey=\",\" name=\"wpTextbox1\" rows='{$rows}'
cols='{$cols}'{$ew}>" .
htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox1 ) ) .
"
</textarea>
Edit includes/EditPage.php. Warning: editing this file could lead to problems throughout your wiki, so be very careful. Find
function editForm. In the list of variables at the top of this function, add this:
$startText = '';
Find an if statement that looks like this:
if(!$this->mTitle->getArticleID()) { # new article
$wgOut->addWikiText(wfmsg('newarticletext'));
}
Within that statement, nest this if statement:
if(!$this->preview) {
$startText = htmlspecialchars(wfMsgForContent("new"));
}
So the overall statement now looks like this:
if(!$this->mTitle->getArticleID()) { # new article
$wgOut->addWikiText(wfmsg('newarticletext'));
if(!$this->preview) {
$startText = htmlspecialchars(wfMsgForContent("new"));
}
}
Finally, find the first textareablock of code:
<textarea tabindex='1' accesskey=\",\" name=\"wpTextbox1\" rows='{$rows}'
cols='{$cols}'{$ew}>" .
htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox1 ) ) .
"
</textarea>
Between the . and ", add $startText ., so now you have this:
<textarea tabindex='1' accesskey=\",\" name=\"wpTextbox1\" rows='{$rows}'
cols='{$cols}'{$ew}>" .
htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox1 ) ) . $startText .
"
</textarea>
If the article is new and not being previewed, the contents of MediaWiki:New will be added to the editing textbox. Otherwise, nothing is added.
[编辑]
Step 3: Upload and Test
If you worked on a local copy ofEditPage.php, upload this file to your live
includesdirectory. Try editing a new article and an old article, and confirm that the hack works as intended.
原文参见: Starting text hack
| MediaWiki扩展简明教程 | Inputbox帮助文档 | 使用Spam黑名单 | 内容折叠隐藏 | 动态文章列表 | 指定图片链接 |
| 代码高亮处理 | 预置初始编辑文本 | 页面访问限制 | 所见即所得编辑器 | QQ在线信息 | |
| 交流:扩展使用 | 投票与评分 | 内容随机展示 | wikitex | 改进设想 | ...更多 |
| 加入google地图和51地图标注功能 | Ajax五颗星评分插件 |



