hostease主机优惠

Mediawiki中文技术论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 5539|回复: 0

MediaWiki修改:预置初始编辑文本

[复制链接]
发表于 2010-12-25 16:22:53 | 显示全部楼层 |阅读模式
HostEase主机优惠
安装破解

本破解易于安装.

第一步: 创建 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”页面
  1. includes/EditPage.php
复制代码
。注意:编辑此文件可能会导致您的wiki出现问题,所以需要格外小心。找到

  1. function editForm
复制代码
。在函数顶部得变量中,添加以下内容:

  1. $startText = '';
复制代码
。找到类似下面代码的语句:

  1. if(!$this->mTitle->getArticleID()) { # new article
  2. $wgOut->addWikiText(wfmsg('newarticletext'));
  3. }
复制代码
在上述代码的if条件语句中,添加如下内容:

  1. if(!$this->preview) {
  2. $startText = htmlspecialchars(wfMsgForContent("new"));
  3. }
复制代码
添加完成后的内容如下所示:

  1. if(!$this->mTitle->getArticleID()) { # new article
  2. $wgOut->addWikiText(wfmsg('newarticletext'));
  3. if(!$this->preview) {
  4.   $startText = htmlspecialchars(wfMsgForContent("new"));
  5. }
  6. }
复制代码
最后,找到第一个代码块
textarea


  1. <textarea tabindex='1' accesskey="," name="wpTextbox1" rows='{$rows}'
  2. cols='{$cols}'{$ew}>" .
  3. htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox1 ) ) .
  4. "
  5. </textarea>
复制代码
Edit

  1. includes/EditPage.php
复制代码
. Warning: editing this file could lead to problems throughout your wiki, so be very careful. Find

  1. function editForm
复制代码
. In the list of variables at the top of this function, add this:

  1. $startText = '';
复制代码
Find an if statement that looks like this:

  1. if(!$this->mTitle->getArticleID()) { # new article
  2. $wgOut->addWikiText(wfmsg('newarticletext'));
  3. }
复制代码
Within that statement, nest this if statement:

  1. if(!$this->preview) {
  2. $startText = htmlspecialchars(wfMsgForContent("new"));
  3. }
复制代码
So the overall statement now looks like this:

  1. if(!$this->mTitle->getArticleID()) { # new article
  2. $wgOut->addWikiText(wfmsg('newarticletext'));
  3. if(!$this->preview) {
  4.   $startText = htmlspecialchars(wfMsgForContent("new"));
  5. }
  6. }
复制代码
Finally, find the first

textarea

block of code:

  1. <textarea tabindex='1' accesskey="," name="wpTextbox1" rows='{$rows}'
  2. cols='{$cols}'{$ew}>" .
  3. htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox1 ) ) .
  4. "
  5. </textarea>
复制代码
Between the . and ", add

  1. $startText .
复制代码
, so now you have this:

  1. <textarea tabindex='1' accesskey="," name="wpTextbox1" rows='{$rows}'
  2. cols='{$cols}'{$ew}>" .
  3. htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox1 ) ) . $startText .
  4. "
  5. </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

  1. EditPage.php
复制代码
, upload this file to your live

  1. includes
复制代码
directory. Try editing a new article and an old article, and confirm that the hack works as intended.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

美国HostEase虚拟主机一年198元

Archiver|手机版|小黑屋|Mediawiki中文技术论坛

GMT+8, 2024-12-27 09:55 , Processed in 0.051109 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.

快速回复 返回顶部 返回列表