Manual:FAQ/zh-hans

From MediaWiki.org
Jump to: navigation, search
有疑问吗?

MediaWiki的常见问题解答(FAQ)。如果您的疑问在这里或者旧的meta FAQ得不到解决,请登陆到我们的 聊天频道帮助中心寻求帮助。

这个常见问题解答将慢慢替代meta上的旧版本,如果在这里找不到您遇到的问题,请试试到那里找。
语言: English  • català • dansk • Deutsch • español • français • ગુજરાતી • עברית • Bahasa Indonesia • italiano • 日本語 • 한국어 • മലയാളം • occitan • polski • português • português do Brasil • русский • Türkçe • 中文 • 中文(简体)‎

Contents


怎样让首页(mainpage)不显示Tagline?[edit | edit source]

我应该怎样安装MediaWiki?[edit | edit source]

MediaWiki的安装可能需要花费您10到30分钟的时间,其中包括上传/复制文件到服务器,并运行安装脚本配置软件——参见安装

您可以在分发包的INSTALL文件中找到详细的安装指南。

我如何打包安装MediaWiki?[edit | edit source]

大部分Linux发行版都会以分发包的格式提供MediaWiki软件。MediaWiki开发团队认为您应该向您的Linux发行版提供者咨询安装与配置的事宜。负责维护这些分发包的独立社群和公司应该向您提供安装指南。

我能在一台服务器上安装多个MediaWiki吗?[edit | edit source]

只要满足下列条件,您就可以在一台服务器上安装多个wiki:

  • 您的每一个wiki使用各自不同的数据库

或者

  • 您的每一个wiki的数据库前缀不相同(如果您用的是PostgreSQL,在不同的模式或用户下,也能达到这一效果)

要了解这些选项的相关信息,可分别参见$wgDBname$wgDBprefix

要了解设置wiki家族的相关信息,可参见Manual:Wiki家族

要了解将多个wiki设置为使用相同服务器、数据库与资源的其他方法,参见来自Steve Rumberg存档)用户的更深层的解释与进一步的意见。

MediaWiki可以工作在安全模式下吗?[edit | edit source]

可以,但其功能会受到一定限制。参见安全模式

MediaWiki需要终端访问吗?[edit | edit source]

终端访问(SSH访问)在安装MediaWiki的过程中并不是必须的,但我们强烈推荐你这么做。如果不能进行终端访问,您可能难以对您的wiki进行备份,或难以将它升级到更新的版本。如果完全脱离终端访问,您将不能完成一些维护任务。

我应该怎样安装插件?[edit | edit source]

参见Manual:Extensions获取安装插件与编写插件的相关信息。参见插件矩阵Category:插件以寻找已有的插件。

我如何才能增加额外的名字空间?[edit | edit source]

要增加名字空间,请修改您的LocalSettings.php文件,并通过$wgExtraNamespaces变量来增加名字空间。您可以将下列代码加到上述文件中以增加“Portal”名字空间及其对应的讨论名字空间:

$wgExtraNamespaces = array(100 => "Portal", 101 => "Portal_talk");

Note 注意:请使用下划线来替代空格,例如Portal_talk。否则,名字空间将不能被正确地定义!

我应该怎样启用上传功能?[edit | edit source]

文件上传是MediaWiki常用的功能之一,但在目前所有的发行版中都被默认关闭了。要启用它们,首先要让网站服务器上的上传文件夹(默认为images)可被写入(chmod 777或允许Apache用户写入内容,等等),然后在LocalSettings.php中将$wgEnableUploads设为true值(例如“$wgEnableUploads = true;”)。参见Manual:配置文件上传获取进一步的信息。

我如何才能插入数学公式?[edit | edit source]

在texvc软件的协助下,MediaWiki允许用户插入数学公式。texvc使用LaTeX来描述数学公式。参见Manual:Math获取安装指南。

我怎样才能刷新被缓存的页面?[edit | edit source]

有时您需要刷新被缓存的页面,比如当页面的导航栏发生了变化后。在页面的动态URL后加上&action=purge即可。

例如:http://www.mediawiki.org/w/index.php?title=Main_Page&action=purge

或在页面的短型URL后加上?action=purge

例如:http://www.mediawiki.org/wiki/Main_Page?action=purge

参见:Manual:刷新缓存Manual:传给index.php的参数


例如,要允许用户上传PDF文件,将下列语句加入LocalSettings.php即可:

$wgFileExtensions[] = 'pdf';

Note 注意:如果要允许用户上传多种类型的文件,语法会有所不同。 要实现这种需求,请仿造下方使用数组来允许png、gif、jpg、jpeg、pdf与txt文件上传的做法。

$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'pdf', 'txt' );

参见Manual:配置文件上传获取进一步的信息。

“文件已损坏或存在无效扩展名”[edit | edit source]

有些用户报告说,在向已允许扩展名列表中增加文件格式后,软件会发生错误。出错后的文字类似于下方:

文件已损坏或存在无效扩展名。请重新检查并上传文件。

可能的解决方案:

  • 设定$wgMimeDetectorCommand的值,例如:在Unix或Linux,您可以将它设为
    $wgMimeDetectorCommand = "file --brief --mime";
  • 编译/安装PHP插件fileinfo
    • Fedora - yum install php-pecl-Fileinfo

参见Manual:Mime类型探测获取进一步的信息。

初始用户并未由安装程序创建[edit | edit source]

有时,安装程序有可能不能成功地创建默认用户,或者用户表因为某种原因丢失了。有两种解决此问题的方案:

maintenance/createAndPromote.php[edit | edit source]

  • 确保已正确设定AdminSettings.php(参见AdminSettings.sample
  • 在终端运行maintenance/createAndPromote.php

这样会创建一名新的用户,并将其提升为管理者。要获取帮助信息,可在运行脚本时加上参数--help

修改数据库[edit | edit source]

  • 使用正规手段注册一个新帐户(Special:Userlogin)。
  • Special:参数设置中查出用户ID。
  • 在数据库运行以下SQL查询:
    • MediaWiki 1.5及更高版本:
      INSERT INTO user_groups ( ug_user, ug_group ) VALUES ( <id>, 'bureaucrat' ), ( <id>, 'sysop' );
    • MediaWiki 1.4:
      UPDATE user_rights SET ur_rights = 'sysop,bureaucrat' WHERE ur_user = <id>;
    • MediaWiki 1.3及更低版本:
      UPDATE user SET user_rights = 'sysop,bureaucrat' WHERE user_id = <id>;

上方的<id>应被修改为您先前在参数设置中查到的用户ID。

我如何才能重置密码?[edit | edit source]

您可以使用maintenance/changePassword.php维护脚本来重置一名用户的密码。

您必须在命令行下运行该脚本。换句话说,请登录到安装wiki的服务器,然后进入命令行提示符。进入安装目录,然后进入maintenance子目录。运行下列命令:

php changePassword.php --user=someuser --password=somepass

这里可见的“somepass”就是您将要设置的密码,而“someuser”就是您将修改其密码的用户名,该用户名应出现在数据库的“user”表中。

您同样可以使用直接修改数据库的老办法。假设变量$wgPasswordSalt已被设为true值(默认),您可以在MySQL中运行下列SQL查询:

 UPDATE USER SET user_password = MD5(CONCAT(user_id, '-', 
   MD5('somepass'))) WHERE user_name = 'someuser';

这里可见的“somepass”就是您将要设置的密码,而“someuser”就是您将修改其密码的用户名,该用户名应出现在数据库的“user”表中。

Note 注意:CONCAT字符串中的user_id是一项列名,不应被替换为'someuser'。

Note 注意:如果您得到了'dbname.user table does not exist'错误,请检查LocalSettings.php文件,并特别注意$wgDBprefix变量的值。如果该变量不为空,请尝试重复执行上述命令,并将SQL查询UPDATE子句中的user替换为$wgDBPrefix_user

如果您使用的是PostGreSQL,请使用下列查询替代:

  UPDATE mwuser SET user_password =
    md5(user_id || '-' || md5('somepass')) WHERE user_name='someuser';

您还可以尝试使用重设密码插件

我怎样在我的Wiki里创建跨wiki链接?[edit | edit source]

数据库专家需要的答案[edit | edit source]

如果您所感兴趣的外部链接链向维基百科,而您希望使用前缀“wp”来链向它(前缀“wikipedia”是链向Wikipedia的默认跨wiki前缀,参见Help:跨wiki链接获取其他默认前缀),运行下列SQL查询来在您的数据库中修改interwiki表

 INSERT INTO interwiki (iw_prefix, iw_url, iw_local, iw_trans) VALUES ('wp', 'http://en.wikipedia.org/wiki/$1', '0', '0');

$1代表外部wiki中的条目名称。

一般用户需要的答案[edit | edit source]

在图形化的SQL程序中(例如PhpMyAdmin),进入interwiki表。选好要插入的那一列,在iw_prefix项中,填入你想要的跨wiki前缀;在iw_url项中,填入外部wiki的基本URL并加上“$1”,$1的含义已在上方数据库专家答案中解释过。iw_localiw_trans则均为默认值零(0)。您将它们留为0即可。

更多相关的信息,参见Help:跨wiki链接

简单答案[edit | edit source]

安装Special:Interwiki插件。然后您就可以通过Special:Interwiki特殊页面来添加或移除跨wiki入口了。

我怎样才能让我的基本URL更短?(例如:是“/wiki/条目名”而不是“/w/index.php?title=条目名”)[edit | edit source]

参见Manual:短URL

MediaWiki.org上所有的内容都是自由下载和使用的吗?[edit | edit source]

是的,在自由软件意义下的自由。参见Project:Copyrights了解本站已有内容在许可协议方面的问题。

我如何管理用户权限?[edit | edit source]

参见Manual:用户权限Manual:用户权限管理获取常见的信息。参见Manual:访问控制获取限制访问的方法与措施。

我怎样才能禁止匿名用户编写任何页面?[edit | edit source]

  • 在LocalSettings.php底部加入$wgGroupPermissions['*']['edit'] = false;语句。

参见Manual:访问控制#限制匿名编辑获取进一步的信息。

我怎样才能禁止匿名用户阅读任何页面?[edit | edit source]

  • 在LocalSettings.php底部加入$wgGroupPermissions['*']['read'] = false;语句

参见Manual:$wgWhitelistRead。参见Manual:访问控制#限制对所有页面的查看获取进一步的信息。

我怎样才能限制帐户的创建?[edit | edit source]

  • 在LocalSettings.php底部加入$wgGroupPermissions['*']['createaccount'] = false;语句

参加Manual:访问控制#限制帐户创建获取进一步的信息。

升级[edit | edit source]

常用的升级过程说明都能在UPGRADE文件中找到。参见Manual:升级

升级有多难?[edit | edit source]

如果您只曾修改过LocalSettings.php文件,而且您是从1.5或更新的版本升级的,那么升级的过程将会非常简单。需要人工插手的工作总共只有几分钟。数据库模式修改的时间将根据您数据库的大小而定——如果是一个拥有百万页面的wiki,那么可能会花费几个小时,但如果只有几千个页面,那么通常几秒钟就完成了。

在同一个主要版本中的小升级,例如从1.13.0到1.13.1,不需要对数据库作出任何修改。您只需要升级文件就行了。

如果您是从1.4或更早的版本升级的话,那么升级过程可能会有一些复杂,因为新版本不再支持UTF-8以外的字符集,存放大量字符的数据库会面临潜在的大量修改。请阅读UPGRADE文件的相关段落获取有关信息。

如果您曾经动过我们的源文件,而且您不愿意让您的修改被覆盖的话,那么升级将变得有些困难。类似diffpatch这样的工具会很有用。还有一种潜在的问题在于您没有维护您使用的插件。请在升级MediaWiki的同时也升级您的插件。

我如何才能从旧版本升级?一步还是逐步?[edit | edit source]

一步就可完成,直接将您的旧版本升级为最新的稳定版。大量的报告以及自动测试指出,您一步就可以完成升级。

如果您不相信这个定论,请阅读此邮件列表的帖子

我应该备份吗?[edit | edit source]

简短的回答:应该。

冗长的回答:这取决于a)你是否重视你的数据,b)创建备份的困难程度以及c)您对MySQL维护与管理的自信程度。

升级失败可能导致您的数据库陷入同时存在两个版本的不一致状态。有可能发生在将某个重要的数据表移动到临时名称后,但在正确重建数据表前失败。也有可能是将某一列修改为错误的数据类型。因升级而造成的不可恢复的数据遗失非常罕见。通常说来,一名有经验的管理员可以恢复被损坏的数据。

恢复过程通常会十分复杂。如果你漏做了备份,却又跑到支持论坛上寻求帮助以修复因升级造成的损坏,支持论坛上的志愿者们往往就不会对你有什么好感。更好的做法是你应尽量恢复到先前的备份,然后向我们报告在升级过程中造成损坏的bug

我能保留我的LocalSettings.php吗?[edit | edit source]

可以,但你可能需要作出一些小的修改。LocalSettings.php的格式大致上是向下兼容的。会影响LocalSettings.php兼容性的修改都会在发行日志(RELEASENOTES)的“configuration changes”一节中找到。

在我升级时我的wiki都能保持在线吗?[edit | edit source]

可以。

如果你是在小版本间升级,你只需要升级源文件。

如果你是在大版本间升级,以下是建议流程:

1. 将新版的MediaWiki解包到一个新的目录下
2. 在新目录中将LocalSettings.php配置正确,并将所有所需的插件都安装好。
3. 在旧目录的LocalSettings.php中配置只读模式

$wgReadOnly = '正在升级到MediaWiki 1.21.2';

4. 在新目录中运行升级脚本。
5. 将旧目录切换为新目录。

界面修改[edit | edit source]

我应该怎样修改logo?[edit | edit source]

出现在每一页左上方的logo是在LocalSettings.php文件中配置$wgLogo变量实现的。

有两种方法来修改logo:

使用你的wiki上传一幅图像并使用它的地址。这样会使得图像的替代变得非常简单,因此如果您要使用这一办法,请保护该图像的页面。

然后在LocalSettings.php中增加$wgLogo一行,例如:

$wgLogo = 'http://yourwiki.org/wiki/images/6/62/photoname.jpg'; 

或者通过其他途径(如FTP)将图像上传到服务器上,然后在LocalSettings.php中增加$wgLogo一行,例如:

$wgLogo = "{$wgScriptPath}/photoname.jpg"; 

在上面的例子中,图像是与LocalSettings.php文件处于同一目录下的。

将这一行放在LocalSettings.php的末尾通常是较好的做法,特别是当你为$wgStylePath或$wgUploadPath指定参数后。

警告! 警告:请勿只覆盖MediaWiki安装后的默认logo(/skins/common/images/wiki.png);这样在你升级后该文件会被改回。

提示:logo图像的大小应为135 x 135像素。

我能定制左上角的logo吗?应该怎样做?[edit | edit source]

logo位于pBody部分外的portlet块中。可以通过p-logo id来识别出。背景图像是由wgLogo变量指定的,该变量定义于/includes/DefaultSettings.php中。它的地址相对于网页服务器的根目录,而非系统根目录。在/LocalSettings.php重定义该变量即可改变图像。如果设置有错,页面将不会出现图像;检查您的网页服务器错误日志,并作出相应的调整。同时,如果logo没有进行修剪,就应亦应确保p-logo的大小能足以盛放它。这需要在样式表中对p-logo样式进行设置(monobook下的Main.css),其默认设置见下:

#p-logo {
    z-index: 3;
    position:absolute; /*needed to use z-index */
    top: 0;
    left: 0;
    height: 155px;
    width: 12em;
    overflow: visible;
}

我如何定制左上角的logo链接,当我点击它时我想前往别的页面?[edit | edit source]

默认设置上,点击logo后会前往首页。如果您希望修改首页的名称,编辑MediaWiki:Mainpage即可。如果想要该链接链向任何URL,在Monobook皮肤下,编辑Monobook.php,找到<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>,将之替换为你所需的URL地址,并将<?php $this->msg('mainpage') ?>替换为你所要显示的链接说明。

链向根目录的例子:替换

         ?>href="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>" <?php
        ?>title="<?php $this->msg('mainpage') ?>"></a>

         ?>href="/" <?php
        ?>title="Root Page Name"></a>

[edit | edit source]

Note that a tag is on top of the logo so if you are trying to reduce the size of the logo's portlet you will also need to change the #p-logo a and #p-logo a:hover rules. The default setting for these is:

#p-logo a,
#p-logo a:hover {
   display: block;
   height: 200px;
   width: 12.2em;
   background-repeat: no-repeat;
   background-position: 35% 50% !important;
   text-decoration: none;
}

This simple customization will re-define the size of all of them at once...

#p-logo,
#p-logo a,
#p-logo a:hover {
   height: 75px;
}

There is one more rule controlling the amount of space between the logo and first portlet in the side column - the padding on the top of #column-one. By default this is:

#column-one { padding-top: 160px; }

If you want to remove the logo completely, comment out the wgLogo variable. Then set the column-one padding to a small value, such as 21:

#column-one { padding-top: 21px; }

You shouldn't edit the CSS file directly. You need go to <Your Wiki URL>?title=MediaWiki:Monobook.css. Hit edit and make your changes there. The content of MediaWiki:Monobook.css page always overrides the default main.css file's contents.

How do I change the icon in the browser's address line (favicon)?如何修改浏览器地址栏的显示图标?[edit | edit source]

  • Simply upload your favicon.ico to the root of your domain/subdomain, make sure file name is in lower case and its name is favicon.ico
  • Alternatively edit the $wgFavicon setting in LocalSettings.php and add $wgFavicon = "$wgScriptPath/path/to/your/favicon.ico";

See Manual:$wgFavicon for more details.

Tip: The favicon image should be either 16 x 16 pixels or 32 x 32 pixels.

Rewrite Rule[edit | edit source]

If you are using a rewrite rule in .htaccess to remove "index.php" from the URL, you will also need to add an exception for .ico files. Simply add the following rule to your .htaccess:

RewriteRule .*\.ico$ - [L]

This rule must appear before the index.php rule.

大小写[edit | edit source]

因为许多服务器(例如运行在类UNIX操作系统上的)只能查找小写的文件名,所以请确保上传图标文件的文件名是小写的。也就是说,原文件名为“Favicon.ico"的图标文件,在上传时应将文件名改为"favicon.ico"。

我怎么定制导航条?[edit | edit source]

使用Monobook皮肤的每一个页面左边是导航条,其内容由您的wiki上的MediaWiki:Sidebar 页面决定. 定制这些内容的相关信息,请参看Manual:Navigation bar.

我怎样在每个页面上放置文本消息(站点通知)?[edit | edit source]

MediaWiki:Sitenotice页面上放置文本。它将会在每篇文章页面的顶部显示。

How do I change which page is the main page?[edit | edit source]

By default, MediaWiki looks for a page with the title Main Page and serves this as the default page. This can be changed by altering the contents of MediaWiki:Mainpage to point to a different title. If this does not change the 'Main Page' link included on the sidebar at install time, edit MediaWiki:Sidebar.

How do I hide the main page title?[edit | edit source]

MediaWiki does not have a built-in option to hide the main page title (see bug 6129). Instead you must use JavaScript or CSS.

MediaWiki version before 1.9, solution to hide the main page title[edit | edit source]

Before MediaWiki 1.9, you have two options:

Apply the patch[edit | edit source]

You can manually apply the patch from r17119 to your copy of MediaWiki and use the solution for 1.9.

FIRST replace or add the lines in three files in the correct place as r17119 did:

  • skins/monobook/Skin.php, add:
$a['class'] = 'ns-'.$wgTitle->getNamespace().'
'.($wgContLang->isRTL() ? "rtl" : "ltr").
' page-'.Sanitizer::escapeId( $wgTitle->getPrefixedText() );
  • includes/SkinTemplate.php, add:
$tpl->set( 'pageclass', 'page-'.Sanitizer::escapeId( $wgTitle->getPrefixedText() ) );
  • includes/MonoBook.php replace:
class="<?php $this->text('nsclass') ?> <?php $this->text('dir') ?>">
with:
class="mediawiki <?php $this->text('nsclass') ?> <?php $this->text('dir') ?> <?php $this->text('pageclass') ?>">

SECOND follow the instructions in #1.9 and above.

JavaScript solution[edit | edit source]

The following JavaScript may or may not work for your wiki (replace "Main Page" with the name of your main page if it differs). Add the code to your wiki's MediaWiki:Common.js or MediaWiki:Monobook.js (Monobook.js for older wikis, Common.js for newer wikis):

var isMainPage = (document.title.substr(0, document.title.lastIndexOf(" - ")) == "Main Page");
var isDiff = (document.location.search &&
                 (document.location.search.indexOf("diff=") != -1 ||
                     document.location.search.indexOf("oldid=") != -1
                 )
             );
if (isMainPage && !isDiff) {
    document.write('<style type="text/css">/*<![CDATA[*/ h1.firstHeading { display: none !important; } /*]]>*/</style>');
}

Mediawiki version 1.9+, solution to hide the main page title[edit | edit source]

In 1.9 and above (or with the modified files above), you can use CSS to hide the main page title.

Add the following to the MediaWiki:Monobook.css (if you're using Monobook; otherwise add this to MediaWiki:Common.css to have it applied to all skins) on your wiki:

body.page-Main_Page h1.firstHeading { display:none; }

Alternatively, you can replace "Main_Page" with another name, but with spaces replaced by underscores _ .

Troubleshooting[edit | edit source]

If this doesn't work, look at the HTML source code to find the correct class to replace "page-Main_Page" with:

<body class="mediawiki ns-0 ltr page-Some_title">

If no such class exists, then you cannot use this feature. You may be using a custom or outdated skin.

Another option is to #REDIRECT from Main_Page to Our_Main_Page.

See also Wikipedia:Main Page alternatives.

我怎样隐藏页面上的目录标签[edit | edit source]

目录标签 (TOC) 会自动显示在含有四个或者以上标题的条目下,有几种方式可以隐藏它:

对于一个页面
将魔术字 __NOTOC__ 放到页面代码中.
对于所有页面
添加规则到 MediaWiki:Common.css:
.toc, #toc { display: none; }
However, this is not the best solution, because the table of contents will be hidden even in those pages in which we want it to be displayed, by using the magic words __FORCETOC__ or __TOC__. A simpler and more efficient alternative is to edit the file /includes/parser/Parser.php, altering in line 3427 the limit of 4 headings:
(($numMatches >= 4) || $this->mForceTocPosition);
to a higher value (e.g. 10). This way the table of contents will only be displayed in pages with 10 or more headings, OR in pages which contain one of the magic words __FORCETOC__ or __TOC__.
每个用户
1 Users can also opt to have the table of contents hidden. This is a user preference, set in Special:Preferences.

How do I change the interface text?[edit | edit source]

Interface text is altered using the MediaWiki namespace. For each deviation from the default in the site language there is a page MediaWiki:Englishmessagename, and for each deviation from the default in each other language a page MediaWiki:Englishmessagename/languagecode. (Since release 1.9 there are no pages for messages equal to the default.). On creation of a page the edit box autofills with the default. When creating a page to override the default it is useful to first save the default version, to allow diffs with it. See also Manual:System message.

How do I change the interface language?[edit | edit source]

To change the default interface language, alter the value of $wgLanguageCode in LocalSettings.php, e.g.

$wgLanguageCode = "fr";

我怎样避免匿名用户的修改?[edit | edit source]

The recommended method is by changing the value of the $wgGroupPermissions configuration option. Edit LocalSettings.php and add the line:

$wgGroupPermissions['*']['edit'] = false;

For more information on using this option, see the Preventing access page and Manual:User rights.

How do I remove the article/edit etc tabs for users who are not logged in?[edit | edit source]

Edit [[MediaWiki:Monobook.css]] on your wiki, and add this:

#ca-edit { display: none; }

See the page source for the various #ca-* ids used in the content tabs.

Note: this will only work for MonoBook (the default skin), and doesn't actually stop people editing.

How do I add/remove tabs throughout my wiki?[edit | edit source]

For example, to remove the talk tab and then add a tab that always goes to the main page you would save this code in extensions/AR-Tabs.php:

 <?php
 $wgHooks['SkinTemplateContentActions'][] = 'ReplaceTabs';
 function ReplaceTabs ($content_actions) {  
     unset( $content_actions['talk'] );    //only this to remove an action
     $maintitle = Title::newFromText(wfMsg('mainpage') );
      $main_action['main'] = array(
        'class' => false or 'selected',    //if the tab should be highlighted
        'text' => wfMsg('sitetitle'),     //what the tab says
        'href' => $maintitle->getFullURL(),   //where it links to
      );
      $content_actions = array_merge( $main_action, $content_actions);   //add a new action
      return true;
 }
 ?>

and then add

require_once("extensions/AR-Tabs.php");

to the bottom of LocalSettings.php

如何仅在一个页面中删除tab?[edit | edit source]

This solution works in MediaWiki version 1.9 and above. In MediaWiki version 1.8 or below, first apply the above patch.

For example, to remove the Discussion (talk) page tab from the Main Page, on the MediaWiki:Monobook.css page add:

.page-Main_Page #ca-talk { display: none !important; }

To modify MediaWiki:Monobook.css you must have administrative privileges.

How do I remove a tab on all pages[edit | edit source]

This solution works in MediaWiki version 1.9 and above. In MediaWiki version 1.8 or below, first apply the above patch.

For example, to remove the Discussion (talk) page tab on all wikipages, on the MediaWiki:Monobook.css page add:

#ca-talk { display:none!important; }

Other tabs to remove are #ca-history and #ca-viewsource. To modify MediaWiki:Monobook.css you must have administrative privileges.

How do I hide the section edit links for users who are not logged in?[edit | edit source]

  1. The recommended method is by changing the value of the $wgDefaultUserOptions configuration option.
    Edit LocalSettings.php and add the line:
    $wgDefaultUserOptions ['editsection'] = false;
    
  2. Alternatively you could manually edit each skin (e.g. MonoBook.php) and add this before </head>:
<?php if(!$this->data['loggedin']) { ?>
      <style>
        .editsection { display: none; }
      </style>
<?php } ?>
If you want to hide the links for all users including logged in users, instead edit monobook/main.css ('not recommended!) and add:
.editsection { display: none; }
Also see How can I prevent editing by anonymous users?

How do I remove the "Talk for this IP" link at the top right when $wgDisableAnonTalk is true?[edit | edit source]

Set $wgShowIPinHeader to false.

How do I remove the "Create an Account or Login" link at the top right of the screen?[edit | edit source]

In Monobook.php change this statement:

  foreach($this->data['personal_urls'] as $key => $item) {

to:

 foreach($this->data['personal_urls'] as $key => $item)  if($this->data['loggedin']==1) {

How do I change the footer?[edit | edit source]

To add or remove items from the footer on your MediaWiki page, you must edit the skin.

For example: if you go in to MonoBook.php (located by default in the skins folder) you will find the following code:

 $footerlinks = array(
   'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
   'privacy', 'about', 'disclaimer', 'tagline',
  );

In the above you can simply add and remove items from the footer that you wish to appear in your footer. Remember the changes may not appear immediately because of MediaWiki caches.

You can also customize the individual items by modifying certain pages or parameters:

See also: Footer, Manual:Skinning#Footer, Manual:Configuration settings#Copyright

Line breaks in footer

For line breaks in the footer, search for Content is available under in the MessagesEn.php and then put line breaks before and after so that it looks like '<br />Content is available under $1.<br />', It is valid XHTML 1.0 Transitional. NOTE: It would probably be better to just edit the system message (see Special pages) to add <br /> before and after the message.

How can I edit / remove the Powered by MediaWiki image in the footer?[edit | edit source]

You can hide the Powered by MediaWiki image by adding the following to your wiki's MediaWiki:Common.css:

#f-poweredbyico { display: none; }

If you want to remove it completely, you could alter /skins/MonoBook.php, which contains the following code that makes the Powered by MediaWiki image appear in the footer:

<?php
                if($this->data['poweredbyico']) { ?>
                                <div id="f-poweredbyico"><?php $this->html('poweredbyico') ?></div>

If you would like to remove this image completely, or edit the image, you must locate and edit poweredbyico. It is located in skins/common/images/ and the image is called poweredby_mediawiki_88x31.png.

If you're happy with the logo (or not) and simply want to change the destination link, the code is in getPoweredBy() function of includes\Skin.php. Just change the line $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>'; to whatever.

How can I change what the <title> of each page is? Where do I make changes?[edit | edit source]

Most of the text that you want to change, can be found in the namespace of MediaWiki.

In order to change titles, texts, announcements and the such, go to Special:Allmessages, where you will see the text associated with the pages you wish to change. You need to log in as an administrator (like the one you made when you installed) to edit the protected entries in the MediaWiki namespace.

If you want to change the title in your browser, you need to edit MediaWiki:Pagetitle. Go there and edit it just like you would any other page in your wiki.

In recent versions of MediaWiki, MediaWiki:Pagetitle is $1 - {{SITENAME}} by default. If {{SITENAME}} is producing the wrong text for you, you need to set $wgSitename in your LocalSettings.php.

If $wgSitename is correct in LocalSettings.php but {{SITENAME}} is still wrong, it may be that you're using a user-contributed language file which incorrectly sets $wgSitename to a transliteration of "Wikipedia". Edit the language file to correct this. For example, the Hebrew language file is at languages/LanguageHe.php in your wiki directory.

Don't forget to clear your browser cache after you fix it.

如何使外部连接在新的窗口中打开?[edit | edit source]

参见 在新的窗口打开外部连接.

如何禁止MediaWiki格式化网址,标签等?[edit | edit source]

在网址或标签两边放置 "<nowiki>" 标记. 比如:

svn co <nowiki>http://somwhere.in.the.net/myproject/</nowiki>

效果: svn co http://somewhere.in.the.net/myproject/

如何强制用户在保存修改前预览?[edit | edit source]

参见 Manual:Force previewExtension:ForcePreview.

如何在编辑页面增加更多的按钮?[edit | edit source]

For adding more toolbar buttons above the edit field, you can use JavaScript code to register them in mwCustomEditButtons in your MediaWiki:Common.js. For example, a button for large text:

var button = {
        "imageFile": "images/5/56/Button_big.png",  //image to be shown on the button (may be a full URL too), 22x22 pixels
        "speedTip": "big text",    //text shown in a tooltip when hovering the mouse over the button
        "tagOpen": "<big>",        //the text to use to mark the beginning of the block
        "tagClose": "</big>",      //the text to use to mark the end of the block (if any)
        "sampleText": "big text"   //the sample text to place inside the block
};
mwCustomEditButtons.push(button);

How can I get more special characters or tags clickable on the edit page?[edit | edit source]

For adding more selectable special characters, etc, below the edit field, See Extension:CharInsert

基本用法[edit | edit source]

我应该怎样编辑页面[edit | edit source]

要编辑一个已经存在的页面,只需要单击这个页面上的编辑链接即可。对于缺省的 Wiki 布局(MonoBook),这个链接位于页面顶部的标签页。点击以后,用户会看到一个表单,待编辑的wiki页面内容会填充到表单输入区域中,用户编辑完毕后,可以点击表单下方的修改按钮以提交修改。

相关信息请参见: MetaWiki:Help:Editing

如何创建新页面[edit | edit source]

有几种方法创建新的wiki页面:

  • 在一个已经存在的页面插入一个链接,这时,这个链接对应的页面还不存在,因此显示红色,我们点击这个红色的页面就可以创建新的页面了。
  • 在浏览器地址栏上输入新的页面地址,例如:http://www.example.com/index.php?title=New_page,然后点击编辑链接。

在某些wiki系统中,搜索页面时如果没有找到任何结果,那么显示搜索结果的页面也会包含一个用于创建新页面的链接。

相关信息请参见帮助:开始新页面

如何删除一个旧版本页面?[edit | edit source]

旧版本页面被保存在数据库内,并且可通过页面历史被访问到。这对于检查页面的变化和纠正(或撤销)一个不好的页面是很有用的。但在某些情况下,出于合理的理由或为了减小数据库的尺寸,管理员有可能想要删除掉这些旧版本信息。

  • 管理员可以用删除页面来删除一个旧的页面版本,然后选择性地恢复要保留的版本。
  • The Oversight extension (also known as HideRevision) can be used to move harmful revisions out of page histories
  • The maintenance/deleteOldRevisions.php maintenance script can mass-delete all old revisions of pages and their associated text records.
  • See also: Manual:Removing embarrassment.

Are there any editing tutorials available?[edit | edit source]

There are several editing tutorials available, mostly on Wikimedia sister projects, such as Wikipedia. There are also markup references, etc. available on Meta.

How do I view the printable form of a page?[edit | edit source]

MediaWiki includes stylesheets which automatically style a page appropriately when it is printed; using the print or print preview function within your browser ought to render the page in a printable form.

You can also view this printable form using the printable version link in the toolbox.

Wiki Importing[edit | edit source]

Importing from MediaWiki XML dumps[edit | edit source]

See Manual:Importing XML dumps

Importing from other types of wiki software[edit | edit source]

Note: The following is directly copied from old meta FAQ. It might need to be corrected.

There is some documentation about importing in the UPGRADE file distributed with MediaWiki.

To follow on from those, this is how at least one individual imported pages from usemod to MediaWiki:

Because MediaWiki does not automatically link to CamelCase style links, you will need to add brackets [[ ]] to all your links. You can do this with the following:

First, obtain ImportStage1.txt (or whatever you want to call it) from the importUseModWiki.php script ( use > to pipe the output to a file )

Second, do

sed '/Importing/!s/\ [A-Z]\w*[a-z]\w*[A-Z]\w*[a-zA-Z]/\ \[\[&\]\] /g'
    ImportStage1.txt > ImportStage2.txt

This should create proper links in place of your CamelCase links.

This doesn't work so well for SubPage links - someone care to fix?

Then,

sed 's/upload\:\w*\.\w*/http\:\/\/aberwiki\.org\/uploads\/& /g'
    ImportStage2.txt > ImportStage3.txt

This fixes your upload links. Change the replace text so it fills in your url such as http://www.yourwiki.org/uploads/filename

You are now ready to import ImportStage3.txt into your database with a command such as

mysql -u<mysqluser> -p<yourpass> <db name> < ImportStage3.txt

Note: If your importUseModWiki.php outputs an XML file instead of SQL statements, this probably means you have a rather new version of MediaWiki. In such a case, you case import the XML file -- see Importing a Wikipedia database dump into MediaWiki, towards the bottom of the page ('Import XML'). Don't forget to rebuild all the tables -- that page also explains how to do that.

Importing from other types of files[edit | edit source]

Here are some info on importing from other types of files:

MediaWiki auto importing script[edit | edit source]

Taken from wiki_import - MediaWiki auto import script:

Description[edit | edit source]

The script is designed to import a whole folder of files into MediaWiki, with the folder directory tree mapped as wiki category hierarchy.

Features[edit | edit source]

  • economic, build wiki site from existing knowledge base collection without "double-entry"
  • persistent, map folder directory tree as wiki category hierarchy
  • sophisticated, import/handle all well-known file types automatically
  • complete, cover every applicable scenario, even the case when you need to control access to individual wiki pages
  • versatile, highly customizable

Quick Help[edit | edit source]

wiki_import.sh $ $Revision: 1.1 $

mediawiki automatic file import script

Usage: wiki_import.sh [OPTIONS]...

The script is designed to import a whole folder of files into mediawiki, with the folder directory tree mapped as wiki category hierarchy.

The specification of the file-to-import is passed from standard input.

Options:

 -s, --sect=n     the root category section of the wiki
                    of the imported article (mandatory)
 -1, --header     include standard header (category hierarchy path & notice)
 -l, --link       link to actual file on the web site
 -f, --footer     include standard footer (article category)
 -R, --res[=p]    add restricted tag in the footer
                    as '{{<Res Param|Root Category> Restricted}}' 
                    (default=`$_opt_sect')

Configuration Options:

 -p, --php=fn     mediawiki import php script specification
 -r, --root=n     the root category name for the whole wiki site
 -m, --max=n      max_allowed_packet for mysqld to import
 -u, --user=n     wiki user used for the import
 -a, --arch=p     the root url that linked-to archive files based on

Examples:

 echo ./path/to/file.ext | wiki_import.sh -1 -l -f -s 'Customer Support' -R 

For the rest of details, check out wiki_import.

更多关于自定义的内容[edit | edit source]

我如何才能允许用户使用HTML标记?[edit | edit source]

参见手册:$wgRawHtml手册:$wgGroupPermissions以及手册:阻止访问

警告! 警告:该功能极易遭到破坏者滥用

参见插件:SecureHTML以及插件:HTMLets来安全地使用HTML标记。

我如何才能允许用户上传HTML文件?[edit | edit source]

参见 手册:允行上传HTML文件

警告! 警告:该功能极易遭到破坏者滥用

为什么……?[edit | edit source]

…is the Help namespace empty?[edit | edit source]

We don't currently have a clean, internationalised set of help pages under a free license. A few developers are hoping to make this possible; however, the Help namespace currently ships in a blank state. You are free to add your own help pages, copy the Public Domain help pages or copy certain of the items from Meta, e.g. the user guide or MediaWiki Handbook, these two collections being free to use under the GNU Free Documentation License.

…are some of my images not showing up after an upgrade?[edit | edit source]

Several users have reported that, following an upgrade or a moving of their wiki, several images fail to be shown inline. The files exist, and the image description pages show a MIME type of unknown / unknown and, in some cases, a warning about potentially dangerous files.

To fix this, run the maintenance/rebuildImages.php script from the command line. This will set MIME information for each file in the database.

…are all PNG files not being turned into thumbnails?[edit | edit source]

After upgrading to a more recent version of PHP, it is possible a different MimeMagic.php function is being used to detect file MIME types, particularly the built-in PHP function mime_content_type, which fails to detect PNG files. Search the web for mime_content_type png for


…is a search for a short keyword giving no hits?[edit | edit source]

By default, MediaWiki uses MyISAM's fulltext matching functionality to allow searching page content. The default settings for this mean that words of less than four characters won't be indexed, so results won't be returned for those queries.

To alter this behaviour, MySQL needs to be reconfigured to index shorter terms, and MediaWiki's search index table needs to be repaired, to rebuild the indices.

…can't I download MediaWiki 1.14?[edit | edit source]

MediaWiki 1.14 is in a development state at present, and has not been packaged into a general release. The code can be downloaded from Subversion if desired.

…doesn't this work? It works on Wikipedia![edit | edit source]

Wikipedia and other Wikimedia web sites use the current version of the code in development; at present, this is MediaWiki 1.14alpha. Coupled with the use of several extensions, this means that functionality between these wikis and your particular setup may differ.

…do I get a 403 Forbidden error after setting permissions on my Fedora system?[edit | edit source]

Fedora Core enables SELinux by default. Instructions for setting SELinux permissions for MediaWiki are available.

…do I get logged out constantly?[edit | edit source]

This is probably related to cookies or session data, for example a problem with PHP's session.save_path [1] setting. See Log in problems.

…is it a good idea to keep user accounts?[edit | edit source]

At many times you just want to remove a user account out of the wiki either because it belonged to a spammer account or you just feel like it. The appropriate choice is to block the account or rename it if needed. Here is why:

Do I just remove his row from the User table?

Rob Church posted the following regarding this issue on the mediawiki-l mailing list:

"If the user has made edits, then removing rows from the user table cause theoretical loss of referential integrity. Now, to be honest with you, I can't think of any conditions where this would cause an actual problem; "undefined behaviour" is the phrase we use.

What I'd suggest doing, to be on the safe side, is running a couple of quick updates against the database:

UPDATE revision SET rev_user = 0 WHERE rev_user = <current_user_id>
UPDATE archive SET ar_user = 0 WHERE ar_user = <current_user_id>

What this will do is cause MediaWiki to treat the revisions as having been made anonymously when generating things like page histories, which should eliminate any problems caused by these routines attempting to check user details from other tables.

If the user has caused log entries, i.e. rows in the logging table, or uploaded images, then the situation becomes trickier, as you'll have to start mopping up all the rows everywhere and it could become a bit of a mess, so if the user's done anything other than edit, I would strongly recommend just blocking them indefinitely.

If the username is offensive or undesirable, then you could consider renaming it using the RenameUser extension."

反垃圾邮件[edit | edit source]

查看Manual:Combating spam获取关于反垃圾邮件的一般信息。

从哪可以获取垃圾邮件黑名单以及如何安装?[edit | edit source]

跟其他官方支持的扩展一样,spam blacklist扩展也可以从Subversion里找到。请查看READMEextension page这两个文档以获取安装及设置的指南。

如何使用$wgSpamRegex来屏蔽多个字符串?[edit | edit source]

尽管$wgSpamRegex在过滤页面内容方面非常强大,在正则表达式里添加多个项目可能把事情弄得很糟糕。 请考虑使用下面的方法:

$wgSpamRegexLines[] = 'display\s*:\s*none';
$wgSpamRegexLines[] = 'overflow\s*:\s*auto';
[...]
$wgSpamRegex = '/(' . implode( '|', $wgSpamRegexLines ) . ')/i';

这段代码范例很方便的在正则表达式里添加额外的字符串而无须每次都费时费力再做调整。这段代码也展示其他两个很流行的屏蔽一些最常见的垃圾信息攻击的过滤器。

参考: Extension:SpamRegex

再来呢?[edit | edit source]

我发现了一个bug或者有功能要求,应该在哪提出呢?[edit | edit source]

Bug及功能要求应该在MediaZilla提交,这是经我们整合的Bugzilla。为避免重复提交,请在提交前检索数据库。

我遇到了很诡异的错误。怎么办?[edit | edit source]

我的问题在这里找不到答案。下一步该怎么办?[edit | edit source]

如果你已经仔细研究了上面的常见问题并且还是找不到答案的话,请尝试以下方法:

还是不行。现在该去哪寻求帮助?[edit | edit source]

推荐阅读[edit | edit source]

语言: English  • català • dansk • Deutsch • español • français • ગુજરાતી • עברית • Bahasa Indonesia • italiano • 日本語 • 한국어 • മലയാളം • occitan • polski • português • português do Brasil • русский • Türkçe • 中文 • 中文(简体)‎