Manual:Code/zh

From MediaWiki.org
Jump to navigation Jump to search
其他语言: English  • Deutsch • français • Bahasa Indonesia • 日本語 • português do Brasil • русский • 中文

本页面描述了MediaWiki源代码中的关键文件与目录。有关更多详细信息,请参见由MediaWiki源代码使用doxygen自动生成文件综合参考资料。

访问节点[edit]

参见Special:Version#Entry point URLs

注意 注意:您可以通过运行该段代码生成此列表:git grep -l /includes/WebStart.php[AP 1][AP 2]

这些是使用wiki时,浏览器可以遇到的文件。所有这些文件都位于wiki根目录,每个文件都搭配.php5包装,对于网络服务器而言,它需要.php5扩展来通过PHP5引擎执行脚本。

文件 描述 Wiki文档
index.php MediaWiki软件的主要访问节点。它处理绝大多数的客户端请求。 Manual:index.php/zhTemplate:Enlink/list1
api.php 用于MediaWiki API的外部访问节点。参见API:Main page/zh Manual:api.php/zhTemplate:Enlink/list1
load.php 用于前端接入以便加载ResourceLoader模块的脚本。 Manual:load.php/zhTemplate:Enlink/list1
img_auth.php 只为已登陆用户提供图片服务的脚本。要配置wiki来启用该脚本,参见Manual:Image Authorisation Manual:img_auth.php/zhTemplate:Enlink/list1
opensearch_desc.php 返回描述MediaWiki搜索引擎网络界面的OpenSearch描述文档 Manual:opensearch_desc.php/zhTemplate:Enlink/list1
profileinfo.php 允许用户查看存储在数据库中的性能分析信息。参见Manual:How to debug#Profiling Manual:profileinfo.php/zhTemplate:Enlink/list1
redirect.php 通过请求的wpDropdown参数,重定向到条目的脚本。需要Nostalgia皮肤在1.22版本中被移除 Manual:redirect.php/zhTemplate:Enlink/list1
thumb.php 用于调整图片的脚本 Manual:thumb.php/zhTemplate:Enlink/list1
thumb_handler.php 用作404处理器,来创建并流出尚不存在图片缩略图的PHP脚本。 Manual:thumb_handler.php/zhTemplate:Enlink/list1
trackback.php 添加Trackback到数据库。在MediaWiki 1.19版本中被移除r104051)。 Manual:trackback.php/zhTemplate:Enlink/list1
  1. 除了thumb_handler.php,它是对thumb.php的简易包装,并因此不会重复包含WebStart.php
  2. 该命令也会返回mw-config/index.php,但与其他文件不同的是,它的目的不是在普通wiki操作期间重复使用;换句话说,它不是影响wiki资源的“访问”节点,但却是启动新安装wiki配置进程的一次性脚本。

/cache/[edit]

用于文件缓存的默认目录,如果启用(通过设置$wgUseFileCache = true;——默认值为false。)。该位置可使用$wgFileCacheDirectory来自定义。

/docs/[edit]

包含各种文本文件,它们应当帮助您了解MediaWiki代码中最重要的部分。

/extensions/[edit]

Mediawiki扩展与核心代码分别放置。安装扩展需要复制相关文件至该目录,并按照扩展自己的安装指导启用它(通常需编辑LocalSettings.php文件)。在当前版本中,有一组扩展与全新MediaWiki安装文件一起分布。

/includes/[edit]

该目录存储MediaWiki需要的常见包含文件。

文件 描述 Wiki文档
includes/Article.php 包含Article类,它提供查看、修改并管理条目的方法。这会维护Wiki页面功能以供向后兼容。 Manual:Article.php/zhTemplate:Enlink/list1
includes/AutoLoader.php 它为整个MediaWiki框架定义自动加载处理器。 Manual:AutoLoader.php/zhTemplate:Enlink/list1
includes/Defines.php 定义多个常量,例如用于名字空间的常量,它被其他文件和类所使用。 Manual:Defines.php/zhTemplate:Enlink/list1
includes/EditPage.php 提供许多有关编辑用户界面的代码 Manual:EditPage.php/zhTemplate:Enlink/list1
includes/GlobalFunctions.php 包含全域使用的功能,例如wfMsgExt。 Manual:GlobalFunctions.php/zhTemplate:Enlink/list1
includes/Linker.php 包含创建内部、外部或图片链接的方法,并执行页面存在检测。 Manual:Linker.php/zh /en
includes/Message.php 提供用于抓取界面消息;提供消息至各种格式的方法。参见Manual:Messages API Manual:Message.php/zh /en
includes/OutputPage.php 处理HTML与wiki文本解析。也将生成<head>元素或其中的一部分。 Manual:OutputPage.php/zh /en
includes/Pager.php 包含用于分页MySQL查询结果的IndexPager类。 Manual:Pager.php/zh /en
includes/Parser.php 包含大多数转换wiki文本至HTML的代码(虽然有几个片段位于Manual:Skin.php)。 Manual:Parser.php/zhTemplate:Enlink/list1
includes/Setup.php 收录常用文件,并初始化全域对象变量,这样MediaWiki可以正常工作。 Manual:Setup.php/zhTemplate:Enlink/list1
includes/Skin.php 封装用于wiki的“外观和感觉”。 Manual:Skin.php/zhTemplate:Enlink/list1
includes/SpecialPage.php 包含SpecialPage类,这是用于所有特殊页面类的父类。它也制作可用的多个静态函数,用于处理特殊页面列表以及多种其他特殊页面类,例如RedirectSpecialPageIncludableSpecialPage。参见Manual:Special pages/zh Manual:SpecialPage.php/zhTemplate:Enlink/list1
includes/SiteStats.php 包含SiteStats类用于网站统计及相关事宜。 Manual:SiteStats.php/zh /en
includes/TemplateParser.php 用于利用HTML模板的函数(不要与Wiki文本模板混淆) Manual:TemplateParser.php/zh /en
includes/Title.php 代表条目的标题,并在多种形式(例如纯文本、URL、数据库关键字等)中进行所有翻译工作。为方便起见,并基于历史原因,它也代表不涉及文本的条目功能,例如访问权限。 Manual:Title.php/zhTemplate:Enlink/list1
includes/User.php 封装用户查看/使用网站的状态。可以查询用户设置、用户名等事物。处理获取并保存数据库用户表的详情,并处理会话与Cookie。 Manual:User.php/zhTemplate:Enlink/list1
includes/UserMailer.php 用于发送邮件的静态函数集合。 Manual:UserMailer.php/zh /en
includes/WebRequest.php 该文件包含WebRequest类的定义。 Manual:WebRequest.php/zhTemplate:Enlink/list1
includes/WebStart.php 它为网络请求进行初始设置:安全检查、加载LocalSettings.phpSetup.php Manual:WebStart.php/zhTemplate:Enlink/list1
includes/MediaWiki.php 该文件由MediaWiki的定义构成。 Manual:MediaWiki.php/zh /en
includes/PathRouter.php 用于将优良url变成MediaWiki可以使用的查询属性的类。 Manual:PathRouter.php/zh /en
includes/WikiPage.php 包含WikiPage类,它代表wiki中的页面。 Manual:WikiPage.php/zhTemplate:Enlink/list1

/includes/actions/[edit]

此目录包含操作类,它们处理可在页面上执行的不同操作(例如查看、删除、编辑等)。所有这些类都是ActionFormlessActionFormAction类的延伸。其中有一些都是小操作,这些操作调用ArticleEditPage类中的方法来进行实际工作。

文件 描述 Wiki文档
includes/actions/CreditsAction.php 处理条目作者的格式化。参见Manual:$wgMaxCredits/zh Manual:CreditsAction.php/zhTemplate:Enlink/list1
includes/actions/DeleteAction.php 处理页面删除。 Manual:DeleteAction.php/zhTemplate:Enlink/list1
includes/actions/EditAction.php 包含类EditActionSubmitAction,可处理编辑和提交操作。 Manual:EditAction.php/zh /en
includes/actions/HistoryAction.php 处理打印某一条目的历史页面。 Manual:HistoryAction.php/zh /en
includes/actions/InfoAction.php 显示有关页面的信息,例如编辑总数和单一编辑者的数量。 Manual:InfoAction.php/zh /en
includes/actions/MarkpatrolledAction.php 处理将修订版本标记为已巡查 Manual:MarkpatrolledAction.php/zh /en
includes/actions/ProtectAction.php 处理保护页面。 Manual:ProtectAction.php/zhTemplate:Enlink/list1
includes/actions/PurgeAction.php 处理刷新页面缓存。 Manual:PurgeAction.php/zhTemplate:Enlink/list1
includes/actions/RawAction.php 处理"action=raw"操作。 Manual:RawAction.php/zh /en
includes/actions/RenderAction.php 处理渲染操作,它显示页面的HTML渲染;与查看操作类似,但只显示未样式化条目文本,没有额外的工具框、搜索框、样式表等。 Manual:RenderAction.php/zh /en
includes/actions/RevertAction.php 包含类RevertFileAction,可处理回退文件。 Manual:RevertAction.php/zh /en
includes/actions/RevisiondeleteAction.php 通过传递请求至Special:RevisionDelete,处理修订版本删除操作。 Manual:RevisiondeleteAction.php/zh /en
includes/actions/RollbackAction.php 处理回退页面。 Manual:RollbackAction.php/zh /en
includes/actions/ViewAction.php 处理查看页面,通过调用Article::view() Manual:ViewAction.php/zh /en
includes/actions/WatchAction.php 包含类WatchActionUnwatchAction,可处理监视和取消监视页面。 Manual:WatchAction.php/zh /en

/includes/api/[edit]

此目录包含用于MediaWiki API的代码。参见API:Main page/zh。最常见的文件是:

文件 描述 Wiki文档
includes/api/ApiBase.php 所有API类的基础类。有很多常见用于所有API操作的代码。继承ContextSource Manual:ApiBase.php/zhTemplate:Enlink/list1
includes/api/ApiFormatBase.php 所有格式类的基础类。继承ApiBase。 Manual:ApiFormatBase.php/zhTemplate:Enlink/list1
includes/api/ApiQueryBase.php 用于所有查询API类的基础类。继承ApiBase。 Manual:ApiQueryBase.php/zhTemplate:Enlink/list1

/includes/cache/[edit]

此目录包含文件,这些文件写有与MediaWiki的缓存机制相关的代码。

文件 描述 Wiki文档
cache/FileCacheBase.php FileCacheBase类是用于提供基于缓存机制文件类的基础类。参见Manual:File cache/zh Manual:FileCacheBase.php/zhTemplate:Enlink/list1
cache/GenderCache.php 当需要时,缓存用户性别来使用正确的名字空间别名。 Manual:GenderCache.php/zh /en
cache/HTMLCacheUpdate.php Invalidates the HTML cache of all the pages linking to a given title. Manual:HTMLCacheUpdate.php/zh /en
HTMLFileCache.php File based caching of HTML pages. Manual:HTMLFileCache.php/zh /en
cache/LinkBatch.php The LinkBatch class represents a list of titles. Manual:LinkBatch.php/zh /en
cache/LinkCache.php Caching for article titles (prefixed DB keys) and ids linked from one source. See also LINKCACHE.TXT. Manual:LinkCache.php/zhTemplate:Enlink/list1
cache/MemcachedSessions.php This file gets included if $wgSessionsInMemcache is set in the config. It redirects session handling functions to store their data in memcached instead of the local filesystem. Manual:MemcachedSessions.php/zh /en
cache/MessageCache.php Performs various MediaWiki namespace-related functions. Manual:MessageCache.php/zhTemplate:Enlink/list1
cache/ObjectFileCache.php File based caching of objects. Manual:ObjectFileCache.php/zh /en
cache/ResourceFileCache.php File based caching of JavaScript and CSS resources. Manual:ResourceFileCache.php/zh /en
cache/SquidUpdate.php Handles purging appropriate Squid URLs given a title (or titles). Manual:SquidUpdate.php/zh /en

/includes/context/[edit]

This directory contains a few classes related to (request) contexts. As of MediaWiki 1.18 the context of a request is encapsulated inside a RequestContext instance which implements IContextSource. A context is a way of grouping the parts of a request together. This reduces the need for globals. See Manual:RequestContext.php for more information.

File Description Wiki docs
includes/context/ContextSource.php The ContextSource class implements the IContextSource interface. It is a helper class: by making a class extend ContextSource the class will be provided with the various getOutput, getSkin, getLanguage, etc. helpers directly and will implement IContextSource. Manual:ContextSource.php/zh /en
includes/context/DerivativeContext.php A DerivativeContext is an IContextSource implementation which will inherit context from another source but allows individual pieces of context to be changed locally. Manual:DerivativeContext.php/zh /en
includes/context/IContextSource.php This file contains the IContextSource interface. This interface should be implemented by objects which provide a context on a request. Manual:IContextSource.php/zh /en
includes/context/RequestContext.php A RequestContext object groups all the pieces relevant to the context of a request into one instance. Manual:RequestContext.php/zh /en

/includes/db/[edit]

This directory contains the code for database support. Database.php provides MediaWiki's database abstraction layer.

/includes/diff/[edit]

This directory contains the standard MediaWiki difference engine. A difference engine computes the difference between two texts. Whether this difference engine is used or some external diff tool, depends on the $wgExternalDiffEngine setting.

File Description Wiki docs
includes/diff/DairikiDiff.php The DairikiDiff engine. Currently the standard diff engine. The file defines several related classes. Manual:DairikiDiff.php/zh /en
includes/diff/DifferenceEngine.php The DifferenceEngine class the interface between MediaWiki and whichever difference engine is used. Which difference engine is used depends on the $wgExternalDiffEngine config setting. Manual:DifferenceEngine.php/zh /en
includes/diff/WikiDiff3.php Another diff engine. Currently not in use. Manual:WikiDiff3.php/zh /en

/includes/jobqueue/jobs/[edit]

Files related to the job queue. Each job class for a specific type of job derives from the Job class and has to implement a run() method which does the actual job.

File Description Wiki docs
includes/job/DoubleRedirectJob.php Job to fix double redirects after moving a page Manual:DoubleRedirectJob.php/zh /en
includes/job/EnotifNotifyJob.php Job for email notification. Manual:EnotifNotifyJob.php/zh /en
includes/job/JobQueue.php Contains the Job class. This is the abstract class to describe a background job. The class also contains static functions for handling jobs (insert jobs in the queue and pop jobs from the queue). Manual:JobQueue.php/zh /en
includes/job/RefreshLinksJob.php Contains the RefreshLinksJob and RefreshLinksJob2 classes for jobs to update links for a given title. They use class LinksUpdate (defined in /includes/LinksUpdate.php) to update several db tables. Manual:RefreshLinksJob.php/zh /en
includes/job/UploadFromUrlJob.php Job for asynchronous upload-by-url. Its an interface to the UploadFromUrl class in /includes/upload/UploadFromUrl.php. Manual:UploadFromUrlJob.php/zh /en

/includes/logging/[edit]

Some files related to logging the events which happen on a Wiki. This directory was introduced in MW 1.19. Some of the files were already present in olders versions, in the includes/ directory.

File Description Wiki docs
includes/logging/LogEntry.php Contains the LogEntry interface and some classes implementing this interface to encapsulate log entries. Introduced in MW 1.19. Manual:LogEntry.php/zh /en
includes/logging/LogEventsList.php A class to list log entries. Manual:LogEventsList.php/zhTemplate:Enlink/list1
includes/logging/LogFormatter.php Contains several classes for formatting log entries. Introduced in MW 1.19. Manual:LogFormatter.php/zh /en
includes/logging/LogPage.php Class to manage a log: add entries to the log and extract information from the log. Manual:LogPage.php/zh /en
includes/logging/LogPager.php Class to list log entries. Implements the ReverseChronologicalPager class. Manual:LogPager.php/zh /en
includes/logging/PatrolLog.php Class containing static functions for working with logs of patrol events. Manual:PatrolLog.php/zhTemplate:Enlink/list1

/includes/media/[edit]

This directory contains files for handling several media formats, mostly images.

/includes/normal/[edit]

This directory contains some Unicode normalization routines. See includes/normal/README for more information.

/includes/objectcache/[edit]

Files related to MediaWiki's caching mechanisms. The files in this directory provide the possibility to store objects in PHP accelerators, in memcached, in a database or in DBA files.

File Description Wiki docs
includes/objectcache/APCBagOStuff.php Implementation of BagOStuff for APC's shared memory functions. Manual:APCBagOStuff.php/zh /en
includes/objectcache/BagOStuff.php Abstract class to be derived by classes which cache objects in PHP accelerators, SQL database or DBA files. It specifies the methods a cache class must provide, like get(), set(), delete(), etc. Manual:BagOStuff.php/zh /en
includes/objectcache/DBABagOStuff.php Implementation of BagOStuff which uses PHP's DBA extension as a backend. Manual:DBABagOStuff.php/zh /en
includes/objectcache/EhcacheBagOStuff.php Implementation of BagOStuff using the Ehcache RESTful web service. Manual:EhcacheBagOStuff.php/zh /en
includes/objectcache/EmptyBagOStuff.php Emulates an empty BagOStuff. Manual:EmptyBagOStuff.php/zh /en
includes/objectcache/MemcachedClient.php Contains the MWMemcached class, a PHP memcache client. Manual:MemcachedClient.php/zh /en
includes/objectcache/MemcachedPhpBagOStuff.php Implementation of BagOStuff using memcached. It uses the MWMemcached class as a pure PHP memcached client. Manual:MemcachedPhpBagOStuff.php/zh /en
includes/objectcache/MultiWriteBagOStuff.php Implementation of BagOStuff that replicates all writes to multiple child caches. Manual:MultiWriteBagOStuff.php/zh /en
includes/objectcache/ObjectCache.php The ObjectCache class contains some static helper functions for caching objects. Manual:ObjectCache.php/zh /en
includes/objectcache/SqlBagOStuff.php Implementation of BagOStuff using a database. Manual:SqlBagOStuff.php/zh /en
includes/objectcache/inCacheBagOStuff.php Implementation of BagOStuff using WinCache. Manual:inCacheBagOStuff.php/zh /en
includes/objectcache/CacheBagOStuff.php Implementation of BagOStuff using XCache. Manual:CacheBagOStuff.php/zh /en

/includes/parser/[edit]

The MediaWiki parser, which transforms wikitext to HTML, can be found here together with related files. The most interesting files in this directory:

File Description Wiki docs
includes/parser/CoreParserFunctions.php A collection of functions which implement the core parser functions. Manual:CoreParserFunctions.php/zhTemplate:Enlink/list1
includes/parser/CoreTagHooks.php Tag hooks provided by MediaWiki core, e.g. <nowiki>, <gallery>, <pre>, .. Manual:CoreTagHooks.php/zh /en
includes/parser/LinkHolderArray.php A LinkHolderArray holds a set of replacement pairs for wiki links. Manual:LinkHolderArray.php/zh /en
includes/parser/Parser.php This file contains the parser. A few regular expressions are included. Manual:Parser.php/zhTemplate:Enlink/list1
includes/parser/ParserCache.php This class handles caching the output from the parser. Manual:ParserCache.php/zh /en
includes/parser/ParserOptions.php The ParserOptions class holds a collection of options for the parser. Manual:ParserOptions.php/zh /en
includes/parser/ParserOutput.php Contains the ParserOutput class, which encapsulates the output of the parser. Manual:ParserOutput.php/zh /en
includes/parser/Preprocessor.php Contains the Preprocessor interface for preprocessors. Also contains the PPFrame and PPNode interfaces. Manual:Preprocessor.php/zh /en
includes/parser/Preprocessor_DOM.php A preprocessor using PHP's DOM extension. This preprocessor is used if the PHP DOM extension is available. Manual:Preprocessor_DOM.php/zh /en
includes/parser/Preprocessor_Hash.php A preprocessor using PHP arrays. This preprocessor is used if the PHP DOM isn't available or when the old XMLDOM extension is present. Manual:Preprocessor_Hash.php/zh /en
includes/parser/Preprocessor_HipHop.php A preprocessor optimised for HipHop, using HipHop-specific syntax. Manual:Preprocessor_HipHop.php/zh /en

/includes/resourceloader/[edit]

Files related to ResourceLoader, a JavaScript/CSS delivery optimizing system for MediaWiki.

/includes/search/[edit]

This directory contains the code to implement the possibility of searching a wiki using one the possible backends.

File Description Wiki docs
includes/search/SearchEngine.php Contains several classes related to searching a wiki. The SearchEngine class is the parent class for specific search implementations. Manual:SearchEngine.php/zh /en
includes/search/SearchIBM_DB2.php Implements SearchEngine using IBM DB2. Manual:SearchIBM_DB2.php/zh /en
includes/search/SearchMssql.php Implements SearchEngine using Msssql. Manual:SearchMssql.php/zh /en
includes/search/SearchMySQL.php Implements SearchEngine using a MySQL search engine. Manual:SearchMySQL.php/zh /en
includes/search/SearchOracle.php Implements SearchEngine using Oracle (ConText). Manual:SearchOracle.php/zh /en
includes/search/SearchSqlite.php Implements SearchEngine using SQLite. Manual:SearchSqlite.php/zh /en

/includes/specials/[edit]

This directory contains the code and classes for the standard special pages. All special page classes derive from class SpecialPage (defined in [1]]). Special pages which come with extension are located in their respective extensions directories. See also Manual:Special pages.

/includes/upload/[edit]

Files providing the backend of MediaWiki's file upload feature.

File Description Wiki docs
includes/upload/UploadBase.php UploadBase and subclasses are the backend of MediaWiki's file uploads. Manual:UploadBase.php/zh /en
includes/upload/UploadFromChunks.php Subclass of UploadBase implementing uploading from chunks. Manual:UploadFromChunks.php/zh /en
includes/upload/UploadFromFile.php Subclass of UploadBase implementing regular file uploads. Manual:UploadFromFile.php/zh /en
includes/upload/UploadFromStash.php Subclass of UploadBase implementing uploading from previously stored file. Manual:UploadFromStash.php/zh /en
includes/upload/UploadFromUrl.php Subclass of UploadBase implementing uploading from a HTTP resource. Manual:UploadFromUrl.php/zh /en
includes/upload/UploadStash.php Provides the possibility to enable applications to temporarily stash files without publishing them to the wiki. Manual:UploadStash.php/zh /en

/images/[edit]

If uploads are enabled in the wiki, files will be put in subdirectories under this directory. See Manual:Image administration#Folders for more details.

/languages/[edit]

该目录包含用于本地化与国际化的文件。要获取快速预览,可参见MediaWiki中的语言

文件 描述 Wiki文档
languages/Language.php 包含Language类,它代表用于附带文本的语言,并也拥有一些字符编码功能,以及其他本地材料。有两个全局变量包含有该类的实例:用于网站语言的$wgContLang变量与用于用户语言的$wgLang变量。 Manual:Language.php/zh /en

/maintenance/[edit]

该目录包含有必须通过命令行界面运行的维护脚本。

参见Manual:Maintenance scripts/zh以获取这些脚本的概况。

/mw-config/[edit]

Entry point for the Config script (the helper script that helps setting up a newly installed wiki). The actual code of the installer is located at /includes/installer/.

/resources/[edit]

This directory contains JavaScript and CSS resources used by MediaWiki, including jQuery.

It also contains binary files like PNG and SVG images, for instance in resources/src/mediawiki/images/: see Manual:Assets.

/serialized/[edit]

Location for serialized objects (database entries converted into files -- see Serialization for more information). The database tables that contain serialized data are listed at Manual:Serialization.

/skins/[edit]

该目录包含了所有皮肤类、JavaScript、CSS以及一些用于皮肤的图片。参见Manual:Skins/zh

/tests/[edit]

Contains various (unit)test related files, including: