wangsisi 发表于 2010-12-25 16:22:53

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

textarea

block 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 of

EditPage.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.
页: [1]
查看完整版本: MediaWiki修改:预置初始编辑文本

BlueHost美国主机优惠码